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

token-js: Add sync version of getAssociatedTokenAddress #3050

Closed
charlie-amihan opened this issue Mar 29, 2022 · 4 comments · Fixed by #3171
Closed

token-js: Add sync version of getAssociatedTokenAddress #3050

charlie-amihan opened this issue Mar 29, 2022 · 4 comments · Fixed by #3171
Labels
good first issue Good for newcomers

Comments

@charlie-amihan
Copy link

export async function getAssociatedTokenAddress(

This references (async) PublicKey.findProgramAddress, which references (async) PublicKey.createProgramAddress...but I'm not sure why https://github.com/solana-labs/solana-web3.js/blob/d93efdf/src/publickey.ts#L146 needs to be async. I may be missing something! It would just be nice to be able to neatly call this synchronously in a test or whatnot without bubbling up async/await.

@joncinque
Copy link
Contributor

You've stumbled on the exact issue -- since this relies on PublicKey.createProgramAddress, it must be async. If we land solana-labs/solana#23185 on the @solana/web3.js side, then we can add a sync version for this too.

@solana-labs solana-labs deleted a comment Apr 9, 2022
@joncinque joncinque added the good first issue Good for newcomers label May 10, 2022
@joncinque
Copy link
Contributor

Now that web3.js has a sync version of createProgramAddress, we can add a sync version of getAssociatedTokenAddress

@joncinque joncinque changed the title Why is getAssociatedTokenAddress async? token-js: Add sync version of getAssociatedTokenAddress May 10, 2022
@dboures
Copy link
Contributor

dboures commented May 13, 2022

How often does the web3.js dependency get updated? I'd be happy to implement this but I don't want to sneak in an unwelcome dependency change, and it looks like we need at least web3.js version 1.40 (currently on 1.36) for this change (solana-labs/solana-web3.js@v1.39.1...v1.40.0).

@joncinque
Copy link
Contributor

It's done as needed, so feel free to do the bump if needed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@joncinque @dboures @charlie-amihan and others