coral-xyz / anchor

⚓ Solana Sealevel Framework
https://anchor-lang.com
Apache License 2.0
3.68k stars 1.35k forks source link

`#[account(associated)]` should not initialize #290

Closed armaniferrante closed 3 years ago

armaniferrante commented 3 years ago

The existing #[account(associated)] api should just check the seeds provided indeed result in the correct associated address. It shouldn't create the PDA account, as it currently does.

Instead, we should force the user to explicitly pass in init, e.g., #[account(init, associated)] to run the account creation flow. Thereafter, one can use #[account(associated)] to perform checks to ensure the correct account and seeds are passed in.

Discussed with @Henry-E.

NorbertBodziony commented 3 years ago

Since this includes some stuff with associated accounts and seed maybe its good idea to also add versioning https://github.com/project-serum/anchor/issues/233 IMO super important for upgradable projects.

armaniferrante commented 3 years ago

Versioning is mostly unrelated. The task here will just change the way the macro interprets the keywords. It's not implementing any new functionality.

armaniferrante commented 3 years ago

Addressed by #318.