Skip to content

Instantly share code, notes, and snippets.

@dehypnosis
Created February 17, 2025 15:57
Show Gist options
  • Save dehypnosis/50a376545fcd40c4ebc5fa40b0b01b94 to your computer and use it in GitHub Desktop.
Save dehypnosis/50a376545fcd40c4ebc5fa40b0b01b94 to your computer and use it in GitHub Desktop.
fn receipt_token_extra_account_metas() -> Result<Vec<ExtraAccountMeta>> {
let extra_account_metas = vec![
// index 5, fund account
ExtraAccountMeta::new_with_seeds(
&[
Seed::Literal {
bytes: FundAccount::SEED.to_vec(),
},
Seed::AccountKey { index: 1 }, // receipt_token_mint
],
false, // is_signer,
true, // is_writable
)?,
// index 6, reward account
ExtraAccountMeta::new_with_seeds(
&[
Seed::Literal {
bytes: reward::RewardAccount::SEED.to_vec(),
},
Seed::AccountKey { index: 1 }, // receipt_token_mint
],
false, // is_signer
true, // is_writable
)?,
// index 7, source user fund account
ExtraAccountMeta::new_with_seeds(
&[
Seed::Literal {
bytes: UserFundAccount::SEED.to_vec(),
},
Seed::AccountKey { index: 1 }, // receipt_token_mint
Seed::AccountData {
account_index: 0,
data_index: 32,
length: 32,
}, // source_token_account.owner, data_index starts from the sum of the front indexes' bytes
],
false, // is_signer
true, // is_writable
)?,
// index 8, source user reward account
ExtraAccountMeta::new_with_seeds(
&[
Seed::Literal {
bytes: reward::UserRewardAccount::SEED.to_vec(),
},
Seed::AccountKey { index: 1 }, // receipt_token_mint
Seed::AccountData {
account_index: 0,
data_index: 32,
length: 32,
}, // source_token_account.owner
],
false, // is_signer
true, // is_writable
)?,
// index 9, destination user fund account
ExtraAccountMeta::new_with_seeds(
&[
Seed::Literal {
bytes: UserFundAccount::SEED.to_vec(),
},
Seed::AccountKey { index: 1 }, // receipt_token_mint
Seed::AccountData {
account_index: 2,
data_index: 32,
length: 32,
}, // destination_token_account.owner
],
false, // is_signer
true, // is_writable
)?,
// index 10, destination user reward account
ExtraAccountMeta::new_with_seeds(
&[
Seed::Literal {
bytes: reward::UserRewardAccount::SEED.to_vec(),
},
Seed::AccountKey { index: 1 }, // receipt_token_mint
Seed::AccountData {
account_index: 2,
data_index: 32,
length: 32,
}, // destination_token_account.owner
],
false, // is_signer
true, // is_writable
)?,
// index 11, event authority
ExtraAccountMeta::new_with_seeds(
&[Seed::Literal {
bytes: b"__event_authority".to_vec(),
}],
false, // is_signer,
false, // is_writable
)?,
// index 12, this program
ExtraAccountMeta::new_with_pubkey(
&crate::ID,
false, // is_signer,
false, // is_writable
)?,
];
Ok(extra_account_metas)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment