Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant