Skip to content

Commit

Permalink
Fixing description of the collect IX arg. (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
blockiosaurus authored Dec 13, 2023
1 parent 913c0bd commit 803bcc5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 34 deletions.
8 changes: 4 additions & 4 deletions clients/js/src/generated/instructions/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import {
export type CollectInstructionAccounts = {
/** Authority to collect fees */
authority?: Signer;
/** PDA to retrieve fees from */
pdaAccount: PublicKey | Pda;
/** The account to transfer collected fees to */
recipient: PublicKey | Pda;
};

// Data.
Expand Down Expand Up @@ -69,10 +69,10 @@ export function collect(
isWritable: false as boolean,
value: input.authority ?? null,
},
pdaAccount: {
recipient: {
index: 1,
isWritable: false as boolean,
value: input.pdaAccount ?? null,
value: input.recipient ?? null,
},
} satisfies ResolvedAccountsWithIndices;

Expand Down
51 changes: 24 additions & 27 deletions clients/rust/src/generated/instructions/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use borsh::BorshSerialize;
pub struct Collect {
/// Authority to collect fees
pub authority: solana_program::pubkey::Pubkey,
/// PDA to retrieve fees from
pub pda_account: solana_program::pubkey::Pubkey,
/// The account to transfer collected fees to
pub recipient: solana_program::pubkey::Pubkey,
}

impl Collect {
Expand All @@ -31,7 +31,7 @@ impl Collect {
true,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.pda_account,
self.recipient,
false,
));
accounts.extend_from_slice(remaining_accounts);
Expand Down Expand Up @@ -61,11 +61,11 @@ impl CollectInstructionData {
/// ### Accounts:
///
/// 0. `[signer]` authority
/// 1. `[]` pda_account
/// 1. `[]` recipient
#[derive(Default)]
pub struct CollectBuilder {
authority: Option<solana_program::pubkey::Pubkey>,
pda_account: Option<solana_program::pubkey::Pubkey>,
recipient: Option<solana_program::pubkey::Pubkey>,
__remaining_accounts: Vec<solana_program::instruction::AccountMeta>,
}

Expand All @@ -79,10 +79,10 @@ impl CollectBuilder {
self.authority = Some(authority);
self
}
/// PDA to retrieve fees from
/// The account to transfer collected fees to
#[inline(always)]
pub fn pda_account(&mut self, pda_account: solana_program::pubkey::Pubkey) -> &mut Self {
self.pda_account = Some(pda_account);
pub fn recipient(&mut self, recipient: solana_program::pubkey::Pubkey) -> &mut Self {
self.recipient = Some(recipient);
self
}
/// Add an aditional account to the instruction.
Expand All @@ -107,7 +107,7 @@ impl CollectBuilder {
pub fn instruction(&self) -> solana_program::instruction::Instruction {
let accounts = Collect {
authority: self.authority.expect("authority is not set"),
pda_account: self.pda_account.expect("pda_account is not set"),
recipient: self.recipient.expect("recipient is not set"),
};

accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
Expand All @@ -118,8 +118,8 @@ impl CollectBuilder {
pub struct CollectCpiAccounts<'a, 'b> {
/// Authority to collect fees
pub authority: &'b solana_program::account_info::AccountInfo<'a>,
/// PDA to retrieve fees from
pub pda_account: &'b solana_program::account_info::AccountInfo<'a>,
/// The account to transfer collected fees to
pub recipient: &'b solana_program::account_info::AccountInfo<'a>,
}

/// `collect` CPI instruction.
Expand All @@ -128,8 +128,8 @@ pub struct CollectCpi<'a, 'b> {
pub __program: &'b solana_program::account_info::AccountInfo<'a>,
/// Authority to collect fees
pub authority: &'b solana_program::account_info::AccountInfo<'a>,
/// PDA to retrieve fees from
pub pda_account: &'b solana_program::account_info::AccountInfo<'a>,
/// The account to transfer collected fees to
pub recipient: &'b solana_program::account_info::AccountInfo<'a>,
}

impl<'a, 'b> CollectCpi<'a, 'b> {
Expand All @@ -140,7 +140,7 @@ impl<'a, 'b> CollectCpi<'a, 'b> {
Self {
__program: program,
authority: accounts.authority,
pda_account: accounts.pda_account,
recipient: accounts.recipient,
}
}
#[inline(always)]
Expand Down Expand Up @@ -182,7 +182,7 @@ impl<'a, 'b> CollectCpi<'a, 'b> {
true,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.pda_account.key,
*self.recipient.key,
false,
));
remaining_accounts.iter().for_each(|remaining_account| {
Expand All @@ -202,7 +202,7 @@ impl<'a, 'b> CollectCpi<'a, 'b> {
let mut account_infos = Vec::with_capacity(2 + 1 + remaining_accounts.len());
account_infos.push(self.__program.clone());
account_infos.push(self.authority.clone());
account_infos.push(self.pda_account.clone());
account_infos.push(self.recipient.clone());
remaining_accounts
.iter()
.for_each(|remaining_account| account_infos.push(remaining_account.0.clone()));
Expand All @@ -220,7 +220,7 @@ impl<'a, 'b> CollectCpi<'a, 'b> {
/// ### Accounts:
///
/// 0. `[signer]` authority
/// 1. `[]` pda_account
/// 1. `[]` recipient
pub struct CollectCpiBuilder<'a, 'b> {
instruction: Box<CollectCpiBuilderInstruction<'a, 'b>>,
}
Expand All @@ -230,7 +230,7 @@ impl<'a, 'b> CollectCpiBuilder<'a, 'b> {
let instruction = Box::new(CollectCpiBuilderInstruction {
__program: program,
authority: None,
pda_account: None,
recipient: None,
__remaining_accounts: Vec::new(),
});
Self { instruction }
Expand All @@ -244,13 +244,13 @@ impl<'a, 'b> CollectCpiBuilder<'a, 'b> {
self.instruction.authority = Some(authority);
self
}
/// PDA to retrieve fees from
/// The account to transfer collected fees to
#[inline(always)]
pub fn pda_account(
pub fn recipient(
&mut self,
pda_account: &'b solana_program::account_info::AccountInfo<'a>,
recipient: &'b solana_program::account_info::AccountInfo<'a>,
) -> &mut Self {
self.instruction.pda_account = Some(pda_account);
self.instruction.recipient = Some(recipient);
self
}
/// Add an additional account to the instruction.
Expand Down Expand Up @@ -299,10 +299,7 @@ impl<'a, 'b> CollectCpiBuilder<'a, 'b> {

authority: self.instruction.authority.expect("authority is not set"),

pda_account: self
.instruction
.pda_account
.expect("pda_account is not set"),
recipient: self.instruction.recipient.expect("recipient is not set"),
};
instruction.invoke_signed_with_remaining_accounts(
signers_seeds,
Expand All @@ -314,7 +311,7 @@ impl<'a, 'b> CollectCpiBuilder<'a, 'b> {
struct CollectCpiBuilderInstruction<'a, 'b> {
__program: &'b solana_program::account_info::AccountInfo<'a>,
authority: Option<&'b solana_program::account_info::AccountInfo<'a>>,
pda_account: Option<&'b solana_program::account_info::AccountInfo<'a>>,
recipient: Option<&'b solana_program::account_info::AccountInfo<'a>>,
/// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`.
__remaining_accounts: Vec<(
&'b solana_program::account_info::AccountInfo<'a>,
Expand Down
4 changes: 2 additions & 2 deletions idls/token_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4499,11 +4499,11 @@
]
},
{
"name": "pdaAccount",
"name": "recipient",
"isMut": false,
"isSigner": false,
"docs": [
"PDA to retrieve fees from"
"The account to transfer collected fees to"
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion programs/token-metadata/program/src/instruction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ pub enum MetadataInstruction {

/// Collect fees stored on PDA accounts.
#[account(0, signer, name="authority", desc="Authority to collect fees")]
#[account(1, name="pda_account", desc="PDA to retrieve fees from")]
#[account(1, name="recipient", desc="The account to transfer collected fees to")]
Collect,

/// Given a token account containing the master edition token to prove authority, and a brand new non-metadata-ed mint with one token
Expand Down

0 comments on commit 803bcc5

Please sign in to comment.