From 03ee89623d8819c83495132a67d86404fe4dd191 Mon Sep 17 00:00:00 2001 From: Loris Leiva Date: Tue, 17 Feb 2026 12:40:15 +0000 Subject: [PATCH] Bump Codama Rust renderer to v2 --- Cargo.lock | 14 +- clients/rust/Cargo.toml | 8 +- clients/rust/src/generated/accounts/nonce.rs | 16 +- clients/rust/src/generated/errors/system.rs | 12 +- .../instructions/advance_nonce_account.rs | 152 ++++++------- .../src/generated/instructions/allocate.rs | 123 +++++------ .../instructions/allocate_with_seed.rs | 137 ++++++------ .../rust/src/generated/instructions/assign.rs | 128 +++++------ .../instructions/assign_with_seed.rs | 143 ++++++------ .../instructions/authorize_nonce_account.rs | 144 ++++++------- .../generated/instructions/create_account.rs | 145 ++++++------- .../instructions/create_account_with_seed.rs | 167 +++++++------- .../instructions/initialize_nonce_account.rs | 163 +++++++------- .../generated/instructions/transfer_sol.rs | 147 ++++++------- .../instructions/transfer_sol_with_seed.rs | 165 +++++++------- .../instructions/upgrade_nonce_account.rs | 111 +++++----- .../instructions/withdraw_nonce_account.rs | 203 ++++++++---------- clients/rust/src/generated/programs.rs | 2 +- clients/rust/src/generated/shared.rs | 6 +- codama.json | 3 +- package.json | 2 +- pnpm-lock.yaml | 149 +++---------- 22 files changed, 916 insertions(+), 1224 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6ecac19..61d121c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1833,9 +1833,9 @@ dependencies = [ [[package]] name = "kaigan" -version = "0.2.5" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6dd100976df9dd59d0c3fecf6f9ad3f161a087374d1b2a77ebb4ad8920f11bb" +checksum = "4f25ded719a2354f6b1a51d0c0741c25bc7afe038617664eb37f6418439eb084" dependencies = [ "borsh 0.10.4", "serde", @@ -3156,9 +3156,9 @@ dependencies = [ [[package]] name = "solana-account-info" -version = "2.2.1" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0c17d606a298a205fae325489fbed88ee6dc4463c111672172327e741c8905d" +checksum = "c8f5152a288ef1912300fc6efa6c2d1f9bb55d9398eb6c72326360b8063987da" dependencies = [ "bincode", "serde", @@ -4761,8 +4761,14 @@ dependencies = [ "num-traits", "serde", "serde_with", + "solana-account", + "solana-account-info", "solana-client", + "solana-cpi", + "solana-instruction", "solana-program", + "solana-program-error", + "solana-pubkey", "solana-sdk", "thiserror 1.0.69", ] diff --git a/clients/rust/Cargo.toml b/clients/rust/Cargo.toml index ad00eef..d0c4b6c 100644 --- a/clients/rust/Cargo.toml +++ b/clients/rust/Cargo.toml @@ -14,7 +14,7 @@ serde = ["dep:serde", "dep:serde_with", "kaigan/serde"] [dependencies] borsh = "^0.10" -kaigan = "^0.2" +kaigan = "^0.3" num-derive = "^0.4" num-traits = "^0.2" serde = { version = "^1.0", features = ["derive"], optional = true } @@ -23,3 +23,9 @@ solana-client = { version = "2.3.4", optional = true } solana-sdk = { version = "2.2.1", optional = true } solana-program = "2.2.1" thiserror = "^1.0" +solana-account = "~2.2" +solana-account-info = "~2.3" +solana-instruction = "~2.3" +solana-program-error = "~2.2" +solana-pubkey = { version = "~2.4", features = ["curve25519", "borsh"] } +solana-cpi = "~2.2" diff --git a/clients/rust/src/generated/accounts/nonce.rs b/clients/rust/src/generated/accounts/nonce.rs index 5423ac4..65e3be2 100644 --- a/clients/rust/src/generated/accounts/nonce.rs +++ b/clients/rust/src/generated/accounts/nonce.rs @@ -9,7 +9,7 @@ use crate::generated::types::NonceState; use crate::generated::types::NonceVersion; use borsh::BorshDeserialize; use borsh::BorshSerialize; -use solana_program::pubkey::Pubkey; +use solana_pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] @@ -39,12 +39,10 @@ impl Nonce { } } -impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for Nonce { +impl<'a> TryFrom<&solana_account_info::AccountInfo<'a>> for Nonce { type Error = std::io::Error; - fn try_from( - account_info: &solana_program::account_info::AccountInfo<'a>, - ) -> Result { + fn try_from(account_info: &solana_account_info::AccountInfo<'a>) -> Result { let mut data: &[u8] = &(*account_info.data).borrow(); Self::deserialize(&mut data) } @@ -53,7 +51,7 @@ impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for Nonce { #[cfg(feature = "fetch")] pub fn fetch_nonce( rpc: &solana_client::rpc_client::RpcClient, - address: &solana_program::pubkey::Pubkey, + address: &solana_pubkey::Pubkey, ) -> Result, std::io::Error> { let accounts = fetch_all_nonce(rpc, &[*address])?; Ok(accounts[0].clone()) @@ -62,7 +60,7 @@ pub fn fetch_nonce( #[cfg(feature = "fetch")] pub fn fetch_all_nonce( rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_program::pubkey::Pubkey], + addresses: &[solana_pubkey::Pubkey], ) -> Result>, std::io::Error> { let accounts = rpc .get_multiple_accounts(addresses) @@ -87,7 +85,7 @@ pub fn fetch_all_nonce( #[cfg(feature = "fetch")] pub fn fetch_maybe_nonce( rpc: &solana_client::rpc_client::RpcClient, - address: &solana_program::pubkey::Pubkey, + address: &solana_pubkey::Pubkey, ) -> Result, std::io::Error> { let accounts = fetch_all_maybe_nonce(rpc, &[*address])?; Ok(accounts[0].clone()) @@ -96,7 +94,7 @@ pub fn fetch_maybe_nonce( #[cfg(feature = "fetch")] pub fn fetch_all_maybe_nonce( rpc: &solana_client::rpc_client::RpcClient, - addresses: &[solana_program::pubkey::Pubkey], + addresses: &[solana_pubkey::Pubkey], ) -> Result>, std::io::Error> { let accounts = rpc .get_multiple_accounts(addresses) diff --git a/clients/rust/src/generated/errors/system.rs b/clients/rust/src/generated/errors/system.rs index 2519664..28266b8 100644 --- a/clients/rust/src/generated/errors/system.rs +++ b/clients/rust/src/generated/errors/system.rs @@ -39,14 +39,8 @@ pub enum SystemError { NonceUnexpectedBlockhashValue = 0x8, } -impl solana_program::program_error::PrintProgramError for SystemError { - fn print(&self) { - solana_program::msg!(&self.to_string()); - } -} - -impl solana_program::decode_error::DecodeError for SystemError { - fn type_of() -> &'static str { - "SystemError" +impl From for solana_program_error::ProgramError { + fn from(e: SystemError) -> Self { + solana_program_error::ProgramError::Custom(e as u32) } } diff --git a/clients/rust/src/generated/instructions/advance_nonce_account.rs b/clients/rust/src/generated/instructions/advance_nonce_account.rs index 189970f..e2608cb 100644 --- a/clients/rust/src/generated/instructions/advance_nonce_account.rs +++ b/clients/rust/src/generated/instructions/advance_nonce_account.rs @@ -8,43 +8,47 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; +pub const ADVANCE_NONCE_ACCOUNT_DISCRIMINATOR: u32 = 4; + /// Accounts. #[derive(Debug)] pub struct AdvanceNonceAccount { - pub nonce_account: solana_program::pubkey::Pubkey, + pub nonce_account: solana_pubkey::Pubkey, - pub recent_blockhashes_sysvar: solana_program::pubkey::Pubkey, + pub recent_blockhashes_sysvar: solana_pubkey::Pubkey, - pub nonce_authority: solana_program::pubkey::Pubkey, + pub nonce_authority: solana_pubkey::Pubkey, } impl AdvanceNonceAccount { - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(&[]) } #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( self.nonce_account, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.recent_blockhashes_sysvar, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.nonce_authority, true, )); accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&AdvanceNonceAccountInstructionData::new()).unwrap(); + let data = AdvanceNonceAccountInstructionData::new() + .try_to_vec() + .unwrap(); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -62,6 +66,10 @@ impl AdvanceNonceAccountInstructionData { pub fn new() -> Self { Self { discriminator: 4 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for AdvanceNonceAccountInstructionData { @@ -79,10 +87,10 @@ impl Default for AdvanceNonceAccountInstructionData { /// 2. `[signer]` nonce_authority #[derive(Clone, Debug, Default)] pub struct AdvanceNonceAccountBuilder { - nonce_account: Option, - recent_blockhashes_sysvar: Option, - nonce_authority: Option, - __remaining_accounts: Vec, + nonce_account: Option, + recent_blockhashes_sysvar: Option, + nonce_authority: Option, + __remaining_accounts: Vec, } impl AdvanceNonceAccountBuilder { @@ -90,7 +98,7 @@ impl AdvanceNonceAccountBuilder { Self::default() } #[inline(always)] - pub fn nonce_account(&mut self, nonce_account: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn nonce_account(&mut self, nonce_account: solana_pubkey::Pubkey) -> &mut Self { self.nonce_account = Some(nonce_account); self } @@ -98,25 +106,19 @@ impl AdvanceNonceAccountBuilder { #[inline(always)] pub fn recent_blockhashes_sysvar( &mut self, - recent_blockhashes_sysvar: solana_program::pubkey::Pubkey, + recent_blockhashes_sysvar: solana_pubkey::Pubkey, ) -> &mut Self { self.recent_blockhashes_sysvar = Some(recent_blockhashes_sysvar); self } #[inline(always)] - pub fn nonce_authority( - &mut self, - nonce_authority: solana_program::pubkey::Pubkey, - ) -> &mut Self { + pub fn nonce_authority(&mut self, nonce_authority: solana_pubkey::Pubkey) -> &mut Self { self.nonce_authority = Some(nonce_authority); self } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -124,17 +126,17 @@ impl AdvanceNonceAccountBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = AdvanceNonceAccount { nonce_account: self.nonce_account.expect("nonce_account is not set"), recent_blockhashes_sysvar: self.recent_blockhashes_sysvar.unwrap_or( - solana_program::pubkey!("SysvarRecentB1ockHashes11111111111111111111"), + solana_pubkey::pubkey!("SysvarRecentB1ockHashes11111111111111111111"), ), nonce_authority: self.nonce_authority.expect("nonce_authority is not set"), }; @@ -145,28 +147,28 @@ impl AdvanceNonceAccountBuilder { /// `advance_nonce_account` CPI accounts. pub struct AdvanceNonceAccountCpiAccounts<'a, 'b> { - pub nonce_account: &'b solana_program::account_info::AccountInfo<'a>, + pub nonce_account: &'b solana_account_info::AccountInfo<'a>, - pub recent_blockhashes_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub recent_blockhashes_sysvar: &'b solana_account_info::AccountInfo<'a>, - pub nonce_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub nonce_authority: &'b solana_account_info::AccountInfo<'a>, } /// `advance_nonce_account` CPI instruction. pub struct AdvanceNonceAccountCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, - pub nonce_account: &'b solana_program::account_info::AccountInfo<'a>, + pub nonce_account: &'b solana_account_info::AccountInfo<'a>, - pub recent_blockhashes_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub recent_blockhashes_sysvar: &'b solana_account_info::AccountInfo<'a>, - pub nonce_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub nonce_authority: &'b solana_account_info::AccountInfo<'a>, } impl<'a, 'b> AdvanceNonceAccountCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: AdvanceNonceAccountCpiAccounts<'a, 'b>, ) -> Self { Self { @@ -177,25 +179,18 @@ impl<'a, 'b> AdvanceNonceAccountCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -204,35 +199,33 @@ impl<'a, 'b> AdvanceNonceAccountCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.nonce_account.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.recent_blockhashes_sysvar.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.nonce_authority.key, true, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let data = borsh::to_vec(&AdvanceNonceAccountInstructionData::new()).unwrap(); + let data = AdvanceNonceAccountInstructionData::new() + .try_to_vec() + .unwrap(); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -247,9 +240,9 @@ impl<'a, 'b> AdvanceNonceAccountCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -267,7 +260,7 @@ pub struct AdvanceNonceAccountCpiBuilder<'a, 'b> { } impl<'a, 'b> AdvanceNonceAccountCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(AdvanceNonceAccountCpiBuilderInstruction { __program: program, nonce_account: None, @@ -280,7 +273,7 @@ impl<'a, 'b> AdvanceNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn nonce_account( &mut self, - nonce_account: &'b solana_program::account_info::AccountInfo<'a>, + nonce_account: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.nonce_account = Some(nonce_account); self @@ -288,7 +281,7 @@ impl<'a, 'b> AdvanceNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn recent_blockhashes_sysvar( &mut self, - recent_blockhashes_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + recent_blockhashes_sysvar: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.recent_blockhashes_sysvar = Some(recent_blockhashes_sysvar); self @@ -296,7 +289,7 @@ impl<'a, 'b> AdvanceNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn nonce_authority( &mut self, - nonce_authority: &'b solana_program::account_info::AccountInfo<'a>, + nonce_authority: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.nonce_authority = Some(nonce_authority); self @@ -305,7 +298,7 @@ impl<'a, 'b> AdvanceNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -321,11 +314,7 @@ impl<'a, 'b> AdvanceNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -333,15 +322,12 @@ impl<'a, 'b> AdvanceNonceAccountCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let instruction = AdvanceNonceAccountCpi { __program: self.instruction.__program, @@ -369,14 +355,10 @@ impl<'a, 'b> AdvanceNonceAccountCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct AdvanceNonceAccountCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - nonce_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, - recent_blockhashes_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, - nonce_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + nonce_account: Option<&'b solana_account_info::AccountInfo<'a>>, + recent_blockhashes_sysvar: Option<&'b solana_account_info::AccountInfo<'a>>, + nonce_authority: Option<&'b solana_account_info::AccountInfo<'a>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/allocate.rs b/clients/rust/src/generated/instructions/allocate.rs index 634e107..e378940 100644 --- a/clients/rust/src/generated/instructions/allocate.rs +++ b/clients/rust/src/generated/instructions/allocate.rs @@ -8,17 +8,16 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; +pub const ALLOCATE_DISCRIMINATOR: u32 = 8; + /// Accounts. #[derive(Debug)] pub struct Allocate { - pub new_account: solana_program::pubkey::Pubkey, + pub new_account: solana_pubkey::Pubkey, } impl Allocate { - pub fn instruction( - &self, - args: AllocateInstructionArgs, - ) -> solana_program::instruction::Instruction { + pub fn instruction(&self, args: AllocateInstructionArgs) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -26,19 +25,16 @@ impl Allocate { pub fn instruction_with_remaining_accounts( &self, args: AllocateInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(1 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.new_account, - true, - )); + accounts.push(solana_instruction::AccountMeta::new(self.new_account, true)); accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AllocateInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = AllocateInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -56,6 +52,10 @@ impl AllocateInstructionData { pub fn new() -> Self { Self { discriminator: 8 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for AllocateInstructionData { @@ -70,6 +70,12 @@ pub struct AllocateInstructionArgs { pub space: u64, } +impl AllocateInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `Allocate`. /// /// ### Accounts: @@ -77,9 +83,9 @@ pub struct AllocateInstructionArgs { /// 0. `[writable, signer]` new_account #[derive(Clone, Debug, Default)] pub struct AllocateBuilder { - new_account: Option, + new_account: Option, space: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl AllocateBuilder { @@ -87,7 +93,7 @@ impl AllocateBuilder { Self::default() } #[inline(always)] - pub fn new_account(&mut self, new_account: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn new_account(&mut self, new_account: solana_pubkey::Pubkey) -> &mut Self { self.new_account = Some(new_account); self } @@ -98,10 +104,7 @@ impl AllocateBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -109,13 +112,13 @@ impl AllocateBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = Allocate { new_account: self.new_account.expect("new_account is not set"), }; @@ -129,22 +132,22 @@ impl AllocateBuilder { /// `allocate` CPI accounts. pub struct AllocateCpiAccounts<'a, 'b> { - pub new_account: &'b solana_program::account_info::AccountInfo<'a>, + pub new_account: &'b solana_account_info::AccountInfo<'a>, } /// `allocate` CPI instruction. pub struct AllocateCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, - pub new_account: &'b solana_program::account_info::AccountInfo<'a>, + pub new_account: &'b solana_account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: AllocateInstructionArgs, } impl<'a, 'b> AllocateCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: AllocateCpiAccounts<'a, 'b>, args: AllocateInstructionArgs, ) -> Self { @@ -155,25 +158,18 @@ impl<'a, 'b> AllocateCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -182,29 +178,25 @@ impl<'a, 'b> AllocateCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(1 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.new_account.key, true, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&AllocateInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = AllocateInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -217,9 +209,9 @@ impl<'a, 'b> AllocateCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -235,7 +227,7 @@ pub struct AllocateCpiBuilder<'a, 'b> { } impl<'a, 'b> AllocateCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(AllocateCpiBuilderInstruction { __program: program, new_account: None, @@ -247,7 +239,7 @@ impl<'a, 'b> AllocateCpiBuilder<'a, 'b> { #[inline(always)] pub fn new_account( &mut self, - new_account: &'b solana_program::account_info::AccountInfo<'a>, + new_account: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.new_account = Some(new_account); self @@ -261,7 +253,7 @@ impl<'a, 'b> AllocateCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -277,11 +269,7 @@ impl<'a, 'b> AllocateCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -289,15 +277,12 @@ impl<'a, 'b> AllocateCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = AllocateInstructionArgs { space: self.instruction.space.clone().expect("space is not set"), }; @@ -319,13 +304,9 @@ impl<'a, 'b> AllocateCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct AllocateCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - new_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + new_account: Option<&'b solana_account_info::AccountInfo<'a>>, space: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/allocate_with_seed.rs b/clients/rust/src/generated/instructions/allocate_with_seed.rs index 71d3220..bff29cf 100644 --- a/clients/rust/src/generated/instructions/allocate_with_seed.rs +++ b/clients/rust/src/generated/instructions/allocate_with_seed.rs @@ -8,21 +8,23 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; use kaigan::types::U64PrefixString; -use solana_program::pubkey::Pubkey; +use solana_pubkey::Pubkey; + +pub const ALLOCATE_WITH_SEED_DISCRIMINATOR: u32 = 9; /// Accounts. #[derive(Debug)] pub struct AllocateWithSeed { - pub new_account: solana_program::pubkey::Pubkey, + pub new_account: solana_pubkey::Pubkey, - pub base_account: solana_program::pubkey::Pubkey, + pub base_account: solana_pubkey::Pubkey, } impl AllocateWithSeed { pub fn instruction( &self, args: AllocateWithSeedInstructionArgs, - ) -> solana_program::instruction::Instruction { + ) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -30,23 +32,23 @@ impl AllocateWithSeed { pub fn instruction_with_remaining_accounts( &self, args: AllocateWithSeedInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( self.new_account, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.base_account, true, )); accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AllocateWithSeedInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = AllocateWithSeedInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -64,6 +66,10 @@ impl AllocateWithSeedInstructionData { pub fn new() -> Self { Self { discriminator: 9 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for AllocateWithSeedInstructionData { @@ -81,6 +87,12 @@ pub struct AllocateWithSeedInstructionArgs { pub program_address: Pubkey, } +impl AllocateWithSeedInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `AllocateWithSeed`. /// /// ### Accounts: @@ -89,13 +101,13 @@ pub struct AllocateWithSeedInstructionArgs { /// 1. `[signer]` base_account #[derive(Clone, Debug, Default)] pub struct AllocateWithSeedBuilder { - new_account: Option, - base_account: Option, + new_account: Option, + base_account: Option, base: Option, seed: Option, space: Option, program_address: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl AllocateWithSeedBuilder { @@ -103,12 +115,12 @@ impl AllocateWithSeedBuilder { Self::default() } #[inline(always)] - pub fn new_account(&mut self, new_account: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn new_account(&mut self, new_account: solana_pubkey::Pubkey) -> &mut Self { self.new_account = Some(new_account); self } #[inline(always)] - pub fn base_account(&mut self, base_account: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn base_account(&mut self, base_account: solana_pubkey::Pubkey) -> &mut Self { self.base_account = Some(base_account); self } @@ -134,10 +146,7 @@ impl AllocateWithSeedBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -145,13 +154,13 @@ impl AllocateWithSeedBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = AllocateWithSeed { new_account: self.new_account.expect("new_account is not set"), base_account: self.base_account.expect("base_account is not set"), @@ -172,26 +181,26 @@ impl AllocateWithSeedBuilder { /// `allocate_with_seed` CPI accounts. pub struct AllocateWithSeedCpiAccounts<'a, 'b> { - pub new_account: &'b solana_program::account_info::AccountInfo<'a>, + pub new_account: &'b solana_account_info::AccountInfo<'a>, - pub base_account: &'b solana_program::account_info::AccountInfo<'a>, + pub base_account: &'b solana_account_info::AccountInfo<'a>, } /// `allocate_with_seed` CPI instruction. pub struct AllocateWithSeedCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, - pub new_account: &'b solana_program::account_info::AccountInfo<'a>, + pub new_account: &'b solana_account_info::AccountInfo<'a>, - pub base_account: &'b solana_program::account_info::AccountInfo<'a>, + pub base_account: &'b solana_account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: AllocateWithSeedInstructionArgs, } impl<'a, 'b> AllocateWithSeedCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: AllocateWithSeedCpiAccounts<'a, 'b>, args: AllocateWithSeedInstructionArgs, ) -> Self { @@ -203,25 +212,18 @@ impl<'a, 'b> AllocateWithSeedCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -230,33 +232,29 @@ impl<'a, 'b> AllocateWithSeedCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.new_account.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.base_account.key, true, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&AllocateWithSeedInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = AllocateWithSeedInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -270,9 +268,9 @@ impl<'a, 'b> AllocateWithSeedCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -289,7 +287,7 @@ pub struct AllocateWithSeedCpiBuilder<'a, 'b> { } impl<'a, 'b> AllocateWithSeedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(AllocateWithSeedCpiBuilderInstruction { __program: program, new_account: None, @@ -305,7 +303,7 @@ impl<'a, 'b> AllocateWithSeedCpiBuilder<'a, 'b> { #[inline(always)] pub fn new_account( &mut self, - new_account: &'b solana_program::account_info::AccountInfo<'a>, + new_account: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.new_account = Some(new_account); self @@ -313,7 +311,7 @@ impl<'a, 'b> AllocateWithSeedCpiBuilder<'a, 'b> { #[inline(always)] pub fn base_account( &mut self, - base_account: &'b solana_program::account_info::AccountInfo<'a>, + base_account: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.base_account = Some(base_account); self @@ -342,7 +340,7 @@ impl<'a, 'b> AllocateWithSeedCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -358,11 +356,7 @@ impl<'a, 'b> AllocateWithSeedCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -370,15 +364,12 @@ impl<'a, 'b> AllocateWithSeedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = AllocateWithSeedInstructionArgs { base: self.instruction.base.clone().expect("base is not set"), seed: self.instruction.seed.clone().expect("seed is not set"), @@ -412,17 +403,13 @@ impl<'a, 'b> AllocateWithSeedCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct AllocateWithSeedCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - new_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, - base_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + new_account: Option<&'b solana_account_info::AccountInfo<'a>>, + base_account: Option<&'b solana_account_info::AccountInfo<'a>>, base: Option, seed: Option, space: Option, program_address: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/assign.rs b/clients/rust/src/generated/instructions/assign.rs index 618d82f..70417e8 100644 --- a/clients/rust/src/generated/instructions/assign.rs +++ b/clients/rust/src/generated/instructions/assign.rs @@ -7,19 +7,18 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; -use solana_program::pubkey::Pubkey; +use solana_pubkey::Pubkey; + +pub const ASSIGN_DISCRIMINATOR: u32 = 1; /// Accounts. #[derive(Debug)] pub struct Assign { - pub account: solana_program::pubkey::Pubkey, + pub account: solana_pubkey::Pubkey, } impl Assign { - pub fn instruction( - &self, - args: AssignInstructionArgs, - ) -> solana_program::instruction::Instruction { + pub fn instruction(&self, args: AssignInstructionArgs) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -27,19 +26,16 @@ impl Assign { pub fn instruction_with_remaining_accounts( &self, args: AssignInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(1 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.account, - true, - )); + accounts.push(solana_instruction::AccountMeta::new(self.account, true)); accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AssignInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = AssignInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -57,6 +53,10 @@ impl AssignInstructionData { pub fn new() -> Self { Self { discriminator: 1 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for AssignInstructionData { @@ -71,6 +71,12 @@ pub struct AssignInstructionArgs { pub program_address: Pubkey, } +impl AssignInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `Assign`. /// /// ### Accounts: @@ -78,9 +84,9 @@ pub struct AssignInstructionArgs { /// 0. `[writable, signer]` account #[derive(Clone, Debug, Default)] pub struct AssignBuilder { - account: Option, + account: Option, program_address: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl AssignBuilder { @@ -88,7 +94,7 @@ impl AssignBuilder { Self::default() } #[inline(always)] - pub fn account(&mut self, account: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn account(&mut self, account: solana_pubkey::Pubkey) -> &mut Self { self.account = Some(account); self } @@ -99,10 +105,7 @@ impl AssignBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -110,13 +113,13 @@ impl AssignBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = Assign { account: self.account.expect("account is not set"), }; @@ -133,22 +136,22 @@ impl AssignBuilder { /// `assign` CPI accounts. pub struct AssignCpiAccounts<'a, 'b> { - pub account: &'b solana_program::account_info::AccountInfo<'a>, + pub account: &'b solana_account_info::AccountInfo<'a>, } /// `assign` CPI instruction. pub struct AssignCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, - pub account: &'b solana_program::account_info::AccountInfo<'a>, + pub account: &'b solana_account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: AssignInstructionArgs, } impl<'a, 'b> AssignCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: AssignCpiAccounts<'a, 'b>, args: AssignInstructionArgs, ) -> Self { @@ -159,25 +162,18 @@ impl<'a, 'b> AssignCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -186,29 +182,25 @@ impl<'a, 'b> AssignCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(1 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.account.key, true, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&AssignInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = AssignInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -221,9 +213,9 @@ impl<'a, 'b> AssignCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -239,7 +231,7 @@ pub struct AssignCpiBuilder<'a, 'b> { } impl<'a, 'b> AssignCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(AssignCpiBuilderInstruction { __program: program, account: None, @@ -249,10 +241,7 @@ impl<'a, 'b> AssignCpiBuilder<'a, 'b> { Self { instruction } } #[inline(always)] - pub fn account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn account(&mut self, account: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.account = Some(account); self } @@ -265,7 +254,7 @@ impl<'a, 'b> AssignCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -281,11 +270,7 @@ impl<'a, 'b> AssignCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -293,15 +278,12 @@ impl<'a, 'b> AssignCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = AssignInstructionArgs { program_address: self .instruction @@ -324,13 +306,9 @@ impl<'a, 'b> AssignCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct AssignCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + account: Option<&'b solana_account_info::AccountInfo<'a>>, program_address: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/assign_with_seed.rs b/clients/rust/src/generated/instructions/assign_with_seed.rs index 4ccbd59..4cef6e8 100644 --- a/clients/rust/src/generated/instructions/assign_with_seed.rs +++ b/clients/rust/src/generated/instructions/assign_with_seed.rs @@ -8,21 +8,23 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; use kaigan::types::U64PrefixString; -use solana_program::pubkey::Pubkey; +use solana_pubkey::Pubkey; + +pub const ASSIGN_WITH_SEED_DISCRIMINATOR: u32 = 10; /// Accounts. #[derive(Debug)] pub struct AssignWithSeed { - pub account: solana_program::pubkey::Pubkey, + pub account: solana_pubkey::Pubkey, - pub base_account: solana_program::pubkey::Pubkey, + pub base_account: solana_pubkey::Pubkey, } impl AssignWithSeed { pub fn instruction( &self, args: AssignWithSeedInstructionArgs, - ) -> solana_program::instruction::Instruction { + ) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -30,23 +32,20 @@ impl AssignWithSeed { pub fn instruction_with_remaining_accounts( &self, args: AssignWithSeedInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.account, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.account, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.base_account, true, )); accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AssignWithSeedInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = AssignWithSeedInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -64,6 +63,10 @@ impl AssignWithSeedInstructionData { pub fn new() -> Self { Self { discriminator: 10 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for AssignWithSeedInstructionData { @@ -80,6 +83,12 @@ pub struct AssignWithSeedInstructionArgs { pub program_address: Pubkey, } +impl AssignWithSeedInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `AssignWithSeed`. /// /// ### Accounts: @@ -88,12 +97,12 @@ pub struct AssignWithSeedInstructionArgs { /// 1. `[signer]` base_account #[derive(Clone, Debug, Default)] pub struct AssignWithSeedBuilder { - account: Option, - base_account: Option, + account: Option, + base_account: Option, base: Option, seed: Option, program_address: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl AssignWithSeedBuilder { @@ -101,12 +110,12 @@ impl AssignWithSeedBuilder { Self::default() } #[inline(always)] - pub fn account(&mut self, account: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn account(&mut self, account: solana_pubkey::Pubkey) -> &mut Self { self.account = Some(account); self } #[inline(always)] - pub fn base_account(&mut self, base_account: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn base_account(&mut self, base_account: solana_pubkey::Pubkey) -> &mut Self { self.base_account = Some(base_account); self } @@ -127,10 +136,7 @@ impl AssignWithSeedBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -138,13 +144,13 @@ impl AssignWithSeedBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = AssignWithSeed { account: self.account.expect("account is not set"), base_account: self.base_account.expect("base_account is not set"), @@ -164,26 +170,26 @@ impl AssignWithSeedBuilder { /// `assign_with_seed` CPI accounts. pub struct AssignWithSeedCpiAccounts<'a, 'b> { - pub account: &'b solana_program::account_info::AccountInfo<'a>, + pub account: &'b solana_account_info::AccountInfo<'a>, - pub base_account: &'b solana_program::account_info::AccountInfo<'a>, + pub base_account: &'b solana_account_info::AccountInfo<'a>, } /// `assign_with_seed` CPI instruction. pub struct AssignWithSeedCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, - pub account: &'b solana_program::account_info::AccountInfo<'a>, + pub account: &'b solana_account_info::AccountInfo<'a>, - pub base_account: &'b solana_program::account_info::AccountInfo<'a>, + pub base_account: &'b solana_account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: AssignWithSeedInstructionArgs, } impl<'a, 'b> AssignWithSeedCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: AssignWithSeedCpiAccounts<'a, 'b>, args: AssignWithSeedInstructionArgs, ) -> Self { @@ -195,25 +201,18 @@ impl<'a, 'b> AssignWithSeedCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -222,33 +221,29 @@ impl<'a, 'b> AssignWithSeedCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.account.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.base_account.key, true, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&AssignWithSeedInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = AssignWithSeedInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -262,9 +257,9 @@ impl<'a, 'b> AssignWithSeedCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -281,7 +276,7 @@ pub struct AssignWithSeedCpiBuilder<'a, 'b> { } impl<'a, 'b> AssignWithSeedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(AssignWithSeedCpiBuilderInstruction { __program: program, account: None, @@ -294,17 +289,14 @@ impl<'a, 'b> AssignWithSeedCpiBuilder<'a, 'b> { Self { instruction } } #[inline(always)] - pub fn account( - &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn account(&mut self, account: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.account = Some(account); self } #[inline(always)] pub fn base_account( &mut self, - base_account: &'b solana_program::account_info::AccountInfo<'a>, + base_account: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.base_account = Some(base_account); self @@ -328,7 +320,7 @@ impl<'a, 'b> AssignWithSeedCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -344,11 +336,7 @@ impl<'a, 'b> AssignWithSeedCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -356,15 +344,12 @@ impl<'a, 'b> AssignWithSeedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = AssignWithSeedInstructionArgs { base: self.instruction.base.clone().expect("base is not set"), seed: self.instruction.seed.clone().expect("seed is not set"), @@ -394,16 +379,12 @@ impl<'a, 'b> AssignWithSeedCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct AssignWithSeedCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - account: Option<&'b solana_program::account_info::AccountInfo<'a>>, - base_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + account: Option<&'b solana_account_info::AccountInfo<'a>>, + base_account: Option<&'b solana_account_info::AccountInfo<'a>>, base: Option, seed: Option, program_address: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/authorize_nonce_account.rs b/clients/rust/src/generated/instructions/authorize_nonce_account.rs index e3ba4d8..28480eb 100644 --- a/clients/rust/src/generated/instructions/authorize_nonce_account.rs +++ b/clients/rust/src/generated/instructions/authorize_nonce_account.rs @@ -7,21 +7,23 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; -use solana_program::pubkey::Pubkey; +use solana_pubkey::Pubkey; + +pub const AUTHORIZE_NONCE_ACCOUNT_DISCRIMINATOR: u32 = 7; /// Accounts. #[derive(Debug)] pub struct AuthorizeNonceAccount { - pub nonce_account: solana_program::pubkey::Pubkey, + pub nonce_account: solana_pubkey::Pubkey, - pub nonce_authority: solana_program::pubkey::Pubkey, + pub nonce_authority: solana_pubkey::Pubkey, } impl AuthorizeNonceAccount { pub fn instruction( &self, args: AuthorizeNonceAccountInstructionArgs, - ) -> solana_program::instruction::Instruction { + ) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -29,23 +31,25 @@ impl AuthorizeNonceAccount { pub fn instruction_with_remaining_accounts( &self, args: AuthorizeNonceAccountInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( self.nonce_account, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.nonce_authority, true, )); accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&AuthorizeNonceAccountInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = AuthorizeNonceAccountInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -63,6 +67,10 @@ impl AuthorizeNonceAccountInstructionData { pub fn new() -> Self { Self { discriminator: 7 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for AuthorizeNonceAccountInstructionData { @@ -77,6 +85,12 @@ pub struct AuthorizeNonceAccountInstructionArgs { pub new_nonce_authority: Pubkey, } +impl AuthorizeNonceAccountInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `AuthorizeNonceAccount`. /// /// ### Accounts: @@ -85,10 +99,10 @@ pub struct AuthorizeNonceAccountInstructionArgs { /// 1. `[signer]` nonce_authority #[derive(Clone, Debug, Default)] pub struct AuthorizeNonceAccountBuilder { - nonce_account: Option, - nonce_authority: Option, + nonce_account: Option, + nonce_authority: Option, new_nonce_authority: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl AuthorizeNonceAccountBuilder { @@ -96,15 +110,12 @@ impl AuthorizeNonceAccountBuilder { Self::default() } #[inline(always)] - pub fn nonce_account(&mut self, nonce_account: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn nonce_account(&mut self, nonce_account: solana_pubkey::Pubkey) -> &mut Self { self.nonce_account = Some(nonce_account); self } #[inline(always)] - pub fn nonce_authority( - &mut self, - nonce_authority: solana_program::pubkey::Pubkey, - ) -> &mut Self { + pub fn nonce_authority(&mut self, nonce_authority: solana_pubkey::Pubkey) -> &mut Self { self.nonce_authority = Some(nonce_authority); self } @@ -115,10 +126,7 @@ impl AuthorizeNonceAccountBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -126,13 +134,13 @@ impl AuthorizeNonceAccountBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = AuthorizeNonceAccount { nonce_account: self.nonce_account.expect("nonce_account is not set"), nonce_authority: self.nonce_authority.expect("nonce_authority is not set"), @@ -150,26 +158,26 @@ impl AuthorizeNonceAccountBuilder { /// `authorize_nonce_account` CPI accounts. pub struct AuthorizeNonceAccountCpiAccounts<'a, 'b> { - pub nonce_account: &'b solana_program::account_info::AccountInfo<'a>, + pub nonce_account: &'b solana_account_info::AccountInfo<'a>, - pub nonce_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub nonce_authority: &'b solana_account_info::AccountInfo<'a>, } /// `authorize_nonce_account` CPI instruction. pub struct AuthorizeNonceAccountCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, - pub nonce_account: &'b solana_program::account_info::AccountInfo<'a>, + pub nonce_account: &'b solana_account_info::AccountInfo<'a>, - pub nonce_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub nonce_authority: &'b solana_account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: AuthorizeNonceAccountInstructionArgs, } impl<'a, 'b> AuthorizeNonceAccountCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: AuthorizeNonceAccountCpiAccounts<'a, 'b>, args: AuthorizeNonceAccountInstructionArgs, ) -> Self { @@ -181,25 +189,18 @@ impl<'a, 'b> AuthorizeNonceAccountCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -208,33 +209,31 @@ impl<'a, 'b> AuthorizeNonceAccountCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.nonce_account.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.nonce_authority.key, true, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&AuthorizeNonceAccountInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = AuthorizeNonceAccountInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -248,9 +247,9 @@ impl<'a, 'b> AuthorizeNonceAccountCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -267,7 +266,7 @@ pub struct AuthorizeNonceAccountCpiBuilder<'a, 'b> { } impl<'a, 'b> AuthorizeNonceAccountCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(AuthorizeNonceAccountCpiBuilderInstruction { __program: program, nonce_account: None, @@ -280,7 +279,7 @@ impl<'a, 'b> AuthorizeNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn nonce_account( &mut self, - nonce_account: &'b solana_program::account_info::AccountInfo<'a>, + nonce_account: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.nonce_account = Some(nonce_account); self @@ -288,7 +287,7 @@ impl<'a, 'b> AuthorizeNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn nonce_authority( &mut self, - nonce_authority: &'b solana_program::account_info::AccountInfo<'a>, + nonce_authority: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.nonce_authority = Some(nonce_authority); self @@ -302,7 +301,7 @@ impl<'a, 'b> AuthorizeNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -318,11 +317,7 @@ impl<'a, 'b> AuthorizeNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -330,15 +325,12 @@ impl<'a, 'b> AuthorizeNonceAccountCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = AuthorizeNonceAccountInstructionArgs { new_nonce_authority: self .instruction @@ -369,14 +361,10 @@ impl<'a, 'b> AuthorizeNonceAccountCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct AuthorizeNonceAccountCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - nonce_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, - nonce_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + nonce_account: Option<&'b solana_account_info::AccountInfo<'a>>, + nonce_authority: Option<&'b solana_account_info::AccountInfo<'a>>, new_nonce_authority: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/create_account.rs b/clients/rust/src/generated/instructions/create_account.rs index bd404db..1819b5e 100644 --- a/clients/rust/src/generated/instructions/create_account.rs +++ b/clients/rust/src/generated/instructions/create_account.rs @@ -7,21 +7,23 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; -use solana_program::pubkey::Pubkey; +use solana_pubkey::Pubkey; + +pub const CREATE_ACCOUNT_DISCRIMINATOR: u32 = 0; /// Accounts. #[derive(Debug)] pub struct CreateAccount { - pub payer: solana_program::pubkey::Pubkey, + pub payer: solana_pubkey::Pubkey, - pub new_account: solana_program::pubkey::Pubkey, + pub new_account: solana_pubkey::Pubkey, } impl CreateAccount { pub fn instruction( &self, args: CreateAccountInstructionArgs, - ) -> solana_program::instruction::Instruction { + ) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -29,22 +31,17 @@ impl CreateAccount { pub fn instruction_with_remaining_accounts( &self, args: CreateAccountInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.payer, true, - )); - accounts.push(solana_program::instruction::AccountMeta::new( - self.new_account, - true, - )); + accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); + accounts.push(solana_instruction::AccountMeta::new(self.new_account, true)); accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreateAccountInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = CreateAccountInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -62,6 +59,10 @@ impl CreateAccountInstructionData { pub fn new() -> Self { Self { discriminator: 0 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for CreateAccountInstructionData { @@ -78,6 +79,12 @@ pub struct CreateAccountInstructionArgs { pub program_address: Pubkey, } +impl CreateAccountInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `CreateAccount`. /// /// ### Accounts: @@ -86,12 +93,12 @@ pub struct CreateAccountInstructionArgs { /// 1. `[writable, signer]` new_account #[derive(Clone, Debug, Default)] pub struct CreateAccountBuilder { - payer: Option, - new_account: Option, + payer: Option, + new_account: Option, lamports: Option, space: Option, program_address: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl CreateAccountBuilder { @@ -99,12 +106,12 @@ impl CreateAccountBuilder { Self::default() } #[inline(always)] - pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { self.payer = Some(payer); self } #[inline(always)] - pub fn new_account(&mut self, new_account: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn new_account(&mut self, new_account: solana_pubkey::Pubkey) -> &mut Self { self.new_account = Some(new_account); self } @@ -125,10 +132,7 @@ impl CreateAccountBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -136,13 +140,13 @@ impl CreateAccountBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = CreateAccount { payer: self.payer.expect("payer is not set"), new_account: self.new_account.expect("new_account is not set"), @@ -162,26 +166,26 @@ impl CreateAccountBuilder { /// `create_account` CPI accounts. pub struct CreateAccountCpiAccounts<'a, 'b> { - pub payer: &'b solana_program::account_info::AccountInfo<'a>, + pub payer: &'b solana_account_info::AccountInfo<'a>, - pub new_account: &'b solana_program::account_info::AccountInfo<'a>, + pub new_account: &'b solana_account_info::AccountInfo<'a>, } /// `create_account` CPI instruction. pub struct CreateAccountCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, - pub payer: &'b solana_program::account_info::AccountInfo<'a>, + pub payer: &'b solana_account_info::AccountInfo<'a>, - pub new_account: &'b solana_program::account_info::AccountInfo<'a>, + pub new_account: &'b solana_account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: CreateAccountInstructionArgs, } impl<'a, 'b> CreateAccountCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: CreateAccountCpiAccounts<'a, 'b>, args: CreateAccountInstructionArgs, ) -> Self { @@ -193,25 +197,18 @@ impl<'a, 'b> CreateAccountCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -220,33 +217,26 @@ impl<'a, 'b> CreateAccountCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.payer.key, - true, - )); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); + accounts.push(solana_instruction::AccountMeta::new( *self.new_account.key, true, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&CreateAccountInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = CreateAccountInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -260,9 +250,9 @@ impl<'a, 'b> CreateAccountCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -279,7 +269,7 @@ pub struct CreateAccountCpiBuilder<'a, 'b> { } impl<'a, 'b> CreateAccountCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(CreateAccountCpiBuilderInstruction { __program: program, payer: None, @@ -292,14 +282,14 @@ impl<'a, 'b> CreateAccountCpiBuilder<'a, 'b> { Self { instruction } } #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.payer = Some(payer); self } #[inline(always)] pub fn new_account( &mut self, - new_account: &'b solana_program::account_info::AccountInfo<'a>, + new_account: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.new_account = Some(new_account); self @@ -323,7 +313,7 @@ impl<'a, 'b> CreateAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -339,11 +329,7 @@ impl<'a, 'b> CreateAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -351,15 +337,12 @@ impl<'a, 'b> CreateAccountCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = CreateAccountInstructionArgs { lamports: self .instruction @@ -393,16 +376,12 @@ impl<'a, 'b> CreateAccountCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct CreateAccountCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - payer: Option<&'b solana_program::account_info::AccountInfo<'a>>, - new_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + payer: Option<&'b solana_account_info::AccountInfo<'a>>, + new_account: Option<&'b solana_account_info::AccountInfo<'a>>, lamports: Option, space: Option, program_address: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/create_account_with_seed.rs b/clients/rust/src/generated/instructions/create_account_with_seed.rs index 73b258c..a4f2ad7 100644 --- a/clients/rust/src/generated/instructions/create_account_with_seed.rs +++ b/clients/rust/src/generated/instructions/create_account_with_seed.rs @@ -8,23 +8,25 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; use kaigan::types::U64PrefixString; -use solana_program::pubkey::Pubkey; +use solana_pubkey::Pubkey; + +pub const CREATE_ACCOUNT_WITH_SEED_DISCRIMINATOR: u32 = 3; /// Accounts. #[derive(Debug)] pub struct CreateAccountWithSeed { - pub payer: solana_program::pubkey::Pubkey, + pub payer: solana_pubkey::Pubkey, - pub new_account: solana_program::pubkey::Pubkey, + pub new_account: solana_pubkey::Pubkey, - pub base_account: Option, + pub base_account: Option, } impl CreateAccountWithSeed { pub fn instruction( &self, args: CreateAccountWithSeedInstructionArgs, - ) -> solana_program::instruction::Instruction { + ) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -32,28 +34,28 @@ impl CreateAccountWithSeed { pub fn instruction_with_remaining_accounts( &self, args: CreateAccountWithSeedInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.payer, true, - )); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new(self.payer, true)); + accounts.push(solana_instruction::AccountMeta::new( self.new_account, false, )); if let Some(base_account) = self.base_account { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( base_account, true, )); } accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&CreateAccountWithSeedInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = CreateAccountWithSeedInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -71,6 +73,10 @@ impl CreateAccountWithSeedInstructionData { pub fn new() -> Self { Self { discriminator: 3 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for CreateAccountWithSeedInstructionData { @@ -89,6 +95,12 @@ pub struct CreateAccountWithSeedInstructionArgs { pub program_address: Pubkey, } +impl CreateAccountWithSeedInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `CreateAccountWithSeed`. /// /// ### Accounts: @@ -98,15 +110,15 @@ pub struct CreateAccountWithSeedInstructionArgs { /// 2. `[signer, optional]` base_account #[derive(Clone, Debug, Default)] pub struct CreateAccountWithSeedBuilder { - payer: Option, - new_account: Option, - base_account: Option, + payer: Option, + new_account: Option, + base_account: Option, base: Option, seed: Option, amount: Option, space: Option, program_address: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl CreateAccountWithSeedBuilder { @@ -114,21 +126,18 @@ impl CreateAccountWithSeedBuilder { Self::default() } #[inline(always)] - pub fn payer(&mut self, payer: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn payer(&mut self, payer: solana_pubkey::Pubkey) -> &mut Self { self.payer = Some(payer); self } #[inline(always)] - pub fn new_account(&mut self, new_account: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn new_account(&mut self, new_account: solana_pubkey::Pubkey) -> &mut Self { self.new_account = Some(new_account); self } /// `[optional account]` #[inline(always)] - pub fn base_account( - &mut self, - base_account: Option, - ) -> &mut Self { + pub fn base_account(&mut self, base_account: Option) -> &mut Self { self.base_account = base_account; self } @@ -159,10 +168,7 @@ impl CreateAccountWithSeedBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -170,13 +176,13 @@ impl CreateAccountWithSeedBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = CreateAccountWithSeed { payer: self.payer.expect("payer is not set"), new_account: self.new_account.expect("new_account is not set"), @@ -199,30 +205,30 @@ impl CreateAccountWithSeedBuilder { /// `create_account_with_seed` CPI accounts. pub struct CreateAccountWithSeedCpiAccounts<'a, 'b> { - pub payer: &'b solana_program::account_info::AccountInfo<'a>, + pub payer: &'b solana_account_info::AccountInfo<'a>, - pub new_account: &'b solana_program::account_info::AccountInfo<'a>, + pub new_account: &'b solana_account_info::AccountInfo<'a>, - pub base_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub base_account: Option<&'b solana_account_info::AccountInfo<'a>>, } /// `create_account_with_seed` CPI instruction. pub struct CreateAccountWithSeedCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, - pub payer: &'b solana_program::account_info::AccountInfo<'a>, + pub payer: &'b solana_account_info::AccountInfo<'a>, - pub new_account: &'b solana_program::account_info::AccountInfo<'a>, + pub new_account: &'b solana_account_info::AccountInfo<'a>, - pub base_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + pub base_account: Option<&'b solana_account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: CreateAccountWithSeedInstructionArgs, } impl<'a, 'b> CreateAccountWithSeedCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: CreateAccountWithSeedCpiAccounts<'a, 'b>, args: CreateAccountWithSeedInstructionArgs, ) -> Self { @@ -235,25 +241,18 @@ impl<'a, 'b> CreateAccountWithSeedCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -262,39 +261,34 @@ impl<'a, 'b> CreateAccountWithSeedCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.payer.key, - true, - )); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new(*self.payer.key, true)); + accounts.push(solana_instruction::AccountMeta::new( *self.new_account.key, false, )); if let Some(base_account) = self.base_account { - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *base_account.key, true, )); } remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&CreateAccountWithSeedInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = CreateAccountWithSeedInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -311,9 +305,9 @@ impl<'a, 'b> CreateAccountWithSeedCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -331,7 +325,7 @@ pub struct CreateAccountWithSeedCpiBuilder<'a, 'b> { } impl<'a, 'b> CreateAccountWithSeedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(CreateAccountWithSeedCpiBuilderInstruction { __program: program, payer: None, @@ -347,14 +341,14 @@ impl<'a, 'b> CreateAccountWithSeedCpiBuilder<'a, 'b> { Self { instruction } } #[inline(always)] - pub fn payer(&mut self, payer: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + pub fn payer(&mut self, payer: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.payer = Some(payer); self } #[inline(always)] pub fn new_account( &mut self, - new_account: &'b solana_program::account_info::AccountInfo<'a>, + new_account: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.new_account = Some(new_account); self @@ -363,7 +357,7 @@ impl<'a, 'b> CreateAccountWithSeedCpiBuilder<'a, 'b> { #[inline(always)] pub fn base_account( &mut self, - base_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + base_account: Option<&'b solana_account_info::AccountInfo<'a>>, ) -> &mut Self { self.instruction.base_account = base_account; self @@ -397,7 +391,7 @@ impl<'a, 'b> CreateAccountWithSeedCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -413,11 +407,7 @@ impl<'a, 'b> CreateAccountWithSeedCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -425,15 +415,12 @@ impl<'a, 'b> CreateAccountWithSeedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = CreateAccountWithSeedInstructionArgs { base: self.instruction.base.clone().expect("base is not set"), seed: self.instruction.seed.clone().expect("seed is not set"), @@ -467,19 +454,15 @@ impl<'a, 'b> CreateAccountWithSeedCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct CreateAccountWithSeedCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - payer: Option<&'b solana_program::account_info::AccountInfo<'a>>, - new_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, - base_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + payer: Option<&'b solana_account_info::AccountInfo<'a>>, + new_account: Option<&'b solana_account_info::AccountInfo<'a>>, + base_account: Option<&'b solana_account_info::AccountInfo<'a>>, base: Option, seed: Option, amount: Option, space: Option, program_address: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/initialize_nonce_account.rs b/clients/rust/src/generated/instructions/initialize_nonce_account.rs index bd4da9e..e304ae6 100644 --- a/clients/rust/src/generated/instructions/initialize_nonce_account.rs +++ b/clients/rust/src/generated/instructions/initialize_nonce_account.rs @@ -7,23 +7,25 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; -use solana_program::pubkey::Pubkey; +use solana_pubkey::Pubkey; + +pub const INITIALIZE_NONCE_ACCOUNT_DISCRIMINATOR: u32 = 6; /// Accounts. #[derive(Debug)] pub struct InitializeNonceAccount { - pub nonce_account: solana_program::pubkey::Pubkey, + pub nonce_account: solana_pubkey::Pubkey, - pub recent_blockhashes_sysvar: solana_program::pubkey::Pubkey, + pub recent_blockhashes_sysvar: solana_pubkey::Pubkey, - pub rent_sysvar: solana_program::pubkey::Pubkey, + pub rent_sysvar: solana_pubkey::Pubkey, } impl InitializeNonceAccount { pub fn instruction( &self, args: InitializeNonceAccountInstructionArgs, - ) -> solana_program::instruction::Instruction { + ) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -31,27 +33,29 @@ impl InitializeNonceAccount { pub fn instruction_with_remaining_accounts( &self, args: InitializeNonceAccountInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( self.nonce_account, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.recent_blockhashes_sysvar, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.rent_sysvar, false, )); accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&InitializeNonceAccountInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = InitializeNonceAccountInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -69,6 +73,10 @@ impl InitializeNonceAccountInstructionData { pub fn new() -> Self { Self { discriminator: 6 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for InitializeNonceAccountInstructionData { @@ -83,6 +91,12 @@ pub struct InitializeNonceAccountInstructionArgs { pub nonce_authority: Pubkey, } +impl InitializeNonceAccountInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `InitializeNonceAccount`. /// /// ### Accounts: @@ -92,11 +106,11 @@ pub struct InitializeNonceAccountInstructionArgs { /// 2. `[optional]` rent_sysvar (default to `SysvarRent111111111111111111111111111111111`) #[derive(Clone, Debug, Default)] pub struct InitializeNonceAccountBuilder { - nonce_account: Option, - recent_blockhashes_sysvar: Option, - rent_sysvar: Option, + nonce_account: Option, + recent_blockhashes_sysvar: Option, + rent_sysvar: Option, nonce_authority: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl InitializeNonceAccountBuilder { @@ -104,7 +118,7 @@ impl InitializeNonceAccountBuilder { Self::default() } #[inline(always)] - pub fn nonce_account(&mut self, nonce_account: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn nonce_account(&mut self, nonce_account: solana_pubkey::Pubkey) -> &mut Self { self.nonce_account = Some(nonce_account); self } @@ -112,14 +126,14 @@ impl InitializeNonceAccountBuilder { #[inline(always)] pub fn recent_blockhashes_sysvar( &mut self, - recent_blockhashes_sysvar: solana_program::pubkey::Pubkey, + recent_blockhashes_sysvar: solana_pubkey::Pubkey, ) -> &mut Self { self.recent_blockhashes_sysvar = Some(recent_blockhashes_sysvar); self } /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` #[inline(always)] - pub fn rent_sysvar(&mut self, rent_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn rent_sysvar(&mut self, rent_sysvar: solana_pubkey::Pubkey) -> &mut Self { self.rent_sysvar = Some(rent_sysvar); self } @@ -130,10 +144,7 @@ impl InitializeNonceAccountBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -141,19 +152,19 @@ impl InitializeNonceAccountBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = InitializeNonceAccount { nonce_account: self.nonce_account.expect("nonce_account is not set"), recent_blockhashes_sysvar: self.recent_blockhashes_sysvar.unwrap_or( - solana_program::pubkey!("SysvarRecentB1ockHashes11111111111111111111"), + solana_pubkey::pubkey!("SysvarRecentB1ockHashes11111111111111111111"), ), - rent_sysvar: self.rent_sysvar.unwrap_or(solana_program::pubkey!( + rent_sysvar: self.rent_sysvar.unwrap_or(solana_pubkey::pubkey!( "SysvarRent111111111111111111111111111111111" )), }; @@ -170,30 +181,30 @@ impl InitializeNonceAccountBuilder { /// `initialize_nonce_account` CPI accounts. pub struct InitializeNonceAccountCpiAccounts<'a, 'b> { - pub nonce_account: &'b solana_program::account_info::AccountInfo<'a>, + pub nonce_account: &'b solana_account_info::AccountInfo<'a>, - pub recent_blockhashes_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub recent_blockhashes_sysvar: &'b solana_account_info::AccountInfo<'a>, - pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub rent_sysvar: &'b solana_account_info::AccountInfo<'a>, } /// `initialize_nonce_account` CPI instruction. pub struct InitializeNonceAccountCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, - pub nonce_account: &'b solana_program::account_info::AccountInfo<'a>, + pub nonce_account: &'b solana_account_info::AccountInfo<'a>, - pub recent_blockhashes_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub recent_blockhashes_sysvar: &'b solana_account_info::AccountInfo<'a>, - pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub rent_sysvar: &'b solana_account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: InitializeNonceAccountInstructionArgs, } impl<'a, 'b> InitializeNonceAccountCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: InitializeNonceAccountCpiAccounts<'a, 'b>, args: InitializeNonceAccountInstructionArgs, ) -> Self { @@ -206,25 +217,18 @@ impl<'a, 'b> InitializeNonceAccountCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -233,37 +237,35 @@ impl<'a, 'b> InitializeNonceAccountCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.nonce_account.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.recent_blockhashes_sysvar.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.rent_sysvar.key, false, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&InitializeNonceAccountInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = InitializeNonceAccountInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -278,9 +280,9 @@ impl<'a, 'b> InitializeNonceAccountCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -298,7 +300,7 @@ pub struct InitializeNonceAccountCpiBuilder<'a, 'b> { } impl<'a, 'b> InitializeNonceAccountCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(InitializeNonceAccountCpiBuilderInstruction { __program: program, nonce_account: None, @@ -312,7 +314,7 @@ impl<'a, 'b> InitializeNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn nonce_account( &mut self, - nonce_account: &'b solana_program::account_info::AccountInfo<'a>, + nonce_account: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.nonce_account = Some(nonce_account); self @@ -320,7 +322,7 @@ impl<'a, 'b> InitializeNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn recent_blockhashes_sysvar( &mut self, - recent_blockhashes_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + recent_blockhashes_sysvar: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.recent_blockhashes_sysvar = Some(recent_blockhashes_sysvar); self @@ -328,7 +330,7 @@ impl<'a, 'b> InitializeNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn rent_sysvar( &mut self, - rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + rent_sysvar: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.rent_sysvar = Some(rent_sysvar); self @@ -342,7 +344,7 @@ impl<'a, 'b> InitializeNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -358,11 +360,7 @@ impl<'a, 'b> InitializeNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -370,15 +368,12 @@ impl<'a, 'b> InitializeNonceAccountCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = InitializeNonceAccountInstructionArgs { nonce_authority: self .instruction @@ -414,15 +409,11 @@ impl<'a, 'b> InitializeNonceAccountCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct InitializeNonceAccountCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - nonce_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, - recent_blockhashes_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, - rent_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + nonce_account: Option<&'b solana_account_info::AccountInfo<'a>>, + recent_blockhashes_sysvar: Option<&'b solana_account_info::AccountInfo<'a>>, + rent_sysvar: Option<&'b solana_account_info::AccountInfo<'a>>, nonce_authority: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/transfer_sol.rs b/clients/rust/src/generated/instructions/transfer_sol.rs index d330bb3..bd43969 100644 --- a/clients/rust/src/generated/instructions/transfer_sol.rs +++ b/clients/rust/src/generated/instructions/transfer_sol.rs @@ -8,19 +8,18 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; +pub const TRANSFER_SOL_DISCRIMINATOR: u32 = 2; + /// Accounts. #[derive(Debug)] pub struct TransferSol { - pub source: solana_program::pubkey::Pubkey, + pub source: solana_pubkey::Pubkey, - pub destination: solana_program::pubkey::Pubkey, + pub destination: solana_pubkey::Pubkey, } impl TransferSol { - pub fn instruction( - &self, - args: TransferSolInstructionArgs, - ) -> solana_program::instruction::Instruction { + pub fn instruction(&self, args: TransferSolInstructionArgs) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -28,23 +27,20 @@ impl TransferSol { pub fn instruction_with_remaining_accounts( &self, args: TransferSolInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.source, - true, - )); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new(self.source, true)); + accounts.push(solana_instruction::AccountMeta::new( self.destination, false, )); accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&TransferSolInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = TransferSolInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -62,6 +58,10 @@ impl TransferSolInstructionData { pub fn new() -> Self { Self { discriminator: 2 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for TransferSolInstructionData { @@ -76,6 +76,12 @@ pub struct TransferSolInstructionArgs { pub amount: u64, } +impl TransferSolInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `TransferSol`. /// /// ### Accounts: @@ -84,10 +90,10 @@ pub struct TransferSolInstructionArgs { /// 1. `[writable]` destination #[derive(Clone, Debug, Default)] pub struct TransferSolBuilder { - source: Option, - destination: Option, + source: Option, + destination: Option, amount: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl TransferSolBuilder { @@ -95,12 +101,12 @@ impl TransferSolBuilder { Self::default() } #[inline(always)] - pub fn source(&mut self, source: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn source(&mut self, source: solana_pubkey::Pubkey) -> &mut Self { self.source = Some(source); self } #[inline(always)] - pub fn destination(&mut self, destination: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn destination(&mut self, destination: solana_pubkey::Pubkey) -> &mut Self { self.destination = Some(destination); self } @@ -111,10 +117,7 @@ impl TransferSolBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -122,13 +125,13 @@ impl TransferSolBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = TransferSol { source: self.source.expect("source is not set"), destination: self.destination.expect("destination is not set"), @@ -143,26 +146,26 @@ impl TransferSolBuilder { /// `transfer_sol` CPI accounts. pub struct TransferSolCpiAccounts<'a, 'b> { - pub source: &'b solana_program::account_info::AccountInfo<'a>, + pub source: &'b solana_account_info::AccountInfo<'a>, - pub destination: &'b solana_program::account_info::AccountInfo<'a>, + pub destination: &'b solana_account_info::AccountInfo<'a>, } /// `transfer_sol` CPI instruction. pub struct TransferSolCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, - pub source: &'b solana_program::account_info::AccountInfo<'a>, + pub source: &'b solana_account_info::AccountInfo<'a>, - pub destination: &'b solana_program::account_info::AccountInfo<'a>, + pub destination: &'b solana_account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: TransferSolInstructionArgs, } impl<'a, 'b> TransferSolCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: TransferSolCpiAccounts<'a, 'b>, args: TransferSolInstructionArgs, ) -> Self { @@ -174,25 +177,18 @@ impl<'a, 'b> TransferSolCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -201,33 +197,26 @@ impl<'a, 'b> TransferSolCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - *self.source.key, - true, - )); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new(*self.source.key, true)); + accounts.push(solana_instruction::AccountMeta::new( *self.destination.key, false, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&TransferSolInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = TransferSolInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -241,9 +230,9 @@ impl<'a, 'b> TransferSolCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -260,7 +249,7 @@ pub struct TransferSolCpiBuilder<'a, 'b> { } impl<'a, 'b> TransferSolCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(TransferSolCpiBuilderInstruction { __program: program, source: None, @@ -271,17 +260,14 @@ impl<'a, 'b> TransferSolCpiBuilder<'a, 'b> { Self { instruction } } #[inline(always)] - pub fn source( - &mut self, - source: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn source(&mut self, source: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.source = Some(source); self } #[inline(always)] pub fn destination( &mut self, - destination: &'b solana_program::account_info::AccountInfo<'a>, + destination: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.destination = Some(destination); self @@ -295,7 +281,7 @@ impl<'a, 'b> TransferSolCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -311,11 +297,7 @@ impl<'a, 'b> TransferSolCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -323,15 +305,12 @@ impl<'a, 'b> TransferSolCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = TransferSolInstructionArgs { amount: self.instruction.amount.clone().expect("amount is not set"), }; @@ -355,14 +334,10 @@ impl<'a, 'b> TransferSolCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct TransferSolCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - source: Option<&'b solana_program::account_info::AccountInfo<'a>>, - destination: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + source: Option<&'b solana_account_info::AccountInfo<'a>>, + destination: Option<&'b solana_account_info::AccountInfo<'a>>, amount: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/transfer_sol_with_seed.rs b/clients/rust/src/generated/instructions/transfer_sol_with_seed.rs index eb08139..957527c 100644 --- a/clients/rust/src/generated/instructions/transfer_sol_with_seed.rs +++ b/clients/rust/src/generated/instructions/transfer_sol_with_seed.rs @@ -8,23 +8,25 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; use kaigan::types::U64PrefixString; -use solana_program::pubkey::Pubkey; +use solana_pubkey::Pubkey; + +pub const TRANSFER_SOL_WITH_SEED_DISCRIMINATOR: u32 = 11; /// Accounts. #[derive(Debug)] pub struct TransferSolWithSeed { - pub source: solana_program::pubkey::Pubkey, + pub source: solana_pubkey::Pubkey, - pub base_account: solana_program::pubkey::Pubkey, + pub base_account: solana_pubkey::Pubkey, - pub destination: solana_program::pubkey::Pubkey, + pub destination: solana_pubkey::Pubkey, } impl TransferSolWithSeed { pub fn instruction( &self, args: TransferSolWithSeedInstructionArgs, - ) -> solana_program::instruction::Instruction { + ) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -32,27 +34,26 @@ impl TransferSolWithSeed { pub fn instruction_with_remaining_accounts( &self, args: TransferSolWithSeedInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( - self.source, - false, - )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new(self.source, false)); + accounts.push(solana_instruction::AccountMeta::new_readonly( self.base_account, true, )); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( self.destination, false, )); accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&TransferSolWithSeedInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = TransferSolWithSeedInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -70,6 +71,10 @@ impl TransferSolWithSeedInstructionData { pub fn new() -> Self { Self { discriminator: 11 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for TransferSolWithSeedInstructionData { @@ -86,6 +91,12 @@ pub struct TransferSolWithSeedInstructionArgs { pub from_owner: Pubkey, } +impl TransferSolWithSeedInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `TransferSolWithSeed`. /// /// ### Accounts: @@ -95,13 +106,13 @@ pub struct TransferSolWithSeedInstructionArgs { /// 2. `[writable]` destination #[derive(Clone, Debug, Default)] pub struct TransferSolWithSeedBuilder { - source: Option, - base_account: Option, - destination: Option, + source: Option, + base_account: Option, + destination: Option, amount: Option, from_seed: Option, from_owner: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl TransferSolWithSeedBuilder { @@ -109,17 +120,17 @@ impl TransferSolWithSeedBuilder { Self::default() } #[inline(always)] - pub fn source(&mut self, source: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn source(&mut self, source: solana_pubkey::Pubkey) -> &mut Self { self.source = Some(source); self } #[inline(always)] - pub fn base_account(&mut self, base_account: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn base_account(&mut self, base_account: solana_pubkey::Pubkey) -> &mut Self { self.base_account = Some(base_account); self } #[inline(always)] - pub fn destination(&mut self, destination: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn destination(&mut self, destination: solana_pubkey::Pubkey) -> &mut Self { self.destination = Some(destination); self } @@ -140,10 +151,7 @@ impl TransferSolWithSeedBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -151,13 +159,13 @@ impl TransferSolWithSeedBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = TransferSolWithSeed { source: self.source.expect("source is not set"), base_account: self.base_account.expect("base_account is not set"), @@ -175,30 +183,30 @@ impl TransferSolWithSeedBuilder { /// `transfer_sol_with_seed` CPI accounts. pub struct TransferSolWithSeedCpiAccounts<'a, 'b> { - pub source: &'b solana_program::account_info::AccountInfo<'a>, + pub source: &'b solana_account_info::AccountInfo<'a>, - pub base_account: &'b solana_program::account_info::AccountInfo<'a>, + pub base_account: &'b solana_account_info::AccountInfo<'a>, - pub destination: &'b solana_program::account_info::AccountInfo<'a>, + pub destination: &'b solana_account_info::AccountInfo<'a>, } /// `transfer_sol_with_seed` CPI instruction. pub struct TransferSolWithSeedCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, - pub source: &'b solana_program::account_info::AccountInfo<'a>, + pub source: &'b solana_account_info::AccountInfo<'a>, - pub base_account: &'b solana_program::account_info::AccountInfo<'a>, + pub base_account: &'b solana_account_info::AccountInfo<'a>, - pub destination: &'b solana_program::account_info::AccountInfo<'a>, + pub destination: &'b solana_account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: TransferSolWithSeedInstructionArgs, } impl<'a, 'b> TransferSolWithSeedCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: TransferSolWithSeedCpiAccounts<'a, 'b>, args: TransferSolWithSeedInstructionArgs, ) -> Self { @@ -211,25 +219,18 @@ impl<'a, 'b> TransferSolWithSeedCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -238,37 +239,35 @@ impl<'a, 'b> TransferSolWithSeedCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.source.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.base_account.key, true, )); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.destination.key, false, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&TransferSolWithSeedInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = TransferSolWithSeedInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -283,9 +282,9 @@ impl<'a, 'b> TransferSolWithSeedCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -303,7 +302,7 @@ pub struct TransferSolWithSeedCpiBuilder<'a, 'b> { } impl<'a, 'b> TransferSolWithSeedCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(TransferSolWithSeedCpiBuilderInstruction { __program: program, source: None, @@ -317,17 +316,14 @@ impl<'a, 'b> TransferSolWithSeedCpiBuilder<'a, 'b> { Self { instruction } } #[inline(always)] - pub fn source( - &mut self, - source: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { + pub fn source(&mut self, source: &'b solana_account_info::AccountInfo<'a>) -> &mut Self { self.instruction.source = Some(source); self } #[inline(always)] pub fn base_account( &mut self, - base_account: &'b solana_program::account_info::AccountInfo<'a>, + base_account: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.base_account = Some(base_account); self @@ -335,7 +331,7 @@ impl<'a, 'b> TransferSolWithSeedCpiBuilder<'a, 'b> { #[inline(always)] pub fn destination( &mut self, - destination: &'b solana_program::account_info::AccountInfo<'a>, + destination: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.destination = Some(destination); self @@ -359,7 +355,7 @@ impl<'a, 'b> TransferSolWithSeedCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -375,11 +371,7 @@ impl<'a, 'b> TransferSolWithSeedCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -387,15 +379,12 @@ impl<'a, 'b> TransferSolWithSeedCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = TransferSolWithSeedInstructionArgs { amount: self.instruction.amount.clone().expect("amount is not set"), from_seed: self @@ -434,17 +423,13 @@ impl<'a, 'b> TransferSolWithSeedCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct TransferSolWithSeedCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - source: Option<&'b solana_program::account_info::AccountInfo<'a>>, - base_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, - destination: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + source: Option<&'b solana_account_info::AccountInfo<'a>>, + base_account: Option<&'b solana_account_info::AccountInfo<'a>>, + destination: Option<&'b solana_account_info::AccountInfo<'a>>, amount: Option, from_seed: Option, from_owner: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/upgrade_nonce_account.rs b/clients/rust/src/generated/instructions/upgrade_nonce_account.rs index d82a046..924aaa0 100644 --- a/clients/rust/src/generated/instructions/upgrade_nonce_account.rs +++ b/clients/rust/src/generated/instructions/upgrade_nonce_account.rs @@ -8,31 +8,35 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; +pub const UPGRADE_NONCE_ACCOUNT_DISCRIMINATOR: u32 = 12; + /// Accounts. #[derive(Debug)] pub struct UpgradeNonceAccount { - pub nonce_account: solana_program::pubkey::Pubkey, + pub nonce_account: solana_pubkey::Pubkey, } impl UpgradeNonceAccount { - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(&[]) } #[allow(clippy::arithmetic_side_effects)] #[allow(clippy::vec_init_then_push)] pub fn instruction_with_remaining_accounts( &self, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(1 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( self.nonce_account, false, )); accounts.extend_from_slice(remaining_accounts); - let data = borsh::to_vec(&UpgradeNonceAccountInstructionData::new()).unwrap(); + let data = UpgradeNonceAccountInstructionData::new() + .try_to_vec() + .unwrap(); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -50,6 +54,10 @@ impl UpgradeNonceAccountInstructionData { pub fn new() -> Self { Self { discriminator: 12 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for UpgradeNonceAccountInstructionData { @@ -65,8 +73,8 @@ impl Default for UpgradeNonceAccountInstructionData { /// 0. `[writable]` nonce_account #[derive(Clone, Debug, Default)] pub struct UpgradeNonceAccountBuilder { - nonce_account: Option, - __remaining_accounts: Vec, + nonce_account: Option, + __remaining_accounts: Vec, } impl UpgradeNonceAccountBuilder { @@ -74,16 +82,13 @@ impl UpgradeNonceAccountBuilder { Self::default() } #[inline(always)] - pub fn nonce_account(&mut self, nonce_account: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn nonce_account(&mut self, nonce_account: solana_pubkey::Pubkey) -> &mut Self { self.nonce_account = Some(nonce_account); self } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -91,13 +96,13 @@ impl UpgradeNonceAccountBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = UpgradeNonceAccount { nonce_account: self.nonce_account.expect("nonce_account is not set"), }; @@ -108,20 +113,20 @@ impl UpgradeNonceAccountBuilder { /// `upgrade_nonce_account` CPI accounts. pub struct UpgradeNonceAccountCpiAccounts<'a, 'b> { - pub nonce_account: &'b solana_program::account_info::AccountInfo<'a>, + pub nonce_account: &'b solana_account_info::AccountInfo<'a>, } /// `upgrade_nonce_account` CPI instruction. pub struct UpgradeNonceAccountCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, - pub nonce_account: &'b solana_program::account_info::AccountInfo<'a>, + pub nonce_account: &'b solana_account_info::AccountInfo<'a>, } impl<'a, 'b> UpgradeNonceAccountCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: UpgradeNonceAccountCpiAccounts<'a, 'b>, ) -> Self { Self { @@ -130,25 +135,18 @@ impl<'a, 'b> UpgradeNonceAccountCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -157,27 +155,25 @@ impl<'a, 'b> UpgradeNonceAccountCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(1 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.nonce_account.key, false, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let data = borsh::to_vec(&UpgradeNonceAccountInstructionData::new()).unwrap(); + let data = UpgradeNonceAccountInstructionData::new() + .try_to_vec() + .unwrap(); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -190,9 +186,9 @@ impl<'a, 'b> UpgradeNonceAccountCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -208,7 +204,7 @@ pub struct UpgradeNonceAccountCpiBuilder<'a, 'b> { } impl<'a, 'b> UpgradeNonceAccountCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(UpgradeNonceAccountCpiBuilderInstruction { __program: program, nonce_account: None, @@ -219,7 +215,7 @@ impl<'a, 'b> UpgradeNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn nonce_account( &mut self, - nonce_account: &'b solana_program::account_info::AccountInfo<'a>, + nonce_account: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.nonce_account = Some(nonce_account); self @@ -228,7 +224,7 @@ impl<'a, 'b> UpgradeNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -244,11 +240,7 @@ impl<'a, 'b> UpgradeNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -256,15 +248,12 @@ impl<'a, 'b> UpgradeNonceAccountCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let instruction = UpgradeNonceAccountCpi { __program: self.instruction.__program, @@ -282,12 +271,8 @@ impl<'a, 'b> UpgradeNonceAccountCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct UpgradeNonceAccountCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - nonce_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + nonce_account: Option<&'b solana_account_info::AccountInfo<'a>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/instructions/withdraw_nonce_account.rs b/clients/rust/src/generated/instructions/withdraw_nonce_account.rs index 207d967..9172029 100644 --- a/clients/rust/src/generated/instructions/withdraw_nonce_account.rs +++ b/clients/rust/src/generated/instructions/withdraw_nonce_account.rs @@ -8,25 +8,27 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; +pub const WITHDRAW_NONCE_ACCOUNT_DISCRIMINATOR: u32 = 5; + /// Accounts. #[derive(Debug)] pub struct WithdrawNonceAccount { - pub nonce_account: solana_program::pubkey::Pubkey, + pub nonce_account: solana_pubkey::Pubkey, - pub recipient_account: solana_program::pubkey::Pubkey, + pub recipient_account: solana_pubkey::Pubkey, - pub recent_blockhashes_sysvar: solana_program::pubkey::Pubkey, + pub recent_blockhashes_sysvar: solana_pubkey::Pubkey, - pub rent_sysvar: solana_program::pubkey::Pubkey, + pub rent_sysvar: solana_pubkey::Pubkey, - pub nonce_authority: solana_program::pubkey::Pubkey, + pub nonce_authority: solana_pubkey::Pubkey, } impl WithdrawNonceAccount { pub fn instruction( &self, args: WithdrawNonceAccountInstructionArgs, - ) -> solana_program::instruction::Instruction { + ) -> solana_instruction::Instruction { self.instruction_with_remaining_accounts(args, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -34,35 +36,37 @@ impl WithdrawNonceAccount { pub fn instruction_with_remaining_accounts( &self, args: WithdrawNonceAccountInstructionArgs, - remaining_accounts: &[solana_program::instruction::AccountMeta], - ) -> solana_program::instruction::Instruction { + remaining_accounts: &[solana_instruction::AccountMeta], + ) -> solana_instruction::Instruction { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( self.nonce_account, false, )); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( self.recipient_account, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.recent_blockhashes_sysvar, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.rent_sysvar, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( self.nonce_authority, true, )); accounts.extend_from_slice(remaining_accounts); - let mut data = borsh::to_vec(&WithdrawNonceAccountInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&args).unwrap(); + let mut data = WithdrawNonceAccountInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = args.try_to_vec().unwrap(); data.append(&mut args); - solana_program::instruction::Instruction { + solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -80,6 +84,10 @@ impl WithdrawNonceAccountInstructionData { pub fn new() -> Self { Self { discriminator: 5 } } + + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } } impl Default for WithdrawNonceAccountInstructionData { @@ -94,6 +102,12 @@ pub struct WithdrawNonceAccountInstructionArgs { pub withdraw_amount: u64, } +impl WithdrawNonceAccountInstructionArgs { + pub(crate) fn try_to_vec(&self) -> Result, std::io::Error> { + borsh::to_vec(self) + } +} + /// Instruction builder for `WithdrawNonceAccount`. /// /// ### Accounts: @@ -105,13 +119,13 @@ pub struct WithdrawNonceAccountInstructionArgs { /// 4. `[signer]` nonce_authority #[derive(Clone, Debug, Default)] pub struct WithdrawNonceAccountBuilder { - nonce_account: Option, - recipient_account: Option, - recent_blockhashes_sysvar: Option, - rent_sysvar: Option, - nonce_authority: Option, + nonce_account: Option, + recipient_account: Option, + recent_blockhashes_sysvar: Option, + rent_sysvar: Option, + nonce_authority: Option, withdraw_amount: Option, - __remaining_accounts: Vec, + __remaining_accounts: Vec, } impl WithdrawNonceAccountBuilder { @@ -119,15 +133,12 @@ impl WithdrawNonceAccountBuilder { Self::default() } #[inline(always)] - pub fn nonce_account(&mut self, nonce_account: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn nonce_account(&mut self, nonce_account: solana_pubkey::Pubkey) -> &mut Self { self.nonce_account = Some(nonce_account); self } #[inline(always)] - pub fn recipient_account( - &mut self, - recipient_account: solana_program::pubkey::Pubkey, - ) -> &mut Self { + pub fn recipient_account(&mut self, recipient_account: solana_pubkey::Pubkey) -> &mut Self { self.recipient_account = Some(recipient_account); self } @@ -135,22 +146,19 @@ impl WithdrawNonceAccountBuilder { #[inline(always)] pub fn recent_blockhashes_sysvar( &mut self, - recent_blockhashes_sysvar: solana_program::pubkey::Pubkey, + recent_blockhashes_sysvar: solana_pubkey::Pubkey, ) -> &mut Self { self.recent_blockhashes_sysvar = Some(recent_blockhashes_sysvar); self } /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` #[inline(always)] - pub fn rent_sysvar(&mut self, rent_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + pub fn rent_sysvar(&mut self, rent_sysvar: solana_pubkey::Pubkey) -> &mut Self { self.rent_sysvar = Some(rent_sysvar); self } #[inline(always)] - pub fn nonce_authority( - &mut self, - nonce_authority: solana_program::pubkey::Pubkey, - ) -> &mut Self { + pub fn nonce_authority(&mut self, nonce_authority: solana_pubkey::Pubkey) -> &mut Self { self.nonce_authority = Some(nonce_authority); self } @@ -161,10 +169,7 @@ impl WithdrawNonceAccountBuilder { } /// Add an additional account to the instruction. #[inline(always)] - pub fn add_remaining_account( - &mut self, - account: solana_program::instruction::AccountMeta, - ) -> &mut Self { + pub fn add_remaining_account(&mut self, account: solana_instruction::AccountMeta) -> &mut Self { self.__remaining_accounts.push(account); self } @@ -172,22 +177,22 @@ impl WithdrawNonceAccountBuilder { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[solana_program::instruction::AccountMeta], + accounts: &[solana_instruction::AccountMeta], ) -> &mut Self { self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn instruction(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_instruction::Instruction { let accounts = WithdrawNonceAccount { nonce_account: self.nonce_account.expect("nonce_account is not set"), recipient_account: self .recipient_account .expect("recipient_account is not set"), recent_blockhashes_sysvar: self.recent_blockhashes_sysvar.unwrap_or( - solana_program::pubkey!("SysvarRecentB1ockHashes11111111111111111111"), + solana_pubkey::pubkey!("SysvarRecentB1ockHashes11111111111111111111"), ), - rent_sysvar: self.rent_sysvar.unwrap_or(solana_program::pubkey!( + rent_sysvar: self.rent_sysvar.unwrap_or(solana_pubkey::pubkey!( "SysvarRent111111111111111111111111111111111" )), nonce_authority: self.nonce_authority.expect("nonce_authority is not set"), @@ -205,38 +210,38 @@ impl WithdrawNonceAccountBuilder { /// `withdraw_nonce_account` CPI accounts. pub struct WithdrawNonceAccountCpiAccounts<'a, 'b> { - pub nonce_account: &'b solana_program::account_info::AccountInfo<'a>, + pub nonce_account: &'b solana_account_info::AccountInfo<'a>, - pub recipient_account: &'b solana_program::account_info::AccountInfo<'a>, + pub recipient_account: &'b solana_account_info::AccountInfo<'a>, - pub recent_blockhashes_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub recent_blockhashes_sysvar: &'b solana_account_info::AccountInfo<'a>, - pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub rent_sysvar: &'b solana_account_info::AccountInfo<'a>, - pub nonce_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub nonce_authority: &'b solana_account_info::AccountInfo<'a>, } /// `withdraw_nonce_account` CPI instruction. pub struct WithdrawNonceAccountCpi<'a, 'b> { /// The program to invoke. - pub __program: &'b solana_program::account_info::AccountInfo<'a>, + pub __program: &'b solana_account_info::AccountInfo<'a>, - pub nonce_account: &'b solana_program::account_info::AccountInfo<'a>, + pub nonce_account: &'b solana_account_info::AccountInfo<'a>, - pub recipient_account: &'b solana_program::account_info::AccountInfo<'a>, + pub recipient_account: &'b solana_account_info::AccountInfo<'a>, - pub recent_blockhashes_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub recent_blockhashes_sysvar: &'b solana_account_info::AccountInfo<'a>, - pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + pub rent_sysvar: &'b solana_account_info::AccountInfo<'a>, - pub nonce_authority: &'b solana_program::account_info::AccountInfo<'a>, + pub nonce_authority: &'b solana_account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: WithdrawNonceAccountInstructionArgs, } impl<'a, 'b> WithdrawNonceAccountCpi<'a, 'b> { pub fn new( - program: &'b solana_program::account_info::AccountInfo<'a>, + program: &'b solana_account_info::AccountInfo<'a>, accounts: WithdrawNonceAccountCpiAccounts<'a, 'b>, args: WithdrawNonceAccountInstructionArgs, ) -> Self { @@ -251,25 +256,18 @@ impl<'a, 'b> WithdrawNonceAccountCpi<'a, 'b> { } } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], &[]) } #[inline(always)] pub fn invoke_with_remaining_accounts( &self, - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) } #[inline(always)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::arithmetic_side_effects)] @@ -278,45 +276,43 @@ impl<'a, 'b> WithdrawNonceAccountCpi<'a, 'b> { pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], - remaining_accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], - ) -> solana_program::entrypoint::ProgramResult { + remaining_accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], + ) -> solana_program_error::ProgramResult { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.nonce_account.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new( + accounts.push(solana_instruction::AccountMeta::new( *self.recipient_account.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.recent_blockhashes_sysvar.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.rent_sysvar.key, false, )); - accounts.push(solana_program::instruction::AccountMeta::new_readonly( + accounts.push(solana_instruction::AccountMeta::new_readonly( *self.nonce_authority.key, true, )); remaining_accounts.iter().for_each(|remaining_account| { - accounts.push(solana_program::instruction::AccountMeta { + accounts.push(solana_instruction::AccountMeta { pubkey: *remaining_account.0.key, is_signer: remaining_account.1, is_writable: remaining_account.2, }) }); - let mut data = borsh::to_vec(&WithdrawNonceAccountInstructionData::new()).unwrap(); - let mut args = borsh::to_vec(&self.__args).unwrap(); + let mut data = WithdrawNonceAccountInstructionData::new() + .try_to_vec() + .unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); - let instruction = solana_program::instruction::Instruction { + let instruction = solana_instruction::Instruction { program_id: crate::SYSTEM_ID, accounts, data, @@ -333,9 +329,9 @@ impl<'a, 'b> WithdrawNonceAccountCpi<'a, 'b> { .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); if signers_seeds.is_empty() { - solana_program::program::invoke(&instruction, &account_infos) + solana_cpi::invoke(&instruction, &account_infos) } else { - solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + solana_cpi::invoke_signed(&instruction, &account_infos, signers_seeds) } } } @@ -355,7 +351,7 @@ pub struct WithdrawNonceAccountCpiBuilder<'a, 'b> { } impl<'a, 'b> WithdrawNonceAccountCpiBuilder<'a, 'b> { - pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + pub fn new(program: &'b solana_account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(WithdrawNonceAccountCpiBuilderInstruction { __program: program, nonce_account: None, @@ -371,7 +367,7 @@ impl<'a, 'b> WithdrawNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn nonce_account( &mut self, - nonce_account: &'b solana_program::account_info::AccountInfo<'a>, + nonce_account: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.nonce_account = Some(nonce_account); self @@ -379,7 +375,7 @@ impl<'a, 'b> WithdrawNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn recipient_account( &mut self, - recipient_account: &'b solana_program::account_info::AccountInfo<'a>, + recipient_account: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.recipient_account = Some(recipient_account); self @@ -387,7 +383,7 @@ impl<'a, 'b> WithdrawNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn recent_blockhashes_sysvar( &mut self, - recent_blockhashes_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + recent_blockhashes_sysvar: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.recent_blockhashes_sysvar = Some(recent_blockhashes_sysvar); self @@ -395,7 +391,7 @@ impl<'a, 'b> WithdrawNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn rent_sysvar( &mut self, - rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + rent_sysvar: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.rent_sysvar = Some(rent_sysvar); self @@ -403,7 +399,7 @@ impl<'a, 'b> WithdrawNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn nonce_authority( &mut self, - nonce_authority: &'b solana_program::account_info::AccountInfo<'a>, + nonce_authority: &'b solana_account_info::AccountInfo<'a>, ) -> &mut Self { self.instruction.nonce_authority = Some(nonce_authority); self @@ -417,7 +413,7 @@ impl<'a, 'b> WithdrawNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_account( &mut self, - account: &'b solana_program::account_info::AccountInfo<'a>, + account: &'b solana_account_info::AccountInfo<'a>, is_writable: bool, is_signer: bool, ) -> &mut Self { @@ -433,11 +429,7 @@ impl<'a, 'b> WithdrawNonceAccountCpiBuilder<'a, 'b> { #[inline(always)] pub fn add_remaining_accounts( &mut self, - accounts: &[( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )], + accounts: &[(&'b solana_account_info::AccountInfo<'a>, bool, bool)], ) -> &mut Self { self.instruction .__remaining_accounts @@ -445,15 +437,12 @@ impl<'a, 'b> WithdrawNonceAccountCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + pub fn invoke(&self) -> solana_program_error::ProgramResult { self.invoke_signed(&[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( - &self, - signers_seeds: &[&[&[u8]]], - ) -> solana_program::entrypoint::ProgramResult { + pub fn invoke_signed(&self, signers_seeds: &[&[&[u8]]]) -> solana_program_error::ProgramResult { let args = WithdrawNonceAccountInstructionArgs { withdraw_amount: self .instruction @@ -499,17 +488,13 @@ impl<'a, 'b> WithdrawNonceAccountCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct WithdrawNonceAccountCpiBuilderInstruction<'a, 'b> { - __program: &'b solana_program::account_info::AccountInfo<'a>, - nonce_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, - recipient_account: Option<&'b solana_program::account_info::AccountInfo<'a>>, - recent_blockhashes_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, - rent_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, - nonce_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + __program: &'b solana_account_info::AccountInfo<'a>, + nonce_account: Option<&'b solana_account_info::AccountInfo<'a>>, + recipient_account: Option<&'b solana_account_info::AccountInfo<'a>>, + recent_blockhashes_sysvar: Option<&'b solana_account_info::AccountInfo<'a>>, + rent_sysvar: Option<&'b solana_account_info::AccountInfo<'a>>, + nonce_authority: Option<&'b solana_account_info::AccountInfo<'a>>, withdraw_amount: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. - __remaining_accounts: Vec<( - &'b solana_program::account_info::AccountInfo<'a>, - bool, - bool, - )>, + __remaining_accounts: Vec<(&'b solana_account_info::AccountInfo<'a>, bool, bool)>, } diff --git a/clients/rust/src/generated/programs.rs b/clients/rust/src/generated/programs.rs index e02ed63..27a2ff8 100644 --- a/clients/rust/src/generated/programs.rs +++ b/clients/rust/src/generated/programs.rs @@ -5,7 +5,7 @@ //! //! -use solana_program::{pubkey, pubkey::Pubkey}; +use solana_pubkey::{pubkey, Pubkey}; /// `system` program ID. pub const SYSTEM_ID: Pubkey = pubkey!("11111111111111111111111111111111"); diff --git a/clients/rust/src/generated/shared.rs b/clients/rust/src/generated/shared.rs index 4b9a0d5..71b906d 100644 --- a/clients/rust/src/generated/shared.rs +++ b/clients/rust/src/generated/shared.rs @@ -8,8 +8,8 @@ #[cfg(feature = "fetch")] #[derive(Debug, Clone)] pub struct DecodedAccount { - pub address: solana_program::pubkey::Pubkey, - pub account: solana_sdk::account::Account, + pub address: solana_pubkey::Pubkey, + pub account: solana_account::Account, pub data: T, } @@ -17,5 +17,5 @@ pub struct DecodedAccount { #[derive(Debug, Clone)] pub enum MaybeAccount { Exists(DecodedAccount), - NotFound(solana_program::pubkey::Pubkey), + NotFound(solana_pubkey::Pubkey), } diff --git a/codama.json b/codama.json index 4ff8682..e8cab3d 100644 --- a/codama.json +++ b/codama.json @@ -15,10 +15,9 @@ "rust": { "from": "@codama/renderers-rust", "args": [ - "clients/rust/src/generated", + "clients/rust", { "anchorTraits": false, - "crateFolder": "clients/rust", "formatCode": true, "toolchain": "+nightly-2025-02-16" } diff --git a/package.json b/package.json index 53faf86..b0b8121 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ }, "devDependencies": { "@codama/renderers-js": "^1.7.0", - "@codama/renderers-rust": "~1.0", + "@codama/renderers-rust": "^2.0.0", "@solana/prettier-config-solana": "0.0.6", "codama": "^1.5.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ee49602..6b1466f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,8 +12,8 @@ importers: specifier: ^1.7.0 version: 1.7.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3) '@codama/renderers-rust': - specifier: ~1.0 - version: 1.0.22(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3) + specifier: ^2.0.0 + version: 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3) '@solana/prettier-config-solana': specifier: 0.0.6 version: 0.0.6(prettier@3.8.1) @@ -27,10 +27,6 @@ packages: resolution: {integrity: sha512-0uLecW/RZC2c1wx3j/eiRAYvilvNY+2DoyEYu/hV0OfM1/uIgIyuy5U+wolV+LY4wLFYdApjYdy+5D32lngCHg==} hasBin: true - '@codama/errors@1.3.0': - resolution: {integrity: sha512-pYp/gOi1c/9btrybWvH2iK5jj7SOpMmyLm9EqbxrivV+lqzfEogU8IG+BLch9sqnuhPgg/PzCaB4sYd438UC/Q==} - hasBin: true - '@codama/errors@1.4.4': resolution: {integrity: sha512-XC86H5X+zGTi0cSRKLc+wFkeXNsvnh+ttOgVnVHIljmXOJWbUt9wXhKding3UftipLWwlHPuoswERJ0vS0mO2A==} hasBin: true @@ -39,43 +35,35 @@ packages: resolution: {integrity: sha512-i4cS+S7JaZXhofQHFY3cwzt8rqxUVPNaeJND5VOyKUbtcOi933YXJXk52gDG4mc+CpGqHJijsJjfSpr1lJGxzg==} hasBin: true - '@codama/node-types@1.3.0': - resolution: {integrity: sha512-3dPbMXR/QgKUqXMMxc6PUi2f8Dq6eZ9P/v6+ChTQFLGhSQmqC1PsCbL77PuM7mf4IK9np1RXFqbC/EVpgLvbgA==} - '@codama/node-types@1.4.4': resolution: {integrity: sha512-uUeIz34Id/TTAMi4k5OVl9FByM/PawnlNIIVqgpooH9AS0UlniICZ+KJ/mdHZidJs/AGo6bSRoOPS1BLtMajyw==} '@codama/node-types@1.5.0': resolution: {integrity: sha512-Ebz2vOUukmNaFXWdkni1ZihXkAIUnPYtqIMXYxKXOxjMP+TGz2q0lGtRo7sqw1pc2ksFBIkfBp5pZsl5p6gwXA==} - '@codama/nodes@1.3.0': - resolution: {integrity: sha512-Spf+Whm4jBLFxGPtJuDGmteGe+avoIDnh6rsByU1iJlYmcJJLjZayexFkvW8+1IeDclUMPQYBSj6SjuQEItLqQ==} - '@codama/nodes@1.4.4': resolution: {integrity: sha512-JzlY5qLk3rhsnu0nerC/Vkc9/2HjdsLtEpBtST0dxC1j9kpfHvIc2uyIj+5hlB1YIBRJIDNo+UOHGla8hidkaA==} '@codama/nodes@1.5.0': resolution: {integrity: sha512-yg+xmorWiMNjS3n19CGIt/FZ/ZCuDIu+HEY45bq6gHu1MN3RtJZY+Q3v0ErnBPA60D8mNWkvkKoeSZXfzcAvfw==} - '@codama/renderers-core@1.0.16': - resolution: {integrity: sha512-IJshH6JsX7GUaYmC6KlOd5pLLyW1Yqd0I8B0pVWvvv9BfPNosC4t4RfusHSkYQePkIvs7CJ7YlwUywwW36Vt8A==} - '@codama/renderers-core@1.3.4': resolution: {integrity: sha512-+qEPsvpCjUElohgJTcVNsjy6u1LjoCcwo72NbcffLF9QU5mUjNwL8EhFouEq2K60H/QKmNaiVKLQfJcQ/xCT9A==} + '@codama/renderers-core@1.3.5': + resolution: {integrity: sha512-MuZLU+3LZPQb1HuZffwZl+v5JHQDe5LYHGhA1wTMNlwRedYIysSxBjogHNciNIHsKP3JjmqyYmLO5LCEp3hjaQ==} + '@codama/renderers-js@1.7.0': resolution: {integrity: sha512-WwKkSkNPdUBVWjGmkG+RNXyZ5K/4ji8UZQGzowDNTrqktUrqPsBThOkc7Zpmv+TpCapxrfjj0Txpo+0q5FjKGw==} engines: {node: '>=20.18.0'} - '@codama/renderers-rust@1.0.22': - resolution: {integrity: sha512-ovK1UyFYt/oWW8W2B6ghe/nc1kvITakVQqVIlK21l2VHGo6yEFcdWvBRYn5VXMuwW0nMwPuC7Hv0eZmGLRR7xg==} + '@codama/renderers-rust@2.0.0': + resolution: {integrity: sha512-un4SoFTVz51hrA+9q/klYQybIHhKnLTK3TnphzeBWKBig1z5WEI11YdfFvi8kEl03m97fg13kwHvhBPpkSxt9A==} + engines: {node: '>=20.18.0'} '@codama/validators@1.5.0': resolution: {integrity: sha512-p3ufDxnCH1jiuHGzcBv4/d+ctzUcKD2K3gX/W8169tC41o9DggjlEpNy1Z6YAAhVb3wHnmXVGA2qmp32rWSfWw==} - '@codama/visitors-core@1.3.0': - resolution: {integrity: sha512-Lldy0aOc882QYDa1IhjXhwpDsQE7oirBaebRddggXYFQs4+cvFROibHXBqG2npHPvQM4Mot6dJHQqffB/QL4iQ==} - '@codama/visitors-core@1.4.4': resolution: {integrity: sha512-vk/4tczViAUHa7c8PF7FxN+JWbuTcDB0pIdrDbbO6eBPKDPQGZCUCEp6rXIYBVxfO129jWrNf2+CuyYre/c/vA==} @@ -85,11 +73,8 @@ packages: '@codama/visitors@1.5.0': resolution: {integrity: sha512-SwtQaleXxAaFz6uHygxki621q4nPUDQlnwEhsg+QKOjHpKWXjLYdJof+R8gUiTV/n7/IeNnjvxJTTNfUsvETPQ==} - '@solana/codecs-core@2.0.0-rc.4': - resolution: {integrity: sha512-JIrTSps032mSE3wBxW3bXOqWfoy4CMy1CX/XeVCijyh5kLVxZTSDIdRTYdePdL1yzaOZF1Xysvt1DhOUgBdM+A==} - engines: {node: '>=20.18.0'} - peerDependencies: - typescript: '>=5' + '@iarna/toml@2.2.5': + resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==} '@solana/codecs-core@6.0.1': resolution: {integrity: sha512-OnUQk94qfvfE0nVveZ638aNUL3tyRJoorUFiAG0ICTGUo3c6fkYb8vH23o/5O2qmuSmYND1sn+UCaldNMVkFpg==} @@ -100,12 +85,6 @@ packages: typescript: optional: true - '@solana/codecs-numbers@2.0.0-rc.4': - resolution: {integrity: sha512-ZJR7TaUO65+3Hzo3YOOUCS0wlzh17IW+j0MZC2LCk1R0woaypRpHKj4iSMYeQOZkMxsd9QT3WNvjFrPC2qA6Sw==} - engines: {node: '>=20.18.0'} - peerDependencies: - typescript: '>=5' - '@solana/codecs-numbers@6.0.1': resolution: {integrity: sha512-ZrI1NjUsf4I+Klue/2rlQbZLcGRom/G2E4VB/8x4IEHGOeFLQhXcxmnib8kdgomQRYOzF1BjVDmCYxvZr+6AWA==} engines: {node: '>=20.18.0'} @@ -115,13 +94,6 @@ packages: typescript: optional: true - '@solana/codecs-strings@2.0.0-rc.4': - resolution: {integrity: sha512-LGfK2RL0BKjYYUfzu2FG/gTgCsYOMz9FKVs2ntji6WneZygPxJTV5W98K3J8Rl0JewpCSCFQH3xjLSHBJUS0fA==} - engines: {node: '>=20.18.0'} - peerDependencies: - fastestsmallesttextencoderdecoder: ^1.0.22 - typescript: '>=5' - '@solana/codecs-strings@6.0.1': resolution: {integrity: sha512-OmMIfMFbbJVIxveBeATKCj9DsmZ8l4vJPnOLHUop0hLWRiYHTQ1qokMqfk/X8PCmUjXmbXnlp63BikGtdKN3/g==} engines: {node: '>=20.18.0'} @@ -134,13 +106,6 @@ packages: typescript: optional: true - '@solana/errors@2.0.0-rc.4': - resolution: {integrity: sha512-0PPaMyB81keEHG/1pnyEuiBVKctbXO641M2w3CIOrYT/wzjunfF0FTxsqq9wYJeYo0AyiefCKGgSPs6wiY2PpQ==} - engines: {node: '>=20.18.0'} - hasBin: true - peerDependencies: - typescript: '>=5' - '@solana/errors@6.0.1': resolution: {integrity: sha512-sMe5GCsXto8F1KDeq9GbZR0+m841SqEYep3NAcYlC0lqF2RG4giaaPQHgrWI5DJR/L7yc8FzUIQfTxnaN7bwOQ==} engines: {node: '>=20.18.0'} @@ -174,10 +139,6 @@ packages: resolution: {integrity: sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==} engines: {node: '>= 0.4'} - chalk@5.6.0: - resolution: {integrity: sha512-46QrSQFyVSEyYAgQ22hQ+zDa60YHA4fBstHmtSApj1Y5vKtG27fWowW03jCk5KcbXEWPZUIR894aARCA/G1kfQ==} - engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} - chalk@5.6.2: resolution: {integrity: sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==} engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} @@ -186,14 +147,6 @@ packages: resolution: {integrity: sha512-hhfSzrOiDX3bV7QmJneEBsBk3ln4gIcMJs6P8BlEJ3EFI+P0QZaTT5W61o8Tq0/79hTZeyj0gP65HZ/LYJil+w==} hasBin: true - commander@12.1.0: - resolution: {integrity: sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==} - engines: {node: '>=18'} - - commander@13.1.0: - resolution: {integrity: sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==} - engines: {node: '>=18'} - commander@14.0.2: resolution: {integrity: sha512-TywoWNNRbhoD0BXs1P3ZEScW8W5iKrnbithIl0YH+uCmBd0QpPOA8yc82DS3BIE5Ma6FnBVUsJ7wVUDz4dvOWQ==} engines: {node: '>=20'} @@ -327,12 +280,6 @@ snapshots: picocolors: 1.1.1 prompts: 2.4.2 - '@codama/errors@1.3.0': - dependencies: - '@codama/node-types': 1.3.0 - chalk: 5.6.0 - commander: 13.1.0 - '@codama/errors@1.4.4': dependencies: '@codama/node-types': 1.4.4 @@ -345,17 +292,10 @@ snapshots: commander: 14.0.2 picocolors: 1.1.1 - '@codama/node-types@1.3.0': {} - '@codama/node-types@1.4.4': {} '@codama/node-types@1.5.0': {} - '@codama/nodes@1.3.0': - dependencies: - '@codama/errors': 1.3.0 - '@codama/node-types': 1.3.0 - '@codama/nodes@1.4.4': dependencies: '@codama/errors': 1.4.4 @@ -366,18 +306,18 @@ snapshots: '@codama/errors': 1.5.0 '@codama/node-types': 1.5.0 - '@codama/renderers-core@1.0.16': - dependencies: - '@codama/errors': 1.3.0 - '@codama/nodes': 1.3.0 - '@codama/visitors-core': 1.3.0 - '@codama/renderers-core@1.3.4': dependencies: '@codama/errors': 1.4.4 '@codama/nodes': 1.4.4 '@codama/visitors-core': 1.4.4 + '@codama/renderers-core@1.3.5': + dependencies: + '@codama/errors': 1.5.0 + '@codama/nodes': 1.5.0 + '@codama/visitors-core': 1.5.0 + '@codama/renderers-js@1.7.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3)': dependencies: '@codama/errors': 1.4.4 @@ -391,14 +331,16 @@ snapshots: - fastestsmallesttextencoderdecoder - typescript - '@codama/renderers-rust@1.0.22(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3)': + '@codama/renderers-rust@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3)': dependencies: - '@codama/errors': 1.3.0 - '@codama/nodes': 1.3.0 - '@codama/renderers-core': 1.0.16 - '@codama/visitors-core': 1.3.0 - '@solana/codecs-strings': 2.0.0-rc.4(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3) + '@codama/errors': 1.5.0 + '@codama/nodes': 1.5.0 + '@codama/renderers-core': 1.3.5 + '@codama/visitors-core': 1.5.0 + '@iarna/toml': 2.2.5 + '@solana/codecs-strings': 6.0.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3) nunjucks: 3.2.4 + semver: 7.7.3 transitivePeerDependencies: - chokidar - fastestsmallesttextencoderdecoder @@ -410,12 +352,6 @@ snapshots: '@codama/nodes': 1.5.0 '@codama/visitors-core': 1.5.0 - '@codama/visitors-core@1.3.0': - dependencies: - '@codama/errors': 1.3.0 - '@codama/nodes': 1.3.0 - json-stable-stringify: 1.3.0 - '@codama/visitors-core@1.4.4': dependencies: '@codama/errors': 1.4.4 @@ -434,10 +370,7 @@ snapshots: '@codama/nodes': 1.5.0 '@codama/visitors-core': 1.5.0 - '@solana/codecs-core@2.0.0-rc.4(typescript@5.7.3)': - dependencies: - '@solana/errors': 2.0.0-rc.4(typescript@5.7.3) - typescript: 5.7.3 + '@iarna/toml@2.2.5': {} '@solana/codecs-core@6.0.1(typescript@5.7.3)': dependencies: @@ -445,12 +378,6 @@ snapshots: optionalDependencies: typescript: 5.7.3 - '@solana/codecs-numbers@2.0.0-rc.4(typescript@5.7.3)': - dependencies: - '@solana/codecs-core': 2.0.0-rc.4(typescript@5.7.3) - '@solana/errors': 2.0.0-rc.4(typescript@5.7.3) - typescript: 5.7.3 - '@solana/codecs-numbers@6.0.1(typescript@5.7.3)': dependencies: '@solana/codecs-core': 6.0.1(typescript@5.7.3) @@ -458,14 +385,6 @@ snapshots: optionalDependencies: typescript: 5.7.3 - '@solana/codecs-strings@2.0.0-rc.4(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3)': - dependencies: - '@solana/codecs-core': 2.0.0-rc.4(typescript@5.7.3) - '@solana/codecs-numbers': 2.0.0-rc.4(typescript@5.7.3) - '@solana/errors': 2.0.0-rc.4(typescript@5.7.3) - fastestsmallesttextencoderdecoder: 1.0.22 - typescript: 5.7.3 - '@solana/codecs-strings@6.0.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.7.3)': dependencies: '@solana/codecs-core': 6.0.1(typescript@5.7.3) @@ -475,12 +394,6 @@ snapshots: fastestsmallesttextencoderdecoder: 1.0.22 typescript: 5.7.3 - '@solana/errors@2.0.0-rc.4(typescript@5.7.3)': - dependencies: - chalk: 5.6.2 - commander: 12.1.0 - typescript: 5.7.3 - '@solana/errors@6.0.1(typescript@5.7.3)': dependencies: chalk: 5.6.2 @@ -513,8 +426,6 @@ snapshots: call-bind-apply-helpers: 1.0.2 get-intrinsic: 1.3.0 - chalk@5.6.0: {} - chalk@5.6.2: {} codama@1.5.0: @@ -525,10 +436,6 @@ snapshots: '@codama/validators': 1.5.0 '@codama/visitors': 1.5.0 - commander@12.1.0: {} - - commander@13.1.0: {} - commander@14.0.2: {} commander@14.0.3: {} @@ -555,7 +462,8 @@ snapshots: dependencies: es-errors: 1.3.0 - fastestsmallesttextencoderdecoder@1.0.22: {} + fastestsmallesttextencoderdecoder@1.0.22: + optional: true function-bind@1.1.2: {} @@ -635,4 +543,5 @@ snapshots: sisteransi@1.0.5: {} - typescript@5.7.3: {} + typescript@5.7.3: + optional: true