Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

findProgramAddress does not need to be async #23184

Closed
yangli-io opened this issue Feb 16, 2022 · 0 comments · Fixed by #23185
Closed

findProgramAddress does not need to be async #23184

yangli-io opened this issue Feb 16, 2022 · 0 comments · Fixed by #23185

Comments

@yangli-io
Copy link
Contributor

yangli-io commented Feb 16, 2022

Problem

findProgramAddress is an async function but nothing about it requires it to be async
This makes it harder to write programs, for example if you wanted to use it in an array map you would have to use promise.all

For example if I wanted to find all the PDA for an account I would need to do something like the below

const findAllDerivedAccounts = await Promise.all(accounts.map(async (account, index) => {
  const [PDA] = await findProgramAddress(account.toBuffer(), programId);

  return PDA; 
}))

Proposed Solution

Remove async from createProgramAddress and findProgramAddress

joncinque pushed a commit that referenced this issue Apr 18, 2022
#23185)

* fix: remove async for createProgramAddress and findProgramAddress (#23184)

make sync

* test: add test to ensure backwards compatibility
jeffwashington pushed a commit to jeffwashington/solana that referenced this issue Jun 30, 2022
solana-labs#23185)

* fix: remove async for createProgramAddress and findProgramAddress (solana-labs#23184)

make sync

* test: add test to ensure backwards compatibility
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant