Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redefine certificate_vault as account owning all certificate ATAs #21

Merged
merged 2 commits into from
Oct 25, 2023

Conversation

gigileungyingchi
Copy link
Contributor

No description provided.

@gigileungyingchi gigileungyingchi force-pushed the redefine-certificate-vault branch 3 times, most recently from e1e290a to dcb0906 Compare October 24, 2023 16:03
@@ -115,9 +116,12 @@ pub struct StoreCertificates<'info> {
pub output_yield_token_account: Account<'info, TokenAccount>,
#[account(
mut,
constraint = certificate_vault.key() == state.certificate_vault @ ErrorCode::IncorrectHoldAccount,
associated_token::mint = output_yield_token_account.mint,
associated_token::authority = state.certificate_vault,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to write it with init_if_needed like this:

#[account(
init_if_needed,
payer = payer,
associated_token::mint = output_yield_token_account.mint,
associated_token::authority = state.certificate_vault,
)]
// the account where we store all the certificates
pub certificate_vault_ata: Account<'info, TokenAccount>,

But got an error of the mint constraint has to be an account field for token initializations (not a public key). Do you know how we can convert the mint address into a mint account? Or is it ok to keep the implementation as it is now and create the certificate_vault_ata on the client side?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what the error is saying is that you need to pass in the mint as an account to the instruction too. So the input accounts should be:

  • payer (signer of the tx, mutable)
  • state
  • retirement cert mint
  • output yield account (the owner of the source token account) <- This should not be mutable btw
  • output yield token account (the source token account - its mint must = the retirement cert mint)
  • certificate vault ATA (init_if_needed, authority = state.certificate_vault, mint = retirement cert mint)
  • the programs.

@gigileungyingchi gigileungyingchi force-pushed the redefine-certificate-vault branch 2 times, most recently from 6a8b57f to 82983a1 Compare October 25, 2023 08:45
@gigileungyingchi gigileungyingchi force-pushed the redefine-certificate-vault branch 3 times, most recently from c80880d to d3d8ec6 Compare October 25, 2023 09:53
@dankelleher dankelleher merged commit 1f37e74 into develop Oct 25, 2023
8 checks passed
@dankelleher dankelleher deleted the redefine-certificate-vault branch October 25, 2023 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants