anchor
anchor copied to clipboard
lang: Allow payer to be PDA
Allow payers in #[account(init)] and #[account(init_if_needed)] to be PDAs.
This PR does the following:
- Added
payer_seeds: Option<ConstraintSeedsGroup>which is the seeds (if avail) of the payer toConstraintInitGroup. - Added payer seeds to
invoke_signed()when generating account creating codes. - Added
tests/pda-payerand added it to CI.
I fixed errors detected by clippy, could anyone please rerun the workflow?
@phqb can you rebase your pr from the current state of master
@phqb is attempting to deploy a commit to the coral-xyz Team on Vercel.
A member of the Team first needs to authorize it.
@phqb can you rebase your pr from the current state of
master
I rebased this PR onto the current master.
I formatted the test file using Prettier. Now cd tests && yarn lint run successfully.
Would absolutely love to get this feature in. We'd appreciate being able to set a PDA as payer to initiate a new account.
can you add a changelog entry for this, please.
I added a changelog entry and rebased this branch to master.
This seems like there's a lot of room for things to go wrong. I can see there's demand for it. But we would need to look into this a bit closer.
For example, I think if it was limited for sure to system program accounts which are PDAs, and in the call to create account we pass the seeds then we maybe could we do that. But allowing a regular AccountInfo which could be owned by the program to pay for an account seems dangerous.
I would need to write all the different combinations of ways that a PDA could be used to pay for an account
- different owners of the PDAs
- there are two different ways that accounts get initialized, one is
create_accountand the other is three separate system program functions
Definitely something worth spending some time on in the future though. And maybe I will have time to audit this before the next release. We will see. The code here could also messed up totally by the new optional accounts constraints.
This needs a bit more attention and time spent on it. Tried to do some work on it today but need to make sure that it's relatively unaffected by the optional accounts PR and that none of the changes in each affect the other.