Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
in this page https://solana.com/developers/courses/onchain-development/anchor-cpi
if you run
anchor test
in the final example, you can see errors:Summary of Changes
the reason is in this line:
developer-content/content/courses/onchain-development/anchor-cpi.md
Line 555 in 5dc01dd
it passed an incorrect mint authority, because in
InitializeMint
, theauthority
passed withuser
, which is the signer. but when it callMintTo
inCpiContext::new_with_signer
,authority
is incorrectly passed asmint
. which is not the authority of itself, instead the signer,ctx.accounts.initializer.to_account_info()
, should be passed in.Fixes #
Also I see in this PR: https://github.com/solana-foundation/developer-content/pull/571/files. it uses the mint as its own authority. well, i am afriad I can't think this is very good based on two reasons:
Security: If the mint were its own authority, anyone who could predict the PDA (which is techincally possible! ) could potentially mint tokens.
Security: If the mint were its own authority, anyone who could predict the PDA could potentially mint tokens.