anchor icon indicating copy to clipboard operation
anchor copied to clipboard

lang: Allow payer to be PDA

Open phqb opened this issue 3 years ago • 10 comments

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 to ConstraintInitGroup.
  • Added payer seeds to invoke_signed() when generating account creating codes.
  • Added tests/pda-payer and added it to CI.

phqb avatar Jun 01 '22 06:06 phqb

I fixed errors detected by clippy, could anyone please rerun the workflow?

phqb avatar Jun 22 '22 11:06 phqb

@phqb can you rebase your pr from the current state of master

callensm avatar Jul 19 '22 16:07 callensm

@phqb is attempting to deploy a commit to the coral-xyz Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Jul 22 '22 09:07 vercel[bot]

@phqb can you rebase your pr from the current state of master

I rebased this PR onto the current master.

phqb avatar Jul 22 '22 10:07 phqb

I formatted the test file using Prettier. Now cd tests && yarn lint run successfully.

phqb avatar Jul 25 '22 03:07 phqb

Would absolutely love to get this feature in. We'd appreciate being able to set a PDA as payer to initiate a new account.

helloosco avatar Aug 25 '22 12:08 helloosco

can you add a changelog entry for this, please.

callensm avatar Aug 25 '22 13:08 callensm

I added a changelog entry and rebased this branch to master.

phqb avatar Sep 06 '22 09:09 phqb

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_account and 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.

Henry-E avatar Dec 06 '22 12:12 Henry-E

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.

Henry-E avatar Dec 14 '22 17:12 Henry-E