developer-content icon indicating copy to clipboard operation
developer-content copied to clipboard

fix and improve signer-auth.md & reinitialization-attacks.md & pda-sharing.md & owner-checks.md & closing-accounts.md & arbitrary-cpi.md

Open wuuer opened this issue 5 months ago • 5 comments

Problem

signer-auth.md

The way to get the seed "*ctx.bumps.get("vault").unwrap()" is outdated for the latest anchor version. Unnecessary parameters in "accounts()" in the test typescript.

reinitialization-attacks.md

Magic number found on space calculation “@project-serum/anchor” is outdated. The two recommendedInitialization test cases do not use the same method to send transactions.

pda-sharing.md

Magic number found on space calculation. "token account" in the" Starter" section should refer to "associated token account" "token account" in the "Add initialize_pool_secure instruction" section should refer to "associated token account" Some typescript code is not synced to the project.

owner-checks.md

Magic number found on space calculation. Unnecessary parameters are found in the test typescript. Two Different ways to send transactions are found.

duplicate-mutable-accounts.md

Magic number found on space calculation. "BorshDeserialize" and "BorshSerialize" are outdated. Test descriptions are not clear enough.

closing-accounts.md

Use InitSpace to calculate space needed for accounts. Delete "force_defund" because “CLOSED_ACCOUNT_DISCRIMINATOR” was removed in the latest version of anchor-lang Add the new secure instruction for account closing in the "Secure account closing" section . Delete Unnecessary parameters found in the test typescript. Change the Logic of account closing "Sets the account discriminator to the CLOSED_ACCOUNT_DISCRIMINATOR variant" to "Assigning the owner of the account to the System Program and rellocating the size of the account's data with 0 bytes."

arbitrary-cpi.md

The anchor cpi lesson link is invalid. Magic number found on space calculation.

Summary of Changes

signer-auth.md

Update the latest way to get the seed. replace "init" with "init_if_needed" for vault field in the struct InitializeVault<'info>. delete unnecessary parameters "accounts()" in the test typescript. Update the project repo links.

reinitialization-attacks.md

Use InitSpace to calculate space needed for accounts. Use "@coral-xyz/anchor" instead of "@project-serum/anchor" for the test typescript. Consistently use "rpc()" to send transactions in the test typescript. Update BDD style for the test typescript.

Also, I made a PR for solana-reinitialization-attacks starter branch and a PR for solana-reinitialization-attacks solution branch which must be sync with this PR.

pda-sharing.md

Use InitSpace to calculate space needed for accounts. change "token account" in the "Starter" section to "associated token account" change "token account" in the "Add `initialize_pool_secure" section to "associated token account"

Also, I made a PR for solana-pda-sharing starter branch and a PR for solana-pda-sharing solution branch which must be synced with this PR.

owner-checks.md

Use InitSpace to calculate space needed for accounts. Delete Unnecessary parameters found in the test typescript. Consistently use "rpc()" as sending transactions in the test typescript.

Also, I made a PR for solana-owner-checks starter branch and a PR for solana-owner-checks solution branch which must be synced with this PR.

duplicate-mutable-accounts.md

Use InitSpace to calculate space needed for accounts. Replace "BorshDeserialize" and "BorshSerialize" with "AnchorDeserialize" and "AnchorSerialize". Make test descriptions more clear.

Also, I made a PR for solana-duplicate-mutable-accounts starter branch and a PR for solana-duplicate-mutable-accounts solution branch which must be synced with this PR.

closing-accounts.md

Use InitSpace to calculate space needed for accounts. Delete "force_defund"  because “CLOSED_ACCOUNT_DISCRIMINATOR” was removed in the latest version of anchor-lang. Add the new secure instruction for account closing in the "Secure account closing" section. Change the Logic of closing account "Sets the account discriminator to the CLOSED_ACCOUNT_DISCRIMINATOR variant" to "Assigning the owner to the System Program".

Also, I made a PR for solana-closing-accounts starter branch and a PR for solana-closing-accounts solution branch which must be synced with this PR.

arbitrary-cpi.md

Fix the anchor cpi lesson link. Use InitSpace to calculate space needed for accounts.

Also, I made a PR for solana-arbitrary-cpi starter branch and a PR for solana-arbitrary-cpi solution branch which must be synced with this PR.

wuuer avatar Aug 28 '24 16:08 wuuer