solana-foundation / developer-content

Collection of Developer content for exploring, learning, and building in the Solana ecosystem.
https://solana.com/developers
143 stars 273 forks source link

fix: read token_account from bumps #589

Open yanCode opened 1 month ago

yanCode commented 1 month ago

Problem

in this page: https://solana.com/developers/courses/program-security/owner-checks current rust code in the tutorial, using syntax *ctx.bumps.get("token_account").unwrap() to read token_account from bumps, that now no longer works on anchor-lang = "0.30.1". In fact, this has already been updated in the sample code repository, https://github.com/yanCode/owner-checks/blob/7bda9fb5051976b37ec7cd68aa9cf9595ad087b8/programs/owner-check/src/lib.rs#L49

I personally think while the code repository got updated, the doc has'nt been update accordingly.

Summary of Changes

Update the code as:

 let seeds = &[b"token".as_ref(), &[ctx.bumps.token_account]];
github-actions[bot] commented 6 days ago

This pull request has been automatically marked as stale because it has not had recent activity. Remove stale label or comment or this will be closed in 7 days.