Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 52 additions & 18 deletions e2e/anchor/src/generated/instructions/create_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ impl CreateGuardInstructionArgs {
///
/// ### Accounts:
///
/// 0. `[writable]` guard
/// 0. `[writable, optional]` guard (default to PDA)
/// 1. `[writable, signer]` mint
/// 2. `[writable]` mint_token_account
/// 2. `[writable, optional]` mint_token_account (default to PDA)
/// 3. `[signer]` guard_authority
/// 4. `[writable, signer]` payer
/// 5. `[optional]` associated_token_program (default to `ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL`)
Expand Down Expand Up @@ -155,6 +155,7 @@ impl CreateGuardBuilder {
pub fn new() -> Self {
Self::default()
}
/// `[optional account, default to PDA]`
#[inline(always)]
pub fn guard(&mut self, guard: solana_address::Address) -> &mut Self {
self.guard = Some(guard);
Expand All @@ -165,6 +166,7 @@ impl CreateGuardBuilder {
self.mint = Some(mint);
self
}
/// `[optional account, default to PDA]`
#[inline(always)]
pub fn mint_token_account(&mut self, mint_token_account: solana_address::Address) -> &mut Self {
self.mint_token_account = Some(mint_token_account);
Expand Down Expand Up @@ -253,23 +255,55 @@ impl CreateGuardBuilder {
}
#[allow(clippy::clone_on_copy)]
pub fn instruction(&self) -> solana_instruction::Instruction {
let mint = self.mint.expect("mint is not set");
let guard = self.guard.unwrap_or_else(|| {
solana_address::Address::find_program_address(
&[
&[
119, 101, 110, 95, 116, 111, 107, 101, 110, 95, 116, 114, 97, 110, 115,
102, 101, 114, 95, 103, 117, 97, 114, 100,
],
&[103, 117, 97, 114, 100, 95, 118, 49],
mint.as_ref(),
],
&crate::WEN_TRANSFER_GUARD_ID,
)
.0
});
let guard_authority = self.guard_authority.expect("guard_authority is not set");
let token_program = self.token_program.unwrap_or(solana_address::address!(
"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
));
let mint_token_account = self.mint_token_account.unwrap_or_else(|| {
solana_address::Address::find_program_address(
&[
guard_authority.as_ref(),
token_program.as_ref(),
mint.as_ref(),
],
&solana_address::address!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),
)
.0
});
let payer = self.payer.expect("payer is not set");
let associated_token_program =
self.associated_token_program
.unwrap_or(solana_address::address!(
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
));
let system_program = self
.system_program
.unwrap_or(solana_address::address!("11111111111111111111111111111111"));

let accounts = CreateGuard {
guard: self.guard.expect("guard is not set"),
mint: self.mint.expect("mint is not set"),
mint_token_account: self
.mint_token_account
.expect("mint_token_account is not set"),
guard_authority: self.guard_authority.expect("guard_authority is not set"),
payer: self.payer.expect("payer is not set"),
associated_token_program: self.associated_token_program.unwrap_or(
solana_address::address!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),
),
token_program: self.token_program.unwrap_or(solana_address::address!(
"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
)),
system_program: self
.system_program
.unwrap_or(solana_address::address!("11111111111111111111111111111111")),
guard,
mint,
mint_token_account,
guard_authority,
payer,
associated_token_program,
token_program,
system_program,
};
let args = CreateGuardInstructionArgs {
name: self.name.clone().expect("name is not set"),
Expand Down
49 changes: 35 additions & 14 deletions e2e/anchor/src/generated/instructions/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl ExecuteInstructionArgs {
/// 1. `[]` mint
/// 2. `[]` destination_account
/// 3. `[]` owner_delegate
/// 4. `[]` extra_metas_account
/// 4. `[optional]` extra_metas_account (default to PDA)
/// 5. `[]` guard
/// 6. `[optional]` instruction_sysvar_account (default to `Sysvar1nstructions1111111111111111111111111`)
#[derive(Clone, Debug, Default)]
Expand Down Expand Up @@ -164,6 +164,7 @@ impl ExecuteBuilder {
self.owner_delegate = Some(owner_delegate);
self
}
/// `[optional account, default to PDA]`
#[inline(always)]
pub fn extra_metas_account(
&mut self,
Expand Down Expand Up @@ -208,20 +209,40 @@ impl ExecuteBuilder {
}
#[allow(clippy::clone_on_copy)]
pub fn instruction(&self) -> solana_instruction::Instruction {
let source_account = self.source_account.expect("source_account is not set");
let mint = self.mint.expect("mint is not set");
let destination_account = self
.destination_account
.expect("destination_account is not set");
let owner_delegate = self.owner_delegate.expect("owner_delegate is not set");
let extra_metas_account = self.extra_metas_account.unwrap_or_else(|| {
solana_address::Address::find_program_address(
&[
&[
101, 120, 116, 114, 97, 45, 97, 99, 99, 111, 117, 110, 116, 45, 109, 101,
116, 97, 115,
],
mint.as_ref(),
],
&crate::WEN_TRANSFER_GUARD_ID,
)
.0
});
let guard = self.guard.expect("guard is not set");
let instruction_sysvar_account =
self.instruction_sysvar_account
.unwrap_or(solana_address::address!(
"Sysvar1nstructions1111111111111111111111111"
));

let accounts = Execute {
source_account: self.source_account.expect("source_account is not set"),
mint: self.mint.expect("mint is not set"),
destination_account: self
.destination_account
.expect("destination_account is not set"),
owner_delegate: self.owner_delegate.expect("owner_delegate is not set"),
extra_metas_account: self
.extra_metas_account
.expect("extra_metas_account is not set"),
guard: self.guard.expect("guard is not set"),
instruction_sysvar_account: self.instruction_sysvar_account.unwrap_or(
solana_address::address!("Sysvar1nstructions1111111111111111111111111"),
),
source_account,
mint,
destination_account,
owner_delegate,
extra_metas_account,
guard,
instruction_sysvar_account,
};
let args = ExecuteInstructionArgs {
amount: self.amount.clone().expect("amount is not set"),
Expand Down
44 changes: 31 additions & 13 deletions e2e/anchor/src/generated/instructions/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl Default for InitializeInstructionData {
///
/// ### Accounts:
///
/// 0. `[writable]` extra_metas_account
/// 0. `[writable, optional]` extra_metas_account (default to PDA)
/// 1. `[]` guard
/// 2. `[]` mint
/// 3. `[writable, signer]` transfer_hook_authority
Expand All @@ -115,6 +115,7 @@ impl InitializeBuilder {
pub fn new() -> Self {
Self::default()
}
/// `[optional account, default to PDA]`
#[inline(always)]
pub fn extra_metas_account(
&mut self,
Expand Down Expand Up @@ -169,19 +170,36 @@ impl InitializeBuilder {
}
#[allow(clippy::clone_on_copy)]
pub fn instruction(&self) -> solana_instruction::Instruction {
let mint = self.mint.expect("mint is not set");
let extra_metas_account = self.extra_metas_account.unwrap_or_else(|| {
solana_address::Address::find_program_address(
&[
&[
101, 120, 116, 114, 97, 45, 97, 99, 99, 111, 117, 110, 116, 45, 109, 101,
116, 97, 115,
],
mint.as_ref(),
],
&crate::WEN_TRANSFER_GUARD_ID,
)
.0
});
let guard = self.guard.expect("guard is not set");
let transfer_hook_authority = self
.transfer_hook_authority
.expect("transfer_hook_authority is not set");
let system_program = self
.system_program
.unwrap_or(solana_address::address!("11111111111111111111111111111111"));
let payer = self.payer.expect("payer is not set");

let accounts = Initialize {
extra_metas_account: self
.extra_metas_account
.expect("extra_metas_account is not set"),
guard: self.guard.expect("guard is not set"),
mint: self.mint.expect("mint is not set"),
transfer_hook_authority: self
.transfer_hook_authority
.expect("transfer_hook_authority is not set"),
system_program: self
.system_program
.unwrap_or(solana_address::address!("11111111111111111111111111111111")),
payer: self.payer.expect("payer is not set"),
extra_metas_account,
guard,
mint,
transfer_hook_authority,
system_program,
payer,
};

accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
Expand Down
56 changes: 44 additions & 12 deletions e2e/anchor/src/generated/instructions/update_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ impl UpdateGuardInstructionArgs {
///
/// ### Accounts:
///
/// 0. `[writable]` guard
/// 0. `[writable, optional]` guard (default to PDA)
/// 1. `[]` mint
/// 2. `[]` token_account
/// 2. `[optional]` token_account (default to PDA)
/// 3. `[signer]` guard_authority
/// 4. `[optional]` token_program (default to `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb`)
/// 5. `[optional]` system_program (default to `11111111111111111111111111111111`)
Expand All @@ -138,6 +138,7 @@ impl UpdateGuardBuilder {
pub fn new() -> Self {
Self::default()
}
/// `[optional account, default to PDA]`
#[inline(always)]
pub fn guard(&mut self, guard: solana_address::Address) -> &mut Self {
self.guard = Some(guard);
Expand All @@ -148,6 +149,7 @@ impl UpdateGuardBuilder {
self.mint = Some(mint);
self
}
/// `[optional account, default to PDA]`
#[inline(always)]
pub fn token_account(&mut self, token_account: solana_address::Address) -> &mut Self {
self.token_account = Some(token_account);
Expand Down Expand Up @@ -207,17 +209,47 @@ impl UpdateGuardBuilder {
}
#[allow(clippy::clone_on_copy)]
pub fn instruction(&self) -> solana_instruction::Instruction {
let mint = self.mint.expect("mint is not set");
let guard = self.guard.unwrap_or_else(|| {
solana_address::Address::find_program_address(
&[
&[
119, 101, 110, 95, 116, 111, 107, 101, 110, 95, 116, 114, 97, 110, 115,
102, 101, 114, 95, 103, 117, 97, 114, 100,
],
&[103, 117, 97, 114, 100, 95, 118, 49],
mint.as_ref(),
],
&crate::WEN_TRANSFER_GUARD_ID,
)
.0
});
let guard_authority = self.guard_authority.expect("guard_authority is not set");
let token_program = self.token_program.unwrap_or(solana_address::address!(
"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
));
let token_account = self.token_account.unwrap_or_else(|| {
solana_address::Address::find_program_address(
&[
guard_authority.as_ref(),
token_program.as_ref(),
mint.as_ref(),
],
&solana_address::address!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"),
)
.0
});
let system_program = self
.system_program
.unwrap_or(solana_address::address!("11111111111111111111111111111111"));

let accounts = UpdateGuard {
guard: self.guard.expect("guard is not set"),
mint: self.mint.expect("mint is not set"),
token_account: self.token_account.expect("token_account is not set"),
guard_authority: self.guard_authority.expect("guard_authority is not set"),
token_program: self.token_program.unwrap_or(solana_address::address!(
"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb"
)),
system_program: self
.system_program
.unwrap_or(solana_address::address!("11111111111111111111111111111111")),
guard,
mint,
token_account,
guard_authority,
token_program,
system_program,
};
let args = UpdateGuardInstructionArgs {
cpi_rule: self.cpi_rule.clone(),
Expand Down
6 changes: 3 additions & 3 deletions e2e/dummy/src/generated/instructions/instruction6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ impl Instruction6Builder {
}
#[allow(clippy::clone_on_copy)]
pub fn instruction(&self) -> solana_instruction::Instruction {
let accounts = Instruction6 {
my_account: self.my_account.expect("my_account is not set"),
};
let my_account = self.my_account.expect("my_account is not set");

let accounts = Instruction6 { my_account };

accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
}
Expand Down
6 changes: 3 additions & 3 deletions e2e/dummy/src/generated/instructions/instruction7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ impl Instruction7Builder {
}
#[allow(clippy::clone_on_copy)]
pub fn instruction(&self) -> solana_instruction::Instruction {
let accounts = Instruction7 {
my_account: self.my_account,
};
let my_account = self.my_account;

let accounts = Instruction7 { my_account };

accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
}
Expand Down
16 changes: 11 additions & 5 deletions e2e/system/src/generated/instructions/advance_nonce_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,18 @@ impl AdvanceNonceAccountBuilder {
}
#[allow(clippy::clone_on_copy)]
pub fn instruction(&self) -> solana_instruction::Instruction {
let nonce_account = self.nonce_account.expect("nonce_account is not set");
let recent_blockhashes_sysvar =
self.recent_blockhashes_sysvar
.unwrap_or(solana_address::address!(
"SysvarRecentB1ockHashes11111111111111111111"
));
let nonce_authority = self.nonce_authority.expect("nonce_authority is not set");

let accounts = AdvanceNonceAccount {
nonce_account: self.nonce_account.expect("nonce_account is not set"),
recent_blockhashes_sysvar: self.recent_blockhashes_sysvar.unwrap_or(
solana_address::address!("SysvarRecentB1ockHashes11111111111111111111"),
),
nonce_authority: self.nonce_authority.expect("nonce_authority is not set"),
nonce_account,
recent_blockhashes_sysvar,
nonce_authority,
};

accounts.instruction_with_remaining_accounts(&self.__remaining_accounts)
Expand Down
6 changes: 3 additions & 3 deletions e2e/system/src/generated/instructions/allocate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ impl AllocateBuilder {
}
#[allow(clippy::clone_on_copy)]
pub fn instruction(&self) -> solana_instruction::Instruction {
let accounts = Allocate {
new_account: self.new_account.expect("new_account is not set"),
};
let new_account = self.new_account.expect("new_account is not set");

let accounts = Allocate { new_account };
let args = AllocateInstructionArgs {
space: self.space.clone().expect("space is not set"),
};
Expand Down
Loading