From c1e24c41189432f7917ffa09ae3c578aceb894b7 Mon Sep 17 00:00:00 2001 From: Fernando Otero Date: Fri, 8 Sep 2023 00:01:26 +0100 Subject: [PATCH] Update Kinobi version for Rust client (#49) * Bump Kinobi version * Update example * Improve hooked type --- .github/workflows/build-rust-client.yml | 2 +- clients/rust/Cargo.lock | 48 +++- clients/rust/Cargo.toml | 3 + clients/rust/README.md | 51 ++-- .../accounts/collection_authority_record.rs | 32 ++- .../rust/src/generated/accounts/edition.rs | 11 + .../src/generated/accounts/edition_marker.rs | 26 +- .../generated/accounts/edition_marker_v2.rs | 24 +- .../src/generated/accounts/master_edition.rs | 24 +- .../rust/src/generated/accounts/metadata.rs | 32 ++- .../accounts/metadata_delegate_record.rs | 48 ++-- clients/rust/src/generated/accounts/mod.rs | 20 +- .../generated/accounts/token_owned_escrow.rs | 13 + .../src/generated/accounts/token_record.rs | 26 +- .../accounts/use_authority_record.rs | 26 +- clients/rust/src/generated/errors/mod.rs | 2 +- .../approve_collection_authority.rs | 144 +++++++++-- .../instructions/approve_use_authority.rs | 161 +++++++++++-- .../bubblegum_set_collection_size.rs | 138 +++++++++-- .../instructions/burn_edition_nft.rs | 139 ++++++++++- .../src/generated/instructions/burn_nft.rs | 138 +++++++++-- .../src/generated/instructions/burn_v1.rs | 225 ++++++++++++++---- .../instructions/close_escrow_account.rs | 134 ++++++++++- .../src/generated/instructions/collect.rs | 114 ++++++++- .../convert_master_edition_v1_to_v2.rs | 117 ++++++++- .../instructions/create_escrow_account.rs | 145 +++++++++-- .../instructions/create_master_edition_v3.rs | 155 ++++++++++-- .../create_metadata_account_v3.rs | 148 ++++++++++-- .../src/generated/instructions/create_v1.rs | 156 ++++++++++-- .../delegate_authority_item_v1.rs | 224 +++++++++++++---- .../delegate_collection_item_v1.rs | 224 +++++++++++++---- .../instructions/delegate_collection_v1.rs | 224 +++++++++++++---- .../instructions/delegate_data_item_v1.rs | 224 +++++++++++++---- .../instructions/delegate_data_v1.rs | 224 +++++++++++++---- .../delegate_locked_transfer_v1.rs | 213 ++++++++++++++--- .../delegate_programmable_config_item_v1.rs | 224 +++++++++++++---- .../delegate_programmable_config_v1.rs | 224 +++++++++++++---- .../instructions/delegate_sale_v1.rs | 213 ++++++++++++++--- .../instructions/delegate_staking_v1.rs | 213 ++++++++++++++--- .../instructions/delegate_standard_v1.rs | 213 ++++++++++++++--- .../instructions/delegate_transfer_v1.rs | 213 ++++++++++++++--- .../instructions/delegate_utility_v1.rs | 213 ++++++++++++++--- ..._from_master_edition_via_printing_token.rs | 167 +++++++++++-- .../instructions/freeze_delegated_account.rs | 124 +++++++++- .../src/generated/instructions/lock_v1.rs | 210 +++++++++++++--- .../src/generated/instructions/migrate.rs | 172 +++++++++++-- ...w_edition_from_master_edition_via_token.rs | 170 +++++++++++-- ...ion_from_master_edition_via_vault_proxy.rs | 179 ++++++++++++-- .../src/generated/instructions/mint_v1.rs | 221 ++++++++++++++--- .../rust/src/generated/instructions/mod.rs | 222 ++++++++++------- .../src/generated/instructions/print_v1.rs | 181 ++++++++++++-- .../generated/instructions/puff_metadata.rs | 111 ++++++++- .../remove_creator_verification.rs | 114 ++++++++- .../instructions/revoke_authority_item_v1.rs | 217 ++++++++++++++--- .../revoke_collection_authority.rs | 123 +++++++++- .../instructions/revoke_collection_item_v1.rs | 217 ++++++++++++++--- .../instructions/revoke_collection_v1.rs | 217 ++++++++++++++--- .../instructions/revoke_data_item_v1.rs | 217 ++++++++++++++--- .../generated/instructions/revoke_data_v1.rs | 217 ++++++++++++++--- .../instructions/revoke_locked_transfer_v1.rs | 206 +++++++++++++--- .../instructions/revoke_migration_v1.rs | 206 +++++++++++++--- .../revoke_programmable_config_item_v1.rs | 217 ++++++++++++++--- .../revoke_programmable_config_v1.rs | 217 ++++++++++++++--- .../generated/instructions/revoke_sale_v1.rs | 206 +++++++++++++--- .../instructions/revoke_staking_v1.rs | 206 +++++++++++++--- .../instructions/revoke_standard_v1.rs | 206 +++++++++++++--- .../instructions/revoke_transfer_v1.rs | 206 +++++++++++++--- .../instructions/revoke_use_authority.rs | 148 ++++++++++-- .../instructions/revoke_utility_v1.rs | 206 +++++++++++++--- .../instructions/set_and_verify_collection.rs | 140 +++++++++-- .../set_and_verify_sized_collection_item.rs | 140 +++++++++-- .../instructions/set_collection_size.rs | 135 +++++++++-- .../instructions/set_token_standard.rs | 128 ++++++++-- .../generated/instructions/sign_metadata.rs | 114 ++++++++- .../instructions/thaw_delegated_account.rs | 124 +++++++++- .../instructions/transfer_out_of_escrow.rs | 166 +++++++++++-- .../src/generated/instructions/transfer_v1.rs | 213 ++++++++++++++--- .../src/generated/instructions/unlock_v1.rs | 210 +++++++++++++--- .../instructions/unverify_collection.rs | 134 +++++++++-- .../instructions/unverify_collection_v1.rs | 147 ++++++++++-- .../instructions/unverify_creator_v1.rs | 155 ++++++++++-- .../unverify_sized_collection_item.rs | 137 +++++++++-- .../update_as_authority_item_delegate_v2.rs | 193 ++++++++++++--- .../update_as_collection_delegate_v2.rs | 193 ++++++++++++--- .../update_as_collection_item_delegate_v2.rs | 193 ++++++++++++--- .../update_as_data_delegate_v2.rs | 193 ++++++++++++--- .../update_as_data_item_delegate_v2.rs | 193 ++++++++++++--- ...date_as_programmable_config_delegate_v2.rs | 182 +++++++++++--- ...as_programmable_config_item_delegate_v2.rs | 182 +++++++++++--- .../update_as_update_authority_v2.rs | 193 ++++++++++++--- .../update_metadata_account_v2.rs | 121 +++++++++- .../update_primary_sale_happened_via_token.rs | 117 ++++++++- .../src/generated/instructions/update_v1.rs | 193 ++++++++++++--- .../rust/src/generated/instructions/use_v1.rs | 204 +++++++++++++--- .../src/generated/instructions/utilize.rs | 168 +++++++++++-- .../instructions/verify_collection.rs | 137 +++++++++-- .../instructions/verify_collection_v1.rs | 158 ++++++++++-- .../instructions/verify_creator_v1.rs | 166 ++++++++++--- .../verify_sized_collection_item.rs | 137 +++++++++-- .../src/generated/types/authority_type.rs | 1 + .../src/generated/types/authorization_data.rs | 1 + clients/rust/src/generated/types/burn_args.rs | 1 + .../rust/src/generated/types/collection.rs | 5 + .../src/generated/types/collection_details.rs | 1 + .../types/collection_details_toggle.rs | 1 + .../src/generated/types/collection_toggle.rs | 1 + .../rust/src/generated/types/create_args.rs | 1 + clients/rust/src/generated/types/creator.rs | 5 + clients/rust/src/generated/types/data.rs | 1 + clients/rust/src/generated/types/data_v2.rs | 1 + .../rust/src/generated/types/delegate_args.rs | 5 + .../src/generated/types/escrow_authority.rs | 1 + clients/rust/src/generated/types/key.rs | 1 + clients/rust/src/generated/types/leaf_info.rs | 1 + clients/rust/src/generated/types/lock_args.rs | 1 + .../generated/types/metadata_delegate_role.rs | 1 + .../src/generated/types/migration_type.rs | 1 + clients/rust/src/generated/types/mint_args.rs | 1 + ...tion_from_master_edition_via_token_args.rs | 1 + clients/rust/src/generated/types/mod.rs | 86 +++---- clients/rust/src/generated/types/payload.rs | 1 + .../rust/src/generated/types/payload_key.rs | 1 + .../rust/src/generated/types/payload_type.rs | 1 + .../rust/src/generated/types/print_args.rs | 1 + .../rust/src/generated/types/print_supply.rs | 1 + .../generated/types/programmable_config.rs | 1 + .../rust/src/generated/types/reservation.rs | 5 + .../src/generated/types/reservation_v1.rs | 5 + .../rust/src/generated/types/revoke_args.rs | 1 + .../src/generated/types/rule_set_toggle.rs | 1 + clients/rust/src/generated/types/seeds_vec.rs | 1 + .../types/set_collection_size_args.rs | 1 + .../generated/types/token_delegate_role.rs | 1 + .../src/generated/types/token_standard.rs | 1 + .../rust/src/generated/types/token_state.rs | 1 + .../rust/src/generated/types/transfer_args.rs | 1 + .../rust/src/generated/types/unlock_args.rs | 1 + .../rust/src/generated/types/update_args.rs | 1 + clients/rust/src/generated/types/use_args.rs | 1 + .../rust/src/generated/types/use_method.rs | 1 + clients/rust/src/generated/types/uses.rs | 1 + .../rust/src/generated/types/uses_toggle.rs | 1 + .../src/generated/types/verification_args.rs | 1 + .../src/hooked/metadata_delegate_role_seed.rs | 12 +- clients/rust/tests/create.rs | 10 +- clients/rust/tests/lock.rs | 12 +- clients/rust/tests/setup/digital_asset.rs | 10 +- package.json | 2 +- pnpm-lock.yaml | 8 +- 149 files changed, 12893 insertions(+), 2427 deletions(-) diff --git a/.github/workflows/build-rust-client.yml b/.github/workflows/build-rust-client.yml index 26867f5d..15f0528a 100644 --- a/.github/workflows/build-rust-client.yml +++ b/.github/workflows/build-rust-client.yml @@ -54,7 +54,7 @@ jobs: - name: Build Rust client shell: bash working-directory: clients/rust - run: cargo build --release + run: cargo build --all-features --release - name: Upload Rust client builds uses: actions/upload-artifact@v3 diff --git a/clients/rust/Cargo.lock b/clients/rust/Cargo.lock index 1bedf332..d6a32f1e 100644 --- a/clients/rust/Cargo.lock +++ b/clients/rust/Cargo.lock @@ -1061,6 +1061,9 @@ name = "deranged" version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" +dependencies = [ + "serde", +] [[package]] name = "derivation-path" @@ -1591,6 +1594,12 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + [[package]] name = "histogram" version = "0.6.9" @@ -1774,6 +1783,7 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", + "serde", ] [[package]] @@ -1784,6 +1794,7 @@ checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" dependencies = [ "equivalent", "hashbrown 0.14.0", + "serde", ] [[package]] @@ -2088,6 +2099,8 @@ dependencies = [ "borsh 0.10.3", "num-derive", "num-traits", + "serde", + "serde_with 3.3.0", "solana-program", "solana-program-test", "solana-sdk", @@ -3129,7 +3142,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe" dependencies = [ "serde", - "serde_with_macros", + "serde_with_macros 2.3.3", +] + +[[package]] +name = "serde_with" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ca3b16a3d82c4088f343b7480a93550b3eabe1a358569c2dfe38bbcead07237" +dependencies = [ + "base64 0.21.3", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.0.0", + "serde", + "serde_json", + "serde_with_macros 3.3.0", + "time 0.3.28", ] [[package]] @@ -3144,6 +3174,18 @@ dependencies = [ "syn 2.0.29", ] +[[package]] +name = "serde_with_macros" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e6be15c453eb305019bfa438b1593c731f36a289a7853f7707ee29e870b3b3c" +dependencies = [ + "darling", + "proc-macro2 1.0.66", + "quote 1.0.33", + "syn 2.0.29", +] + [[package]] name = "sha-1" version = "0.10.1" @@ -4005,7 +4047,7 @@ dependencies = [ "serde_bytes", "serde_derive", "serde_json", - "serde_with", + "serde_with 2.3.3", "sha2 0.10.7", "sha3 0.10.8", "solana-frozen-abi", @@ -5590,4 +5632,4 @@ dependencies = [ "cc", "libc", "pkg-config", -] \ No newline at end of file +] diff --git a/clients/rust/Cargo.toml b/clients/rust/Cargo.toml index 8f53eda9..f427de75 100644 --- a/clients/rust/Cargo.toml +++ b/clients/rust/Cargo.toml @@ -13,11 +13,14 @@ crate-type = ["cdylib", "lib"] [features] test-sbf = [] +serde = ["dep:serde", "dep:serde_with"] [dependencies] borsh = ">= 0.9" num-derive = "^0.3" num-traits = "^0.2" +serde = { version = "^1.0", features = ["derive"], optional = true } +serde_with = { version = "^3.0", optional = true } solana-program = "^1.14" thiserror = "^1.0" diff --git a/clients/rust/README.md b/clients/rust/README.md index 3220657f..6f1e7d97 100644 --- a/clients/rust/README.md +++ b/clients/rust/README.md @@ -107,7 +107,7 @@ Alternatively, you can use the `CreateV1Builder` to create the appropriate instr ```rust let create_ix = CreateV1Builder::new() .metadata(metadata) - .master_edition(master_edition) + .master_edition(Some(master_edition)) .mint(mint_pubkey, true) .authority(payer_pubkey) .payer(payer_pubkey) @@ -169,7 +169,7 @@ pub struct TransferV1Cpi<'a> { } ``` -After filling in the instruction account info and argument fields, you can use the `invoke()` or `invoke_signed(...)` method to perform the CPI: +After filling in the program, instruction accounts and argument fields, you can use the `invoke()` or `invoke_signed(...)` method to perform the CPI: ```rust // instruction args @@ -179,27 +179,29 @@ let mut args = TransferV1InstructionArgs { }; // instruction accounts -let cpi_transfer = TransferV1Cpi { - __program: metadata_program_info, - __args: args, - token: owner_token_info, - token_owner: owner_info, - destination_token: destination_token_info, - destination_owner: destination_info, - mint: mint_info, - metadata: metadata_info, - authority: vault_info, - payer: payer_info, - system_program: system_program_info, - sysvar_instructions: sysvar_instructions_info, - spl_token_program: spl_token_program_info, - spl_ata_program: spl_ata_program_info, - edition: edition_info, - token_record: None, - destination_token_record: None, - authorization_rules: None, - authorization_rules_program: None, -}; +let cpi_transfer = TransferV1Cpi::new( + metadata_program_info, + TransferV1CpiAccounts { + token: owner_token_info, + token_owner: owner_info, + destination_token: destination_token_info, + destination_owner: destination_info, + mint: mint_info, + metadata: metadata_info, + authority: vault_info, + payer: payer_info, + system_program: system_program_info, + sysvar_instructions: sysvar_instructions_info, + spl_token_program: spl_token_program_info, + spl_ata_program: spl_ata_program_info, + edition: edition_info, + token_record: None, + destination_token_record: None, + authorization_rules: None, + authorization_rules_program: None, + }, + args, +); // performs the CPI cpi_transfer.invoke_signed(&[&signer_seeds]) @@ -222,8 +224,7 @@ let cpi_transfer = TransferV1CpiBuilder::new(metadata_program_info) .sysvar_instructions(sysvar_instructions_info) .spl_token_program(spl_token_program_info) .spl_ata_program(spl_ata_program_info) - .amount(amount) - .build(); + .amount(amount); // performs the CPI cpi_transfer.invoke_signed(&[&signer_seeds]) diff --git a/clients/rust/src/generated/accounts/collection_authority_record.rs b/clients/rust/src/generated/accounts/collection_authority_record.rs index 657840e8..574f599f 100644 --- a/clients/rust/src/generated/accounts/collection_authority_record.rs +++ b/clients/rust/src/generated/accounts/collection_authority_record.rs @@ -11,6 +11,7 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CollectionAuthorityRecord { pub key: Key, pub bump: u8, @@ -18,38 +19,45 @@ pub struct CollectionAuthorityRecord { } impl CollectionAuthorityRecord { - pub fn find_pda( - mint: &Pubkey, - collection_authority: &Pubkey, - ) -> (solana_program::pubkey::Pubkey, u8) { - solana_program::pubkey::Pubkey::find_program_address( + pub fn create_pda( + mint: Pubkey, + collection_authority: Pubkey, + bump: u8, + ) -> Result { + solana_program::pubkey::Pubkey::create_program_address( &[ "metadata".as_bytes(), crate::MPL_TOKEN_METADATA_ID.as_ref(), mint.as_ref(), "collection_authority".as_bytes(), collection_authority.as_ref(), + &[bump], ], &crate::MPL_TOKEN_METADATA_ID, ) } - pub fn create_pda( - mint: Pubkey, - collection_authority: Pubkey, - bump: u8, - ) -> Result { - solana_program::pubkey::Pubkey::create_program_address( + + pub fn find_pda( + mint: &Pubkey, + collection_authority: &Pubkey, + ) -> (solana_program::pubkey::Pubkey, u8) { + solana_program::pubkey::Pubkey::find_program_address( &[ "metadata".as_bytes(), crate::MPL_TOKEN_METADATA_ID.as_ref(), mint.as_ref(), "collection_authority".as_bytes(), collection_authority.as_ref(), - &[bump], ], &crate::MPL_TOKEN_METADATA_ID, ) } + + #[inline(always)] + pub fn from_bytes(data: &[u8]) -> Result { + let mut data = data; + Self::deserialize(&mut data) + } } impl<'a> TryFrom<&'a solana_program::account_info::AccountInfo<'a>> for CollectionAuthorityRecord { diff --git a/clients/rust/src/generated/accounts/edition.rs b/clients/rust/src/generated/accounts/edition.rs index 87853288..9e29270f 100644 --- a/clients/rust/src/generated/accounts/edition.rs +++ b/clients/rust/src/generated/accounts/edition.rs @@ -11,14 +11,25 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Edition { pub key: Key, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] pub parent: Pubkey, pub edition: u64, } impl Edition { pub const LEN: usize = 41; + + #[inline(always)] + pub fn from_bytes(data: &[u8]) -> Result { + let mut data = data; + Self::deserialize(&mut data) + } } impl<'a> TryFrom<&'a solana_program::account_info::AccountInfo<'a>> for Edition { diff --git a/clients/rust/src/generated/accounts/edition_marker.rs b/clients/rust/src/generated/accounts/edition_marker.rs index 1f7f5b93..39b3cc3e 100644 --- a/clients/rust/src/generated/accounts/edition_marker.rs +++ b/clients/rust/src/generated/accounts/edition_marker.rs @@ -11,6 +11,7 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct EditionMarker { pub key: Key, pub ledger: [u8; 31], @@ -19,35 +20,42 @@ pub struct EditionMarker { impl EditionMarker { pub const LEN: usize = 32; - pub fn find_pda(mint: &Pubkey, edition_marker: &str) -> (solana_program::pubkey::Pubkey, u8) { - solana_program::pubkey::Pubkey::find_program_address( + pub fn create_pda( + mint: Pubkey, + edition_marker: &str, + bump: u8, + ) -> Result { + solana_program::pubkey::Pubkey::create_program_address( &[ "metadata".as_bytes(), crate::MPL_TOKEN_METADATA_ID.as_ref(), mint.as_ref(), "edition".as_bytes(), edition_marker.to_string().as_ref(), + &[bump], ], &crate::MPL_TOKEN_METADATA_ID, ) } - pub fn create_pda( - mint: Pubkey, - edition_marker: &str, - bump: u8, - ) -> Result { - solana_program::pubkey::Pubkey::create_program_address( + + pub fn find_pda(mint: &Pubkey, edition_marker: &str) -> (solana_program::pubkey::Pubkey, u8) { + solana_program::pubkey::Pubkey::find_program_address( &[ "metadata".as_bytes(), crate::MPL_TOKEN_METADATA_ID.as_ref(), mint.as_ref(), "edition".as_bytes(), edition_marker.to_string().as_ref(), - &[bump], ], &crate::MPL_TOKEN_METADATA_ID, ) } + + #[inline(always)] + pub fn from_bytes(data: &[u8]) -> Result { + let mut data = data; + Self::deserialize(&mut data) + } } impl<'a> TryFrom<&'a solana_program::account_info::AccountInfo<'a>> for EditionMarker { diff --git a/clients/rust/src/generated/accounts/edition_marker_v2.rs b/clients/rust/src/generated/accounts/edition_marker_v2.rs index 4732e702..0ea7d88e 100644 --- a/clients/rust/src/generated/accounts/edition_marker_v2.rs +++ b/clients/rust/src/generated/accounts/edition_marker_v2.rs @@ -11,40 +11,48 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct EditionMarkerV2 { pub key: Key, pub ledger: Vec, } impl EditionMarkerV2 { - pub fn find_pda(mint: &Pubkey) -> (solana_program::pubkey::Pubkey, u8) { - solana_program::pubkey::Pubkey::find_program_address( + pub fn create_pda( + mint: Pubkey, + bump: u8, + ) -> Result { + solana_program::pubkey::Pubkey::create_program_address( &[ "metadata".as_bytes(), crate::MPL_TOKEN_METADATA_ID.as_ref(), mint.as_ref(), "edition".as_bytes(), "marker".as_bytes(), + &[bump], ], &crate::MPL_TOKEN_METADATA_ID, ) } - pub fn create_pda( - mint: Pubkey, - bump: u8, - ) -> Result { - solana_program::pubkey::Pubkey::create_program_address( + + pub fn find_pda(mint: &Pubkey) -> (solana_program::pubkey::Pubkey, u8) { + solana_program::pubkey::Pubkey::find_program_address( &[ "metadata".as_bytes(), crate::MPL_TOKEN_METADATA_ID.as_ref(), mint.as_ref(), "edition".as_bytes(), "marker".as_bytes(), - &[bump], ], &crate::MPL_TOKEN_METADATA_ID, ) } + + #[inline(always)] + pub fn from_bytes(data: &[u8]) -> Result { + let mut data = data; + Self::deserialize(&mut data) + } } impl<'a> TryFrom<&'a solana_program::account_info::AccountInfo<'a>> for EditionMarkerV2 { diff --git a/clients/rust/src/generated/accounts/master_edition.rs b/clients/rust/src/generated/accounts/master_edition.rs index db1b6b3f..a0833b9e 100644 --- a/clients/rust/src/generated/accounts/master_edition.rs +++ b/clients/rust/src/generated/accounts/master_edition.rs @@ -11,6 +11,7 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MasterEdition { pub key: Key, pub supply: u64, @@ -18,32 +19,39 @@ pub struct MasterEdition { } impl MasterEdition { - pub fn find_pda(mint: &Pubkey) -> (solana_program::pubkey::Pubkey, u8) { - solana_program::pubkey::Pubkey::find_program_address( + pub fn create_pda( + mint: Pubkey, + bump: u8, + ) -> Result { + solana_program::pubkey::Pubkey::create_program_address( &[ "metadata".as_bytes(), crate::MPL_TOKEN_METADATA_ID.as_ref(), mint.as_ref(), "edition".as_bytes(), + &[bump], ], &crate::MPL_TOKEN_METADATA_ID, ) } - pub fn create_pda( - mint: Pubkey, - bump: u8, - ) -> Result { - solana_program::pubkey::Pubkey::create_program_address( + + pub fn find_pda(mint: &Pubkey) -> (solana_program::pubkey::Pubkey, u8) { + solana_program::pubkey::Pubkey::find_program_address( &[ "metadata".as_bytes(), crate::MPL_TOKEN_METADATA_ID.as_ref(), mint.as_ref(), "edition".as_bytes(), - &[bump], ], &crate::MPL_TOKEN_METADATA_ID, ) } + + #[inline(always)] + pub fn from_bytes(data: &[u8]) -> Result { + let mut data = data; + Self::deserialize(&mut data) + } } impl<'a> TryFrom<&'a solana_program::account_info::AccountInfo<'a>> for MasterEdition { diff --git a/clients/rust/src/generated/accounts/metadata.rs b/clients/rust/src/generated/accounts/metadata.rs index 033b4c07..6201c00a 100644 --- a/clients/rust/src/generated/accounts/metadata.rs +++ b/clients/rust/src/generated/accounts/metadata.rs @@ -17,9 +17,18 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Metadata { pub key: Key, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] pub update_authority: Pubkey, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] pub mint: Pubkey, pub name: String, pub symbol: String, @@ -37,30 +46,37 @@ pub struct Metadata { } impl Metadata { - pub fn find_pda(mint: &Pubkey) -> (solana_program::pubkey::Pubkey, u8) { - solana_program::pubkey::Pubkey::find_program_address( + pub fn create_pda( + mint: Pubkey, + bump: u8, + ) -> Result { + solana_program::pubkey::Pubkey::create_program_address( &[ "metadata".as_bytes(), crate::MPL_TOKEN_METADATA_ID.as_ref(), mint.as_ref(), + &[bump], ], &crate::MPL_TOKEN_METADATA_ID, ) } - pub fn create_pda( - mint: Pubkey, - bump: u8, - ) -> Result { - solana_program::pubkey::Pubkey::create_program_address( + + pub fn find_pda(mint: &Pubkey) -> (solana_program::pubkey::Pubkey, u8) { + solana_program::pubkey::Pubkey::find_program_address( &[ "metadata".as_bytes(), crate::MPL_TOKEN_METADATA_ID.as_ref(), mint.as_ref(), - &[bump], ], &crate::MPL_TOKEN_METADATA_ID, ) } + + #[inline(always)] + pub fn from_bytes(data: &[u8]) -> Result { + let mut data = data; + Self::deserialize(&mut data) + } } impl<'a> TryFrom<&'a solana_program::account_info::AccountInfo<'a>> for Metadata { diff --git a/clients/rust/src/generated/accounts/metadata_delegate_record.rs b/clients/rust/src/generated/accounts/metadata_delegate_record.rs index 17c61b50..d723a1c0 100644 --- a/clients/rust/src/generated/accounts/metadata_delegate_record.rs +++ b/clients/rust/src/generated/accounts/metadata_delegate_record.rs @@ -12,24 +12,38 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MetadataDelegateRecord { pub key: Key, pub bump: u8, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] pub mint: Pubkey, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] pub delegate: Pubkey, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] pub update_authority: Pubkey, } impl MetadataDelegateRecord { pub const LEN: usize = 98; - pub fn find_pda( - mint: &Pubkey, + pub fn create_pda( + mint: Pubkey, delegate_role: MetadataDelegateRoleSeed, - update_authority: &Pubkey, - delegate: &Pubkey, - ) -> (solana_program::pubkey::Pubkey, u8) { - solana_program::pubkey::Pubkey::find_program_address( + update_authority: Pubkey, + delegate: Pubkey, + bump: u8, + ) -> Result { + solana_program::pubkey::Pubkey::create_program_address( &[ "metadata".as_bytes(), crate::MPL_TOKEN_METADATA_ID.as_ref(), @@ -37,18 +51,19 @@ impl MetadataDelegateRecord { delegate_role.to_string().as_ref(), update_authority.as_ref(), delegate.as_ref(), + &[bump], ], &crate::MPL_TOKEN_METADATA_ID, ) } - pub fn create_pda( - mint: Pubkey, + + pub fn find_pda( + mint: &Pubkey, delegate_role: MetadataDelegateRoleSeed, - update_authority: Pubkey, - delegate: Pubkey, - bump: u8, - ) -> Result { - solana_program::pubkey::Pubkey::create_program_address( + update_authority: &Pubkey, + delegate: &Pubkey, + ) -> (solana_program::pubkey::Pubkey, u8) { + solana_program::pubkey::Pubkey::find_program_address( &[ "metadata".as_bytes(), crate::MPL_TOKEN_METADATA_ID.as_ref(), @@ -56,11 +71,16 @@ impl MetadataDelegateRecord { delegate_role.to_string().as_ref(), update_authority.as_ref(), delegate.as_ref(), - &[bump], ], &crate::MPL_TOKEN_METADATA_ID, ) } + + #[inline(always)] + pub fn from_bytes(data: &[u8]) -> Result { + let mut data = data; + Self::deserialize(&mut data) + } } impl<'a> TryFrom<&'a solana_program::account_info::AccountInfo<'a>> for MetadataDelegateRecord { diff --git a/clients/rust/src/generated/accounts/mod.rs b/clients/rust/src/generated/accounts/mod.rs index 7fe23f41..94bed0c0 100644 --- a/clients/rust/src/generated/accounts/mod.rs +++ b/clients/rust/src/generated/accounts/mod.rs @@ -5,16 +5,16 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -pub mod collection_authority_record; -pub mod edition; -pub mod edition_marker; -pub mod edition_marker_v2; -pub mod master_edition; -pub mod metadata; -pub mod metadata_delegate_record; -pub mod token_owned_escrow; -pub mod token_record; -pub mod use_authority_record; +pub(crate) mod collection_authority_record; +pub(crate) mod edition; +pub(crate) mod edition_marker; +pub(crate) mod edition_marker_v2; +pub(crate) mod master_edition; +pub(crate) mod metadata; +pub(crate) mod metadata_delegate_record; +pub(crate) mod token_owned_escrow; +pub(crate) mod token_record; +pub(crate) mod use_authority_record; pub use self::collection_authority_record::*; pub use self::edition::*; diff --git a/clients/rust/src/generated/accounts/token_owned_escrow.rs b/clients/rust/src/generated/accounts/token_owned_escrow.rs index f15a6c0b..77393a1f 100644 --- a/clients/rust/src/generated/accounts/token_owned_escrow.rs +++ b/clients/rust/src/generated/accounts/token_owned_escrow.rs @@ -12,13 +12,26 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TokenOwnedEscrow { pub key: Key, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] pub base_token: Pubkey, pub authority: EscrowAuthority, pub bump: u8, } +impl TokenOwnedEscrow { + #[inline(always)] + pub fn from_bytes(data: &[u8]) -> Result { + let mut data = data; + Self::deserialize(&mut data) + } +} + impl<'a> TryFrom<&'a solana_program::account_info::AccountInfo<'a>> for TokenOwnedEscrow { type Error = std::io::Error; diff --git a/clients/rust/src/generated/accounts/token_record.rs b/clients/rust/src/generated/accounts/token_record.rs index 7840e082..2ae65010 100644 --- a/clients/rust/src/generated/accounts/token_record.rs +++ b/clients/rust/src/generated/accounts/token_record.rs @@ -13,6 +13,7 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TokenRecord { pub key: Key, pub bump: u8, @@ -26,35 +27,42 @@ pub struct TokenRecord { impl TokenRecord { pub const LEN: usize = 80; - pub fn find_pda(mint: &Pubkey, token: &Pubkey) -> (solana_program::pubkey::Pubkey, u8) { - solana_program::pubkey::Pubkey::find_program_address( + pub fn create_pda( + mint: Pubkey, + token: Pubkey, + bump: u8, + ) -> Result { + solana_program::pubkey::Pubkey::create_program_address( &[ "metadata".as_bytes(), crate::MPL_TOKEN_METADATA_ID.as_ref(), mint.as_ref(), "token_record".as_bytes(), token.as_ref(), + &[bump], ], &crate::MPL_TOKEN_METADATA_ID, ) } - pub fn create_pda( - mint: Pubkey, - token: Pubkey, - bump: u8, - ) -> Result { - solana_program::pubkey::Pubkey::create_program_address( + + pub fn find_pda(mint: &Pubkey, token: &Pubkey) -> (solana_program::pubkey::Pubkey, u8) { + solana_program::pubkey::Pubkey::find_program_address( &[ "metadata".as_bytes(), crate::MPL_TOKEN_METADATA_ID.as_ref(), mint.as_ref(), "token_record".as_bytes(), token.as_ref(), - &[bump], ], &crate::MPL_TOKEN_METADATA_ID, ) } + + #[inline(always)] + pub fn from_bytes(data: &[u8]) -> Result { + let mut data = data; + Self::deserialize(&mut data) + } } impl<'a> TryFrom<&'a solana_program::account_info::AccountInfo<'a>> for TokenRecord { diff --git a/clients/rust/src/generated/accounts/use_authority_record.rs b/clients/rust/src/generated/accounts/use_authority_record.rs index 2a514bce..11f59c29 100644 --- a/clients/rust/src/generated/accounts/use_authority_record.rs +++ b/clients/rust/src/generated/accounts/use_authority_record.rs @@ -11,6 +11,7 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UseAuthorityRecord { pub key: Key, pub allowed_uses: u64, @@ -20,35 +21,42 @@ pub struct UseAuthorityRecord { impl UseAuthorityRecord { pub const LEN: usize = 10; - pub fn find_pda(mint: &Pubkey, use_authority: &Pubkey) -> (solana_program::pubkey::Pubkey, u8) { - solana_program::pubkey::Pubkey::find_program_address( + pub fn create_pda( + mint: Pubkey, + use_authority: Pubkey, + bump: u8, + ) -> Result { + solana_program::pubkey::Pubkey::create_program_address( &[ "metadata".as_bytes(), crate::MPL_TOKEN_METADATA_ID.as_ref(), mint.as_ref(), "user".as_bytes(), use_authority.as_ref(), + &[bump], ], &crate::MPL_TOKEN_METADATA_ID, ) } - pub fn create_pda( - mint: Pubkey, - use_authority: Pubkey, - bump: u8, - ) -> Result { - solana_program::pubkey::Pubkey::create_program_address( + + pub fn find_pda(mint: &Pubkey, use_authority: &Pubkey) -> (solana_program::pubkey::Pubkey, u8) { + solana_program::pubkey::Pubkey::find_program_address( &[ "metadata".as_bytes(), crate::MPL_TOKEN_METADATA_ID.as_ref(), mint.as_ref(), "user".as_bytes(), use_authority.as_ref(), - &[bump], ], &crate::MPL_TOKEN_METADATA_ID, ) } + + #[inline(always)] + pub fn from_bytes(data: &[u8]) -> Result { + let mut data = data; + Self::deserialize(&mut data) + } } impl<'a> TryFrom<&'a solana_program::account_info::AccountInfo<'a>> for UseAuthorityRecord { diff --git a/clients/rust/src/generated/errors/mod.rs b/clients/rust/src/generated/errors/mod.rs index af3ff710..4cbf11e8 100644 --- a/clients/rust/src/generated/errors/mod.rs +++ b/clients/rust/src/generated/errors/mod.rs @@ -5,6 +5,6 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -pub mod mpl_token_metadata; +pub(crate) mod mpl_token_metadata; pub use self::mpl_token_metadata::MplTokenMetadataError; diff --git a/clients/rust/src/generated/instructions/approve_collection_authority.rs b/clients/rust/src/generated/instructions/approve_collection_authority.rs index 2d28d78c..06e27459 100644 --- a/clients/rust/src/generated/instructions/approve_collection_authority.rs +++ b/clients/rust/src/generated/instructions/approve_collection_authority.rs @@ -29,9 +29,15 @@ pub struct ApproveCollectionAuthority { } impl ApproveCollectionAuthority { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(8); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.collection_authority_record, false, @@ -63,6 +69,9 @@ impl ApproveCollectionAuthority { rent, false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = ApproveCollectionAuthorityInstructionData::new() .try_to_vec() .unwrap(); @@ -97,6 +106,7 @@ pub struct ApproveCollectionAuthorityBuilder { mint: Option, system_program: Option, rent: Option, + __remaining_accounts: Vec, } impl ApproveCollectionAuthorityBuilder { @@ -148,6 +158,7 @@ impl ApproveCollectionAuthorityBuilder { self.mint = Some(mint); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { @@ -157,12 +168,22 @@ impl ApproveCollectionAuthorityBuilder { /// `[optional account]` /// Rent info #[inline(always)] - pub fn rent(&mut self, rent: solana_program::pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); + pub fn rent(&mut self, rent: Option) -> &mut Self { + self.rent = rent; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = ApproveCollectionAuthority { collection_authority_record: self .collection_authority_record @@ -180,10 +201,30 @@ impl ApproveCollectionAuthorityBuilder { rent: self.rent, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `approve_collection_authority` CPI accounts. +pub struct ApproveCollectionAuthorityCpiAccounts<'a> { + /// Collection Authority Record PDA + pub collection_authority_record: &'a solana_program::account_info::AccountInfo<'a>, + /// A Collection Authority + pub new_collection_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Update Authority of Collection NFT + pub update_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// Collection Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of Collection Metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Rent info + pub rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `approve_collection_authority` CPI instruction. pub struct ApproveCollectionAuthorityCpi<'a> { /// The program to invoke. @@ -207,16 +248,48 @@ pub struct ApproveCollectionAuthorityCpi<'a> { } impl<'a> ApproveCollectionAuthorityCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: ApproveCollectionAuthorityCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + collection_authority_record: accounts.collection_authority_record, + new_collection_authority: accounts.new_collection_authority, + update_authority: accounts.update_authority, + payer: accounts.payer, + metadata: accounts.metadata, + mint: accounts.mint, + system_program: accounts.system_program, + rent: accounts.rent, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8); + let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.collection_authority_record.key, false, @@ -250,6 +323,9 @@ impl<'a> ApproveCollectionAuthorityCpi<'a> { *rent.key, false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = ApproveCollectionAuthorityInstructionData::new() .try_to_vec() .unwrap(); @@ -259,7 +335,7 @@ impl<'a> ApproveCollectionAuthorityCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(8 + 1); + let mut account_infos = Vec::with_capacity(8 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.collection_authority_record.clone()); account_infos.push(self.new_collection_authority.clone()); @@ -271,6 +347,9 @@ impl<'a> ApproveCollectionAuthorityCpi<'a> { if let Some(rent) = self.rent { account_infos.push(rent.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -297,6 +376,7 @@ impl<'a> ApproveCollectionAuthorityCpiBuilder<'a> { mint: None, system_program: None, rent: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -360,13 +440,42 @@ impl<'a> ApproveCollectionAuthorityCpiBuilder<'a> { /// `[optional account]` /// Rent info #[inline(always)] - pub fn rent(&mut self, rent: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); + pub fn rent( + &mut self, + rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.rent = rent; + self + } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); self } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> ApproveCollectionAuthorityCpi<'a> { - ApproveCollectionAuthorityCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = ApproveCollectionAuthorityCpi { __program: self.instruction.__program, collection_authority_record: self @@ -396,7 +505,11 @@ impl<'a> ApproveCollectionAuthorityCpiBuilder<'a> { .expect("system_program is not set"), rent: self.instruction.rent, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -410,4 +523,5 @@ struct ApproveCollectionAuthorityCpiBuilderInstruction<'a> { mint: Option<&'a solana_program::account_info::AccountInfo<'a>>, system_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/approve_use_authority.rs b/clients/rust/src/generated/instructions/approve_use_authority.rs index 371504c8..7d377f7b 100644 --- a/clients/rust/src/generated/instructions/approve_use_authority.rs +++ b/clients/rust/src/generated/instructions/approve_use_authority.rs @@ -35,12 +35,19 @@ pub struct ApproveUseAuthority { } impl ApproveUseAuthority { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: ApproveUseAuthorityInstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(11); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: ApproveUseAuthorityInstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.use_authority_record, false, @@ -82,6 +89,9 @@ impl ApproveUseAuthority { rent, false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = ApproveUseAuthorityInstructionData::new() .try_to_vec() .unwrap(); @@ -107,7 +117,8 @@ impl ApproveUseAuthorityInstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ApproveUseAuthorityInstructionArgs { pub number_of_uses: u64, } @@ -127,6 +138,7 @@ pub struct ApproveUseAuthorityBuilder { system_program: Option, rent: Option, number_of_uses: Option, + __remaining_accounts: Vec, } impl ApproveUseAuthorityBuilder { @@ -187,12 +199,14 @@ impl ApproveUseAuthorityBuilder { self.burner = Some(burner); self } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` /// Token program #[inline(always)] pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self { self.token_program = Some(token_program); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { @@ -202,8 +216,8 @@ impl ApproveUseAuthorityBuilder { /// `[optional account]` /// Rent info #[inline(always)] - pub fn rent(&mut self, rent: solana_program::pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); + pub fn rent(&mut self, rent: Option) -> &mut Self { + self.rent = rent; self } #[inline(always)] @@ -211,8 +225,18 @@ impl ApproveUseAuthorityBuilder { self.number_of_uses = Some(number_of_uses); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = ApproveUseAuthority { use_authority_record: self .use_authority_record @@ -241,10 +265,36 @@ impl ApproveUseAuthorityBuilder { .expect("number_of_uses is not set"), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `approve_use_authority` CPI accounts. +pub struct ApproveUseAuthorityCpiAccounts<'a> { + /// Use Authority Record PDA + pub use_authority_record: &'a solana_program::account_info::AccountInfo<'a>, + /// Owner + pub owner: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// A Use Authority + pub user: &'a solana_program::account_info::AccountInfo<'a>, + /// Owned Token Account Of Mint + pub owner_token_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of Metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Program As Signer (Burner) + pub burner: &'a solana_program::account_info::AccountInfo<'a>, + /// Token program + pub token_program: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Rent info + pub rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `approve_use_authority` CPI instruction. pub struct ApproveUseAuthorityCpi<'a> { /// The program to invoke. @@ -276,16 +326,53 @@ pub struct ApproveUseAuthorityCpi<'a> { } impl<'a> ApproveUseAuthorityCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: ApproveUseAuthorityCpiAccounts<'a>, + args: ApproveUseAuthorityInstructionArgs, + ) -> Self { + Self { + __program: program, + use_authority_record: accounts.use_authority_record, + owner: accounts.owner, + payer: accounts.payer, + user: accounts.user, + owner_token_account: accounts.owner_token_account, + metadata: accounts.metadata, + mint: accounts.mint, + burner: accounts.burner, + token_program: accounts.token_program, + system_program: accounts.system_program, + rent: accounts.rent, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11); + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.use_authority_record.key, false, @@ -331,6 +418,9 @@ impl<'a> ApproveUseAuthorityCpi<'a> { *rent.key, false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = ApproveUseAuthorityInstructionData::new() .try_to_vec() .unwrap(); @@ -342,7 +432,7 @@ impl<'a> ApproveUseAuthorityCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(11 + 1); + let mut account_infos = Vec::with_capacity(11 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.use_authority_record.clone()); account_infos.push(self.owner.clone()); @@ -357,6 +447,9 @@ impl<'a> ApproveUseAuthorityCpi<'a> { if let Some(rent) = self.rent { account_infos.push(rent.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -387,6 +480,7 @@ impl<'a> ApproveUseAuthorityCpiBuilder<'a> { system_program: None, rent: None, number_of_uses: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -471,8 +565,11 @@ impl<'a> ApproveUseAuthorityCpiBuilder<'a> { /// `[optional account]` /// Rent info #[inline(always)] - pub fn rent(&mut self, rent: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); + pub fn rent( + &mut self, + rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.rent = rent; self } #[inline(always)] @@ -480,8 +577,34 @@ impl<'a> ApproveUseAuthorityCpiBuilder<'a> { self.instruction.number_of_uses = Some(number_of_uses); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> ApproveUseAuthorityCpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = ApproveUseAuthorityInstructionArgs { number_of_uses: self .instruction @@ -489,8 +612,7 @@ impl<'a> ApproveUseAuthorityCpiBuilder<'a> { .clone() .expect("number_of_uses is not set"), }; - - ApproveUseAuthorityCpi { + let instruction = ApproveUseAuthorityCpi { __program: self.instruction.__program, use_authority_record: self @@ -527,7 +649,11 @@ impl<'a> ApproveUseAuthorityCpiBuilder<'a> { rent: self.instruction.rent, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -545,4 +671,5 @@ struct ApproveUseAuthorityCpiBuilderInstruction<'a> { system_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, number_of_uses: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/bubblegum_set_collection_size.rs b/clients/rust/src/generated/instructions/bubblegum_set_collection_size.rs index 135df73d..0b6d6947 100644 --- a/clients/rust/src/generated/instructions/bubblegum_set_collection_size.rs +++ b/clients/rust/src/generated/instructions/bubblegum_set_collection_size.rs @@ -24,12 +24,19 @@ pub struct BubblegumSetCollectionSize { } impl BubblegumSetCollectionSize { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: BubblegumSetCollectionSizeInstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(5); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: BubblegumSetCollectionSizeInstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.collection_metadata, false, @@ -52,6 +59,9 @@ impl BubblegumSetCollectionSize { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = BubblegumSetCollectionSizeInstructionData::new() .try_to_vec() .unwrap(); @@ -77,7 +87,8 @@ impl BubblegumSetCollectionSizeInstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct BubblegumSetCollectionSizeInstructionArgs { pub set_collection_size_args: SetCollectionSizeArgs, } @@ -91,6 +102,7 @@ pub struct BubblegumSetCollectionSizeBuilder { bubblegum_signer: Option, collection_authority_record: Option, set_collection_size_args: Option, + __remaining_accounts: Vec, } impl BubblegumSetCollectionSizeBuilder { @@ -138,9 +150,9 @@ impl BubblegumSetCollectionSizeBuilder { #[inline(always)] pub fn collection_authority_record( &mut self, - collection_authority_record: solana_program::pubkey::Pubkey, + collection_authority_record: Option, ) -> &mut Self { - self.collection_authority_record = Some(collection_authority_record); + self.collection_authority_record = collection_authority_record; self } #[inline(always)] @@ -151,8 +163,18 @@ impl BubblegumSetCollectionSizeBuilder { self.set_collection_size_args = Some(set_collection_size_args); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = BubblegumSetCollectionSize { collection_metadata: self .collection_metadata @@ -171,10 +193,24 @@ impl BubblegumSetCollectionSizeBuilder { .expect("set_collection_size_args is not set"), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `bubblegum_set_collection_size` CPI accounts. +pub struct BubblegumSetCollectionSizeCpiAccounts<'a> { + /// Collection Metadata account + pub collection_metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Collection Update authority + pub collection_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of the Collection + pub collection_mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Signing PDA of Bubblegum program + pub bubblegum_signer: &'a solana_program::account_info::AccountInfo<'a>, + /// Collection Authority Record PDA + pub collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `bubblegum_set_collection_size` CPI instruction. pub struct BubblegumSetCollectionSizeCpi<'a> { /// The program to invoke. @@ -194,16 +230,47 @@ pub struct BubblegumSetCollectionSizeCpi<'a> { } impl<'a> BubblegumSetCollectionSizeCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: BubblegumSetCollectionSizeCpiAccounts<'a>, + args: BubblegumSetCollectionSizeInstructionArgs, + ) -> Self { + Self { + __program: program, + collection_metadata: accounts.collection_metadata, + collection_authority: accounts.collection_authority, + collection_mint: accounts.collection_mint, + bubblegum_signer: accounts.bubblegum_signer, + collection_authority_record: accounts.collection_authority_record, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5); + let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.collection_metadata.key, false, @@ -226,6 +293,9 @@ impl<'a> BubblegumSetCollectionSizeCpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = BubblegumSetCollectionSizeInstructionData::new() .try_to_vec() .unwrap(); @@ -237,7 +307,7 @@ impl<'a> BubblegumSetCollectionSizeCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(5 + 1); + let mut account_infos = Vec::with_capacity(5 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.collection_metadata.clone()); account_infos.push(self.collection_authority.clone()); @@ -246,6 +316,9 @@ impl<'a> BubblegumSetCollectionSizeCpi<'a> { if let Some(collection_authority_record) = self.collection_authority_record { account_infos.push(collection_authority_record.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -270,6 +343,7 @@ impl<'a> BubblegumSetCollectionSizeCpiBuilder<'a> { bubblegum_signer: None, collection_authority_record: None, set_collection_size_args: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -314,9 +388,9 @@ impl<'a> BubblegumSetCollectionSizeCpiBuilder<'a> { #[inline(always)] pub fn collection_authority_record( &mut self, - collection_authority_record: &'a solana_program::account_info::AccountInfo<'a>, + collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.collection_authority_record = Some(collection_authority_record); + self.instruction.collection_authority_record = collection_authority_record; self } #[inline(always)] @@ -327,8 +401,34 @@ impl<'a> BubblegumSetCollectionSizeCpiBuilder<'a> { self.instruction.set_collection_size_args = Some(set_collection_size_args); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> BubblegumSetCollectionSizeCpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = BubblegumSetCollectionSizeInstructionArgs { set_collection_size_args: self .instruction @@ -336,8 +436,7 @@ impl<'a> BubblegumSetCollectionSizeCpiBuilder<'a> { .clone() .expect("set_collection_size_args is not set"), }; - - BubblegumSetCollectionSizeCpi { + let instruction = BubblegumSetCollectionSizeCpi { __program: self.instruction.__program, collection_metadata: self @@ -362,7 +461,11 @@ impl<'a> BubblegumSetCollectionSizeCpiBuilder<'a> { collection_authority_record: self.instruction.collection_authority_record, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -374,4 +477,5 @@ struct BubblegumSetCollectionSizeCpiBuilderInstruction<'a> { bubblegum_signer: Option<&'a solana_program::account_info::AccountInfo<'a>>, collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, set_collection_size_args: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/burn_edition_nft.rs b/clients/rust/src/generated/instructions/burn_edition_nft.rs index 2a63927f..9e2bb2dc 100644 --- a/clients/rust/src/generated/instructions/burn_edition_nft.rs +++ b/clients/rust/src/generated/instructions/burn_edition_nft.rs @@ -33,9 +33,15 @@ pub struct BurnEditionNft { } impl BurnEditionNft { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(10); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.metadata, false, @@ -75,6 +81,9 @@ impl BurnEditionNft { self.spl_token_program, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = BurnEditionNftInstructionData::new().try_to_vec().unwrap(); solana_program::instruction::Instruction { @@ -109,6 +118,7 @@ pub struct BurnEditionNftBuilder { print_edition_account: Option, edition_marker_account: Option, spl_token_program: Option, + __remaining_accounts: Vec, } impl BurnEditionNftBuilder { @@ -190,6 +200,7 @@ impl BurnEditionNftBuilder { self.edition_marker_account = Some(edition_marker_account); self } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` /// SPL Token Program #[inline(always)] pub fn spl_token_program( @@ -199,8 +210,18 @@ impl BurnEditionNftBuilder { self.spl_token_program = Some(spl_token_program); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = BurnEditionNft { metadata: self.metadata.expect("metadata is not set"), owner: self.owner.expect("owner is not set"), @@ -230,10 +251,34 @@ impl BurnEditionNftBuilder { )), }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `burn_edition_nft` CPI accounts. +pub struct BurnEditionNftCpiAccounts<'a> { + /// Metadata (pda of ['metadata', program id, mint id]) + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// NFT owner + pub owner: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of the print edition NFT + pub print_edition_mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of the original/master NFT + pub master_edition_mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account the print edition NFT is in + pub print_edition_token_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account the Master Edition NFT is in + pub master_edition_token_account: &'a solana_program::account_info::AccountInfo<'a>, + /// MasterEdition2 of the original NFT + pub master_edition_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Print Edition account of the NFT + pub print_edition_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition Marker PDA of the NFT + pub edition_marker_account: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, +} + /// `burn_edition_nft` CPI instruction. pub struct BurnEditionNftCpi<'a> { /// The program to invoke. @@ -261,16 +306,50 @@ pub struct BurnEditionNftCpi<'a> { } impl<'a> BurnEditionNftCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: BurnEditionNftCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + metadata: accounts.metadata, + owner: accounts.owner, + print_edition_mint: accounts.print_edition_mint, + master_edition_mint: accounts.master_edition_mint, + print_edition_token_account: accounts.print_edition_token_account, + master_edition_token_account: accounts.master_edition_token_account, + master_edition_account: accounts.master_edition_account, + print_edition_account: accounts.print_edition_account, + edition_marker_account: accounts.edition_marker_account, + spl_token_program: accounts.spl_token_program, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(10); + let mut accounts = Vec::with_capacity(10 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.metadata.key, false, @@ -311,6 +390,9 @@ impl<'a> BurnEditionNftCpi<'a> { *self.spl_token_program.key, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = BurnEditionNftInstructionData::new().try_to_vec().unwrap(); let instruction = solana_program::instruction::Instruction { @@ -318,7 +400,7 @@ impl<'a> BurnEditionNftCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(10 + 1); + let mut account_infos = Vec::with_capacity(10 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.metadata.clone()); account_infos.push(self.owner.clone()); @@ -330,6 +412,9 @@ impl<'a> BurnEditionNftCpi<'a> { account_infos.push(self.print_edition_account.clone()); account_infos.push(self.edition_marker_account.clone()); account_infos.push(self.spl_token_program.clone()); + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -358,6 +443,7 @@ impl<'a> BurnEditionNftCpiBuilder<'a> { print_edition_account: None, edition_marker_account: None, spl_token_program: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -448,9 +534,35 @@ impl<'a> BurnEditionNftCpiBuilder<'a> { self.instruction.spl_token_program = Some(spl_token_program); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> BurnEditionNftCpi<'a> { - BurnEditionNftCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = BurnEditionNftCpi { __program: self.instruction.__program, metadata: self.instruction.metadata.expect("metadata is not set"), @@ -496,7 +608,11 @@ impl<'a> BurnEditionNftCpiBuilder<'a> { .instruction .spl_token_program .expect("spl_token_program is not set"), - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -512,4 +628,5 @@ struct BurnEditionNftCpiBuilderInstruction<'a> { print_edition_account: Option<&'a solana_program::account_info::AccountInfo<'a>>, edition_marker_account: Option<&'a solana_program::account_info::AccountInfo<'a>>, spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/burn_nft.rs b/clients/rust/src/generated/instructions/burn_nft.rs index 3aeea0e6..1efc7096 100644 --- a/clients/rust/src/generated/instructions/burn_nft.rs +++ b/clients/rust/src/generated/instructions/burn_nft.rs @@ -27,9 +27,15 @@ pub struct BurnNft { } impl BurnNft { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(7); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.metadata, false, @@ -58,6 +64,9 @@ impl BurnNft { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = BurnNftInstructionData::new().try_to_vec().unwrap(); solana_program::instruction::Instruction { @@ -89,6 +98,7 @@ pub struct BurnNftBuilder { master_edition_account: Option, spl_token_program: Option, collection_metadata: Option, + __remaining_accounts: Vec, } impl BurnNftBuilder { @@ -128,6 +138,7 @@ impl BurnNftBuilder { self.master_edition_account = Some(master_edition_account); self } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` /// SPL Token Program #[inline(always)] pub fn spl_token_program( @@ -142,13 +153,23 @@ impl BurnNftBuilder { #[inline(always)] pub fn collection_metadata( &mut self, - collection_metadata: solana_program::pubkey::Pubkey, + collection_metadata: Option, ) -> &mut Self { - self.collection_metadata = Some(collection_metadata); + self.collection_metadata = collection_metadata; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = BurnNft { metadata: self.metadata.expect("metadata is not set"), owner: self.owner.expect("owner is not set"), @@ -163,10 +184,28 @@ impl BurnNftBuilder { collection_metadata: self.collection_metadata, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `burn_nft` CPI accounts. +pub struct BurnNftCpiAccounts<'a> { + /// Metadata (pda of ['metadata', program id, mint id]) + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// NFT owner + pub owner: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of the NFT + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account to close + pub token_account: &'a solana_program::account_info::AccountInfo<'a>, + /// MasterEdition2 of the NFT + pub master_edition_account: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata of the Collection + pub collection_metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `burn_nft` CPI instruction. pub struct BurnNftCpi<'a> { /// The program to invoke. @@ -188,16 +227,47 @@ pub struct BurnNftCpi<'a> { } impl<'a> BurnNftCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: BurnNftCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + metadata: accounts.metadata, + owner: accounts.owner, + mint: accounts.mint, + token_account: accounts.token_account, + master_edition_account: accounts.master_edition_account, + spl_token_program: accounts.spl_token_program, + collection_metadata: accounts.collection_metadata, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7); + let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.metadata.key, false, @@ -228,6 +298,9 @@ impl<'a> BurnNftCpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = BurnNftInstructionData::new().try_to_vec().unwrap(); let instruction = solana_program::instruction::Instruction { @@ -235,7 +308,7 @@ impl<'a> BurnNftCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(7 + 1); + let mut account_infos = Vec::with_capacity(7 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.metadata.clone()); account_infos.push(self.owner.clone()); @@ -246,6 +319,9 @@ impl<'a> BurnNftCpi<'a> { if let Some(collection_metadata) = self.collection_metadata { account_infos.push(collection_metadata.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -271,6 +347,7 @@ impl<'a> BurnNftCpiBuilder<'a> { master_edition_account: None, spl_token_program: None, collection_metadata: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -327,14 +404,40 @@ impl<'a> BurnNftCpiBuilder<'a> { #[inline(always)] pub fn collection_metadata( &mut self, - collection_metadata: &'a solana_program::account_info::AccountInfo<'a>, + collection_metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.collection_metadata = collection_metadata; + self + } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, ) -> &mut Self { - self.instruction.collection_metadata = Some(collection_metadata); + self.instruction.__remaining_accounts.push(account); self } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> BurnNftCpi<'a> { - BurnNftCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = BurnNftCpi { __program: self.instruction.__program, metadata: self.instruction.metadata.expect("metadata is not set"), @@ -359,7 +462,11 @@ impl<'a> BurnNftCpiBuilder<'a> { .expect("spl_token_program is not set"), collection_metadata: self.instruction.collection_metadata, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -372,4 +479,5 @@ struct BurnNftCpiBuilderInstruction<'a> { master_edition_account: Option<&'a solana_program::account_info::AccountInfo<'a>>, spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, collection_metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/burn_v1.rs b/clients/rust/src/generated/instructions/burn_v1.rs index 47b3216d..3e82db66 100644 --- a/clients/rust/src/generated/instructions/burn_v1.rs +++ b/clients/rust/src/generated/instructions/burn_v1.rs @@ -41,12 +41,19 @@ pub struct BurnV1 { } impl BurnV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: BurnV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: BurnV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.authority, true, @@ -149,6 +156,9 @@ impl BurnV1 { self.spl_token_program, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = BurnV1InstructionData::new().try_to_vec().unwrap(); let mut args = args.try_to_vec().unwrap(); data.append(&mut args); @@ -176,7 +186,8 @@ impl BurnV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct BurnV1InstructionArgs { pub amount: u64, } @@ -199,6 +210,7 @@ pub struct BurnV1Builder { sysvar_instructions: Option, spl_token_program: Option, amount: Option, + __remaining_accounts: Vec, } impl BurnV1Builder { @@ -216,9 +228,9 @@ impl BurnV1Builder { #[inline(always)] pub fn collection_metadata( &mut self, - collection_metadata: solana_program::pubkey::Pubkey, + collection_metadata: Option, ) -> &mut Self { - self.collection_metadata = Some(collection_metadata); + self.collection_metadata = collection_metadata; self } /// Metadata (pda of ['metadata', program id, mint id]) @@ -230,8 +242,8 @@ impl BurnV1Builder { /// `[optional account]` /// Edition of the asset #[inline(always)] - pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.edition = Some(edition); + pub fn edition(&mut self, edition: Option) -> &mut Self { + self.edition = edition; self } /// Mint of token asset @@ -249,8 +261,11 @@ impl BurnV1Builder { /// `[optional account]` /// Master edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` @@ -258,9 +273,9 @@ impl BurnV1Builder { #[inline(always)] pub fn master_edition_mint( &mut self, - master_edition_mint: solana_program::pubkey::Pubkey, + master_edition_mint: Option, ) -> &mut Self { - self.master_edition_mint = Some(master_edition_mint); + self.master_edition_mint = master_edition_mint; self } /// `[optional account]` @@ -268,31 +283,39 @@ impl BurnV1Builder { #[inline(always)] pub fn master_edition_token( &mut self, - master_edition_token: solana_program::pubkey::Pubkey, + master_edition_token: Option, ) -> &mut Self { - self.master_edition_token = Some(master_edition_token); + self.master_edition_token = master_edition_token; self } /// `[optional account]` /// Edition marker account #[inline(always)] - pub fn edition_marker(&mut self, edition_marker: solana_program::pubkey::Pubkey) -> &mut Self { - self.edition_marker = Some(edition_marker); + pub fn edition_marker( + &mut self, + edition_marker: Option, + ) -> &mut Self { + self.edition_marker = edition_marker; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -302,6 +325,7 @@ impl BurnV1Builder { self.sysvar_instructions = Some(sysvar_instructions); self } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` /// SPL Token Program #[inline(always)] pub fn spl_token_program( @@ -317,8 +341,18 @@ impl BurnV1Builder { self.amount = Some(amount); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = BurnV1 { authority: self.authority.expect("authority is not set"), collection_metadata: self.collection_metadata, @@ -345,10 +379,42 @@ impl BurnV1Builder { amount: self.amount.clone().unwrap_or(1), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `burn_v1` CPI accounts. +pub struct BurnV1CpiAccounts<'a> { + /// Asset owner or Utility delegate + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata of the Collection + pub collection_metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Metadata (pda of ['metadata', program id, mint id]) + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition of the asset + pub edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of token asset + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account to close + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Master edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Master edition mint of the asset + pub master_edition_mint: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Master edition token account + pub master_edition_token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Edition marker account + pub edition_marker: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, +} + /// `burn_v1` CPI instruction. pub struct BurnV1Cpi<'a> { /// The program to invoke. @@ -386,16 +452,56 @@ pub struct BurnV1Cpi<'a> { } impl<'a> BurnV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: BurnV1CpiAccounts<'a>, + args: BurnV1InstructionArgs, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + collection_metadata: accounts.collection_metadata, + metadata: accounts.metadata, + edition: accounts.edition, + mint: accounts.mint, + token: accounts.token, + master_edition: accounts.master_edition, + master_edition_mint: accounts.master_edition_mint, + master_edition_token: accounts.master_edition_token, + edition_marker: accounts.edition_marker, + token_record: accounts.token_record, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.authority.key, true, @@ -501,6 +607,9 @@ impl<'a> BurnV1Cpi<'a> { *self.spl_token_program.key, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = BurnV1InstructionData::new().try_to_vec().unwrap(); let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); @@ -510,7 +619,7 @@ impl<'a> BurnV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.authority.clone()); if let Some(collection_metadata) = self.collection_metadata { @@ -540,6 +649,9 @@ impl<'a> BurnV1Cpi<'a> { account_infos.push(self.system_program.clone()); account_infos.push(self.sysvar_instructions.clone()); account_infos.push(self.spl_token_program.clone()); + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -573,6 +685,7 @@ impl<'a> BurnV1CpiBuilder<'a> { sysvar_instructions: None, spl_token_program: None, amount: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -590,9 +703,9 @@ impl<'a> BurnV1CpiBuilder<'a> { #[inline(always)] pub fn collection_metadata( &mut self, - collection_metadata: &'a solana_program::account_info::AccountInfo<'a>, + collection_metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.collection_metadata = Some(collection_metadata); + self.instruction.collection_metadata = collection_metadata; self } /// Metadata (pda of ['metadata', program id, mint id]) @@ -609,9 +722,9 @@ impl<'a> BurnV1CpiBuilder<'a> { #[inline(always)] pub fn edition( &mut self, - edition: &'a solana_program::account_info::AccountInfo<'a>, + edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.edition = Some(edition); + self.instruction.edition = edition; self } /// Mint of token asset @@ -631,9 +744,9 @@ impl<'a> BurnV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -641,9 +754,9 @@ impl<'a> BurnV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition_mint( &mut self, - master_edition_mint: &'a solana_program::account_info::AccountInfo<'a>, + master_edition_mint: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition_mint = Some(master_edition_mint); + self.instruction.master_edition_mint = master_edition_mint; self } /// `[optional account]` @@ -651,9 +764,9 @@ impl<'a> BurnV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition_token( &mut self, - master_edition_token: &'a solana_program::account_info::AccountInfo<'a>, + master_edition_token: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition_token = Some(master_edition_token); + self.instruction.master_edition_token = master_edition_token; self } /// `[optional account]` @@ -661,9 +774,9 @@ impl<'a> BurnV1CpiBuilder<'a> { #[inline(always)] pub fn edition_marker( &mut self, - edition_marker: &'a solana_program::account_info::AccountInfo<'a>, + edition_marker: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.edition_marker = Some(edition_marker); + self.instruction.edition_marker = edition_marker; self } /// `[optional account]` @@ -671,9 +784,9 @@ impl<'a> BurnV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// System program @@ -709,13 +822,38 @@ impl<'a> BurnV1CpiBuilder<'a> { self.instruction.amount = Some(amount); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> BurnV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = BurnV1InstructionArgs { amount: self.instruction.amount.clone().unwrap_or(1), }; - - BurnV1Cpi { + let instruction = BurnV1Cpi { __program: self.instruction.__program, authority: self.instruction.authority.expect("authority is not set"), @@ -755,7 +893,11 @@ impl<'a> BurnV1CpiBuilder<'a> { .spl_token_program .expect("spl_token_program is not set"), __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -776,4 +918,5 @@ struct BurnV1CpiBuilderInstruction<'a> { sysvar_instructions: Option<&'a solana_program::account_info::AccountInfo<'a>>, spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, amount: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/close_escrow_account.rs b/clients/rust/src/generated/instructions/close_escrow_account.rs index 5cc745dc..51fd6503 100644 --- a/clients/rust/src/generated/instructions/close_escrow_account.rs +++ b/clients/rust/src/generated/instructions/close_escrow_account.rs @@ -29,9 +29,15 @@ pub struct CloseEscrowAccount { } impl CloseEscrowAccount { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(8); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.escrow, false, @@ -62,6 +68,9 @@ impl CloseEscrowAccount { self.sysvar_instructions, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = CloseEscrowAccountInstructionData::new() .try_to_vec() .unwrap(); @@ -96,6 +105,7 @@ pub struct CloseEscrowAccountBuilder { payer: Option, system_program: Option, sysvar_instructions: Option, + __remaining_accounts: Vec, } impl CloseEscrowAccountBuilder { @@ -138,12 +148,14 @@ impl CloseEscrowAccountBuilder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -153,8 +165,18 @@ impl CloseEscrowAccountBuilder { self.sysvar_instructions = Some(sysvar_instructions); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = CloseEscrowAccount { escrow: self.escrow.expect("escrow is not set"), metadata: self.metadata.expect("metadata is not set"), @@ -170,10 +192,30 @@ impl CloseEscrowAccountBuilder { )), }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `close_escrow_account` CPI accounts. +pub struct CloseEscrowAccountCpiAccounts<'a> { + /// Escrow account + pub escrow: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint account + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account + pub token_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition account + pub edition: &'a solana_program::account_info::AccountInfo<'a>, + /// Wallet paying for the transaction and new account + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, +} + /// `close_escrow_account` CPI instruction. pub struct CloseEscrowAccountCpi<'a> { /// The program to invoke. @@ -197,16 +239,48 @@ pub struct CloseEscrowAccountCpi<'a> { } impl<'a> CloseEscrowAccountCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: CloseEscrowAccountCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + escrow: accounts.escrow, + metadata: accounts.metadata, + mint: accounts.mint, + token_account: accounts.token_account, + edition: accounts.edition, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8); + let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.escrow.key, false, @@ -239,6 +313,9 @@ impl<'a> CloseEscrowAccountCpi<'a> { *self.sysvar_instructions.key, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = CloseEscrowAccountInstructionData::new() .try_to_vec() .unwrap(); @@ -248,7 +325,7 @@ impl<'a> CloseEscrowAccountCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(8 + 1); + let mut account_infos = Vec::with_capacity(8 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.escrow.clone()); account_infos.push(self.metadata.clone()); @@ -258,6 +335,9 @@ impl<'a> CloseEscrowAccountCpi<'a> { account_infos.push(self.payer.clone()); account_infos.push(self.system_program.clone()); account_infos.push(self.sysvar_instructions.clone()); + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -284,6 +364,7 @@ impl<'a> CloseEscrowAccountCpiBuilder<'a> { payer: None, system_program: None, sysvar_instructions: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -353,9 +434,35 @@ impl<'a> CloseEscrowAccountCpiBuilder<'a> { self.instruction.sysvar_instructions = Some(sysvar_instructions); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> CloseEscrowAccountCpi<'a> { - CloseEscrowAccountCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = CloseEscrowAccountCpi { __program: self.instruction.__program, escrow: self.instruction.escrow.expect("escrow is not set"), @@ -382,7 +489,11 @@ impl<'a> CloseEscrowAccountCpiBuilder<'a> { .instruction .sysvar_instructions .expect("sysvar_instructions is not set"), - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -396,4 +507,5 @@ struct CloseEscrowAccountCpiBuilderInstruction<'a> { payer: Option<&'a solana_program::account_info::AccountInfo<'a>>, system_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, sysvar_instructions: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/collect.rs b/clients/rust/src/generated/instructions/collect.rs index 285a7742..2a641b15 100644 --- a/clients/rust/src/generated/instructions/collect.rs +++ b/clients/rust/src/generated/instructions/collect.rs @@ -17,9 +17,15 @@ pub struct Collect { } impl Collect { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(2); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, true, @@ -28,6 +34,9 @@ impl Collect { self.pda_account, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = CollectInstructionData::new().try_to_vec().unwrap(); solana_program::instruction::Instruction { @@ -54,6 +63,7 @@ impl CollectInstructionData { pub struct CollectBuilder { authority: Option, pda_account: Option, + __remaining_accounts: Vec, } impl CollectBuilder { @@ -72,17 +82,35 @@ impl CollectBuilder { self.pda_account = Some(pda_account); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = Collect { authority: self.authority.expect("authority is not set"), pda_account: self.pda_account.expect("pda_account is not set"), }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `collect` CPI accounts. +pub struct CollectCpiAccounts<'a> { + /// Authority to collect fees + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// PDA to retrieve fees from + pub pda_account: &'a solana_program::account_info::AccountInfo<'a>, +} + /// `collect` CPI instruction. pub struct CollectCpi<'a> { /// The program to invoke. @@ -94,16 +122,42 @@ pub struct CollectCpi<'a> { } impl<'a> CollectCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: CollectCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + pda_account: accounts.pda_account, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2); + let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, true, @@ -112,6 +166,9 @@ impl<'a> CollectCpi<'a> { *self.pda_account.key, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = CollectInstructionData::new().try_to_vec().unwrap(); let instruction = solana_program::instruction::Instruction { @@ -119,10 +176,13 @@ impl<'a> CollectCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(2 + 1); + let mut account_infos = Vec::with_capacity(2 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.authority.clone()); account_infos.push(self.pda_account.clone()); + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -143,6 +203,7 @@ impl<'a> CollectCpiBuilder<'a> { __program: program, authority: None, pda_account: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -164,9 +225,35 @@ impl<'a> CollectCpiBuilder<'a> { self.instruction.pda_account = Some(pda_account); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> CollectCpi<'a> { - CollectCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = CollectCpi { __program: self.instruction.__program, authority: self.instruction.authority.expect("authority is not set"), @@ -175,7 +262,11 @@ impl<'a> CollectCpiBuilder<'a> { .instruction .pda_account .expect("pda_account is not set"), - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -183,4 +274,5 @@ struct CollectCpiBuilderInstruction<'a> { __program: &'a solana_program::account_info::AccountInfo<'a>, authority: Option<&'a solana_program::account_info::AccountInfo<'a>>, pda_account: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/convert_master_edition_v1_to_v2.rs b/clients/rust/src/generated/instructions/convert_master_edition_v1_to_v2.rs index 617394f9..1049bece 100644 --- a/clients/rust/src/generated/instructions/convert_master_edition_v1_to_v2.rs +++ b/clients/rust/src/generated/instructions/convert_master_edition_v1_to_v2.rs @@ -19,9 +19,15 @@ pub struct ConvertMasterEditionV1ToV2 { } impl ConvertMasterEditionV1ToV2 { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(3); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.master_edition, false, @@ -34,6 +40,9 @@ impl ConvertMasterEditionV1ToV2 { self.printing_mint, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = ConvertMasterEditionV1ToV2InstructionData::new() .try_to_vec() .unwrap(); @@ -63,6 +72,7 @@ pub struct ConvertMasterEditionV1ToV2Builder { master_edition: Option, one_time_auth: Option, printing_mint: Option, + __remaining_accounts: Vec, } impl ConvertMasterEditionV1ToV2Builder { @@ -87,18 +97,38 @@ impl ConvertMasterEditionV1ToV2Builder { self.printing_mint = Some(printing_mint); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = ConvertMasterEditionV1ToV2 { master_edition: self.master_edition.expect("master_edition is not set"), one_time_auth: self.one_time_auth.expect("one_time_auth is not set"), printing_mint: self.printing_mint.expect("printing_mint is not set"), }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `convert_master_edition_v1_to_v2` CPI accounts. +pub struct ConvertMasterEditionV1ToV2CpiAccounts<'a> { + /// Master Record Edition V1 (pda of ['metadata', program id, master metadata mint id, 'edition']) + pub master_edition: &'a solana_program::account_info::AccountInfo<'a>, + /// One time authorization mint + pub one_time_auth: &'a solana_program::account_info::AccountInfo<'a>, + /// Printing mint + pub printing_mint: &'a solana_program::account_info::AccountInfo<'a>, +} + /// `convert_master_edition_v1_to_v2` CPI instruction. pub struct ConvertMasterEditionV1ToV2Cpi<'a> { /// The program to invoke. @@ -112,16 +142,43 @@ pub struct ConvertMasterEditionV1ToV2Cpi<'a> { } impl<'a> ConvertMasterEditionV1ToV2Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: ConvertMasterEditionV1ToV2CpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + master_edition: accounts.master_edition, + one_time_auth: accounts.one_time_auth, + printing_mint: accounts.printing_mint, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3); + let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.master_edition.key, false, @@ -134,6 +191,9 @@ impl<'a> ConvertMasterEditionV1ToV2Cpi<'a> { *self.printing_mint.key, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = ConvertMasterEditionV1ToV2InstructionData::new() .try_to_vec() .unwrap(); @@ -143,11 +203,14 @@ impl<'a> ConvertMasterEditionV1ToV2Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(3 + 1); + let mut account_infos = Vec::with_capacity(3 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.master_edition.clone()); account_infos.push(self.one_time_auth.clone()); account_infos.push(self.printing_mint.clone()); + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -169,6 +232,7 @@ impl<'a> ConvertMasterEditionV1ToV2CpiBuilder<'a> { master_edition: None, one_time_auth: None, printing_mint: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -199,9 +263,35 @@ impl<'a> ConvertMasterEditionV1ToV2CpiBuilder<'a> { self.instruction.printing_mint = Some(printing_mint); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> ConvertMasterEditionV1ToV2Cpi<'a> { - ConvertMasterEditionV1ToV2Cpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = ConvertMasterEditionV1ToV2Cpi { __program: self.instruction.__program, master_edition: self @@ -218,7 +308,11 @@ impl<'a> ConvertMasterEditionV1ToV2CpiBuilder<'a> { .instruction .printing_mint .expect("printing_mint is not set"), - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -227,4 +321,5 @@ struct ConvertMasterEditionV1ToV2CpiBuilderInstruction<'a> { master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, one_time_auth: Option<&'a solana_program::account_info::AccountInfo<'a>>, printing_mint: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/create_escrow_account.rs b/clients/rust/src/generated/instructions/create_escrow_account.rs index f72d4542..2d4c69fb 100644 --- a/clients/rust/src/generated/instructions/create_escrow_account.rs +++ b/clients/rust/src/generated/instructions/create_escrow_account.rs @@ -31,9 +31,15 @@ pub struct CreateEscrowAccount { } impl CreateEscrowAccount { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(9); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.escrow, false, @@ -69,6 +75,9 @@ impl CreateEscrowAccount { authority, true, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = CreateEscrowAccountInstructionData::new() .try_to_vec() .unwrap(); @@ -104,6 +113,7 @@ pub struct CreateEscrowAccountBuilder { system_program: Option, sysvar_instructions: Option, authority: Option, + __remaining_accounts: Vec, } impl CreateEscrowAccountBuilder { @@ -146,12 +156,14 @@ impl CreateEscrowAccountBuilder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -164,12 +176,22 @@ impl CreateEscrowAccountBuilder { /// `[optional account]` /// Authority/creator of the escrow account #[inline(always)] - pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); + pub fn authority(&mut self, authority: Option) -> &mut Self { + self.authority = authority; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = CreateEscrowAccount { escrow: self.escrow.expect("escrow is not set"), metadata: self.metadata.expect("metadata is not set"), @@ -186,10 +208,32 @@ impl CreateEscrowAccountBuilder { authority: self.authority, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `create_escrow_account` CPI accounts. +pub struct CreateEscrowAccountCpiAccounts<'a> { + /// Escrow account + pub escrow: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint account + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of the token + pub token_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition account + pub edition: &'a solana_program::account_info::AccountInfo<'a>, + /// Wallet paying for the transaction and new account + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// Authority/creator of the escrow account + pub authority: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `create_escrow_account` CPI instruction. pub struct CreateEscrowAccountCpi<'a> { /// The program to invoke. @@ -215,16 +259,49 @@ pub struct CreateEscrowAccountCpi<'a> { } impl<'a> CreateEscrowAccountCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: CreateEscrowAccountCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + escrow: accounts.escrow, + metadata: accounts.metadata, + mint: accounts.mint, + token_account: accounts.token_account, + edition: accounts.edition, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + authority: accounts.authority, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(9); + let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.escrow.key, false, @@ -263,6 +340,9 @@ impl<'a> CreateEscrowAccountCpi<'a> { true, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = CreateEscrowAccountInstructionData::new() .try_to_vec() .unwrap(); @@ -272,7 +352,7 @@ impl<'a> CreateEscrowAccountCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(9 + 1); + let mut account_infos = Vec::with_capacity(9 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.escrow.clone()); account_infos.push(self.metadata.clone()); @@ -285,6 +365,9 @@ impl<'a> CreateEscrowAccountCpi<'a> { if let Some(authority) = self.authority { account_infos.push(authority.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -312,6 +395,7 @@ impl<'a> CreateEscrowAccountCpiBuilder<'a> { system_program: None, sysvar_instructions: None, authority: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -386,14 +470,40 @@ impl<'a> CreateEscrowAccountCpiBuilder<'a> { #[inline(always)] pub fn authority( &mut self, - authority: &'a solana_program::account_info::AccountInfo<'a>, + authority: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.authority = authority; + self + } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, ) -> &mut Self { - self.instruction.authority = Some(authority); + self.instruction.__remaining_accounts.push(account); self } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> CreateEscrowAccountCpi<'a> { - CreateEscrowAccountCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = CreateEscrowAccountCpi { __program: self.instruction.__program, escrow: self.instruction.escrow.expect("escrow is not set"), @@ -422,7 +532,11 @@ impl<'a> CreateEscrowAccountCpiBuilder<'a> { .expect("sysvar_instructions is not set"), authority: self.instruction.authority, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -437,4 +551,5 @@ struct CreateEscrowAccountCpiBuilderInstruction<'a> { system_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, sysvar_instructions: Option<&'a solana_program::account_info::AccountInfo<'a>>, authority: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/create_master_edition_v3.rs b/clients/rust/src/generated/instructions/create_master_edition_v3.rs index b7345e68..22932be8 100644 --- a/clients/rust/src/generated/instructions/create_master_edition_v3.rs +++ b/clients/rust/src/generated/instructions/create_master_edition_v3.rs @@ -31,12 +31,19 @@ pub struct CreateMasterEditionV3 { } impl CreateMasterEditionV3 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: CreateMasterEditionV3InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(9); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: CreateMasterEditionV3InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.edition, false, @@ -72,6 +79,9 @@ impl CreateMasterEditionV3 { rent, false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = CreateMasterEditionV3InstructionData::new() .try_to_vec() .unwrap(); @@ -97,7 +107,8 @@ impl CreateMasterEditionV3InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreateMasterEditionV3InstructionArgs { pub max_supply: Option, } @@ -115,6 +126,7 @@ pub struct CreateMasterEditionV3Builder { system_program: Option, rent: Option, max_supply: Option, + __remaining_accounts: Vec, } impl CreateMasterEditionV3Builder { @@ -160,12 +172,14 @@ impl CreateMasterEditionV3Builder { self.metadata = Some(metadata); self } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` /// Token program #[inline(always)] pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self { self.token_program = Some(token_program); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { @@ -175,8 +189,8 @@ impl CreateMasterEditionV3Builder { /// `[optional account]` /// Rent info #[inline(always)] - pub fn rent(&mut self, rent: solana_program::pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); + pub fn rent(&mut self, rent: Option) -> &mut Self { + self.rent = rent; self } /// `[optional argument]` @@ -185,8 +199,18 @@ impl CreateMasterEditionV3Builder { self.max_supply = Some(max_supply); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = CreateMasterEditionV3 { edition: self.edition.expect("edition is not set"), mint: self.mint.expect("mint is not set"), @@ -206,10 +230,32 @@ impl CreateMasterEditionV3Builder { max_supply: self.max_supply.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `create_master_edition_v3` CPI accounts. +pub struct CreateMasterEditionV3CpiAccounts<'a> { + /// Unallocated edition V2 account with address as pda of ['metadata', program id, mint, 'edition'] + pub edition: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata mint + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Update authority + pub update_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint authority on the metadata's mint - THIS WILL TRANSFER AUTHORITY AWAY FROM THIS KEY + pub mint_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Token program + pub token_program: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Rent info + pub rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `create_master_edition_v3` CPI instruction. pub struct CreateMasterEditionV3Cpi<'a> { /// The program to invoke. @@ -237,16 +283,51 @@ pub struct CreateMasterEditionV3Cpi<'a> { } impl<'a> CreateMasterEditionV3Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: CreateMasterEditionV3CpiAccounts<'a>, + args: CreateMasterEditionV3InstructionArgs, + ) -> Self { + Self { + __program: program, + edition: accounts.edition, + mint: accounts.mint, + update_authority: accounts.update_authority, + mint_authority: accounts.mint_authority, + payer: accounts.payer, + metadata: accounts.metadata, + token_program: accounts.token_program, + system_program: accounts.system_program, + rent: accounts.rent, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(9); + let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.edition.key, false, @@ -284,6 +365,9 @@ impl<'a> CreateMasterEditionV3Cpi<'a> { *rent.key, false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = CreateMasterEditionV3InstructionData::new() .try_to_vec() .unwrap(); @@ -295,7 +379,7 @@ impl<'a> CreateMasterEditionV3Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(9 + 1); + let mut account_infos = Vec::with_capacity(9 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.edition.clone()); account_infos.push(self.mint.clone()); @@ -308,6 +392,9 @@ impl<'a> CreateMasterEditionV3Cpi<'a> { if let Some(rent) = self.rent { account_infos.push(rent.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -336,6 +423,7 @@ impl<'a> CreateMasterEditionV3CpiBuilder<'a> { system_program: None, rent: None, max_supply: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -408,8 +496,11 @@ impl<'a> CreateMasterEditionV3CpiBuilder<'a> { /// `[optional account]` /// Rent info #[inline(always)] - pub fn rent(&mut self, rent: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); + pub fn rent( + &mut self, + rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.rent = rent; self } /// `[optional argument]` @@ -418,13 +509,38 @@ impl<'a> CreateMasterEditionV3CpiBuilder<'a> { self.instruction.max_supply = Some(max_supply); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> CreateMasterEditionV3Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = CreateMasterEditionV3InstructionArgs { max_supply: self.instruction.max_supply.clone(), }; - - CreateMasterEditionV3Cpi { + let instruction = CreateMasterEditionV3Cpi { __program: self.instruction.__program, edition: self.instruction.edition.expect("edition is not set"), @@ -457,7 +573,11 @@ impl<'a> CreateMasterEditionV3CpiBuilder<'a> { rent: self.instruction.rent, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -473,4 +593,5 @@ struct CreateMasterEditionV3CpiBuilderInstruction<'a> { system_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, max_supply: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/create_metadata_account_v3.rs b/clients/rust/src/generated/instructions/create_metadata_account_v3.rs index f1e536e8..334d1a1f 100644 --- a/clients/rust/src/generated/instructions/create_metadata_account_v3.rs +++ b/clients/rust/src/generated/instructions/create_metadata_account_v3.rs @@ -29,12 +29,19 @@ pub struct CreateMetadataAccountV3 { } impl CreateMetadataAccountV3 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: CreateMetadataAccountV3InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(7); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: CreateMetadataAccountV3InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.metadata, false, @@ -62,6 +69,9 @@ impl CreateMetadataAccountV3 { rent, false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = CreateMetadataAccountV3InstructionData::new() .try_to_vec() .unwrap(); @@ -87,7 +97,8 @@ impl CreateMetadataAccountV3InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreateMetadataAccountV3InstructionArgs { pub data: DataV2, pub is_mutable: bool, @@ -107,6 +118,7 @@ pub struct CreateMetadataAccountV3Builder { data: Option, is_mutable: Option, collection_details: Option, + __remaining_accounts: Vec, } impl CreateMetadataAccountV3Builder { @@ -146,6 +158,7 @@ impl CreateMetadataAccountV3Builder { self.update_authority = Some(update_authority); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { @@ -155,8 +168,8 @@ impl CreateMetadataAccountV3Builder { /// `[optional account]` /// Rent info #[inline(always)] - pub fn rent(&mut self, rent: solana_program::pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); + pub fn rent(&mut self, rent: Option) -> &mut Self { + self.rent = rent; self } #[inline(always)] @@ -175,8 +188,18 @@ impl CreateMetadataAccountV3Builder { self.collection_details = Some(collection_details); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = CreateMetadataAccountV3 { metadata: self.metadata.expect("metadata is not set"), mint: self.mint.expect("mint is not set"), @@ -194,10 +217,28 @@ impl CreateMetadataAccountV3Builder { collection_details: self.collection_details.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `create_metadata_account_v3` CPI accounts. +pub struct CreateMetadataAccountV3CpiAccounts<'a> { + /// Metadata key (pda of ['metadata', program id, mint id]) + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of token asset + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint authority + pub mint_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// update authority info + pub update_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Rent info + pub rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `create_metadata_account_v3` CPI instruction. pub struct CreateMetadataAccountV3Cpi<'a> { /// The program to invoke. @@ -221,16 +262,49 @@ pub struct CreateMetadataAccountV3Cpi<'a> { } impl<'a> CreateMetadataAccountV3Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: CreateMetadataAccountV3CpiAccounts<'a>, + args: CreateMetadataAccountV3InstructionArgs, + ) -> Self { + Self { + __program: program, + metadata: accounts.metadata, + mint: accounts.mint, + mint_authority: accounts.mint_authority, + payer: accounts.payer, + update_authority: accounts.update_authority, + system_program: accounts.system_program, + rent: accounts.rent, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7); + let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.metadata.key, false, @@ -260,6 +334,9 @@ impl<'a> CreateMetadataAccountV3Cpi<'a> { *rent.key, false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = CreateMetadataAccountV3InstructionData::new() .try_to_vec() .unwrap(); @@ -271,7 +348,7 @@ impl<'a> CreateMetadataAccountV3Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(7 + 1); + let mut account_infos = Vec::with_capacity(7 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.metadata.clone()); account_infos.push(self.mint.clone()); @@ -282,6 +359,9 @@ impl<'a> CreateMetadataAccountV3Cpi<'a> { if let Some(rent) = self.rent { account_infos.push(rent.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -310,6 +390,7 @@ impl<'a> CreateMetadataAccountV3CpiBuilder<'a> { data: None, is_mutable: None, collection_details: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -364,8 +445,11 @@ impl<'a> CreateMetadataAccountV3CpiBuilder<'a> { /// `[optional account]` /// Rent info #[inline(always)] - pub fn rent(&mut self, rent: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); + pub fn rent( + &mut self, + rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.rent = rent; self } #[inline(always)] @@ -384,8 +468,34 @@ impl<'a> CreateMetadataAccountV3CpiBuilder<'a> { self.instruction.collection_details = Some(collection_details); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> CreateMetadataAccountV3Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = CreateMetadataAccountV3InstructionArgs { data: self.instruction.data.clone().expect("data is not set"), is_mutable: self @@ -395,8 +505,7 @@ impl<'a> CreateMetadataAccountV3CpiBuilder<'a> { .expect("is_mutable is not set"), collection_details: self.instruction.collection_details.clone(), }; - - CreateMetadataAccountV3Cpi { + let instruction = CreateMetadataAccountV3Cpi { __program: self.instruction.__program, metadata: self.instruction.metadata.expect("metadata is not set"), @@ -422,7 +531,11 @@ impl<'a> CreateMetadataAccountV3CpiBuilder<'a> { rent: self.instruction.rent, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -438,4 +551,5 @@ struct CreateMetadataAccountV3CpiBuilderInstruction<'a> { data: Option, is_mutable: Option, collection_details: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/create_v1.rs b/clients/rust/src/generated/instructions/create_v1.rs index 92c79f32..fbba2635 100644 --- a/clients/rust/src/generated/instructions/create_v1.rs +++ b/clients/rust/src/generated/instructions/create_v1.rs @@ -38,12 +38,19 @@ pub struct CreateV1 { } impl CreateV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: CreateV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(9); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: CreateV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.metadata, false, @@ -86,6 +93,9 @@ impl CreateV1 { self.spl_token_program, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = CreateV1InstructionData::new().try_to_vec().unwrap(); let mut args = args.try_to_vec().unwrap(); data.append(&mut args); @@ -113,7 +123,8 @@ impl CreateV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreateV1InstructionArgs { pub name: String, pub symbol: String, @@ -157,6 +168,7 @@ pub struct CreateV1Builder { rule_set: Option, decimals: Option, print_supply: Option, + __remaining_accounts: Vec, } impl CreateV1Builder { @@ -172,8 +184,11 @@ impl CreateV1Builder { /// `[optional account]` /// Unallocated edition account with address as pda of ['metadata', program id, mint, 'edition'] #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// Mint of token asset @@ -204,12 +219,14 @@ impl CreateV1Builder { self.update_authority = Some((update_authority, as_signer)); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -219,6 +236,7 @@ impl CreateV1Builder { self.sysvar_instructions = Some(sysvar_instructions); self } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` /// SPL Token program #[inline(always)] pub fn spl_token_program( @@ -308,8 +326,18 @@ impl CreateV1Builder { self.print_supply = Some(print_supply); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = CreateV1 { metadata: self.metadata.expect("metadata is not set"), master_edition: self.master_edition, @@ -350,10 +378,32 @@ impl CreateV1Builder { print_supply: self.print_supply.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `create_v1` CPI accounts. +pub struct CreateV1CpiAccounts<'a> { + /// Unallocated metadata account with address as pda of ['metadata', program id, mint id] + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Unallocated edition account with address as pda of ['metadata', program id, mint, 'edition'] + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of token asset + pub mint: (&'a solana_program::account_info::AccountInfo<'a>, bool), + /// Mint authority + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// Update authority for the metadata account + pub update_authority: (&'a solana_program::account_info::AccountInfo<'a>, bool), + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token program + pub spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, +} + /// `create_v1` CPI instruction. pub struct CreateV1Cpi<'a> { /// The program to invoke. @@ -381,16 +431,51 @@ pub struct CreateV1Cpi<'a> { } impl<'a> CreateV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: CreateV1CpiAccounts<'a>, + args: CreateV1InstructionArgs, + ) -> Self { + Self { + __program: program, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + mint: accounts.mint, + authority: accounts.authority, + payer: accounts.payer, + update_authority: accounts.update_authority, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(9); + let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.metadata.key, false, @@ -434,6 +519,9 @@ impl<'a> CreateV1Cpi<'a> { *self.spl_token_program.key, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = CreateV1InstructionData::new().try_to_vec().unwrap(); let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); @@ -443,7 +531,7 @@ impl<'a> CreateV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(9 + 1); + let mut account_infos = Vec::with_capacity(9 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.metadata.clone()); if let Some(master_edition) = self.master_edition { @@ -456,6 +544,9 @@ impl<'a> CreateV1Cpi<'a> { account_infos.push(self.system_program.clone()); account_infos.push(self.sysvar_instructions.clone()); account_infos.push(self.spl_token_program.clone()); + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -497,6 +588,7 @@ impl<'a> CreateV1CpiBuilder<'a> { rule_set: None, decimals: None, print_supply: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -514,9 +606,9 @@ impl<'a> CreateV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// Mint of token asset @@ -661,8 +753,34 @@ impl<'a> CreateV1CpiBuilder<'a> { self.instruction.print_supply = Some(print_supply); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> CreateV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = CreateV1InstructionArgs { name: self.instruction.name.clone().expect("name is not set"), symbol: self.instruction.symbol.clone().unwrap_or(String::from("")), @@ -691,8 +809,7 @@ impl<'a> CreateV1CpiBuilder<'a> { decimals: self.instruction.decimals.clone(), print_supply: self.instruction.print_supply.clone(), }; - - CreateV1Cpi { + let instruction = CreateV1Cpi { __program: self.instruction.__program, metadata: self.instruction.metadata.expect("metadata is not set"), @@ -725,7 +842,11 @@ impl<'a> CreateV1CpiBuilder<'a> { .spl_token_program .expect("spl_token_program is not set"), __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -754,4 +875,5 @@ struct CreateV1CpiBuilderInstruction<'a> { rule_set: Option, decimals: Option, print_supply: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/delegate_authority_item_v1.rs b/clients/rust/src/generated/instructions/delegate_authority_item_v1.rs index 72619cf5..51f9d7d3 100644 --- a/clients/rust/src/generated/instructions/delegate_authority_item_v1.rs +++ b/clients/rust/src/generated/instructions/delegate_authority_item_v1.rs @@ -42,12 +42,19 @@ pub struct DelegateAuthorityItemV1 { } impl DelegateAuthorityItemV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: DelegateAuthorityItemV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: DelegateAuthorityItemV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -148,6 +155,9 @@ impl DelegateAuthorityItemV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateAuthorityItemV1InstructionData::new() .try_to_vec() .unwrap(); @@ -177,7 +187,8 @@ impl DelegateAuthorityItemV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DelegateAuthorityItemV1InstructionArgs { pub authorization_data: Option, } @@ -200,6 +211,7 @@ pub struct DelegateAuthorityItemV1Builder { authorization_rules_program: Option, authorization_rules: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl DelegateAuthorityItemV1Builder { @@ -211,9 +223,9 @@ impl DelegateAuthorityItemV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -231,15 +243,21 @@ impl DelegateAuthorityItemV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -251,8 +269,8 @@ impl DelegateAuthorityItemV1Builder { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Update authority or token owner @@ -267,12 +285,14 @@ impl DelegateAuthorityItemV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -287,9 +307,9 @@ impl DelegateAuthorityItemV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -297,9 +317,9 @@ impl DelegateAuthorityItemV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -307,9 +327,9 @@ impl DelegateAuthorityItemV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -318,8 +338,18 @@ impl DelegateAuthorityItemV1Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = DelegateAuthorityItemV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -344,10 +374,42 @@ impl DelegateAuthorityItemV1Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `delegate_authority_item_v1` CPI accounts. +pub struct DelegateAuthorityItemV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `delegate_authority_item_v1` CPI instruction. pub struct DelegateAuthorityItemV1Cpi<'a> { /// The program to invoke. @@ -385,16 +447,56 @@ pub struct DelegateAuthorityItemV1Cpi<'a> { } impl<'a> DelegateAuthorityItemV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: DelegateAuthorityItemV1CpiAccounts<'a>, + args: DelegateAuthorityItemV1InstructionArgs, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -499,6 +601,9 @@ impl<'a> DelegateAuthorityItemV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateAuthorityItemV1InstructionData::new() .try_to_vec() .unwrap(); @@ -510,7 +615,7 @@ impl<'a> DelegateAuthorityItemV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -540,6 +645,9 @@ impl<'a> DelegateAuthorityItemV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -573,6 +681,7 @@ impl<'a> DelegateAuthorityItemV1CpiBuilder<'a> { authorization_rules_program: None, authorization_rules: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -581,9 +690,9 @@ impl<'a> DelegateAuthorityItemV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -609,9 +718,9 @@ impl<'a> DelegateAuthorityItemV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -619,9 +728,9 @@ impl<'a> DelegateAuthorityItemV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -633,8 +742,11 @@ impl<'a> DelegateAuthorityItemV1CpiBuilder<'a> { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Update authority or token owner @@ -675,9 +787,9 @@ impl<'a> DelegateAuthorityItemV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -685,9 +797,9 @@ impl<'a> DelegateAuthorityItemV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -695,9 +807,9 @@ impl<'a> DelegateAuthorityItemV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -706,13 +818,38 @@ impl<'a> DelegateAuthorityItemV1CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> DelegateAuthorityItemV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = DelegateAuthorityItemV1InstructionArgs { authorization_data: self.instruction.authorization_data.clone(), }; - - DelegateAuthorityItemV1Cpi { + let instruction = DelegateAuthorityItemV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -749,7 +886,11 @@ impl<'a> DelegateAuthorityItemV1CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -770,4 +911,5 @@ struct DelegateAuthorityItemV1CpiBuilderInstruction<'a> { authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/delegate_collection_item_v1.rs b/clients/rust/src/generated/instructions/delegate_collection_item_v1.rs index 575e2f06..21d1983e 100644 --- a/clients/rust/src/generated/instructions/delegate_collection_item_v1.rs +++ b/clients/rust/src/generated/instructions/delegate_collection_item_v1.rs @@ -42,12 +42,19 @@ pub struct DelegateCollectionItemV1 { } impl DelegateCollectionItemV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: DelegateCollectionItemV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: DelegateCollectionItemV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -148,6 +155,9 @@ impl DelegateCollectionItemV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateCollectionItemV1InstructionData::new() .try_to_vec() .unwrap(); @@ -177,7 +187,8 @@ impl DelegateCollectionItemV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DelegateCollectionItemV1InstructionArgs { pub authorization_data: Option, } @@ -200,6 +211,7 @@ pub struct DelegateCollectionItemV1Builder { authorization_rules_program: Option, authorization_rules: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl DelegateCollectionItemV1Builder { @@ -211,9 +223,9 @@ impl DelegateCollectionItemV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -231,15 +243,21 @@ impl DelegateCollectionItemV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -251,8 +269,8 @@ impl DelegateCollectionItemV1Builder { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Update authority or token owner @@ -267,12 +285,14 @@ impl DelegateCollectionItemV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -287,9 +307,9 @@ impl DelegateCollectionItemV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -297,9 +317,9 @@ impl DelegateCollectionItemV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -307,9 +327,9 @@ impl DelegateCollectionItemV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -318,8 +338,18 @@ impl DelegateCollectionItemV1Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = DelegateCollectionItemV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -344,10 +374,42 @@ impl DelegateCollectionItemV1Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `delegate_collection_item_v1` CPI accounts. +pub struct DelegateCollectionItemV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `delegate_collection_item_v1` CPI instruction. pub struct DelegateCollectionItemV1Cpi<'a> { /// The program to invoke. @@ -385,16 +447,56 @@ pub struct DelegateCollectionItemV1Cpi<'a> { } impl<'a> DelegateCollectionItemV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: DelegateCollectionItemV1CpiAccounts<'a>, + args: DelegateCollectionItemV1InstructionArgs, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -499,6 +601,9 @@ impl<'a> DelegateCollectionItemV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateCollectionItemV1InstructionData::new() .try_to_vec() .unwrap(); @@ -510,7 +615,7 @@ impl<'a> DelegateCollectionItemV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -540,6 +645,9 @@ impl<'a> DelegateCollectionItemV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -573,6 +681,7 @@ impl<'a> DelegateCollectionItemV1CpiBuilder<'a> { authorization_rules_program: None, authorization_rules: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -581,9 +690,9 @@ impl<'a> DelegateCollectionItemV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -609,9 +718,9 @@ impl<'a> DelegateCollectionItemV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -619,9 +728,9 @@ impl<'a> DelegateCollectionItemV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -633,8 +742,11 @@ impl<'a> DelegateCollectionItemV1CpiBuilder<'a> { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Update authority or token owner @@ -675,9 +787,9 @@ impl<'a> DelegateCollectionItemV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -685,9 +797,9 @@ impl<'a> DelegateCollectionItemV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -695,9 +807,9 @@ impl<'a> DelegateCollectionItemV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -706,13 +818,38 @@ impl<'a> DelegateCollectionItemV1CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> DelegateCollectionItemV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = DelegateCollectionItemV1InstructionArgs { authorization_data: self.instruction.authorization_data.clone(), }; - - DelegateCollectionItemV1Cpi { + let instruction = DelegateCollectionItemV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -749,7 +886,11 @@ impl<'a> DelegateCollectionItemV1CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -770,4 +911,5 @@ struct DelegateCollectionItemV1CpiBuilderInstruction<'a> { authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/delegate_collection_v1.rs b/clients/rust/src/generated/instructions/delegate_collection_v1.rs index 45aa6d90..ee9899be 100644 --- a/clients/rust/src/generated/instructions/delegate_collection_v1.rs +++ b/clients/rust/src/generated/instructions/delegate_collection_v1.rs @@ -42,12 +42,19 @@ pub struct DelegateCollectionV1 { } impl DelegateCollectionV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: DelegateCollectionV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: DelegateCollectionV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -148,6 +155,9 @@ impl DelegateCollectionV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateCollectionV1InstructionData::new() .try_to_vec() .unwrap(); @@ -177,7 +187,8 @@ impl DelegateCollectionV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DelegateCollectionV1InstructionArgs { pub authorization_data: Option, } @@ -200,6 +211,7 @@ pub struct DelegateCollectionV1Builder { authorization_rules_program: Option, authorization_rules: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl DelegateCollectionV1Builder { @@ -211,9 +223,9 @@ impl DelegateCollectionV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -231,15 +243,21 @@ impl DelegateCollectionV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -251,8 +269,8 @@ impl DelegateCollectionV1Builder { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Update authority or token owner @@ -267,12 +285,14 @@ impl DelegateCollectionV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -287,9 +307,9 @@ impl DelegateCollectionV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -297,9 +317,9 @@ impl DelegateCollectionV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -307,9 +327,9 @@ impl DelegateCollectionV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -318,8 +338,18 @@ impl DelegateCollectionV1Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = DelegateCollectionV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -344,10 +374,42 @@ impl DelegateCollectionV1Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `delegate_collection_v1` CPI accounts. +pub struct DelegateCollectionV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `delegate_collection_v1` CPI instruction. pub struct DelegateCollectionV1Cpi<'a> { /// The program to invoke. @@ -385,16 +447,56 @@ pub struct DelegateCollectionV1Cpi<'a> { } impl<'a> DelegateCollectionV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: DelegateCollectionV1CpiAccounts<'a>, + args: DelegateCollectionV1InstructionArgs, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -499,6 +601,9 @@ impl<'a> DelegateCollectionV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateCollectionV1InstructionData::new() .try_to_vec() .unwrap(); @@ -510,7 +615,7 @@ impl<'a> DelegateCollectionV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -540,6 +645,9 @@ impl<'a> DelegateCollectionV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -573,6 +681,7 @@ impl<'a> DelegateCollectionV1CpiBuilder<'a> { authorization_rules_program: None, authorization_rules: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -581,9 +690,9 @@ impl<'a> DelegateCollectionV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -609,9 +718,9 @@ impl<'a> DelegateCollectionV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -619,9 +728,9 @@ impl<'a> DelegateCollectionV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -633,8 +742,11 @@ impl<'a> DelegateCollectionV1CpiBuilder<'a> { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Update authority or token owner @@ -675,9 +787,9 @@ impl<'a> DelegateCollectionV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -685,9 +797,9 @@ impl<'a> DelegateCollectionV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -695,9 +807,9 @@ impl<'a> DelegateCollectionV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -706,13 +818,38 @@ impl<'a> DelegateCollectionV1CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> DelegateCollectionV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = DelegateCollectionV1InstructionArgs { authorization_data: self.instruction.authorization_data.clone(), }; - - DelegateCollectionV1Cpi { + let instruction = DelegateCollectionV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -749,7 +886,11 @@ impl<'a> DelegateCollectionV1CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -770,4 +911,5 @@ struct DelegateCollectionV1CpiBuilderInstruction<'a> { authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/delegate_data_item_v1.rs b/clients/rust/src/generated/instructions/delegate_data_item_v1.rs index 2094250c..7607510d 100644 --- a/clients/rust/src/generated/instructions/delegate_data_item_v1.rs +++ b/clients/rust/src/generated/instructions/delegate_data_item_v1.rs @@ -42,12 +42,19 @@ pub struct DelegateDataItemV1 { } impl DelegateDataItemV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: DelegateDataItemV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: DelegateDataItemV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -148,6 +155,9 @@ impl DelegateDataItemV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateDataItemV1InstructionData::new() .try_to_vec() .unwrap(); @@ -177,7 +187,8 @@ impl DelegateDataItemV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DelegateDataItemV1InstructionArgs { pub authorization_data: Option, } @@ -200,6 +211,7 @@ pub struct DelegateDataItemV1Builder { authorization_rules_program: Option, authorization_rules: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl DelegateDataItemV1Builder { @@ -211,9 +223,9 @@ impl DelegateDataItemV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -231,15 +243,21 @@ impl DelegateDataItemV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -251,8 +269,8 @@ impl DelegateDataItemV1Builder { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Update authority or token owner @@ -267,12 +285,14 @@ impl DelegateDataItemV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -287,9 +307,9 @@ impl DelegateDataItemV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -297,9 +317,9 @@ impl DelegateDataItemV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -307,9 +327,9 @@ impl DelegateDataItemV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -318,8 +338,18 @@ impl DelegateDataItemV1Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = DelegateDataItemV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -344,10 +374,42 @@ impl DelegateDataItemV1Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `delegate_data_item_v1` CPI accounts. +pub struct DelegateDataItemV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `delegate_data_item_v1` CPI instruction. pub struct DelegateDataItemV1Cpi<'a> { /// The program to invoke. @@ -385,16 +447,56 @@ pub struct DelegateDataItemV1Cpi<'a> { } impl<'a> DelegateDataItemV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: DelegateDataItemV1CpiAccounts<'a>, + args: DelegateDataItemV1InstructionArgs, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -499,6 +601,9 @@ impl<'a> DelegateDataItemV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateDataItemV1InstructionData::new() .try_to_vec() .unwrap(); @@ -510,7 +615,7 @@ impl<'a> DelegateDataItemV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -540,6 +645,9 @@ impl<'a> DelegateDataItemV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -573,6 +681,7 @@ impl<'a> DelegateDataItemV1CpiBuilder<'a> { authorization_rules_program: None, authorization_rules: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -581,9 +690,9 @@ impl<'a> DelegateDataItemV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -609,9 +718,9 @@ impl<'a> DelegateDataItemV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -619,9 +728,9 @@ impl<'a> DelegateDataItemV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -633,8 +742,11 @@ impl<'a> DelegateDataItemV1CpiBuilder<'a> { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Update authority or token owner @@ -675,9 +787,9 @@ impl<'a> DelegateDataItemV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -685,9 +797,9 @@ impl<'a> DelegateDataItemV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -695,9 +807,9 @@ impl<'a> DelegateDataItemV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -706,13 +818,38 @@ impl<'a> DelegateDataItemV1CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> DelegateDataItemV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = DelegateDataItemV1InstructionArgs { authorization_data: self.instruction.authorization_data.clone(), }; - - DelegateDataItemV1Cpi { + let instruction = DelegateDataItemV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -749,7 +886,11 @@ impl<'a> DelegateDataItemV1CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -770,4 +911,5 @@ struct DelegateDataItemV1CpiBuilderInstruction<'a> { authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/delegate_data_v1.rs b/clients/rust/src/generated/instructions/delegate_data_v1.rs index bc4628bd..1973d563 100644 --- a/clients/rust/src/generated/instructions/delegate_data_v1.rs +++ b/clients/rust/src/generated/instructions/delegate_data_v1.rs @@ -42,12 +42,19 @@ pub struct DelegateDataV1 { } impl DelegateDataV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: DelegateDataV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: DelegateDataV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -148,6 +155,9 @@ impl DelegateDataV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateDataV1InstructionData::new().try_to_vec().unwrap(); let mut args = args.try_to_vec().unwrap(); data.append(&mut args); @@ -175,7 +185,8 @@ impl DelegateDataV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DelegateDataV1InstructionArgs { pub authorization_data: Option, } @@ -198,6 +209,7 @@ pub struct DelegateDataV1Builder { authorization_rules_program: Option, authorization_rules: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl DelegateDataV1Builder { @@ -209,9 +221,9 @@ impl DelegateDataV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -229,15 +241,21 @@ impl DelegateDataV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -249,8 +267,8 @@ impl DelegateDataV1Builder { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Update authority or token owner @@ -265,12 +283,14 @@ impl DelegateDataV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -285,9 +305,9 @@ impl DelegateDataV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -295,9 +315,9 @@ impl DelegateDataV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -305,9 +325,9 @@ impl DelegateDataV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -316,8 +336,18 @@ impl DelegateDataV1Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = DelegateDataV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -342,10 +372,42 @@ impl DelegateDataV1Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `delegate_data_v1` CPI accounts. +pub struct DelegateDataV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `delegate_data_v1` CPI instruction. pub struct DelegateDataV1Cpi<'a> { /// The program to invoke. @@ -383,16 +445,56 @@ pub struct DelegateDataV1Cpi<'a> { } impl<'a> DelegateDataV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: DelegateDataV1CpiAccounts<'a>, + args: DelegateDataV1InstructionArgs, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -497,6 +599,9 @@ impl<'a> DelegateDataV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateDataV1InstructionData::new().try_to_vec().unwrap(); let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); @@ -506,7 +611,7 @@ impl<'a> DelegateDataV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -536,6 +641,9 @@ impl<'a> DelegateDataV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -569,6 +677,7 @@ impl<'a> DelegateDataV1CpiBuilder<'a> { authorization_rules_program: None, authorization_rules: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -577,9 +686,9 @@ impl<'a> DelegateDataV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -605,9 +714,9 @@ impl<'a> DelegateDataV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -615,9 +724,9 @@ impl<'a> DelegateDataV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -629,8 +738,11 @@ impl<'a> DelegateDataV1CpiBuilder<'a> { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Update authority or token owner @@ -671,9 +783,9 @@ impl<'a> DelegateDataV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -681,9 +793,9 @@ impl<'a> DelegateDataV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -691,9 +803,9 @@ impl<'a> DelegateDataV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -702,13 +814,38 @@ impl<'a> DelegateDataV1CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> DelegateDataV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = DelegateDataV1InstructionArgs { authorization_data: self.instruction.authorization_data.clone(), }; - - DelegateDataV1Cpi { + let instruction = DelegateDataV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -745,7 +882,11 @@ impl<'a> DelegateDataV1CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -766,4 +907,5 @@ struct DelegateDataV1CpiBuilderInstruction<'a> { authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/delegate_locked_transfer_v1.rs b/clients/rust/src/generated/instructions/delegate_locked_transfer_v1.rs index ae126287..decc2b63 100644 --- a/clients/rust/src/generated/instructions/delegate_locked_transfer_v1.rs +++ b/clients/rust/src/generated/instructions/delegate_locked_transfer_v1.rs @@ -43,12 +43,19 @@ pub struct DelegateLockedTransferV1 { } impl DelegateLockedTransferV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: DelegateLockedTransferV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: DelegateLockedTransferV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -144,6 +151,9 @@ impl DelegateLockedTransferV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateLockedTransferV1InstructionData::new() .try_to_vec() .unwrap(); @@ -173,7 +183,8 @@ impl DelegateLockedTransferV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DelegateLockedTransferV1InstructionArgs { pub amount: u64, pub locked_address: Pubkey, @@ -200,6 +211,7 @@ pub struct DelegateLockedTransferV1Builder { amount: Option, locked_address: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl DelegateLockedTransferV1Builder { @@ -211,9 +223,9 @@ impl DelegateLockedTransferV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -231,15 +243,21 @@ impl DelegateLockedTransferV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -266,12 +284,14 @@ impl DelegateLockedTransferV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -286,9 +306,9 @@ impl DelegateLockedTransferV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -296,9 +316,9 @@ impl DelegateLockedTransferV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -306,9 +326,9 @@ impl DelegateLockedTransferV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to '1']` @@ -328,8 +348,18 @@ impl DelegateLockedTransferV1Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = DelegateLockedTransferV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -359,10 +389,42 @@ impl DelegateLockedTransferV1Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `delegate_locked_transfer_v1` CPI accounts. +pub struct DelegateLockedTransferV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `delegate_locked_transfer_v1` CPI instruction. pub struct DelegateLockedTransferV1Cpi<'a> { /// The program to invoke. @@ -400,16 +462,56 @@ pub struct DelegateLockedTransferV1Cpi<'a> { } impl<'a> DelegateLockedTransferV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: DelegateLockedTransferV1CpiAccounts<'a>, + args: DelegateLockedTransferV1InstructionArgs, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -508,6 +610,9 @@ impl<'a> DelegateLockedTransferV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateLockedTransferV1InstructionData::new() .try_to_vec() .unwrap(); @@ -519,7 +624,7 @@ impl<'a> DelegateLockedTransferV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -547,6 +652,9 @@ impl<'a> DelegateLockedTransferV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -582,6 +690,7 @@ impl<'a> DelegateLockedTransferV1CpiBuilder<'a> { amount: None, locked_address: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -590,9 +699,9 @@ impl<'a> DelegateLockedTransferV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -618,9 +727,9 @@ impl<'a> DelegateLockedTransferV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -628,9 +737,9 @@ impl<'a> DelegateLockedTransferV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -683,9 +792,9 @@ impl<'a> DelegateLockedTransferV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -693,9 +802,9 @@ impl<'a> DelegateLockedTransferV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -703,9 +812,9 @@ impl<'a> DelegateLockedTransferV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to '1']` @@ -725,8 +834,34 @@ impl<'a> DelegateLockedTransferV1CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> DelegateLockedTransferV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = DelegateLockedTransferV1InstructionArgs { amount: self.instruction.amount.clone().unwrap_or(1), locked_address: self @@ -736,8 +871,7 @@ impl<'a> DelegateLockedTransferV1CpiBuilder<'a> { .expect("locked_address is not set"), authorization_data: self.instruction.authorization_data.clone(), }; - - DelegateLockedTransferV1Cpi { + let instruction = DelegateLockedTransferV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -774,7 +908,11 @@ impl<'a> DelegateLockedTransferV1CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -797,4 +935,5 @@ struct DelegateLockedTransferV1CpiBuilderInstruction<'a> { amount: Option, locked_address: Option, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/delegate_programmable_config_item_v1.rs b/clients/rust/src/generated/instructions/delegate_programmable_config_item_v1.rs index 26de8c51..d559acbe 100644 --- a/clients/rust/src/generated/instructions/delegate_programmable_config_item_v1.rs +++ b/clients/rust/src/generated/instructions/delegate_programmable_config_item_v1.rs @@ -42,12 +42,19 @@ pub struct DelegateProgrammableConfigItemV1 { } impl DelegateProgrammableConfigItemV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: DelegateProgrammableConfigItemV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: DelegateProgrammableConfigItemV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -148,6 +155,9 @@ impl DelegateProgrammableConfigItemV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateProgrammableConfigItemV1InstructionData::new() .try_to_vec() .unwrap(); @@ -177,7 +187,8 @@ impl DelegateProgrammableConfigItemV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DelegateProgrammableConfigItemV1InstructionArgs { pub authorization_data: Option, } @@ -200,6 +211,7 @@ pub struct DelegateProgrammableConfigItemV1Builder { authorization_rules_program: Option, authorization_rules: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl DelegateProgrammableConfigItemV1Builder { @@ -211,9 +223,9 @@ impl DelegateProgrammableConfigItemV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -231,15 +243,21 @@ impl DelegateProgrammableConfigItemV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -251,8 +269,8 @@ impl DelegateProgrammableConfigItemV1Builder { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Update authority or token owner @@ -267,12 +285,14 @@ impl DelegateProgrammableConfigItemV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -287,9 +307,9 @@ impl DelegateProgrammableConfigItemV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -297,9 +317,9 @@ impl DelegateProgrammableConfigItemV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -307,9 +327,9 @@ impl DelegateProgrammableConfigItemV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -318,8 +338,18 @@ impl DelegateProgrammableConfigItemV1Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = DelegateProgrammableConfigItemV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -344,10 +374,42 @@ impl DelegateProgrammableConfigItemV1Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `delegate_programmable_config_item_v1` CPI accounts. +pub struct DelegateProgrammableConfigItemV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `delegate_programmable_config_item_v1` CPI instruction. pub struct DelegateProgrammableConfigItemV1Cpi<'a> { /// The program to invoke. @@ -385,16 +447,56 @@ pub struct DelegateProgrammableConfigItemV1Cpi<'a> { } impl<'a> DelegateProgrammableConfigItemV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: DelegateProgrammableConfigItemV1CpiAccounts<'a>, + args: DelegateProgrammableConfigItemV1InstructionArgs, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -499,6 +601,9 @@ impl<'a> DelegateProgrammableConfigItemV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateProgrammableConfigItemV1InstructionData::new() .try_to_vec() .unwrap(); @@ -510,7 +615,7 @@ impl<'a> DelegateProgrammableConfigItemV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -540,6 +645,9 @@ impl<'a> DelegateProgrammableConfigItemV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -573,6 +681,7 @@ impl<'a> DelegateProgrammableConfigItemV1CpiBuilder<'a> { authorization_rules_program: None, authorization_rules: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -581,9 +690,9 @@ impl<'a> DelegateProgrammableConfigItemV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -609,9 +718,9 @@ impl<'a> DelegateProgrammableConfigItemV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -619,9 +728,9 @@ impl<'a> DelegateProgrammableConfigItemV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -633,8 +742,11 @@ impl<'a> DelegateProgrammableConfigItemV1CpiBuilder<'a> { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Update authority or token owner @@ -675,9 +787,9 @@ impl<'a> DelegateProgrammableConfigItemV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -685,9 +797,9 @@ impl<'a> DelegateProgrammableConfigItemV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -695,9 +807,9 @@ impl<'a> DelegateProgrammableConfigItemV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -706,13 +818,38 @@ impl<'a> DelegateProgrammableConfigItemV1CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> DelegateProgrammableConfigItemV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = DelegateProgrammableConfigItemV1InstructionArgs { authorization_data: self.instruction.authorization_data.clone(), }; - - DelegateProgrammableConfigItemV1Cpi { + let instruction = DelegateProgrammableConfigItemV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -749,7 +886,11 @@ impl<'a> DelegateProgrammableConfigItemV1CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -770,4 +911,5 @@ struct DelegateProgrammableConfigItemV1CpiBuilderInstruction<'a> { authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/delegate_programmable_config_v1.rs b/clients/rust/src/generated/instructions/delegate_programmable_config_v1.rs index 6cc05f84..b0e4563e 100644 --- a/clients/rust/src/generated/instructions/delegate_programmable_config_v1.rs +++ b/clients/rust/src/generated/instructions/delegate_programmable_config_v1.rs @@ -42,12 +42,19 @@ pub struct DelegateProgrammableConfigV1 { } impl DelegateProgrammableConfigV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: DelegateProgrammableConfigV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: DelegateProgrammableConfigV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -148,6 +155,9 @@ impl DelegateProgrammableConfigV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateProgrammableConfigV1InstructionData::new() .try_to_vec() .unwrap(); @@ -177,7 +187,8 @@ impl DelegateProgrammableConfigV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DelegateProgrammableConfigV1InstructionArgs { pub authorization_data: Option, } @@ -200,6 +211,7 @@ pub struct DelegateProgrammableConfigV1Builder { authorization_rules_program: Option, authorization_rules: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl DelegateProgrammableConfigV1Builder { @@ -211,9 +223,9 @@ impl DelegateProgrammableConfigV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -231,15 +243,21 @@ impl DelegateProgrammableConfigV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -251,8 +269,8 @@ impl DelegateProgrammableConfigV1Builder { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Update authority or token owner @@ -267,12 +285,14 @@ impl DelegateProgrammableConfigV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -287,9 +307,9 @@ impl DelegateProgrammableConfigV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -297,9 +317,9 @@ impl DelegateProgrammableConfigV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -307,9 +327,9 @@ impl DelegateProgrammableConfigV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -318,8 +338,18 @@ impl DelegateProgrammableConfigV1Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = DelegateProgrammableConfigV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -344,10 +374,42 @@ impl DelegateProgrammableConfigV1Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `delegate_programmable_config_v1` CPI accounts. +pub struct DelegateProgrammableConfigV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `delegate_programmable_config_v1` CPI instruction. pub struct DelegateProgrammableConfigV1Cpi<'a> { /// The program to invoke. @@ -385,16 +447,56 @@ pub struct DelegateProgrammableConfigV1Cpi<'a> { } impl<'a> DelegateProgrammableConfigV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: DelegateProgrammableConfigV1CpiAccounts<'a>, + args: DelegateProgrammableConfigV1InstructionArgs, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -499,6 +601,9 @@ impl<'a> DelegateProgrammableConfigV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateProgrammableConfigV1InstructionData::new() .try_to_vec() .unwrap(); @@ -510,7 +615,7 @@ impl<'a> DelegateProgrammableConfigV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -540,6 +645,9 @@ impl<'a> DelegateProgrammableConfigV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -573,6 +681,7 @@ impl<'a> DelegateProgrammableConfigV1CpiBuilder<'a> { authorization_rules_program: None, authorization_rules: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -581,9 +690,9 @@ impl<'a> DelegateProgrammableConfigV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -609,9 +718,9 @@ impl<'a> DelegateProgrammableConfigV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -619,9 +728,9 @@ impl<'a> DelegateProgrammableConfigV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -633,8 +742,11 @@ impl<'a> DelegateProgrammableConfigV1CpiBuilder<'a> { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Update authority or token owner @@ -675,9 +787,9 @@ impl<'a> DelegateProgrammableConfigV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -685,9 +797,9 @@ impl<'a> DelegateProgrammableConfigV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -695,9 +807,9 @@ impl<'a> DelegateProgrammableConfigV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -706,13 +818,38 @@ impl<'a> DelegateProgrammableConfigV1CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> DelegateProgrammableConfigV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = DelegateProgrammableConfigV1InstructionArgs { authorization_data: self.instruction.authorization_data.clone(), }; - - DelegateProgrammableConfigV1Cpi { + let instruction = DelegateProgrammableConfigV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -749,7 +886,11 @@ impl<'a> DelegateProgrammableConfigV1CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -770,4 +911,5 @@ struct DelegateProgrammableConfigV1CpiBuilderInstruction<'a> { authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/delegate_sale_v1.rs b/clients/rust/src/generated/instructions/delegate_sale_v1.rs index d0ecd1ee..fa633b9e 100644 --- a/clients/rust/src/generated/instructions/delegate_sale_v1.rs +++ b/clients/rust/src/generated/instructions/delegate_sale_v1.rs @@ -42,12 +42,19 @@ pub struct DelegateSaleV1 { } impl DelegateSaleV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: DelegateSaleV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: DelegateSaleV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -143,6 +150,9 @@ impl DelegateSaleV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateSaleV1InstructionData::new().try_to_vec().unwrap(); let mut args = args.try_to_vec().unwrap(); data.append(&mut args); @@ -170,7 +180,8 @@ impl DelegateSaleV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DelegateSaleV1InstructionArgs { pub amount: u64, pub authorization_data: Option, @@ -195,6 +206,7 @@ pub struct DelegateSaleV1Builder { authorization_rules: Option, amount: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl DelegateSaleV1Builder { @@ -206,9 +218,9 @@ impl DelegateSaleV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -226,15 +238,21 @@ impl DelegateSaleV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -261,12 +279,14 @@ impl DelegateSaleV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -281,9 +301,9 @@ impl DelegateSaleV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -291,9 +311,9 @@ impl DelegateSaleV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -301,9 +321,9 @@ impl DelegateSaleV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to '1']` @@ -318,8 +338,18 @@ impl DelegateSaleV1Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = DelegateSaleV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -345,10 +375,42 @@ impl DelegateSaleV1Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `delegate_sale_v1` CPI accounts. +pub struct DelegateSaleV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `delegate_sale_v1` CPI instruction. pub struct DelegateSaleV1Cpi<'a> { /// The program to invoke. @@ -386,16 +448,56 @@ pub struct DelegateSaleV1Cpi<'a> { } impl<'a> DelegateSaleV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: DelegateSaleV1CpiAccounts<'a>, + args: DelegateSaleV1InstructionArgs, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -494,6 +596,9 @@ impl<'a> DelegateSaleV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateSaleV1InstructionData::new().try_to_vec().unwrap(); let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); @@ -503,7 +608,7 @@ impl<'a> DelegateSaleV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -531,6 +636,9 @@ impl<'a> DelegateSaleV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -565,6 +673,7 @@ impl<'a> DelegateSaleV1CpiBuilder<'a> { authorization_rules: None, amount: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -573,9 +682,9 @@ impl<'a> DelegateSaleV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -601,9 +710,9 @@ impl<'a> DelegateSaleV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -611,9 +720,9 @@ impl<'a> DelegateSaleV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -666,9 +775,9 @@ impl<'a> DelegateSaleV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -676,9 +785,9 @@ impl<'a> DelegateSaleV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -686,9 +795,9 @@ impl<'a> DelegateSaleV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to '1']` @@ -703,14 +812,39 @@ impl<'a> DelegateSaleV1CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> DelegateSaleV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = DelegateSaleV1InstructionArgs { amount: self.instruction.amount.clone().unwrap_or(1), authorization_data: self.instruction.authorization_data.clone(), }; - - DelegateSaleV1Cpi { + let instruction = DelegateSaleV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -747,7 +881,11 @@ impl<'a> DelegateSaleV1CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -769,4 +907,5 @@ struct DelegateSaleV1CpiBuilderInstruction<'a> { authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, amount: Option, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/delegate_staking_v1.rs b/clients/rust/src/generated/instructions/delegate_staking_v1.rs index 06e081f8..8b3bc44f 100644 --- a/clients/rust/src/generated/instructions/delegate_staking_v1.rs +++ b/clients/rust/src/generated/instructions/delegate_staking_v1.rs @@ -42,12 +42,19 @@ pub struct DelegateStakingV1 { } impl DelegateStakingV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: DelegateStakingV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: DelegateStakingV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -143,6 +150,9 @@ impl DelegateStakingV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateStakingV1InstructionData::new() .try_to_vec() .unwrap(); @@ -172,7 +182,8 @@ impl DelegateStakingV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DelegateStakingV1InstructionArgs { pub amount: u64, pub authorization_data: Option, @@ -197,6 +208,7 @@ pub struct DelegateStakingV1Builder { authorization_rules: Option, amount: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl DelegateStakingV1Builder { @@ -208,9 +220,9 @@ impl DelegateStakingV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -228,15 +240,21 @@ impl DelegateStakingV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -263,12 +281,14 @@ impl DelegateStakingV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -283,9 +303,9 @@ impl DelegateStakingV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -293,9 +313,9 @@ impl DelegateStakingV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -303,9 +323,9 @@ impl DelegateStakingV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to '1']` @@ -320,8 +340,18 @@ impl DelegateStakingV1Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = DelegateStakingV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -347,10 +377,42 @@ impl DelegateStakingV1Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `delegate_staking_v1` CPI accounts. +pub struct DelegateStakingV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `delegate_staking_v1` CPI instruction. pub struct DelegateStakingV1Cpi<'a> { /// The program to invoke. @@ -388,16 +450,56 @@ pub struct DelegateStakingV1Cpi<'a> { } impl<'a> DelegateStakingV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: DelegateStakingV1CpiAccounts<'a>, + args: DelegateStakingV1InstructionArgs, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -496,6 +598,9 @@ impl<'a> DelegateStakingV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateStakingV1InstructionData::new() .try_to_vec() .unwrap(); @@ -507,7 +612,7 @@ impl<'a> DelegateStakingV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -535,6 +640,9 @@ impl<'a> DelegateStakingV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -569,6 +677,7 @@ impl<'a> DelegateStakingV1CpiBuilder<'a> { authorization_rules: None, amount: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -577,9 +686,9 @@ impl<'a> DelegateStakingV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -605,9 +714,9 @@ impl<'a> DelegateStakingV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -615,9 +724,9 @@ impl<'a> DelegateStakingV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -670,9 +779,9 @@ impl<'a> DelegateStakingV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -680,9 +789,9 @@ impl<'a> DelegateStakingV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -690,9 +799,9 @@ impl<'a> DelegateStakingV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to '1']` @@ -707,14 +816,39 @@ impl<'a> DelegateStakingV1CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> DelegateStakingV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = DelegateStakingV1InstructionArgs { amount: self.instruction.amount.clone().unwrap_or(1), authorization_data: self.instruction.authorization_data.clone(), }; - - DelegateStakingV1Cpi { + let instruction = DelegateStakingV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -751,7 +885,11 @@ impl<'a> DelegateStakingV1CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -773,4 +911,5 @@ struct DelegateStakingV1CpiBuilderInstruction<'a> { authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, amount: Option, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/delegate_standard_v1.rs b/clients/rust/src/generated/instructions/delegate_standard_v1.rs index 6b05b3ea..d6052d3e 100644 --- a/clients/rust/src/generated/instructions/delegate_standard_v1.rs +++ b/clients/rust/src/generated/instructions/delegate_standard_v1.rs @@ -41,12 +41,19 @@ pub struct DelegateStandardV1 { } impl DelegateStandardV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: DelegateStandardV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: DelegateStandardV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -142,6 +149,9 @@ impl DelegateStandardV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateStandardV1InstructionData::new() .try_to_vec() .unwrap(); @@ -171,7 +181,8 @@ impl DelegateStandardV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DelegateStandardV1InstructionArgs { pub amount: u64, } @@ -194,6 +205,7 @@ pub struct DelegateStandardV1Builder { authorization_rules_program: Option, authorization_rules: Option, amount: Option, + __remaining_accounts: Vec, } impl DelegateStandardV1Builder { @@ -205,9 +217,9 @@ impl DelegateStandardV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -225,15 +237,21 @@ impl DelegateStandardV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -260,12 +278,14 @@ impl DelegateStandardV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -280,9 +300,9 @@ impl DelegateStandardV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -290,9 +310,9 @@ impl DelegateStandardV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -300,9 +320,9 @@ impl DelegateStandardV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to '1']` @@ -311,8 +331,18 @@ impl DelegateStandardV1Builder { self.amount = Some(amount); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = DelegateStandardV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -337,10 +367,42 @@ impl DelegateStandardV1Builder { amount: self.amount.clone().unwrap_or(1), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `delegate_standard_v1` CPI accounts. +pub struct DelegateStandardV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `delegate_standard_v1` CPI instruction. pub struct DelegateStandardV1Cpi<'a> { /// The program to invoke. @@ -378,16 +440,56 @@ pub struct DelegateStandardV1Cpi<'a> { } impl<'a> DelegateStandardV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: DelegateStandardV1CpiAccounts<'a>, + args: DelegateStandardV1InstructionArgs, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -486,6 +588,9 @@ impl<'a> DelegateStandardV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateStandardV1InstructionData::new() .try_to_vec() .unwrap(); @@ -497,7 +602,7 @@ impl<'a> DelegateStandardV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -525,6 +630,9 @@ impl<'a> DelegateStandardV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -558,6 +666,7 @@ impl<'a> DelegateStandardV1CpiBuilder<'a> { authorization_rules_program: None, authorization_rules: None, amount: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -566,9 +675,9 @@ impl<'a> DelegateStandardV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -594,9 +703,9 @@ impl<'a> DelegateStandardV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -604,9 +713,9 @@ impl<'a> DelegateStandardV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -659,9 +768,9 @@ impl<'a> DelegateStandardV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -669,9 +778,9 @@ impl<'a> DelegateStandardV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -679,9 +788,9 @@ impl<'a> DelegateStandardV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to '1']` @@ -690,13 +799,38 @@ impl<'a> DelegateStandardV1CpiBuilder<'a> { self.instruction.amount = Some(amount); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> DelegateStandardV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = DelegateStandardV1InstructionArgs { amount: self.instruction.amount.clone().unwrap_or(1), }; - - DelegateStandardV1Cpi { + let instruction = DelegateStandardV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -733,7 +867,11 @@ impl<'a> DelegateStandardV1CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -754,4 +892,5 @@ struct DelegateStandardV1CpiBuilderInstruction<'a> { authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, amount: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/delegate_transfer_v1.rs b/clients/rust/src/generated/instructions/delegate_transfer_v1.rs index 97b39ffb..69f0e9d4 100644 --- a/clients/rust/src/generated/instructions/delegate_transfer_v1.rs +++ b/clients/rust/src/generated/instructions/delegate_transfer_v1.rs @@ -42,12 +42,19 @@ pub struct DelegateTransferV1 { } impl DelegateTransferV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: DelegateTransferV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: DelegateTransferV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -143,6 +150,9 @@ impl DelegateTransferV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateTransferV1InstructionData::new() .try_to_vec() .unwrap(); @@ -172,7 +182,8 @@ impl DelegateTransferV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DelegateTransferV1InstructionArgs { pub amount: u64, pub authorization_data: Option, @@ -197,6 +208,7 @@ pub struct DelegateTransferV1Builder { authorization_rules: Option, amount: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl DelegateTransferV1Builder { @@ -208,9 +220,9 @@ impl DelegateTransferV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -228,15 +240,21 @@ impl DelegateTransferV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -263,12 +281,14 @@ impl DelegateTransferV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -283,9 +303,9 @@ impl DelegateTransferV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -293,9 +313,9 @@ impl DelegateTransferV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -303,9 +323,9 @@ impl DelegateTransferV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to '1']` @@ -320,8 +340,18 @@ impl DelegateTransferV1Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = DelegateTransferV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -347,10 +377,42 @@ impl DelegateTransferV1Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `delegate_transfer_v1` CPI accounts. +pub struct DelegateTransferV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `delegate_transfer_v1` CPI instruction. pub struct DelegateTransferV1Cpi<'a> { /// The program to invoke. @@ -388,16 +450,56 @@ pub struct DelegateTransferV1Cpi<'a> { } impl<'a> DelegateTransferV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: DelegateTransferV1CpiAccounts<'a>, + args: DelegateTransferV1InstructionArgs, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -496,6 +598,9 @@ impl<'a> DelegateTransferV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateTransferV1InstructionData::new() .try_to_vec() .unwrap(); @@ -507,7 +612,7 @@ impl<'a> DelegateTransferV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -535,6 +640,9 @@ impl<'a> DelegateTransferV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -569,6 +677,7 @@ impl<'a> DelegateTransferV1CpiBuilder<'a> { authorization_rules: None, amount: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -577,9 +686,9 @@ impl<'a> DelegateTransferV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -605,9 +714,9 @@ impl<'a> DelegateTransferV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -615,9 +724,9 @@ impl<'a> DelegateTransferV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -670,9 +779,9 @@ impl<'a> DelegateTransferV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -680,9 +789,9 @@ impl<'a> DelegateTransferV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -690,9 +799,9 @@ impl<'a> DelegateTransferV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to '1']` @@ -707,14 +816,39 @@ impl<'a> DelegateTransferV1CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> DelegateTransferV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = DelegateTransferV1InstructionArgs { amount: self.instruction.amount.clone().unwrap_or(1), authorization_data: self.instruction.authorization_data.clone(), }; - - DelegateTransferV1Cpi { + let instruction = DelegateTransferV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -751,7 +885,11 @@ impl<'a> DelegateTransferV1CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -773,4 +911,5 @@ struct DelegateTransferV1CpiBuilderInstruction<'a> { authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, amount: Option, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/delegate_utility_v1.rs b/clients/rust/src/generated/instructions/delegate_utility_v1.rs index 4b1070dd..6cd90145 100644 --- a/clients/rust/src/generated/instructions/delegate_utility_v1.rs +++ b/clients/rust/src/generated/instructions/delegate_utility_v1.rs @@ -42,12 +42,19 @@ pub struct DelegateUtilityV1 { } impl DelegateUtilityV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: DelegateUtilityV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: DelegateUtilityV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -143,6 +150,9 @@ impl DelegateUtilityV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateUtilityV1InstructionData::new() .try_to_vec() .unwrap(); @@ -172,7 +182,8 @@ impl DelegateUtilityV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DelegateUtilityV1InstructionArgs { pub amount: u64, pub authorization_data: Option, @@ -197,6 +208,7 @@ pub struct DelegateUtilityV1Builder { authorization_rules: Option, amount: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl DelegateUtilityV1Builder { @@ -208,9 +220,9 @@ impl DelegateUtilityV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -228,15 +240,21 @@ impl DelegateUtilityV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -263,12 +281,14 @@ impl DelegateUtilityV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -283,9 +303,9 @@ impl DelegateUtilityV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -293,9 +313,9 @@ impl DelegateUtilityV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -303,9 +323,9 @@ impl DelegateUtilityV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to '1']` @@ -320,8 +340,18 @@ impl DelegateUtilityV1Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = DelegateUtilityV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -347,10 +377,42 @@ impl DelegateUtilityV1Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `delegate_utility_v1` CPI accounts. +pub struct DelegateUtilityV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `delegate_utility_v1` CPI instruction. pub struct DelegateUtilityV1Cpi<'a> { /// The program to invoke. @@ -388,16 +450,56 @@ pub struct DelegateUtilityV1Cpi<'a> { } impl<'a> DelegateUtilityV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: DelegateUtilityV1CpiAccounts<'a>, + args: DelegateUtilityV1InstructionArgs, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -496,6 +598,9 @@ impl<'a> DelegateUtilityV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = DelegateUtilityV1InstructionData::new() .try_to_vec() .unwrap(); @@ -507,7 +612,7 @@ impl<'a> DelegateUtilityV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -535,6 +640,9 @@ impl<'a> DelegateUtilityV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -569,6 +677,7 @@ impl<'a> DelegateUtilityV1CpiBuilder<'a> { authorization_rules: None, amount: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -577,9 +686,9 @@ impl<'a> DelegateUtilityV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -605,9 +714,9 @@ impl<'a> DelegateUtilityV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -615,9 +724,9 @@ impl<'a> DelegateUtilityV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -670,9 +779,9 @@ impl<'a> DelegateUtilityV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -680,9 +789,9 @@ impl<'a> DelegateUtilityV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -690,9 +799,9 @@ impl<'a> DelegateUtilityV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to '1']` @@ -707,14 +816,39 @@ impl<'a> DelegateUtilityV1CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> DelegateUtilityV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = DelegateUtilityV1InstructionArgs { amount: self.instruction.amount.clone().unwrap_or(1), authorization_data: self.instruction.authorization_data.clone(), }; - - DelegateUtilityV1Cpi { + let instruction = DelegateUtilityV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -751,7 +885,11 @@ impl<'a> DelegateUtilityV1CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -773,4 +911,5 @@ struct DelegateUtilityV1CpiBuilderInstruction<'a> { authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, amount: Option, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/deprecated_mint_new_edition_from_master_edition_via_printing_token.rs b/clients/rust/src/generated/instructions/deprecated_mint_new_edition_from_master_edition_via_printing_token.rs index 1b6e642d..91a86ee9 100644 --- a/clients/rust/src/generated/instructions/deprecated_mint_new_edition_from_master_edition_via_printing_token.rs +++ b/clients/rust/src/generated/instructions/deprecated_mint_new_edition_from_master_edition_via_printing_token.rs @@ -45,9 +45,15 @@ pub struct DeprecatedMintNewEditionFromMasterEditionViaPrintingToken { } impl DeprecatedMintNewEditionFromMasterEditionViaPrintingToken { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(16); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.metadata, false, @@ -111,6 +117,9 @@ impl DeprecatedMintNewEditionFromMasterEditionViaPrintingToken { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenInstructionData::new() .try_to_vec() .unwrap(); @@ -153,6 +162,7 @@ pub struct DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenBuilder { system_program: Option, rent: Option, reservation_list: Option, + __remaining_accounts: Vec, } impl DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenBuilder { @@ -240,18 +250,21 @@ impl DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenBuilder { self.master_metadata = Some(master_metadata); self } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` /// Token program #[inline(always)] pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self { self.token_program = Some(token_program); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` /// Rent info #[inline(always)] pub fn rent(&mut self, rent: solana_program::pubkey::Pubkey) -> &mut Self { @@ -263,13 +276,23 @@ impl DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenBuilder { #[inline(always)] pub fn reservation_list( &mut self, - reservation_list: solana_program::pubkey::Pubkey, + reservation_list: Option, ) -> &mut Self { - self.reservation_list = Some(reservation_list); + self.reservation_list = reservation_list; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = DeprecatedMintNewEditionFromMasterEditionViaPrintingToken { metadata: self.metadata.expect("metadata is not set"), edition: self.edition.expect("edition is not set"), @@ -299,10 +322,46 @@ impl DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenBuilder { reservation_list: self.reservation_list, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `deprecated_mint_new_edition_from_master_edition_via_printing_token` CPI accounts. +pub struct DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenCpiAccounts<'a> { + /// New Metadata key (pda of ['metadata', program id, mint id]) + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// New Edition V1 (pda of ['metadata', program id, mint id, 'edition']) + pub edition: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Record Edition V1 (pda of ['metadata', program id, master metadata mint id, 'edition']) + pub master_edition: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of new token - THIS WILL TRANSFER AUTHORITY AWAY FROM THIS KEY + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint authority of new mint + pub mint_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Printing Mint of master record edition + pub printing_mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account containing Printing mint token to be transferred + pub master_token_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition pda to mark creation - will be checked for pre-existence. (pda of ['metadata', program id, master mint id, edition_number]) + pub edition_marker: &'a solana_program::account_info::AccountInfo<'a>, + /// Burn authority for this token + pub burn_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// update authority info for new metadata account + pub master_update_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Master record metadata account + pub master_metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Token program + pub token_program: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Rent info + pub rent: &'a solana_program::account_info::AccountInfo<'a>, + /// Reservation List - If present, and you are on this list, you can get an edition number given by your position on the list. + pub reservation_list: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `deprecated_mint_new_edition_from_master_edition_via_printing_token` CPI instruction. pub struct DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenCpi<'a> { /// The program to invoke. @@ -342,16 +401,56 @@ pub struct DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenCpi<'a> { } impl<'a> DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + metadata: accounts.metadata, + edition: accounts.edition, + master_edition: accounts.master_edition, + mint: accounts.mint, + mint_authority: accounts.mint_authority, + printing_mint: accounts.printing_mint, + master_token_account: accounts.master_token_account, + edition_marker: accounts.edition_marker, + burn_authority: accounts.burn_authority, + payer: accounts.payer, + master_update_authority: accounts.master_update_authority, + master_metadata: accounts.master_metadata, + token_program: accounts.token_program, + system_program: accounts.system_program, + rent: accounts.rent, + reservation_list: accounts.reservation_list, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(16); + let mut accounts = Vec::with_capacity(16 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.metadata.key, false, @@ -418,6 +517,9 @@ impl<'a> DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenCpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenInstructionData::new() .try_to_vec() .unwrap(); @@ -427,7 +529,7 @@ impl<'a> DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(16 + 1); + let mut account_infos = Vec::with_capacity(16 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.metadata.clone()); account_infos.push(self.edition.clone()); @@ -447,6 +549,9 @@ impl<'a> DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenCpi<'a> { if let Some(reservation_list) = self.reservation_list { account_infos.push(reservation_list.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -483,6 +588,7 @@ impl<'a> DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenCpiBuilder<'a> system_program: None, rent: None, reservation_list: None, + __remaining_accounts: Vec::new(), }, ); Self { instruction } @@ -618,14 +724,40 @@ impl<'a> DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenCpiBuilder<'a> #[inline(always)] pub fn reservation_list( &mut self, - reservation_list: &'a solana_program::account_info::AccountInfo<'a>, + reservation_list: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.reservation_list = reservation_list; + self + } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], ) -> &mut Self { - self.instruction.reservation_list = Some(reservation_list); + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); self } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenCpi<'a> { - DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenCpi { __program: self.instruction.__program, metadata: self.instruction.metadata.expect("metadata is not set"), @@ -689,7 +821,11 @@ impl<'a> DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenCpiBuilder<'a> rent: self.instruction.rent.expect("rent is not set"), reservation_list: self.instruction.reservation_list, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -711,4 +847,5 @@ struct DeprecatedMintNewEditionFromMasterEditionViaPrintingTokenCpiBuilderInstru system_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, reservation_list: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/freeze_delegated_account.rs b/clients/rust/src/generated/instructions/freeze_delegated_account.rs index 5a7ac7c5..ea8ec7c2 100644 --- a/clients/rust/src/generated/instructions/freeze_delegated_account.rs +++ b/clients/rust/src/generated/instructions/freeze_delegated_account.rs @@ -23,9 +23,15 @@ pub struct FreezeDelegatedAccount { } impl FreezeDelegatedAccount { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(5); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.delegate, true, @@ -45,6 +51,9 @@ impl FreezeDelegatedAccount { self.token_program, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = FreezeDelegatedAccountInstructionData::new() .try_to_vec() .unwrap(); @@ -76,6 +85,7 @@ pub struct FreezeDelegatedAccountBuilder { edition: Option, mint: Option, token_program: Option, + __remaining_accounts: Vec, } impl FreezeDelegatedAccountBuilder { @@ -106,14 +116,25 @@ impl FreezeDelegatedAccountBuilder { self.mint = Some(mint); self } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` /// Token Program #[inline(always)] pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self { self.token_program = Some(token_program); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = FreezeDelegatedAccount { delegate: self.delegate.expect("delegate is not set"), token_account: self.token_account.expect("token_account is not set"), @@ -124,10 +145,24 @@ impl FreezeDelegatedAccountBuilder { )), }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `freeze_delegated_account` CPI accounts. +pub struct FreezeDelegatedAccountCpiAccounts<'a> { + /// Delegate + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account to freeze + pub token_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition + pub edition: &'a solana_program::account_info::AccountInfo<'a>, + /// Token mint + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token Program + pub token_program: &'a solana_program::account_info::AccountInfo<'a>, +} + /// `freeze_delegated_account` CPI instruction. pub struct FreezeDelegatedAccountCpi<'a> { /// The program to invoke. @@ -145,16 +180,45 @@ pub struct FreezeDelegatedAccountCpi<'a> { } impl<'a> FreezeDelegatedAccountCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: FreezeDelegatedAccountCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + delegate: accounts.delegate, + token_account: accounts.token_account, + edition: accounts.edition, + mint: accounts.mint, + token_program: accounts.token_program, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5); + let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.delegate.key, true, @@ -175,6 +239,9 @@ impl<'a> FreezeDelegatedAccountCpi<'a> { *self.token_program.key, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = FreezeDelegatedAccountInstructionData::new() .try_to_vec() .unwrap(); @@ -184,13 +251,16 @@ impl<'a> FreezeDelegatedAccountCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(5 + 1); + let mut account_infos = Vec::with_capacity(5 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.delegate.clone()); account_infos.push(self.token_account.clone()); account_infos.push(self.edition.clone()); account_infos.push(self.mint.clone()); account_infos.push(self.token_program.clone()); + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -214,6 +284,7 @@ impl<'a> FreezeDelegatedAccountCpiBuilder<'a> { edition: None, mint: None, token_program: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -259,9 +330,35 @@ impl<'a> FreezeDelegatedAccountCpiBuilder<'a> { self.instruction.token_program = Some(token_program); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> FreezeDelegatedAccountCpi<'a> { - FreezeDelegatedAccountCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = FreezeDelegatedAccountCpi { __program: self.instruction.__program, delegate: self.instruction.delegate.expect("delegate is not set"), @@ -279,7 +376,11 @@ impl<'a> FreezeDelegatedAccountCpiBuilder<'a> { .instruction .token_program .expect("token_program is not set"), - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -290,4 +391,5 @@ struct FreezeDelegatedAccountCpiBuilderInstruction<'a> { edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, mint: Option<&'a solana_program::account_info::AccountInfo<'a>>, token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/lock_v1.rs b/clients/rust/src/generated/instructions/lock_v1.rs index 494f1baf..e642bdfe 100644 --- a/clients/rust/src/generated/instructions/lock_v1.rs +++ b/clients/rust/src/generated/instructions/lock_v1.rs @@ -40,12 +40,19 @@ pub struct LockV1 { } impl LockV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: LockV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(13); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: LockV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, true, @@ -136,6 +143,9 @@ impl LockV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = LockV1InstructionData::new().try_to_vec().unwrap(); let mut args = args.try_to_vec().unwrap(); data.append(&mut args); @@ -163,7 +173,8 @@ impl LockV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct LockV1InstructionArgs { pub authorization_data: Option, } @@ -185,6 +196,7 @@ pub struct LockV1Builder { authorization_rules_program: Option, authorization_rules: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl LockV1Builder { @@ -200,8 +212,11 @@ impl LockV1Builder { /// `[optional account]` /// Token owner account #[inline(always)] - pub fn token_owner(&mut self, token_owner: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_owner = Some(token_owner); + pub fn token_owner( + &mut self, + token_owner: Option, + ) -> &mut Self { + self.token_owner = token_owner; self } /// Token account @@ -225,15 +240,18 @@ impl LockV1Builder { /// `[optional account]` /// Edition account #[inline(always)] - pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.edition = Some(edition); + pub fn edition(&mut self, edition: Option) -> &mut Self { + self.edition = edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Payer @@ -242,12 +260,14 @@ impl LockV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// System program #[inline(always)] pub fn sysvar_instructions( @@ -262,9 +282,9 @@ impl LockV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -272,9 +292,9 @@ impl LockV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -282,9 +302,9 @@ impl LockV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -293,8 +313,18 @@ impl LockV1Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = LockV1 { authority: self.authority.expect("authority is not set"), token_owner: self.token_owner, @@ -318,10 +348,40 @@ impl LockV1Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `lock_v1` CPI accounts. +pub struct LockV1CpiAccounts<'a> { + /// Delegate or freeze authority + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Token owner account + pub token_owner: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token account + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint account + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition account + pub edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `lock_v1` CPI instruction. pub struct LockV1Cpi<'a> { /// The program to invoke. @@ -357,16 +417,55 @@ pub struct LockV1Cpi<'a> { } impl<'a> LockV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: LockV1CpiAccounts<'a>, + args: LockV1InstructionArgs, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + token_owner: accounts.token_owner, + token: accounts.token, + mint: accounts.mint, + metadata: accounts.metadata, + edition: accounts.edition, + token_record: accounts.token_record, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(13); + let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, true, @@ -461,6 +560,9 @@ impl<'a> LockV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = LockV1InstructionData::new().try_to_vec().unwrap(); let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); @@ -470,7 +572,7 @@ impl<'a> LockV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(13 + 1); + let mut account_infos = Vec::with_capacity(13 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.authority.clone()); if let Some(token_owner) = self.token_owner { @@ -497,6 +599,9 @@ impl<'a> LockV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -529,6 +634,7 @@ impl<'a> LockV1CpiBuilder<'a> { authorization_rules_program: None, authorization_rules: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -546,9 +652,9 @@ impl<'a> LockV1CpiBuilder<'a> { #[inline(always)] pub fn token_owner( &mut self, - token_owner: &'a solana_program::account_info::AccountInfo<'a>, + token_owner: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_owner = Some(token_owner); + self.instruction.token_owner = token_owner; self } /// Token account @@ -577,9 +683,9 @@ impl<'a> LockV1CpiBuilder<'a> { #[inline(always)] pub fn edition( &mut self, - edition: &'a solana_program::account_info::AccountInfo<'a>, + edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.edition = Some(edition); + self.instruction.edition = edition; self } /// `[optional account]` @@ -587,9 +693,9 @@ impl<'a> LockV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Payer @@ -621,9 +727,9 @@ impl<'a> LockV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -631,9 +737,9 @@ impl<'a> LockV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -641,9 +747,9 @@ impl<'a> LockV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -652,13 +758,38 @@ impl<'a> LockV1CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> LockV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = LockV1InstructionArgs { authorization_data: self.instruction.authorization_data.clone(), }; - - LockV1Cpi { + let instruction = LockV1Cpi { __program: self.instruction.__program, authority: self.instruction.authority.expect("authority is not set"), @@ -693,7 +824,11 @@ impl<'a> LockV1CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -713,4 +848,5 @@ struct LockV1CpiBuilderInstruction<'a> { authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/migrate.rs b/clients/rust/src/generated/instructions/migrate.rs index cf31f2ab..cb9b0407 100644 --- a/clients/rust/src/generated/instructions/migrate.rs +++ b/clients/rust/src/generated/instructions/migrate.rs @@ -43,9 +43,15 @@ pub struct Migrate { } impl Migrate { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(15); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.metadata, false, @@ -117,6 +123,9 @@ impl Migrate { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = MigrateInstructionData::new().try_to_vec().unwrap(); solana_program::instruction::Instruction { @@ -156,6 +165,7 @@ pub struct MigrateBuilder { spl_token_program: Option, authorization_rules_program: Option, authorization_rules: Option, + __remaining_accounts: Vec, } impl MigrateBuilder { @@ -228,12 +238,14 @@ impl MigrateBuilder { self.token_record = Some(token_record); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instruction sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -243,6 +255,7 @@ impl MigrateBuilder { self.sysvar_instructions = Some(sysvar_instructions); self } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` /// SPL Token Program #[inline(always)] pub fn spl_token_program( @@ -257,9 +270,9 @@ impl MigrateBuilder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -267,13 +280,23 @@ impl MigrateBuilder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = Migrate { metadata: self.metadata.expect("metadata is not set"), edition: self.edition.expect("edition is not set"), @@ -300,10 +323,44 @@ impl MigrateBuilder { authorization_rules: self.authorization_rules, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `migrate` CPI accounts. +pub struct MigrateCpiAccounts<'a> { + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition account + pub edition: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account owner + pub token_owner: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint account + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// Update authority + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Collection metadata account + pub collection_metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Delegate record account + pub delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + /// Token record account + pub token_record: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instruction sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `migrate` CPI instruction. pub struct MigrateCpi<'a> { /// The program to invoke. @@ -341,16 +398,55 @@ pub struct MigrateCpi<'a> { } impl<'a> MigrateCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: MigrateCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + metadata: accounts.metadata, + edition: accounts.edition, + token: accounts.token, + token_owner: accounts.token_owner, + mint: accounts.mint, + payer: accounts.payer, + authority: accounts.authority, + collection_metadata: accounts.collection_metadata, + delegate_record: accounts.delegate_record, + token_record: accounts.token_record, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15); + let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.metadata.key, false, @@ -425,6 +521,9 @@ impl<'a> MigrateCpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = MigrateInstructionData::new().try_to_vec().unwrap(); let instruction = solana_program::instruction::Instruction { @@ -432,7 +531,7 @@ impl<'a> MigrateCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(15 + 1); + let mut account_infos = Vec::with_capacity(15 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.metadata.clone()); account_infos.push(self.edition.clone()); @@ -453,6 +552,9 @@ impl<'a> MigrateCpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -486,6 +588,7 @@ impl<'a> MigrateCpiBuilder<'a> { spl_token_program: None, authorization_rules_program: None, authorization_rules: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -602,9 +705,9 @@ impl<'a> MigrateCpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -612,14 +715,40 @@ impl<'a> MigrateCpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); self } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> MigrateCpi<'a> { - MigrateCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = MigrateCpi { __program: self.instruction.__program, metadata: self.instruction.metadata.expect("metadata is not set"), @@ -672,7 +801,11 @@ impl<'a> MigrateCpiBuilder<'a> { authorization_rules_program: self.instruction.authorization_rules_program, authorization_rules: self.instruction.authorization_rules, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -693,4 +826,5 @@ struct MigrateCpiBuilderInstruction<'a> { spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/mint_new_edition_from_master_edition_via_token.rs b/clients/rust/src/generated/instructions/mint_new_edition_from_master_edition_via_token.rs index af742b10..3ebdbd4e 100644 --- a/clients/rust/src/generated/instructions/mint_new_edition_from_master_edition_via_token.rs +++ b/clients/rust/src/generated/instructions/mint_new_edition_from_master_edition_via_token.rs @@ -42,12 +42,19 @@ pub struct MintNewEditionFromMasterEditionViaToken { } impl MintNewEditionFromMasterEditionViaToken { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: MintNewEditionFromMasterEditionViaTokenInstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: MintNewEditionFromMasterEditionViaTokenInstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.new_metadata, false, @@ -104,6 +111,9 @@ impl MintNewEditionFromMasterEditionViaToken { rent, false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = MintNewEditionFromMasterEditionViaTokenInstructionData::new() .try_to_vec() .unwrap(); @@ -129,7 +139,8 @@ impl MintNewEditionFromMasterEditionViaTokenInstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MintNewEditionFromMasterEditionViaTokenInstructionArgs { pub mint_new_edition_from_master_edition_via_token_args: MintNewEditionFromMasterEditionViaTokenArgs, @@ -154,6 +165,7 @@ pub struct MintNewEditionFromMasterEditionViaTokenBuilder { rent: Option, mint_new_edition_from_master_edition_via_token_args: Option, + __remaining_accounts: Vec, } impl MintNewEditionFromMasterEditionViaTokenBuilder { @@ -238,12 +250,14 @@ impl MintNewEditionFromMasterEditionViaTokenBuilder { self.metadata = Some(metadata); self } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` /// Token program #[inline(always)] pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self { self.token_program = Some(token_program); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { @@ -253,8 +267,8 @@ impl MintNewEditionFromMasterEditionViaTokenBuilder { /// `[optional account]` /// Rent info #[inline(always)] - pub fn rent(&mut self, rent: solana_program::pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); + pub fn rent(&mut self, rent: Option) -> &mut Self { + self.rent = rent; self } #[inline(always)] @@ -266,8 +280,18 @@ impl MintNewEditionFromMasterEditionViaTokenBuilder { Some(mint_new_edition_from_master_edition_via_token_args); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = MintNewEditionFromMasterEditionViaToken { new_metadata: self.new_metadata.expect("new_metadata is not set"), new_edition: self.new_edition.expect("new_edition is not set"), @@ -301,10 +325,42 @@ impl MintNewEditionFromMasterEditionViaTokenBuilder { .expect("mint_new_edition_from_master_edition_via_token_args is not set"), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `mint_new_edition_from_master_edition_via_token` CPI accounts. +pub struct MintNewEditionFromMasterEditionViaTokenCpiAccounts<'a> { + /// New Metadata key (pda of ['metadata', program id, mint id]) + pub new_metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// New Edition (pda of ['metadata', program id, mint id, 'edition']) + pub new_edition: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Record Edition V2 (pda of ['metadata', program id, master metadata mint id, 'edition']) + pub master_edition: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of new token - THIS WILL TRANSFER AUTHORITY AWAY FROM THIS KEY + pub new_mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition pda to mark creation - will be checked for pre-existence. (pda of ['metadata', program id, master metadata mint id, 'edition', edition_number]) where edition_number is NOT the edition number you pass in args but actually edition_number = floor(edition/EDITION_MARKER_BIT_SIZE). + pub edition_mark_pda: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint authority of new mint + pub new_mint_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// owner of token account containing master token (#8) + pub token_account_owner: &'a solana_program::account_info::AccountInfo<'a>, + /// token account containing token from master metadata mint + pub token_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Update authority info for new metadata + pub new_metadata_update_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Master record metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Token program + pub token_program: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Rent info + pub rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `mint_new_edition_from_master_edition_via_token` CPI instruction. pub struct MintNewEditionFromMasterEditionViaTokenCpi<'a> { /// The program to invoke. @@ -342,16 +398,56 @@ pub struct MintNewEditionFromMasterEditionViaTokenCpi<'a> { } impl<'a> MintNewEditionFromMasterEditionViaTokenCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: MintNewEditionFromMasterEditionViaTokenCpiAccounts<'a>, + args: MintNewEditionFromMasterEditionViaTokenInstructionArgs, + ) -> Self { + Self { + __program: program, + new_metadata: accounts.new_metadata, + new_edition: accounts.new_edition, + master_edition: accounts.master_edition, + new_mint: accounts.new_mint, + edition_mark_pda: accounts.edition_mark_pda, + new_mint_authority: accounts.new_mint_authority, + payer: accounts.payer, + token_account_owner: accounts.token_account_owner, + token_account: accounts.token_account, + new_metadata_update_authority: accounts.new_metadata_update_authority, + metadata: accounts.metadata, + token_program: accounts.token_program, + system_program: accounts.system_program, + rent: accounts.rent, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.new_metadata.key, false, @@ -409,6 +505,9 @@ impl<'a> MintNewEditionFromMasterEditionViaTokenCpi<'a> { *rent.key, false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = MintNewEditionFromMasterEditionViaTokenInstructionData::new() .try_to_vec() .unwrap(); @@ -420,7 +519,7 @@ impl<'a> MintNewEditionFromMasterEditionViaTokenCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.new_metadata.clone()); account_infos.push(self.new_edition.clone()); @@ -438,6 +537,9 @@ impl<'a> MintNewEditionFromMasterEditionViaTokenCpi<'a> { if let Some(rent) = self.rent { account_infos.push(rent.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -472,6 +574,7 @@ impl<'a> MintNewEditionFromMasterEditionViaTokenCpiBuilder<'a> { system_program: None, rent: None, mint_new_edition_from_master_edition_via_token_args: None, + __remaining_accounts: Vec::new(), }, ); Self { instruction } @@ -593,8 +696,11 @@ impl<'a> MintNewEditionFromMasterEditionViaTokenCpiBuilder<'a> { /// `[optional account]` /// Rent info #[inline(always)] - pub fn rent(&mut self, rent: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); + pub fn rent( + &mut self, + rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.rent = rent; self } #[inline(always)] @@ -607,8 +713,34 @@ impl<'a> MintNewEditionFromMasterEditionViaTokenCpiBuilder<'a> { Some(mint_new_edition_from_master_edition_via_token_args); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> MintNewEditionFromMasterEditionViaTokenCpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = MintNewEditionFromMasterEditionViaTokenInstructionArgs { mint_new_edition_from_master_edition_via_token_args: self .instruction @@ -616,8 +748,7 @@ impl<'a> MintNewEditionFromMasterEditionViaTokenCpiBuilder<'a> { .clone() .expect("mint_new_edition_from_master_edition_via_token_args is not set"), }; - - MintNewEditionFromMasterEditionViaTokenCpi { + let instruction = MintNewEditionFromMasterEditionViaTokenCpi { __program: self.instruction.__program, new_metadata: self @@ -678,7 +809,11 @@ impl<'a> MintNewEditionFromMasterEditionViaTokenCpiBuilder<'a> { rent: self.instruction.rent, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -700,4 +835,5 @@ struct MintNewEditionFromMasterEditionViaTokenCpiBuilderInstruction<'a> { rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, mint_new_edition_from_master_edition_via_token_args: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/mint_new_edition_from_master_edition_via_vault_proxy.rs b/clients/rust/src/generated/instructions/mint_new_edition_from_master_edition_via_vault_proxy.rs index 8e7f29f7..4adb54a7 100644 --- a/clients/rust/src/generated/instructions/mint_new_edition_from_master_edition_via_vault_proxy.rs +++ b/clients/rust/src/generated/instructions/mint_new_edition_from_master_edition_via_vault_proxy.rs @@ -48,12 +48,19 @@ pub struct MintNewEditionFromMasterEditionViaVaultProxy { } impl MintNewEditionFromMasterEditionViaVaultProxy { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: MintNewEditionFromMasterEditionViaVaultProxyInstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(17); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: MintNewEditionFromMasterEditionViaVaultProxyInstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(17 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.new_metadata, false, @@ -121,6 +128,9 @@ impl MintNewEditionFromMasterEditionViaVaultProxy { rent, false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = MintNewEditionFromMasterEditionViaVaultProxyInstructionData::new() .try_to_vec() .unwrap(); @@ -146,7 +156,8 @@ impl MintNewEditionFromMasterEditionViaVaultProxyInstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MintNewEditionFromMasterEditionViaVaultProxyInstructionArgs { pub mint_new_edition_from_master_edition_via_token_args: MintNewEditionFromMasterEditionViaTokenArgs, @@ -174,6 +185,7 @@ pub struct MintNewEditionFromMasterEditionViaVaultProxyBuilder { rent: Option, mint_new_edition_from_master_edition_via_token_args: Option, + __remaining_accounts: Vec, } impl MintNewEditionFromMasterEditionViaVaultProxyBuilder { @@ -276,6 +288,7 @@ impl MintNewEditionFromMasterEditionViaVaultProxyBuilder { self.metadata = Some(metadata); self } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` /// Token program #[inline(always)] pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self { @@ -291,6 +304,7 @@ impl MintNewEditionFromMasterEditionViaVaultProxyBuilder { self.token_vault_program = Some(token_vault_program); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { @@ -300,8 +314,8 @@ impl MintNewEditionFromMasterEditionViaVaultProxyBuilder { /// `[optional account]` /// Rent info #[inline(always)] - pub fn rent(&mut self, rent: solana_program::pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); + pub fn rent(&mut self, rent: Option) -> &mut Self { + self.rent = rent; self } #[inline(always)] @@ -313,8 +327,18 @@ impl MintNewEditionFromMasterEditionViaVaultProxyBuilder { Some(mint_new_edition_from_master_edition_via_token_args); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = MintNewEditionFromMasterEditionViaVaultProxy { new_metadata: self.new_metadata.expect("new_metadata is not set"), new_edition: self.new_edition.expect("new_edition is not set"), @@ -355,10 +379,48 @@ impl MintNewEditionFromMasterEditionViaVaultProxyBuilder { .expect("mint_new_edition_from_master_edition_via_token_args is not set"), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `mint_new_edition_from_master_edition_via_vault_proxy` CPI accounts. +pub struct MintNewEditionFromMasterEditionViaVaultProxyCpiAccounts<'a> { + /// New Metadata key (pda of ['metadata', program id, mint id]) + pub new_metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// New Edition (pda of ['metadata', program id, mint id, 'edition']) + pub new_edition: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Record Edition V2 (pda of ['metadata', program id, master metadata mint id, 'edition'] + pub master_edition: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of new token - THIS WILL TRANSFER AUTHORITY AWAY FROM THIS KEY + pub new_mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition pda to mark creation - will be checked for pre-existence. (pda of ['metadata', program id, master metadata mint id, 'edition', edition_number]) where edition_number is NOT the edition number you pass in args but actually edition_number = floor(edition/EDITION_MARKER_BIT_SIZE). + pub edition_mark_pda: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint authority of new mint + pub new_mint_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// Vault authority + pub vault_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Safety deposit token store account + pub safety_deposit_store: &'a solana_program::account_info::AccountInfo<'a>, + /// Safety deposit box + pub safety_deposit_box: &'a solana_program::account_info::AccountInfo<'a>, + /// Vault + pub vault: &'a solana_program::account_info::AccountInfo<'a>, + /// Update authority info for new metadata + pub new_metadata_update_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Master record metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Token program + pub token_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Token vault program + pub token_vault_program: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Rent info + pub rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `mint_new_edition_from_master_edition_via_vault_proxy` CPI instruction. pub struct MintNewEditionFromMasterEditionViaVaultProxyCpi<'a> { /// The program to invoke. @@ -402,16 +464,59 @@ pub struct MintNewEditionFromMasterEditionViaVaultProxyCpi<'a> { } impl<'a> MintNewEditionFromMasterEditionViaVaultProxyCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: MintNewEditionFromMasterEditionViaVaultProxyCpiAccounts<'a>, + args: MintNewEditionFromMasterEditionViaVaultProxyInstructionArgs, + ) -> Self { + Self { + __program: program, + new_metadata: accounts.new_metadata, + new_edition: accounts.new_edition, + master_edition: accounts.master_edition, + new_mint: accounts.new_mint, + edition_mark_pda: accounts.edition_mark_pda, + new_mint_authority: accounts.new_mint_authority, + payer: accounts.payer, + vault_authority: accounts.vault_authority, + safety_deposit_store: accounts.safety_deposit_store, + safety_deposit_box: accounts.safety_deposit_box, + vault: accounts.vault, + new_metadata_update_authority: accounts.new_metadata_update_authority, + metadata: accounts.metadata, + token_program: accounts.token_program, + token_vault_program: accounts.token_vault_program, + system_program: accounts.system_program, + rent: accounts.rent, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(17); + let mut accounts = Vec::with_capacity(17 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.new_metadata.key, false, @@ -481,6 +586,9 @@ impl<'a> MintNewEditionFromMasterEditionViaVaultProxyCpi<'a> { *rent.key, false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = MintNewEditionFromMasterEditionViaVaultProxyInstructionData::new() .try_to_vec() .unwrap(); @@ -492,7 +600,7 @@ impl<'a> MintNewEditionFromMasterEditionViaVaultProxyCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(17 + 1); + let mut account_infos = Vec::with_capacity(17 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.new_metadata.clone()); account_infos.push(self.new_edition.clone()); @@ -513,6 +621,9 @@ impl<'a> MintNewEditionFromMasterEditionViaVaultProxyCpi<'a> { if let Some(rent) = self.rent { account_infos.push(rent.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -550,6 +661,7 @@ impl<'a> MintNewEditionFromMasterEditionViaVaultProxyCpiBuilder<'a> { system_program: None, rent: None, mint_new_edition_from_master_edition_via_token_args: None, + __remaining_accounts: Vec::new(), }, ); Self { instruction } @@ -695,8 +807,11 @@ impl<'a> MintNewEditionFromMasterEditionViaVaultProxyCpiBuilder<'a> { /// `[optional account]` /// Rent info #[inline(always)] - pub fn rent(&mut self, rent: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); + pub fn rent( + &mut self, + rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.rent = rent; self } #[inline(always)] @@ -709,8 +824,34 @@ impl<'a> MintNewEditionFromMasterEditionViaVaultProxyCpiBuilder<'a> { Some(mint_new_edition_from_master_edition_via_token_args); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> MintNewEditionFromMasterEditionViaVaultProxyCpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = MintNewEditionFromMasterEditionViaVaultProxyInstructionArgs { mint_new_edition_from_master_edition_via_token_args: self .instruction @@ -718,8 +859,7 @@ impl<'a> MintNewEditionFromMasterEditionViaVaultProxyCpiBuilder<'a> { .clone() .expect("mint_new_edition_from_master_edition_via_token_args is not set"), }; - - MintNewEditionFromMasterEditionViaVaultProxyCpi { + let instruction = MintNewEditionFromMasterEditionViaVaultProxyCpi { __program: self.instruction.__program, new_metadata: self @@ -792,7 +932,11 @@ impl<'a> MintNewEditionFromMasterEditionViaVaultProxyCpiBuilder<'a> { rent: self.instruction.rent, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -817,4 +961,5 @@ struct MintNewEditionFromMasterEditionViaVaultProxyCpiBuilderInstruction<'a> { rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, mint_new_edition_from_master_edition_via_token_args: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/mint_v1.rs b/clients/rust/src/generated/instructions/mint_v1.rs index 4e7acad6..1a27e54c 100644 --- a/clients/rust/src/generated/instructions/mint_v1.rs +++ b/clients/rust/src/generated/instructions/mint_v1.rs @@ -44,12 +44,19 @@ pub struct MintV1 { } impl MintV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: MintV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(15); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: MintV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.token, false, )); @@ -149,6 +156,9 @@ impl MintV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = MintV1InstructionData::new().try_to_vec().unwrap(); let mut args = args.try_to_vec().unwrap(); data.append(&mut args); @@ -176,7 +186,8 @@ impl MintV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MintV1InstructionArgs { pub amount: u64, pub authorization_data: Option, @@ -202,6 +213,7 @@ pub struct MintV1Builder { authorization_rules: Option, amount: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl MintV1Builder { @@ -217,8 +229,11 @@ impl MintV1Builder { /// `[optional account]` /// Owner of the token account #[inline(always)] - pub fn token_owner(&mut self, token_owner: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_owner = Some(token_owner); + pub fn token_owner( + &mut self, + token_owner: Option, + ) -> &mut Self { + self.token_owner = token_owner; self } /// Metadata account (pda of ['metadata', program id, mint id]) @@ -230,15 +245,21 @@ impl MintV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of token asset @@ -258,9 +279,9 @@ impl MintV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Payer @@ -269,12 +290,14 @@ impl MintV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -284,6 +307,7 @@ impl MintV1Builder { self.sysvar_instructions = Some(sysvar_instructions); self } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` /// SPL Token program #[inline(always)] pub fn spl_token_program( @@ -293,6 +317,7 @@ impl MintV1Builder { self.spl_token_program = Some(spl_token_program); self } + /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` /// SPL Associated Token Account program #[inline(always)] pub fn spl_ata_program( @@ -307,9 +332,9 @@ impl MintV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -317,9 +342,9 @@ impl MintV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to '1']` @@ -334,8 +359,18 @@ impl MintV1Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = MintV1 { token: self.token.expect("token is not set"), token_owner: self.token_owner, @@ -366,10 +401,44 @@ impl MintV1Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `mint_v1` CPI accounts. +pub struct MintV1CpiAccounts<'a> { + /// Token or Associated Token account + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Owner of the token account + pub token_owner: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Metadata account (pda of ['metadata', program id, mint id]) + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of token asset + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// (Mint or Update) authority + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata delegate record + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token program + pub spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Associated Token Account program + pub spl_ata_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Token Authorization Rules program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `mint_v1` CPI instruction. pub struct MintV1Cpi<'a> { /// The program to invoke. @@ -409,16 +478,57 @@ pub struct MintV1Cpi<'a> { } impl<'a> MintV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: MintV1CpiAccounts<'a>, + args: MintV1InstructionArgs, + ) -> Self { + Self { + __program: program, + token: accounts.token, + token_owner: accounts.token_owner, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + authority: accounts.authority, + delegate_record: accounts.delegate_record, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + spl_ata_program: accounts.spl_ata_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(15); + let mut accounts = Vec::with_capacity(15 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.token.key, false, @@ -521,6 +631,9 @@ impl<'a> MintV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = MintV1InstructionData::new().try_to_vec().unwrap(); let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); @@ -530,7 +643,7 @@ impl<'a> MintV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(15 + 1); + let mut account_infos = Vec::with_capacity(15 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.token.clone()); if let Some(token_owner) = self.token_owner { @@ -559,6 +672,9 @@ impl<'a> MintV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -594,6 +710,7 @@ impl<'a> MintV1CpiBuilder<'a> { authorization_rules: None, amount: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -608,9 +725,9 @@ impl<'a> MintV1CpiBuilder<'a> { #[inline(always)] pub fn token_owner( &mut self, - token_owner: &'a solana_program::account_info::AccountInfo<'a>, + token_owner: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_owner = Some(token_owner); + self.instruction.token_owner = token_owner; self } /// Metadata account (pda of ['metadata', program id, mint id]) @@ -627,9 +744,9 @@ impl<'a> MintV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -637,9 +754,9 @@ impl<'a> MintV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of token asset @@ -662,9 +779,9 @@ impl<'a> MintV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Payer @@ -714,9 +831,9 @@ impl<'a> MintV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -724,9 +841,9 @@ impl<'a> MintV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to '1']` @@ -741,14 +858,39 @@ impl<'a> MintV1CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> MintV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = MintV1InstructionArgs { amount: self.instruction.amount.clone().unwrap_or(1), authorization_data: self.instruction.authorization_data.clone(), }; - - MintV1Cpi { + let instruction = MintV1Cpi { __program: self.instruction.__program, token: self.instruction.token.expect("token is not set"), @@ -793,7 +935,11 @@ impl<'a> MintV1CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -816,4 +962,5 @@ struct MintV1CpiBuilderInstruction<'a> { authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, amount: Option, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/mod.rs b/clients/rust/src/generated/instructions/mod.rs index 33965ba6..2a80938b 100644 --- a/clients/rust/src/generated/instructions/mod.rs +++ b/clients/rust/src/generated/instructions/mod.rs @@ -5,88 +5,88 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -pub mod approve_collection_authority; -pub mod approve_use_authority; -pub mod bubblegum_set_collection_size; -pub mod burn_edition_nft; -pub mod burn_nft; -pub mod burn_v1; -pub mod close_escrow_account; -pub mod collect; -pub mod convert_master_edition_v1_to_v2; -pub mod create_escrow_account; -pub mod create_master_edition_v3; -pub mod create_metadata_account_v3; -pub mod create_v1; -pub mod delegate_authority_item_v1; -pub mod delegate_collection_item_v1; -pub mod delegate_collection_v1; -pub mod delegate_data_item_v1; -pub mod delegate_data_v1; -pub mod delegate_locked_transfer_v1; -pub mod delegate_programmable_config_item_v1; -pub mod delegate_programmable_config_v1; -pub mod delegate_sale_v1; -pub mod delegate_staking_v1; -pub mod delegate_standard_v1; -pub mod delegate_transfer_v1; -pub mod delegate_utility_v1; -pub mod deprecated_mint_new_edition_from_master_edition_via_printing_token; -pub mod freeze_delegated_account; -pub mod lock_v1; -pub mod migrate; -pub mod mint_new_edition_from_master_edition_via_token; -pub mod mint_new_edition_from_master_edition_via_vault_proxy; -pub mod mint_v1; -pub mod print_v1; -pub mod puff_metadata; -pub mod remove_creator_verification; -pub mod revoke_authority_item_v1; -pub mod revoke_collection_authority; -pub mod revoke_collection_item_v1; -pub mod revoke_collection_v1; -pub mod revoke_data_item_v1; -pub mod revoke_data_v1; -pub mod revoke_locked_transfer_v1; -pub mod revoke_migration_v1; -pub mod revoke_programmable_config_item_v1; -pub mod revoke_programmable_config_v1; -pub mod revoke_sale_v1; -pub mod revoke_staking_v1; -pub mod revoke_standard_v1; -pub mod revoke_transfer_v1; -pub mod revoke_use_authority; -pub mod revoke_utility_v1; -pub mod set_and_verify_collection; -pub mod set_and_verify_sized_collection_item; -pub mod set_collection_size; -pub mod set_token_standard; -pub mod sign_metadata; -pub mod thaw_delegated_account; -pub mod transfer_out_of_escrow; -pub mod transfer_v1; -pub mod unlock_v1; -pub mod unverify_collection; -pub mod unverify_collection_v1; -pub mod unverify_creator_v1; -pub mod unverify_sized_collection_item; -pub mod update_as_authority_item_delegate_v2; -pub mod update_as_collection_delegate_v2; -pub mod update_as_collection_item_delegate_v2; -pub mod update_as_data_delegate_v2; -pub mod update_as_data_item_delegate_v2; -pub mod update_as_programmable_config_delegate_v2; -pub mod update_as_programmable_config_item_delegate_v2; -pub mod update_as_update_authority_v2; -pub mod update_metadata_account_v2; -pub mod update_primary_sale_happened_via_token; -pub mod update_v1; -pub mod use_v1; -pub mod utilize; -pub mod verify_collection; -pub mod verify_collection_v1; -pub mod verify_creator_v1; -pub mod verify_sized_collection_item; +pub(crate) mod approve_collection_authority; +pub(crate) mod approve_use_authority; +pub(crate) mod bubblegum_set_collection_size; +pub(crate) mod burn_edition_nft; +pub(crate) mod burn_nft; +pub(crate) mod burn_v1; +pub(crate) mod close_escrow_account; +pub(crate) mod collect; +pub(crate) mod convert_master_edition_v1_to_v2; +pub(crate) mod create_escrow_account; +pub(crate) mod create_master_edition_v3; +pub(crate) mod create_metadata_account_v3; +pub(crate) mod create_v1; +pub(crate) mod delegate_authority_item_v1; +pub(crate) mod delegate_collection_item_v1; +pub(crate) mod delegate_collection_v1; +pub(crate) mod delegate_data_item_v1; +pub(crate) mod delegate_data_v1; +pub(crate) mod delegate_locked_transfer_v1; +pub(crate) mod delegate_programmable_config_item_v1; +pub(crate) mod delegate_programmable_config_v1; +pub(crate) mod delegate_sale_v1; +pub(crate) mod delegate_staking_v1; +pub(crate) mod delegate_standard_v1; +pub(crate) mod delegate_transfer_v1; +pub(crate) mod delegate_utility_v1; +pub(crate) mod deprecated_mint_new_edition_from_master_edition_via_printing_token; +pub(crate) mod freeze_delegated_account; +pub(crate) mod lock_v1; +pub(crate) mod migrate; +pub(crate) mod mint_new_edition_from_master_edition_via_token; +pub(crate) mod mint_new_edition_from_master_edition_via_vault_proxy; +pub(crate) mod mint_v1; +pub(crate) mod print_v1; +pub(crate) mod puff_metadata; +pub(crate) mod remove_creator_verification; +pub(crate) mod revoke_authority_item_v1; +pub(crate) mod revoke_collection_authority; +pub(crate) mod revoke_collection_item_v1; +pub(crate) mod revoke_collection_v1; +pub(crate) mod revoke_data_item_v1; +pub(crate) mod revoke_data_v1; +pub(crate) mod revoke_locked_transfer_v1; +pub(crate) mod revoke_migration_v1; +pub(crate) mod revoke_programmable_config_item_v1; +pub(crate) mod revoke_programmable_config_v1; +pub(crate) mod revoke_sale_v1; +pub(crate) mod revoke_staking_v1; +pub(crate) mod revoke_standard_v1; +pub(crate) mod revoke_transfer_v1; +pub(crate) mod revoke_use_authority; +pub(crate) mod revoke_utility_v1; +pub(crate) mod set_and_verify_collection; +pub(crate) mod set_and_verify_sized_collection_item; +pub(crate) mod set_collection_size; +pub(crate) mod set_token_standard; +pub(crate) mod sign_metadata; +pub(crate) mod thaw_delegated_account; +pub(crate) mod transfer_out_of_escrow; +pub(crate) mod transfer_v1; +pub(crate) mod unlock_v1; +pub(crate) mod unverify_collection; +pub(crate) mod unverify_collection_v1; +pub(crate) mod unverify_creator_v1; +pub(crate) mod unverify_sized_collection_item; +pub(crate) mod update_as_authority_item_delegate_v2; +pub(crate) mod update_as_collection_delegate_v2; +pub(crate) mod update_as_collection_item_delegate_v2; +pub(crate) mod update_as_data_delegate_v2; +pub(crate) mod update_as_data_item_delegate_v2; +pub(crate) mod update_as_programmable_config_delegate_v2; +pub(crate) mod update_as_programmable_config_item_delegate_v2; +pub(crate) mod update_as_update_authority_v2; +pub(crate) mod update_metadata_account_v2; +pub(crate) mod update_primary_sale_happened_via_token; +pub(crate) mod update_v1; +pub(crate) mod use_v1; +pub(crate) mod utilize; +pub(crate) mod verify_collection; +pub(crate) mod verify_collection_v1; +pub(crate) mod verify_creator_v1; +pub(crate) mod verify_sized_collection_item; pub use self::approve_collection_authority::*; pub use self::approve_use_authority::*; @@ -170,3 +170,61 @@ pub use self::verify_collection::*; pub use self::verify_collection_v1::*; pub use self::verify_creator_v1::*; pub use self::verify_sized_collection_item::*; + +#[derive(Clone, Copy)] +pub enum InstructionAccount { + Readonly(solana_program::pubkey::Pubkey), + ReadonlySigner(solana_program::pubkey::Pubkey), + Writable(solana_program::pubkey::Pubkey), + WritableSigner(solana_program::pubkey::Pubkey), +} + +impl InstructionAccount { + pub fn to_account_meta(&self) -> solana_program::instruction::AccountMeta { + let (pubkey, writable, signer) = match self { + InstructionAccount::Readonly(pubkey) => (pubkey, false, false), + InstructionAccount::ReadonlySigner(pubkey) => (pubkey, false, true), + InstructionAccount::Writable(pubkey) => (pubkey, true, false), + InstructionAccount::WritableSigner(pubkey) => (pubkey, true, true), + }; + + if writable { + solana_program::instruction::AccountMeta::new(*pubkey, signer) + } else { + solana_program::instruction::AccountMeta::new_readonly(*pubkey, signer) + } + } +} + +#[derive(Clone, Copy)] +pub enum InstructionAccountInfo<'a> { + Readonly(&'a solana_program::account_info::AccountInfo<'a>), + ReadonlySigner(&'a solana_program::account_info::AccountInfo<'a>), + Writable(&'a solana_program::account_info::AccountInfo<'a>), + WritableSigner(&'a solana_program::account_info::AccountInfo<'a>), +} + +impl<'a> InstructionAccountInfo<'a> { + pub fn to_account_meta(&self) -> solana_program::instruction::AccountMeta { + let (pubkey, writable, signer) = match self { + InstructionAccountInfo::Readonly(account_info) => (account_info.key, false, false), + InstructionAccountInfo::ReadonlySigner(account_info) => (account_info.key, false, true), + InstructionAccountInfo::Writable(account_info) => (account_info.key, true, false), + InstructionAccountInfo::WritableSigner(account_info) => (account_info.key, true, true), + }; + + if writable { + solana_program::instruction::AccountMeta::new(*pubkey, signer) + } else { + solana_program::instruction::AccountMeta::new_readonly(*pubkey, signer) + } + } + pub fn account_info(&self) -> &'a solana_program::account_info::AccountInfo<'a> { + match self { + InstructionAccountInfo::Readonly(account_info) + | InstructionAccountInfo::ReadonlySigner(account_info) + | InstructionAccountInfo::Writable(account_info) + | InstructionAccountInfo::WritableSigner(account_info) => account_info, + } + } +} diff --git a/clients/rust/src/generated/instructions/print_v1.rs b/clients/rust/src/generated/instructions/print_v1.rs index c8be17ef..7b0f7f83 100644 --- a/clients/rust/src/generated/instructions/print_v1.rs +++ b/clients/rust/src/generated/instructions/print_v1.rs @@ -49,12 +49,19 @@ pub struct PrintV1 { } impl PrintV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: PrintV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(18); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: PrintV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(18 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.edition_metadata, false, @@ -133,6 +140,9 @@ impl PrintV1 { self.system_program, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = PrintV1InstructionData::new().try_to_vec().unwrap(); let mut args = args.try_to_vec().unwrap(); data.append(&mut args); @@ -160,7 +170,8 @@ impl PrintV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct PrintV1InstructionArgs { pub edition_number: u64, } @@ -187,6 +198,7 @@ pub struct PrintV1Builder { sysvar_instructions: Option, system_program: Option, edition_number: Option, + __remaining_accounts: Vec, } impl PrintV1Builder { @@ -250,9 +262,9 @@ impl PrintV1Builder { #[inline(always)] pub fn edition_token_record( &mut self, - edition_token_record: solana_program::pubkey::Pubkey, + edition_token_record: Option, ) -> &mut Self { - self.edition_token_record = Some(edition_token_record); + self.edition_token_record = edition_token_record; self } /// Master Record Edition V2 (pda of ['metadata', program id, master metadata mint id, 'edition']) @@ -312,6 +324,7 @@ impl PrintV1Builder { self.update_authority = Some(update_authority); self } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` /// Token program #[inline(always)] pub fn spl_token_program( @@ -321,6 +334,7 @@ impl PrintV1Builder { self.spl_token_program = Some(spl_token_program); self } + /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` /// SPL Associated Token Account program #[inline(always)] pub fn spl_ata_program( @@ -330,6 +344,7 @@ impl PrintV1Builder { self.spl_ata_program = Some(spl_ata_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -339,6 +354,7 @@ impl PrintV1Builder { self.sysvar_instructions = Some(sysvar_instructions); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { @@ -350,8 +366,18 @@ impl PrintV1Builder { self.edition_number = Some(edition_number); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = PrintV1 { edition_metadata: self.edition_metadata.expect("edition_metadata is not set"), edition: self.edition.expect("edition is not set"), @@ -399,10 +425,50 @@ impl PrintV1Builder { .expect("edition_number is not set"), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `print_v1` CPI accounts. +pub struct PrintV1CpiAccounts<'a> { + /// New Metadata key (pda of ['metadata', program id, mint id]) + pub edition_metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// New Edition (pda of ['metadata', program id, mint id, 'edition']) + pub edition: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of new token - THIS WILL TRANSFER AUTHORITY AWAY FROM THIS KEY + pub edition_mint: (&'a solana_program::account_info::AccountInfo<'a>, bool), + /// Owner of the token account of new token + pub edition_token_account_owner: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of new token + pub edition_token_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint authority of new mint + pub edition_mint_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Token record account + pub edition_token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Master Record Edition V2 (pda of ['metadata', program id, master metadata mint id, 'edition']) + pub master_edition: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition pda to mark creation - will be checked for pre-existence. (pda of ['metadata', program id, master metadata mint id, 'edition', edition_number]) where edition_number is NOT the edition number you pass in args but actually edition_number = floor(edition/EDITION_MARKER_BIT_SIZE). + pub edition_marker_pda: &'a solana_program::account_info::AccountInfo<'a>, + /// payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// owner of token account containing master token + pub master_token_account_owner: &'a solana_program::account_info::AccountInfo<'a>, + /// token account containing token from master metadata mint + pub master_token_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Master record metadata account + pub master_metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// The update authority of the master edition. + pub update_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Token program + pub spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Associated Token Account program + pub spl_ata_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, +} + /// `print_v1` CPI instruction. pub struct PrintV1Cpi<'a> { /// The program to invoke. @@ -448,16 +514,60 @@ pub struct PrintV1Cpi<'a> { } impl<'a> PrintV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: PrintV1CpiAccounts<'a>, + args: PrintV1InstructionArgs, + ) -> Self { + Self { + __program: program, + edition_metadata: accounts.edition_metadata, + edition: accounts.edition, + edition_mint: accounts.edition_mint, + edition_token_account_owner: accounts.edition_token_account_owner, + edition_token_account: accounts.edition_token_account, + edition_mint_authority: accounts.edition_mint_authority, + edition_token_record: accounts.edition_token_record, + master_edition: accounts.master_edition, + edition_marker_pda: accounts.edition_marker_pda, + payer: accounts.payer, + master_token_account_owner: accounts.master_token_account_owner, + master_token_account: accounts.master_token_account, + master_metadata: accounts.master_metadata, + update_authority: accounts.update_authority, + spl_token_program: accounts.spl_token_program, + spl_ata_program: accounts.spl_ata_program, + sysvar_instructions: accounts.sysvar_instructions, + system_program: accounts.system_program, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(18); + let mut accounts = Vec::with_capacity(18 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.edition_metadata.key, false, @@ -537,6 +647,9 @@ impl<'a> PrintV1Cpi<'a> { *self.system_program.key, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = PrintV1InstructionData::new().try_to_vec().unwrap(); let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); @@ -546,7 +659,7 @@ impl<'a> PrintV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(18 + 1); + let mut account_infos = Vec::with_capacity(18 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.edition_metadata.clone()); account_infos.push(self.edition.clone()); @@ -568,6 +681,9 @@ impl<'a> PrintV1Cpi<'a> { account_infos.push(self.spl_ata_program.clone()); account_infos.push(self.sysvar_instructions.clone()); account_infos.push(self.system_program.clone()); + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -605,6 +721,7 @@ impl<'a> PrintV1CpiBuilder<'a> { sysvar_instructions: None, system_program: None, edition_number: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -668,9 +785,9 @@ impl<'a> PrintV1CpiBuilder<'a> { #[inline(always)] pub fn edition_token_record( &mut self, - edition_token_record: &'a solana_program::account_info::AccountInfo<'a>, + edition_token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.edition_token_record = Some(edition_token_record); + self.instruction.edition_token_record = edition_token_record; self } /// Master Record Edition V2 (pda of ['metadata', program id, master metadata mint id, 'edition']) @@ -774,8 +891,34 @@ impl<'a> PrintV1CpiBuilder<'a> { self.instruction.edition_number = Some(edition_number); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> PrintV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = PrintV1InstructionArgs { edition_number: self .instruction @@ -783,8 +926,7 @@ impl<'a> PrintV1CpiBuilder<'a> { .clone() .expect("edition_number is not set"), }; - - PrintV1Cpi { + let instruction = PrintV1Cpi { __program: self.instruction.__program, edition_metadata: self @@ -868,7 +1010,11 @@ impl<'a> PrintV1CpiBuilder<'a> { .system_program .expect("system_program is not set"), __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -893,4 +1039,5 @@ struct PrintV1CpiBuilderInstruction<'a> { sysvar_instructions: Option<&'a solana_program::account_info::AccountInfo<'a>>, system_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, edition_number: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/puff_metadata.rs b/clients/rust/src/generated/instructions/puff_metadata.rs index 84c62d4e..8152983d 100644 --- a/clients/rust/src/generated/instructions/puff_metadata.rs +++ b/clients/rust/src/generated/instructions/puff_metadata.rs @@ -15,13 +15,22 @@ pub struct PuffMetadata { } impl PuffMetadata { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(1); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(1 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.metadata, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = PuffMetadataInstructionData::new().try_to_vec().unwrap(); solana_program::instruction::Instruction { @@ -47,6 +56,7 @@ impl PuffMetadataInstructionData { #[derive(Default)] pub struct PuffMetadataBuilder { metadata: Option, + __remaining_accounts: Vec, } impl PuffMetadataBuilder { @@ -59,16 +69,32 @@ impl PuffMetadataBuilder { self.metadata = Some(metadata); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = PuffMetadata { metadata: self.metadata.expect("metadata is not set"), }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `puff_metadata` CPI accounts. +pub struct PuffMetadataCpiAccounts<'a> { + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, +} + /// `puff_metadata` CPI instruction. pub struct PuffMetadataCpi<'a> { /// The program to invoke. @@ -78,20 +104,48 @@ pub struct PuffMetadataCpi<'a> { } impl<'a> PuffMetadataCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: PuffMetadataCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + metadata: accounts.metadata, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(1); + let mut accounts = Vec::with_capacity(1 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.metadata.key, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = PuffMetadataInstructionData::new().try_to_vec().unwrap(); let instruction = solana_program::instruction::Instruction { @@ -99,9 +153,12 @@ impl<'a> PuffMetadataCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(1 + 1); + let mut account_infos = Vec::with_capacity(1 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.metadata.clone()); + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -121,6 +178,7 @@ impl<'a> PuffMetadataCpiBuilder<'a> { let instruction = Box::new(PuffMetadataCpiBuilderInstruction { __program: program, metadata: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -133,17 +191,48 @@ impl<'a> PuffMetadataCpiBuilder<'a> { self.instruction.metadata = Some(metadata); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> PuffMetadataCpi<'a> { - PuffMetadataCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = PuffMetadataCpi { __program: self.instruction.__program, metadata: self.instruction.metadata.expect("metadata is not set"), - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } struct PuffMetadataCpiBuilderInstruction<'a> { __program: &'a solana_program::account_info::AccountInfo<'a>, metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/remove_creator_verification.rs b/clients/rust/src/generated/instructions/remove_creator_verification.rs index d3acc793..d6b85253 100644 --- a/clients/rust/src/generated/instructions/remove_creator_verification.rs +++ b/clients/rust/src/generated/instructions/remove_creator_verification.rs @@ -17,9 +17,15 @@ pub struct RemoveCreatorVerification { } impl RemoveCreatorVerification { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(2); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.metadata, false, @@ -28,6 +34,9 @@ impl RemoveCreatorVerification { self.creator, true, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RemoveCreatorVerificationInstructionData::new() .try_to_vec() .unwrap(); @@ -56,6 +65,7 @@ impl RemoveCreatorVerificationInstructionData { pub struct RemoveCreatorVerificationBuilder { metadata: Option, creator: Option, + __remaining_accounts: Vec, } impl RemoveCreatorVerificationBuilder { @@ -74,17 +84,35 @@ impl RemoveCreatorVerificationBuilder { self.creator = Some(creator); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = RemoveCreatorVerification { metadata: self.metadata.expect("metadata is not set"), creator: self.creator.expect("creator is not set"), }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `remove_creator_verification` CPI accounts. +pub struct RemoveCreatorVerificationCpiAccounts<'a> { + /// Metadata (pda of ['metadata', program id, mint id]) + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Creator + pub creator: &'a solana_program::account_info::AccountInfo<'a>, +} + /// `remove_creator_verification` CPI instruction. pub struct RemoveCreatorVerificationCpi<'a> { /// The program to invoke. @@ -96,16 +124,42 @@ pub struct RemoveCreatorVerificationCpi<'a> { } impl<'a> RemoveCreatorVerificationCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: RemoveCreatorVerificationCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + metadata: accounts.metadata, + creator: accounts.creator, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2); + let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.metadata.key, false, @@ -114,6 +168,9 @@ impl<'a> RemoveCreatorVerificationCpi<'a> { *self.creator.key, true, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RemoveCreatorVerificationInstructionData::new() .try_to_vec() .unwrap(); @@ -123,10 +180,13 @@ impl<'a> RemoveCreatorVerificationCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(2 + 1); + let mut account_infos = Vec::with_capacity(2 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.metadata.clone()); account_infos.push(self.creator.clone()); + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -147,6 +207,7 @@ impl<'a> RemoveCreatorVerificationCpiBuilder<'a> { __program: program, metadata: None, creator: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -168,15 +229,45 @@ impl<'a> RemoveCreatorVerificationCpiBuilder<'a> { self.instruction.creator = Some(creator); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> RemoveCreatorVerificationCpi<'a> { - RemoveCreatorVerificationCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = RemoveCreatorVerificationCpi { __program: self.instruction.__program, metadata: self.instruction.metadata.expect("metadata is not set"), creator: self.instruction.creator.expect("creator is not set"), - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -184,4 +275,5 @@ struct RemoveCreatorVerificationCpiBuilderInstruction<'a> { __program: &'a solana_program::account_info::AccountInfo<'a>, metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, creator: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/revoke_authority_item_v1.rs b/clients/rust/src/generated/instructions/revoke_authority_item_v1.rs index 11b75b34..05c92410 100644 --- a/clients/rust/src/generated/instructions/revoke_authority_item_v1.rs +++ b/clients/rust/src/generated/instructions/revoke_authority_item_v1.rs @@ -41,9 +41,15 @@ pub struct RevokeAuthorityItemV1 { } impl RevokeAuthorityItemV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -144,6 +150,9 @@ impl RevokeAuthorityItemV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeAuthorityItemV1InstructionData::new() .try_to_vec() .unwrap(); @@ -188,6 +197,7 @@ pub struct RevokeAuthorityItemV1Builder { spl_token_program: Option, authorization_rules_program: Option, authorization_rules: Option, + __remaining_accounts: Vec, } impl RevokeAuthorityItemV1Builder { @@ -199,9 +209,9 @@ impl RevokeAuthorityItemV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -219,15 +229,21 @@ impl RevokeAuthorityItemV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -239,8 +255,8 @@ impl RevokeAuthorityItemV1Builder { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Update authority or token owner @@ -255,12 +271,14 @@ impl RevokeAuthorityItemV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -275,9 +293,9 @@ impl RevokeAuthorityItemV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -285,9 +303,9 @@ impl RevokeAuthorityItemV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -295,13 +313,23 @@ impl RevokeAuthorityItemV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = RevokeAuthorityItemV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -323,10 +351,42 @@ impl RevokeAuthorityItemV1Builder { authorization_rules: self.authorization_rules, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `revoke_authority_item_v1` CPI accounts. +pub struct RevokeAuthorityItemV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `revoke_authority_item_v1` CPI instruction. pub struct RevokeAuthorityItemV1Cpi<'a> { /// The program to invoke. @@ -362,16 +422,54 @@ pub struct RevokeAuthorityItemV1Cpi<'a> { } impl<'a> RevokeAuthorityItemV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: RevokeAuthorityItemV1CpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -476,6 +574,9 @@ impl<'a> RevokeAuthorityItemV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeAuthorityItemV1InstructionData::new() .try_to_vec() .unwrap(); @@ -485,7 +586,7 @@ impl<'a> RevokeAuthorityItemV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -515,6 +616,9 @@ impl<'a> RevokeAuthorityItemV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -547,6 +651,7 @@ impl<'a> RevokeAuthorityItemV1CpiBuilder<'a> { spl_token_program: None, authorization_rules_program: None, authorization_rules: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -555,9 +660,9 @@ impl<'a> RevokeAuthorityItemV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -583,9 +688,9 @@ impl<'a> RevokeAuthorityItemV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -593,9 +698,9 @@ impl<'a> RevokeAuthorityItemV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -607,8 +712,11 @@ impl<'a> RevokeAuthorityItemV1CpiBuilder<'a> { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Update authority or token owner @@ -649,9 +757,9 @@ impl<'a> RevokeAuthorityItemV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -659,9 +767,9 @@ impl<'a> RevokeAuthorityItemV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -669,14 +777,40 @@ impl<'a> RevokeAuthorityItemV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); self } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> RevokeAuthorityItemV1Cpi<'a> { - RevokeAuthorityItemV1Cpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = RevokeAuthorityItemV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -712,7 +846,11 @@ impl<'a> RevokeAuthorityItemV1CpiBuilder<'a> { authorization_rules_program: self.instruction.authorization_rules_program, authorization_rules: self.instruction.authorization_rules, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -732,4 +870,5 @@ struct RevokeAuthorityItemV1CpiBuilderInstruction<'a> { spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/revoke_collection_authority.rs b/clients/rust/src/generated/instructions/revoke_collection_authority.rs index 7c62381f..293fdbc4 100644 --- a/clients/rust/src/generated/instructions/revoke_collection_authority.rs +++ b/clients/rust/src/generated/instructions/revoke_collection_authority.rs @@ -23,9 +23,15 @@ pub struct RevokeCollectionAuthority { } impl RevokeCollectionAuthority { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(5); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.collection_authority_record, false, @@ -45,6 +51,9 @@ impl RevokeCollectionAuthority { accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.mint, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeCollectionAuthorityInstructionData::new() .try_to_vec() .unwrap(); @@ -76,6 +85,7 @@ pub struct RevokeCollectionAuthorityBuilder { revoke_authority: Option, metadata: Option, mint: Option, + __remaining_accounts: Vec, } impl RevokeCollectionAuthorityBuilder { @@ -121,8 +131,18 @@ impl RevokeCollectionAuthorityBuilder { self.mint = Some(mint); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = RevokeCollectionAuthority { collection_authority_record: self .collection_authority_record @@ -135,10 +155,24 @@ impl RevokeCollectionAuthorityBuilder { mint: self.mint.expect("mint is not set"), }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `revoke_collection_authority` CPI accounts. +pub struct RevokeCollectionAuthorityCpiAccounts<'a> { + /// Collection Authority Record PDA + pub collection_authority_record: &'a solana_program::account_info::AccountInfo<'a>, + /// Delegated Collection Authority + pub delegate_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Update Authority, or Delegated Authority, of Collection NFT + pub revoke_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of Metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, +} + /// `revoke_collection_authority` CPI instruction. pub struct RevokeCollectionAuthorityCpi<'a> { /// The program to invoke. @@ -156,16 +190,45 @@ pub struct RevokeCollectionAuthorityCpi<'a> { } impl<'a> RevokeCollectionAuthorityCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: RevokeCollectionAuthorityCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + collection_authority_record: accounts.collection_authority_record, + delegate_authority: accounts.delegate_authority, + revoke_authority: accounts.revoke_authority, + metadata: accounts.metadata, + mint: accounts.mint, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5); + let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.collection_authority_record.key, false, @@ -186,6 +249,9 @@ impl<'a> RevokeCollectionAuthorityCpi<'a> { *self.mint.key, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeCollectionAuthorityInstructionData::new() .try_to_vec() .unwrap(); @@ -195,13 +261,16 @@ impl<'a> RevokeCollectionAuthorityCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(5 + 1); + let mut account_infos = Vec::with_capacity(5 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.collection_authority_record.clone()); account_infos.push(self.delegate_authority.clone()); account_infos.push(self.revoke_authority.clone()); account_infos.push(self.metadata.clone()); account_infos.push(self.mint.clone()); + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -225,6 +294,7 @@ impl<'a> RevokeCollectionAuthorityCpiBuilder<'a> { revoke_authority: None, metadata: None, mint: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -270,9 +340,35 @@ impl<'a> RevokeCollectionAuthorityCpiBuilder<'a> { self.instruction.mint = Some(mint); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> RevokeCollectionAuthorityCpi<'a> { - RevokeCollectionAuthorityCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = RevokeCollectionAuthorityCpi { __program: self.instruction.__program, collection_authority_record: self @@ -293,7 +389,11 @@ impl<'a> RevokeCollectionAuthorityCpiBuilder<'a> { metadata: self.instruction.metadata.expect("metadata is not set"), mint: self.instruction.mint.expect("mint is not set"), - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -304,4 +404,5 @@ struct RevokeCollectionAuthorityCpiBuilderInstruction<'a> { revoke_authority: Option<&'a solana_program::account_info::AccountInfo<'a>>, metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, mint: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/revoke_collection_item_v1.rs b/clients/rust/src/generated/instructions/revoke_collection_item_v1.rs index 4685d667..3277947d 100644 --- a/clients/rust/src/generated/instructions/revoke_collection_item_v1.rs +++ b/clients/rust/src/generated/instructions/revoke_collection_item_v1.rs @@ -41,9 +41,15 @@ pub struct RevokeCollectionItemV1 { } impl RevokeCollectionItemV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -144,6 +150,9 @@ impl RevokeCollectionItemV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeCollectionItemV1InstructionData::new() .try_to_vec() .unwrap(); @@ -188,6 +197,7 @@ pub struct RevokeCollectionItemV1Builder { spl_token_program: Option, authorization_rules_program: Option, authorization_rules: Option, + __remaining_accounts: Vec, } impl RevokeCollectionItemV1Builder { @@ -199,9 +209,9 @@ impl RevokeCollectionItemV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -219,15 +229,21 @@ impl RevokeCollectionItemV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -239,8 +255,8 @@ impl RevokeCollectionItemV1Builder { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Update authority or token owner @@ -255,12 +271,14 @@ impl RevokeCollectionItemV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -275,9 +293,9 @@ impl RevokeCollectionItemV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -285,9 +303,9 @@ impl RevokeCollectionItemV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -295,13 +313,23 @@ impl RevokeCollectionItemV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = RevokeCollectionItemV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -323,10 +351,42 @@ impl RevokeCollectionItemV1Builder { authorization_rules: self.authorization_rules, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `revoke_collection_item_v1` CPI accounts. +pub struct RevokeCollectionItemV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `revoke_collection_item_v1` CPI instruction. pub struct RevokeCollectionItemV1Cpi<'a> { /// The program to invoke. @@ -362,16 +422,54 @@ pub struct RevokeCollectionItemV1Cpi<'a> { } impl<'a> RevokeCollectionItemV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: RevokeCollectionItemV1CpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -476,6 +574,9 @@ impl<'a> RevokeCollectionItemV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeCollectionItemV1InstructionData::new() .try_to_vec() .unwrap(); @@ -485,7 +586,7 @@ impl<'a> RevokeCollectionItemV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -515,6 +616,9 @@ impl<'a> RevokeCollectionItemV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -547,6 +651,7 @@ impl<'a> RevokeCollectionItemV1CpiBuilder<'a> { spl_token_program: None, authorization_rules_program: None, authorization_rules: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -555,9 +660,9 @@ impl<'a> RevokeCollectionItemV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -583,9 +688,9 @@ impl<'a> RevokeCollectionItemV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -593,9 +698,9 @@ impl<'a> RevokeCollectionItemV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -607,8 +712,11 @@ impl<'a> RevokeCollectionItemV1CpiBuilder<'a> { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Update authority or token owner @@ -649,9 +757,9 @@ impl<'a> RevokeCollectionItemV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -659,9 +767,9 @@ impl<'a> RevokeCollectionItemV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -669,14 +777,40 @@ impl<'a> RevokeCollectionItemV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); self } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> RevokeCollectionItemV1Cpi<'a> { - RevokeCollectionItemV1Cpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = RevokeCollectionItemV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -712,7 +846,11 @@ impl<'a> RevokeCollectionItemV1CpiBuilder<'a> { authorization_rules_program: self.instruction.authorization_rules_program, authorization_rules: self.instruction.authorization_rules, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -732,4 +870,5 @@ struct RevokeCollectionItemV1CpiBuilderInstruction<'a> { spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/revoke_collection_v1.rs b/clients/rust/src/generated/instructions/revoke_collection_v1.rs index 596210e8..3eae71a0 100644 --- a/clients/rust/src/generated/instructions/revoke_collection_v1.rs +++ b/clients/rust/src/generated/instructions/revoke_collection_v1.rs @@ -41,9 +41,15 @@ pub struct RevokeCollectionV1 { } impl RevokeCollectionV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -144,6 +150,9 @@ impl RevokeCollectionV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeCollectionV1InstructionData::new() .try_to_vec() .unwrap(); @@ -188,6 +197,7 @@ pub struct RevokeCollectionV1Builder { spl_token_program: Option, authorization_rules_program: Option, authorization_rules: Option, + __remaining_accounts: Vec, } impl RevokeCollectionV1Builder { @@ -199,9 +209,9 @@ impl RevokeCollectionV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -219,15 +229,21 @@ impl RevokeCollectionV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -239,8 +255,8 @@ impl RevokeCollectionV1Builder { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Update authority or token owner @@ -255,12 +271,14 @@ impl RevokeCollectionV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -275,9 +293,9 @@ impl RevokeCollectionV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -285,9 +303,9 @@ impl RevokeCollectionV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -295,13 +313,23 @@ impl RevokeCollectionV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = RevokeCollectionV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -323,10 +351,42 @@ impl RevokeCollectionV1Builder { authorization_rules: self.authorization_rules, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `revoke_collection_v1` CPI accounts. +pub struct RevokeCollectionV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `revoke_collection_v1` CPI instruction. pub struct RevokeCollectionV1Cpi<'a> { /// The program to invoke. @@ -362,16 +422,54 @@ pub struct RevokeCollectionV1Cpi<'a> { } impl<'a> RevokeCollectionV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: RevokeCollectionV1CpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -476,6 +574,9 @@ impl<'a> RevokeCollectionV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeCollectionV1InstructionData::new() .try_to_vec() .unwrap(); @@ -485,7 +586,7 @@ impl<'a> RevokeCollectionV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -515,6 +616,9 @@ impl<'a> RevokeCollectionV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -547,6 +651,7 @@ impl<'a> RevokeCollectionV1CpiBuilder<'a> { spl_token_program: None, authorization_rules_program: None, authorization_rules: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -555,9 +660,9 @@ impl<'a> RevokeCollectionV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -583,9 +688,9 @@ impl<'a> RevokeCollectionV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -593,9 +698,9 @@ impl<'a> RevokeCollectionV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -607,8 +712,11 @@ impl<'a> RevokeCollectionV1CpiBuilder<'a> { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Update authority or token owner @@ -649,9 +757,9 @@ impl<'a> RevokeCollectionV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -659,9 +767,9 @@ impl<'a> RevokeCollectionV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -669,14 +777,40 @@ impl<'a> RevokeCollectionV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); self } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> RevokeCollectionV1Cpi<'a> { - RevokeCollectionV1Cpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = RevokeCollectionV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -712,7 +846,11 @@ impl<'a> RevokeCollectionV1CpiBuilder<'a> { authorization_rules_program: self.instruction.authorization_rules_program, authorization_rules: self.instruction.authorization_rules, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -732,4 +870,5 @@ struct RevokeCollectionV1CpiBuilderInstruction<'a> { spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/revoke_data_item_v1.rs b/clients/rust/src/generated/instructions/revoke_data_item_v1.rs index 269b3fbd..ae4e11ab 100644 --- a/clients/rust/src/generated/instructions/revoke_data_item_v1.rs +++ b/clients/rust/src/generated/instructions/revoke_data_item_v1.rs @@ -41,9 +41,15 @@ pub struct RevokeDataItemV1 { } impl RevokeDataItemV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -144,6 +150,9 @@ impl RevokeDataItemV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeDataItemV1InstructionData::new().try_to_vec().unwrap(); solana_program::instruction::Instruction { @@ -186,6 +195,7 @@ pub struct RevokeDataItemV1Builder { spl_token_program: Option, authorization_rules_program: Option, authorization_rules: Option, + __remaining_accounts: Vec, } impl RevokeDataItemV1Builder { @@ -197,9 +207,9 @@ impl RevokeDataItemV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -217,15 +227,21 @@ impl RevokeDataItemV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -237,8 +253,8 @@ impl RevokeDataItemV1Builder { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Update authority or token owner @@ -253,12 +269,14 @@ impl RevokeDataItemV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -273,9 +291,9 @@ impl RevokeDataItemV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -283,9 +301,9 @@ impl RevokeDataItemV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -293,13 +311,23 @@ impl RevokeDataItemV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = RevokeDataItemV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -321,10 +349,42 @@ impl RevokeDataItemV1Builder { authorization_rules: self.authorization_rules, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `revoke_data_item_v1` CPI accounts. +pub struct RevokeDataItemV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `revoke_data_item_v1` CPI instruction. pub struct RevokeDataItemV1Cpi<'a> { /// The program to invoke. @@ -360,16 +420,54 @@ pub struct RevokeDataItemV1Cpi<'a> { } impl<'a> RevokeDataItemV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: RevokeDataItemV1CpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -474,6 +572,9 @@ impl<'a> RevokeDataItemV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeDataItemV1InstructionData::new().try_to_vec().unwrap(); let instruction = solana_program::instruction::Instruction { @@ -481,7 +582,7 @@ impl<'a> RevokeDataItemV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -511,6 +612,9 @@ impl<'a> RevokeDataItemV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -543,6 +647,7 @@ impl<'a> RevokeDataItemV1CpiBuilder<'a> { spl_token_program: None, authorization_rules_program: None, authorization_rules: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -551,9 +656,9 @@ impl<'a> RevokeDataItemV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -579,9 +684,9 @@ impl<'a> RevokeDataItemV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -589,9 +694,9 @@ impl<'a> RevokeDataItemV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -603,8 +708,11 @@ impl<'a> RevokeDataItemV1CpiBuilder<'a> { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Update authority or token owner @@ -645,9 +753,9 @@ impl<'a> RevokeDataItemV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -655,9 +763,9 @@ impl<'a> RevokeDataItemV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -665,14 +773,40 @@ impl<'a> RevokeDataItemV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); self } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> RevokeDataItemV1Cpi<'a> { - RevokeDataItemV1Cpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = RevokeDataItemV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -708,7 +842,11 @@ impl<'a> RevokeDataItemV1CpiBuilder<'a> { authorization_rules_program: self.instruction.authorization_rules_program, authorization_rules: self.instruction.authorization_rules, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -728,4 +866,5 @@ struct RevokeDataItemV1CpiBuilderInstruction<'a> { spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/revoke_data_v1.rs b/clients/rust/src/generated/instructions/revoke_data_v1.rs index 85ebbd23..32aec39a 100644 --- a/clients/rust/src/generated/instructions/revoke_data_v1.rs +++ b/clients/rust/src/generated/instructions/revoke_data_v1.rs @@ -41,9 +41,15 @@ pub struct RevokeDataV1 { } impl RevokeDataV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -144,6 +150,9 @@ impl RevokeDataV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeDataV1InstructionData::new().try_to_vec().unwrap(); solana_program::instruction::Instruction { @@ -186,6 +195,7 @@ pub struct RevokeDataV1Builder { spl_token_program: Option, authorization_rules_program: Option, authorization_rules: Option, + __remaining_accounts: Vec, } impl RevokeDataV1Builder { @@ -197,9 +207,9 @@ impl RevokeDataV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -217,15 +227,21 @@ impl RevokeDataV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -237,8 +253,8 @@ impl RevokeDataV1Builder { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Update authority or token owner @@ -253,12 +269,14 @@ impl RevokeDataV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -273,9 +291,9 @@ impl RevokeDataV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -283,9 +301,9 @@ impl RevokeDataV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -293,13 +311,23 @@ impl RevokeDataV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = RevokeDataV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -321,10 +349,42 @@ impl RevokeDataV1Builder { authorization_rules: self.authorization_rules, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `revoke_data_v1` CPI accounts. +pub struct RevokeDataV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `revoke_data_v1` CPI instruction. pub struct RevokeDataV1Cpi<'a> { /// The program to invoke. @@ -360,16 +420,54 @@ pub struct RevokeDataV1Cpi<'a> { } impl<'a> RevokeDataV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: RevokeDataV1CpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -474,6 +572,9 @@ impl<'a> RevokeDataV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeDataV1InstructionData::new().try_to_vec().unwrap(); let instruction = solana_program::instruction::Instruction { @@ -481,7 +582,7 @@ impl<'a> RevokeDataV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -511,6 +612,9 @@ impl<'a> RevokeDataV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -543,6 +647,7 @@ impl<'a> RevokeDataV1CpiBuilder<'a> { spl_token_program: None, authorization_rules_program: None, authorization_rules: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -551,9 +656,9 @@ impl<'a> RevokeDataV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -579,9 +684,9 @@ impl<'a> RevokeDataV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -589,9 +694,9 @@ impl<'a> RevokeDataV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -603,8 +708,11 @@ impl<'a> RevokeDataV1CpiBuilder<'a> { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Update authority or token owner @@ -645,9 +753,9 @@ impl<'a> RevokeDataV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -655,9 +763,9 @@ impl<'a> RevokeDataV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -665,14 +773,40 @@ impl<'a> RevokeDataV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); self } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> RevokeDataV1Cpi<'a> { - RevokeDataV1Cpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = RevokeDataV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -708,7 +842,11 @@ impl<'a> RevokeDataV1CpiBuilder<'a> { authorization_rules_program: self.instruction.authorization_rules_program, authorization_rules: self.instruction.authorization_rules, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -728,4 +866,5 @@ struct RevokeDataV1CpiBuilderInstruction<'a> { spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/revoke_locked_transfer_v1.rs b/clients/rust/src/generated/instructions/revoke_locked_transfer_v1.rs index 65c062af..6e2d3c37 100644 --- a/clients/rust/src/generated/instructions/revoke_locked_transfer_v1.rs +++ b/clients/rust/src/generated/instructions/revoke_locked_transfer_v1.rs @@ -41,9 +41,15 @@ pub struct RevokeLockedTransferV1 { } impl RevokeLockedTransferV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -139,6 +145,9 @@ impl RevokeLockedTransferV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeLockedTransferV1InstructionData::new() .try_to_vec() .unwrap(); @@ -183,6 +192,7 @@ pub struct RevokeLockedTransferV1Builder { spl_token_program: Option, authorization_rules_program: Option, authorization_rules: Option, + __remaining_accounts: Vec, } impl RevokeLockedTransferV1Builder { @@ -194,9 +204,9 @@ impl RevokeLockedTransferV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -214,15 +224,21 @@ impl RevokeLockedTransferV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -249,12 +265,14 @@ impl RevokeLockedTransferV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -269,9 +287,9 @@ impl RevokeLockedTransferV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -279,9 +297,9 @@ impl RevokeLockedTransferV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -289,13 +307,23 @@ impl RevokeLockedTransferV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = RevokeLockedTransferV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -317,10 +345,42 @@ impl RevokeLockedTransferV1Builder { authorization_rules: self.authorization_rules, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `revoke_locked_transfer_v1` CPI accounts. +pub struct RevokeLockedTransferV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `revoke_locked_transfer_v1` CPI instruction. pub struct RevokeLockedTransferV1Cpi<'a> { /// The program to invoke. @@ -356,16 +416,54 @@ pub struct RevokeLockedTransferV1Cpi<'a> { } impl<'a> RevokeLockedTransferV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: RevokeLockedTransferV1CpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -464,6 +562,9 @@ impl<'a> RevokeLockedTransferV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeLockedTransferV1InstructionData::new() .try_to_vec() .unwrap(); @@ -473,7 +574,7 @@ impl<'a> RevokeLockedTransferV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -501,6 +602,9 @@ impl<'a> RevokeLockedTransferV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -533,6 +637,7 @@ impl<'a> RevokeLockedTransferV1CpiBuilder<'a> { spl_token_program: None, authorization_rules_program: None, authorization_rules: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -541,9 +646,9 @@ impl<'a> RevokeLockedTransferV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -569,9 +674,9 @@ impl<'a> RevokeLockedTransferV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -579,9 +684,9 @@ impl<'a> RevokeLockedTransferV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -634,9 +739,9 @@ impl<'a> RevokeLockedTransferV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -644,9 +749,9 @@ impl<'a> RevokeLockedTransferV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -654,14 +759,40 @@ impl<'a> RevokeLockedTransferV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> RevokeLockedTransferV1Cpi<'a> { - RevokeLockedTransferV1Cpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = RevokeLockedTransferV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -697,7 +828,11 @@ impl<'a> RevokeLockedTransferV1CpiBuilder<'a> { authorization_rules_program: self.instruction.authorization_rules_program, authorization_rules: self.instruction.authorization_rules, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -717,4 +852,5 @@ struct RevokeLockedTransferV1CpiBuilderInstruction<'a> { spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/revoke_migration_v1.rs b/clients/rust/src/generated/instructions/revoke_migration_v1.rs index eb40149f..f211c3ca 100644 --- a/clients/rust/src/generated/instructions/revoke_migration_v1.rs +++ b/clients/rust/src/generated/instructions/revoke_migration_v1.rs @@ -41,9 +41,15 @@ pub struct RevokeMigrationV1 { } impl RevokeMigrationV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -139,6 +145,9 @@ impl RevokeMigrationV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeMigrationV1InstructionData::new() .try_to_vec() .unwrap(); @@ -183,6 +192,7 @@ pub struct RevokeMigrationV1Builder { spl_token_program: Option, authorization_rules_program: Option, authorization_rules: Option, + __remaining_accounts: Vec, } impl RevokeMigrationV1Builder { @@ -194,9 +204,9 @@ impl RevokeMigrationV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -214,15 +224,21 @@ impl RevokeMigrationV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -249,12 +265,14 @@ impl RevokeMigrationV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -269,9 +287,9 @@ impl RevokeMigrationV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -279,9 +297,9 @@ impl RevokeMigrationV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -289,13 +307,23 @@ impl RevokeMigrationV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = RevokeMigrationV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -317,10 +345,42 @@ impl RevokeMigrationV1Builder { authorization_rules: self.authorization_rules, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `revoke_migration_v1` CPI accounts. +pub struct RevokeMigrationV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `revoke_migration_v1` CPI instruction. pub struct RevokeMigrationV1Cpi<'a> { /// The program to invoke. @@ -356,16 +416,54 @@ pub struct RevokeMigrationV1Cpi<'a> { } impl<'a> RevokeMigrationV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: RevokeMigrationV1CpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -464,6 +562,9 @@ impl<'a> RevokeMigrationV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeMigrationV1InstructionData::new() .try_to_vec() .unwrap(); @@ -473,7 +574,7 @@ impl<'a> RevokeMigrationV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -501,6 +602,9 @@ impl<'a> RevokeMigrationV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -533,6 +637,7 @@ impl<'a> RevokeMigrationV1CpiBuilder<'a> { spl_token_program: None, authorization_rules_program: None, authorization_rules: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -541,9 +646,9 @@ impl<'a> RevokeMigrationV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -569,9 +674,9 @@ impl<'a> RevokeMigrationV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -579,9 +684,9 @@ impl<'a> RevokeMigrationV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -634,9 +739,9 @@ impl<'a> RevokeMigrationV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -644,9 +749,9 @@ impl<'a> RevokeMigrationV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -654,14 +759,40 @@ impl<'a> RevokeMigrationV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> RevokeMigrationV1Cpi<'a> { - RevokeMigrationV1Cpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = RevokeMigrationV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -697,7 +828,11 @@ impl<'a> RevokeMigrationV1CpiBuilder<'a> { authorization_rules_program: self.instruction.authorization_rules_program, authorization_rules: self.instruction.authorization_rules, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -717,4 +852,5 @@ struct RevokeMigrationV1CpiBuilderInstruction<'a> { spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/revoke_programmable_config_item_v1.rs b/clients/rust/src/generated/instructions/revoke_programmable_config_item_v1.rs index ac85c71f..6961fc92 100644 --- a/clients/rust/src/generated/instructions/revoke_programmable_config_item_v1.rs +++ b/clients/rust/src/generated/instructions/revoke_programmable_config_item_v1.rs @@ -41,9 +41,15 @@ pub struct RevokeProgrammableConfigItemV1 { } impl RevokeProgrammableConfigItemV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -144,6 +150,9 @@ impl RevokeProgrammableConfigItemV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeProgrammableConfigItemV1InstructionData::new() .try_to_vec() .unwrap(); @@ -188,6 +197,7 @@ pub struct RevokeProgrammableConfigItemV1Builder { spl_token_program: Option, authorization_rules_program: Option, authorization_rules: Option, + __remaining_accounts: Vec, } impl RevokeProgrammableConfigItemV1Builder { @@ -199,9 +209,9 @@ impl RevokeProgrammableConfigItemV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -219,15 +229,21 @@ impl RevokeProgrammableConfigItemV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -239,8 +255,8 @@ impl RevokeProgrammableConfigItemV1Builder { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Update authority or token owner @@ -255,12 +271,14 @@ impl RevokeProgrammableConfigItemV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -275,9 +293,9 @@ impl RevokeProgrammableConfigItemV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -285,9 +303,9 @@ impl RevokeProgrammableConfigItemV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -295,13 +313,23 @@ impl RevokeProgrammableConfigItemV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = RevokeProgrammableConfigItemV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -323,10 +351,42 @@ impl RevokeProgrammableConfigItemV1Builder { authorization_rules: self.authorization_rules, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `revoke_programmable_config_item_v1` CPI accounts. +pub struct RevokeProgrammableConfigItemV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `revoke_programmable_config_item_v1` CPI instruction. pub struct RevokeProgrammableConfigItemV1Cpi<'a> { /// The program to invoke. @@ -362,16 +422,54 @@ pub struct RevokeProgrammableConfigItemV1Cpi<'a> { } impl<'a> RevokeProgrammableConfigItemV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: RevokeProgrammableConfigItemV1CpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -476,6 +574,9 @@ impl<'a> RevokeProgrammableConfigItemV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeProgrammableConfigItemV1InstructionData::new() .try_to_vec() .unwrap(); @@ -485,7 +586,7 @@ impl<'a> RevokeProgrammableConfigItemV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -515,6 +616,9 @@ impl<'a> RevokeProgrammableConfigItemV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -547,6 +651,7 @@ impl<'a> RevokeProgrammableConfigItemV1CpiBuilder<'a> { spl_token_program: None, authorization_rules_program: None, authorization_rules: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -555,9 +660,9 @@ impl<'a> RevokeProgrammableConfigItemV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -583,9 +688,9 @@ impl<'a> RevokeProgrammableConfigItemV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -593,9 +698,9 @@ impl<'a> RevokeProgrammableConfigItemV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -607,8 +712,11 @@ impl<'a> RevokeProgrammableConfigItemV1CpiBuilder<'a> { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Update authority or token owner @@ -649,9 +757,9 @@ impl<'a> RevokeProgrammableConfigItemV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -659,9 +767,9 @@ impl<'a> RevokeProgrammableConfigItemV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -669,14 +777,40 @@ impl<'a> RevokeProgrammableConfigItemV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); self } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> RevokeProgrammableConfigItemV1Cpi<'a> { - RevokeProgrammableConfigItemV1Cpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = RevokeProgrammableConfigItemV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -712,7 +846,11 @@ impl<'a> RevokeProgrammableConfigItemV1CpiBuilder<'a> { authorization_rules_program: self.instruction.authorization_rules_program, authorization_rules: self.instruction.authorization_rules, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -732,4 +870,5 @@ struct RevokeProgrammableConfigItemV1CpiBuilderInstruction<'a> { spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/revoke_programmable_config_v1.rs b/clients/rust/src/generated/instructions/revoke_programmable_config_v1.rs index 4539704b..bbf635c5 100644 --- a/clients/rust/src/generated/instructions/revoke_programmable_config_v1.rs +++ b/clients/rust/src/generated/instructions/revoke_programmable_config_v1.rs @@ -41,9 +41,15 @@ pub struct RevokeProgrammableConfigV1 { } impl RevokeProgrammableConfigV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -144,6 +150,9 @@ impl RevokeProgrammableConfigV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeProgrammableConfigV1InstructionData::new() .try_to_vec() .unwrap(); @@ -188,6 +197,7 @@ pub struct RevokeProgrammableConfigV1Builder { spl_token_program: Option, authorization_rules_program: Option, authorization_rules: Option, + __remaining_accounts: Vec, } impl RevokeProgrammableConfigV1Builder { @@ -199,9 +209,9 @@ impl RevokeProgrammableConfigV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -219,15 +229,21 @@ impl RevokeProgrammableConfigV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -239,8 +255,8 @@ impl RevokeProgrammableConfigV1Builder { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Update authority or token owner @@ -255,12 +271,14 @@ impl RevokeProgrammableConfigV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -275,9 +293,9 @@ impl RevokeProgrammableConfigV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -285,9 +303,9 @@ impl RevokeProgrammableConfigV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -295,13 +313,23 @@ impl RevokeProgrammableConfigV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = RevokeProgrammableConfigV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -323,10 +351,42 @@ impl RevokeProgrammableConfigV1Builder { authorization_rules: self.authorization_rules, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `revoke_programmable_config_v1` CPI accounts. +pub struct RevokeProgrammableConfigV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `revoke_programmable_config_v1` CPI instruction. pub struct RevokeProgrammableConfigV1Cpi<'a> { /// The program to invoke. @@ -362,16 +422,54 @@ pub struct RevokeProgrammableConfigV1Cpi<'a> { } impl<'a> RevokeProgrammableConfigV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: RevokeProgrammableConfigV1CpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -476,6 +574,9 @@ impl<'a> RevokeProgrammableConfigV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeProgrammableConfigV1InstructionData::new() .try_to_vec() .unwrap(); @@ -485,7 +586,7 @@ impl<'a> RevokeProgrammableConfigV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -515,6 +616,9 @@ impl<'a> RevokeProgrammableConfigV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -547,6 +651,7 @@ impl<'a> RevokeProgrammableConfigV1CpiBuilder<'a> { spl_token_program: None, authorization_rules_program: None, authorization_rules: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -555,9 +660,9 @@ impl<'a> RevokeProgrammableConfigV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -583,9 +688,9 @@ impl<'a> RevokeProgrammableConfigV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -593,9 +698,9 @@ impl<'a> RevokeProgrammableConfigV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -607,8 +712,11 @@ impl<'a> RevokeProgrammableConfigV1CpiBuilder<'a> { /// `[optional account]` /// Token account of mint #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Update authority or token owner @@ -649,9 +757,9 @@ impl<'a> RevokeProgrammableConfigV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -659,9 +767,9 @@ impl<'a> RevokeProgrammableConfigV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -669,14 +777,40 @@ impl<'a> RevokeProgrammableConfigV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); self } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> RevokeProgrammableConfigV1Cpi<'a> { - RevokeProgrammableConfigV1Cpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = RevokeProgrammableConfigV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -712,7 +846,11 @@ impl<'a> RevokeProgrammableConfigV1CpiBuilder<'a> { authorization_rules_program: self.instruction.authorization_rules_program, authorization_rules: self.instruction.authorization_rules, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -732,4 +870,5 @@ struct RevokeProgrammableConfigV1CpiBuilderInstruction<'a> { spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/revoke_sale_v1.rs b/clients/rust/src/generated/instructions/revoke_sale_v1.rs index 8c917e73..28a6d27c 100644 --- a/clients/rust/src/generated/instructions/revoke_sale_v1.rs +++ b/clients/rust/src/generated/instructions/revoke_sale_v1.rs @@ -41,9 +41,15 @@ pub struct RevokeSaleV1 { } impl RevokeSaleV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -139,6 +145,9 @@ impl RevokeSaleV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeSaleV1InstructionData::new().try_to_vec().unwrap(); solana_program::instruction::Instruction { @@ -181,6 +190,7 @@ pub struct RevokeSaleV1Builder { spl_token_program: Option, authorization_rules_program: Option, authorization_rules: Option, + __remaining_accounts: Vec, } impl RevokeSaleV1Builder { @@ -192,9 +202,9 @@ impl RevokeSaleV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -212,15 +222,21 @@ impl RevokeSaleV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -247,12 +263,14 @@ impl RevokeSaleV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -267,9 +285,9 @@ impl RevokeSaleV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -277,9 +295,9 @@ impl RevokeSaleV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -287,13 +305,23 @@ impl RevokeSaleV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = RevokeSaleV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -315,10 +343,42 @@ impl RevokeSaleV1Builder { authorization_rules: self.authorization_rules, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `revoke_sale_v1` CPI accounts. +pub struct RevokeSaleV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `revoke_sale_v1` CPI instruction. pub struct RevokeSaleV1Cpi<'a> { /// The program to invoke. @@ -354,16 +414,54 @@ pub struct RevokeSaleV1Cpi<'a> { } impl<'a> RevokeSaleV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: RevokeSaleV1CpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -462,6 +560,9 @@ impl<'a> RevokeSaleV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeSaleV1InstructionData::new().try_to_vec().unwrap(); let instruction = solana_program::instruction::Instruction { @@ -469,7 +570,7 @@ impl<'a> RevokeSaleV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -497,6 +598,9 @@ impl<'a> RevokeSaleV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -529,6 +633,7 @@ impl<'a> RevokeSaleV1CpiBuilder<'a> { spl_token_program: None, authorization_rules_program: None, authorization_rules: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -537,9 +642,9 @@ impl<'a> RevokeSaleV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -565,9 +670,9 @@ impl<'a> RevokeSaleV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -575,9 +680,9 @@ impl<'a> RevokeSaleV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -630,9 +735,9 @@ impl<'a> RevokeSaleV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -640,9 +745,9 @@ impl<'a> RevokeSaleV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -650,14 +755,40 @@ impl<'a> RevokeSaleV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> RevokeSaleV1Cpi<'a> { - RevokeSaleV1Cpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = RevokeSaleV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -693,7 +824,11 @@ impl<'a> RevokeSaleV1CpiBuilder<'a> { authorization_rules_program: self.instruction.authorization_rules_program, authorization_rules: self.instruction.authorization_rules, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -713,4 +848,5 @@ struct RevokeSaleV1CpiBuilderInstruction<'a> { spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/revoke_staking_v1.rs b/clients/rust/src/generated/instructions/revoke_staking_v1.rs index 803c22a5..abdf9889 100644 --- a/clients/rust/src/generated/instructions/revoke_staking_v1.rs +++ b/clients/rust/src/generated/instructions/revoke_staking_v1.rs @@ -41,9 +41,15 @@ pub struct RevokeStakingV1 { } impl RevokeStakingV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -139,6 +145,9 @@ impl RevokeStakingV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeStakingV1InstructionData::new().try_to_vec().unwrap(); solana_program::instruction::Instruction { @@ -181,6 +190,7 @@ pub struct RevokeStakingV1Builder { spl_token_program: Option, authorization_rules_program: Option, authorization_rules: Option, + __remaining_accounts: Vec, } impl RevokeStakingV1Builder { @@ -192,9 +202,9 @@ impl RevokeStakingV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -212,15 +222,21 @@ impl RevokeStakingV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -247,12 +263,14 @@ impl RevokeStakingV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -267,9 +285,9 @@ impl RevokeStakingV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -277,9 +295,9 @@ impl RevokeStakingV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -287,13 +305,23 @@ impl RevokeStakingV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = RevokeStakingV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -315,10 +343,42 @@ impl RevokeStakingV1Builder { authorization_rules: self.authorization_rules, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `revoke_staking_v1` CPI accounts. +pub struct RevokeStakingV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `revoke_staking_v1` CPI instruction. pub struct RevokeStakingV1Cpi<'a> { /// The program to invoke. @@ -354,16 +414,54 @@ pub struct RevokeStakingV1Cpi<'a> { } impl<'a> RevokeStakingV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: RevokeStakingV1CpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -462,6 +560,9 @@ impl<'a> RevokeStakingV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeStakingV1InstructionData::new().try_to_vec().unwrap(); let instruction = solana_program::instruction::Instruction { @@ -469,7 +570,7 @@ impl<'a> RevokeStakingV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -497,6 +598,9 @@ impl<'a> RevokeStakingV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -529,6 +633,7 @@ impl<'a> RevokeStakingV1CpiBuilder<'a> { spl_token_program: None, authorization_rules_program: None, authorization_rules: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -537,9 +642,9 @@ impl<'a> RevokeStakingV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -565,9 +670,9 @@ impl<'a> RevokeStakingV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -575,9 +680,9 @@ impl<'a> RevokeStakingV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -630,9 +735,9 @@ impl<'a> RevokeStakingV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -640,9 +745,9 @@ impl<'a> RevokeStakingV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -650,14 +755,40 @@ impl<'a> RevokeStakingV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> RevokeStakingV1Cpi<'a> { - RevokeStakingV1Cpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = RevokeStakingV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -693,7 +824,11 @@ impl<'a> RevokeStakingV1CpiBuilder<'a> { authorization_rules_program: self.instruction.authorization_rules_program, authorization_rules: self.instruction.authorization_rules, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -713,4 +848,5 @@ struct RevokeStakingV1CpiBuilderInstruction<'a> { spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/revoke_standard_v1.rs b/clients/rust/src/generated/instructions/revoke_standard_v1.rs index 34f468ee..516a0507 100644 --- a/clients/rust/src/generated/instructions/revoke_standard_v1.rs +++ b/clients/rust/src/generated/instructions/revoke_standard_v1.rs @@ -41,9 +41,15 @@ pub struct RevokeStandardV1 { } impl RevokeStandardV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -139,6 +145,9 @@ impl RevokeStandardV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeStandardV1InstructionData::new().try_to_vec().unwrap(); solana_program::instruction::Instruction { @@ -181,6 +190,7 @@ pub struct RevokeStandardV1Builder { spl_token_program: Option, authorization_rules_program: Option, authorization_rules: Option, + __remaining_accounts: Vec, } impl RevokeStandardV1Builder { @@ -192,9 +202,9 @@ impl RevokeStandardV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -212,15 +222,21 @@ impl RevokeStandardV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -247,12 +263,14 @@ impl RevokeStandardV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -267,9 +285,9 @@ impl RevokeStandardV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -277,9 +295,9 @@ impl RevokeStandardV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -287,13 +305,23 @@ impl RevokeStandardV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = RevokeStandardV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -315,10 +343,42 @@ impl RevokeStandardV1Builder { authorization_rules: self.authorization_rules, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `revoke_standard_v1` CPI accounts. +pub struct RevokeStandardV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `revoke_standard_v1` CPI instruction. pub struct RevokeStandardV1Cpi<'a> { /// The program to invoke. @@ -354,16 +414,54 @@ pub struct RevokeStandardV1Cpi<'a> { } impl<'a> RevokeStandardV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: RevokeStandardV1CpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -462,6 +560,9 @@ impl<'a> RevokeStandardV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeStandardV1InstructionData::new().try_to_vec().unwrap(); let instruction = solana_program::instruction::Instruction { @@ -469,7 +570,7 @@ impl<'a> RevokeStandardV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -497,6 +598,9 @@ impl<'a> RevokeStandardV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -529,6 +633,7 @@ impl<'a> RevokeStandardV1CpiBuilder<'a> { spl_token_program: None, authorization_rules_program: None, authorization_rules: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -537,9 +642,9 @@ impl<'a> RevokeStandardV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -565,9 +670,9 @@ impl<'a> RevokeStandardV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -575,9 +680,9 @@ impl<'a> RevokeStandardV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -630,9 +735,9 @@ impl<'a> RevokeStandardV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -640,9 +745,9 @@ impl<'a> RevokeStandardV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -650,14 +755,40 @@ impl<'a> RevokeStandardV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> RevokeStandardV1Cpi<'a> { - RevokeStandardV1Cpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = RevokeStandardV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -693,7 +824,11 @@ impl<'a> RevokeStandardV1CpiBuilder<'a> { authorization_rules_program: self.instruction.authorization_rules_program, authorization_rules: self.instruction.authorization_rules, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -713,4 +848,5 @@ struct RevokeStandardV1CpiBuilderInstruction<'a> { spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/revoke_transfer_v1.rs b/clients/rust/src/generated/instructions/revoke_transfer_v1.rs index 7b763235..0a15aeb4 100644 --- a/clients/rust/src/generated/instructions/revoke_transfer_v1.rs +++ b/clients/rust/src/generated/instructions/revoke_transfer_v1.rs @@ -41,9 +41,15 @@ pub struct RevokeTransferV1 { } impl RevokeTransferV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -139,6 +145,9 @@ impl RevokeTransferV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeTransferV1InstructionData::new().try_to_vec().unwrap(); solana_program::instruction::Instruction { @@ -181,6 +190,7 @@ pub struct RevokeTransferV1Builder { spl_token_program: Option, authorization_rules_program: Option, authorization_rules: Option, + __remaining_accounts: Vec, } impl RevokeTransferV1Builder { @@ -192,9 +202,9 @@ impl RevokeTransferV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -212,15 +222,21 @@ impl RevokeTransferV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -247,12 +263,14 @@ impl RevokeTransferV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -267,9 +285,9 @@ impl RevokeTransferV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -277,9 +295,9 @@ impl RevokeTransferV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -287,13 +305,23 @@ impl RevokeTransferV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = RevokeTransferV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -315,10 +343,42 @@ impl RevokeTransferV1Builder { authorization_rules: self.authorization_rules, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `revoke_transfer_v1` CPI accounts. +pub struct RevokeTransferV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `revoke_transfer_v1` CPI instruction. pub struct RevokeTransferV1Cpi<'a> { /// The program to invoke. @@ -354,16 +414,54 @@ pub struct RevokeTransferV1Cpi<'a> { } impl<'a> RevokeTransferV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: RevokeTransferV1CpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -462,6 +560,9 @@ impl<'a> RevokeTransferV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeTransferV1InstructionData::new().try_to_vec().unwrap(); let instruction = solana_program::instruction::Instruction { @@ -469,7 +570,7 @@ impl<'a> RevokeTransferV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -497,6 +598,9 @@ impl<'a> RevokeTransferV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -529,6 +633,7 @@ impl<'a> RevokeTransferV1CpiBuilder<'a> { spl_token_program: None, authorization_rules_program: None, authorization_rules: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -537,9 +642,9 @@ impl<'a> RevokeTransferV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -565,9 +670,9 @@ impl<'a> RevokeTransferV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -575,9 +680,9 @@ impl<'a> RevokeTransferV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -630,9 +735,9 @@ impl<'a> RevokeTransferV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -640,9 +745,9 @@ impl<'a> RevokeTransferV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -650,14 +755,40 @@ impl<'a> RevokeTransferV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> RevokeTransferV1Cpi<'a> { - RevokeTransferV1Cpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = RevokeTransferV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -693,7 +824,11 @@ impl<'a> RevokeTransferV1CpiBuilder<'a> { authorization_rules_program: self.instruction.authorization_rules_program, authorization_rules: self.instruction.authorization_rules, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -713,4 +848,5 @@ struct RevokeTransferV1CpiBuilderInstruction<'a> { spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/revoke_use_authority.rs b/clients/rust/src/generated/instructions/revoke_use_authority.rs index ff891144..e672740c 100644 --- a/clients/rust/src/generated/instructions/revoke_use_authority.rs +++ b/clients/rust/src/generated/instructions/revoke_use_authority.rs @@ -31,9 +31,15 @@ pub struct RevokeUseAuthority { } impl RevokeUseAuthority { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(9); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.use_authority_record, false, @@ -68,6 +74,9 @@ impl RevokeUseAuthority { rent, false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeUseAuthorityInstructionData::new() .try_to_vec() .unwrap(); @@ -103,6 +112,7 @@ pub struct RevokeUseAuthorityBuilder { token_program: Option, system_program: Option, rent: Option, + __remaining_accounts: Vec, } impl RevokeUseAuthorityBuilder { @@ -151,12 +161,14 @@ impl RevokeUseAuthorityBuilder { self.metadata = Some(metadata); self } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` /// Token program #[inline(always)] pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self { self.token_program = Some(token_program); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { @@ -166,12 +178,22 @@ impl RevokeUseAuthorityBuilder { /// `[optional account]` /// Rent info #[inline(always)] - pub fn rent(&mut self, rent: solana_program::pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); + pub fn rent(&mut self, rent: Option) -> &mut Self { + self.rent = rent; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = RevokeUseAuthority { use_authority_record: self .use_authority_record @@ -192,10 +214,32 @@ impl RevokeUseAuthorityBuilder { rent: self.rent, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `revoke_use_authority` CPI accounts. +pub struct RevokeUseAuthorityCpiAccounts<'a> { + /// Use Authority Record PDA + pub use_authority_record: &'a solana_program::account_info::AccountInfo<'a>, + /// Owner + pub owner: &'a solana_program::account_info::AccountInfo<'a>, + /// A Use Authority + pub user: &'a solana_program::account_info::AccountInfo<'a>, + /// Owned Token Account Of Mint + pub owner_token_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of Metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Token program + pub token_program: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Rent info + pub rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `revoke_use_authority` CPI instruction. pub struct RevokeUseAuthorityCpi<'a> { /// The program to invoke. @@ -221,16 +265,49 @@ pub struct RevokeUseAuthorityCpi<'a> { } impl<'a> RevokeUseAuthorityCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: RevokeUseAuthorityCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + use_authority_record: accounts.use_authority_record, + owner: accounts.owner, + user: accounts.user, + owner_token_account: accounts.owner_token_account, + mint: accounts.mint, + metadata: accounts.metadata, + token_program: accounts.token_program, + system_program: accounts.system_program, + rent: accounts.rent, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(9); + let mut accounts = Vec::with_capacity(9 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.use_authority_record.key, false, @@ -268,6 +345,9 @@ impl<'a> RevokeUseAuthorityCpi<'a> { *rent.key, false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeUseAuthorityInstructionData::new() .try_to_vec() .unwrap(); @@ -277,7 +357,7 @@ impl<'a> RevokeUseAuthorityCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(9 + 1); + let mut account_infos = Vec::with_capacity(9 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.use_authority_record.clone()); account_infos.push(self.owner.clone()); @@ -290,6 +370,9 @@ impl<'a> RevokeUseAuthorityCpi<'a> { if let Some(rent) = self.rent { account_infos.push(rent.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -317,6 +400,7 @@ impl<'a> RevokeUseAuthorityCpiBuilder<'a> { token_program: None, system_program: None, rent: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -386,13 +470,42 @@ impl<'a> RevokeUseAuthorityCpiBuilder<'a> { /// `[optional account]` /// Rent info #[inline(always)] - pub fn rent(&mut self, rent: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); + pub fn rent( + &mut self, + rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.rent = rent; self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> RevokeUseAuthorityCpi<'a> { - RevokeUseAuthorityCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = RevokeUseAuthorityCpi { __program: self.instruction.__program, use_authority_record: self @@ -424,7 +537,11 @@ impl<'a> RevokeUseAuthorityCpiBuilder<'a> { .expect("system_program is not set"), rent: self.instruction.rent, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -439,4 +556,5 @@ struct RevokeUseAuthorityCpiBuilderInstruction<'a> { token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, system_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, rent: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/revoke_utility_v1.rs b/clients/rust/src/generated/instructions/revoke_utility_v1.rs index 01d87bf1..f8e6cfb1 100644 --- a/clients/rust/src/generated/instructions/revoke_utility_v1.rs +++ b/clients/rust/src/generated/instructions/revoke_utility_v1.rs @@ -41,9 +41,15 @@ pub struct RevokeUtilityV1 { } impl RevokeUtilityV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(14); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( delegate_record, @@ -139,6 +145,9 @@ impl RevokeUtilityV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeUtilityV1InstructionData::new().try_to_vec().unwrap(); solana_program::instruction::Instruction { @@ -181,6 +190,7 @@ pub struct RevokeUtilityV1Builder { spl_token_program: Option, authorization_rules_program: Option, authorization_rules: Option, + __remaining_accounts: Vec, } impl RevokeUtilityV1Builder { @@ -192,9 +202,9 @@ impl RevokeUtilityV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -212,15 +222,21 @@ impl RevokeUtilityV1Builder { /// `[optional account]` /// Master Edition account #[inline(always)] - pub fn master_edition(&mut self, master_edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.master_edition = Some(master_edition); + pub fn master_edition( + &mut self, + master_edition: Option, + ) -> &mut Self { + self.master_edition = master_edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Mint of metadata @@ -247,12 +263,14 @@ impl RevokeUtilityV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -267,9 +285,9 @@ impl RevokeUtilityV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -277,9 +295,9 @@ impl RevokeUtilityV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -287,13 +305,23 @@ impl RevokeUtilityV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = RevokeUtilityV1 { delegate_record: self.delegate_record, delegate: self.delegate.expect("delegate is not set"), @@ -315,10 +343,42 @@ impl RevokeUtilityV1Builder { authorization_rules: self.authorization_rules, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `revoke_utility_v1` CPI accounts. +pub struct RevokeUtilityV1CpiAccounts<'a> { + /// Delegate record account + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner of the delegated account + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Master Edition account + pub master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint of metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account of mint + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Update authority or token owner + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `revoke_utility_v1` CPI instruction. pub struct RevokeUtilityV1Cpi<'a> { /// The program to invoke. @@ -354,16 +414,54 @@ pub struct RevokeUtilityV1Cpi<'a> { } impl<'a> RevokeUtilityV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: RevokeUtilityV1CpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + delegate_record: accounts.delegate_record, + delegate: accounts.delegate, + metadata: accounts.metadata, + master_edition: accounts.master_edition, + token_record: accounts.token_record, + mint: accounts.mint, + token: accounts.token, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(14); + let mut accounts = Vec::with_capacity(14 + remaining_accounts.len()); if let Some(delegate_record) = self.delegate_record { accounts.push(solana_program::instruction::AccountMeta::new( *delegate_record.key, @@ -462,6 +560,9 @@ impl<'a> RevokeUtilityV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = RevokeUtilityV1InstructionData::new().try_to_vec().unwrap(); let instruction = solana_program::instruction::Instruction { @@ -469,7 +570,7 @@ impl<'a> RevokeUtilityV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(14 + 1); + let mut account_infos = Vec::with_capacity(14 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); if let Some(delegate_record) = self.delegate_record { account_infos.push(delegate_record.clone()); @@ -497,6 +598,9 @@ impl<'a> RevokeUtilityV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -529,6 +633,7 @@ impl<'a> RevokeUtilityV1CpiBuilder<'a> { spl_token_program: None, authorization_rules_program: None, authorization_rules: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -537,9 +642,9 @@ impl<'a> RevokeUtilityV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Owner of the delegated account @@ -565,9 +670,9 @@ impl<'a> RevokeUtilityV1CpiBuilder<'a> { #[inline(always)] pub fn master_edition( &mut self, - master_edition: &'a solana_program::account_info::AccountInfo<'a>, + master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.master_edition = Some(master_edition); + self.instruction.master_edition = master_edition; self } /// `[optional account]` @@ -575,9 +680,9 @@ impl<'a> RevokeUtilityV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Mint of metadata @@ -630,9 +735,9 @@ impl<'a> RevokeUtilityV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -640,9 +745,9 @@ impl<'a> RevokeUtilityV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -650,14 +755,40 @@ impl<'a> RevokeUtilityV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> RevokeUtilityV1Cpi<'a> { - RevokeUtilityV1Cpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = RevokeUtilityV1Cpi { __program: self.instruction.__program, delegate_record: self.instruction.delegate_record, @@ -693,7 +824,11 @@ impl<'a> RevokeUtilityV1CpiBuilder<'a> { authorization_rules_program: self.instruction.authorization_rules_program, authorization_rules: self.instruction.authorization_rules, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -713,4 +848,5 @@ struct RevokeUtilityV1CpiBuilderInstruction<'a> { spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/set_and_verify_collection.rs b/clients/rust/src/generated/instructions/set_and_verify_collection.rs index df987ba5..7ee4597d 100644 --- a/clients/rust/src/generated/instructions/set_and_verify_collection.rs +++ b/clients/rust/src/generated/instructions/set_and_verify_collection.rs @@ -29,9 +29,15 @@ pub struct SetAndVerifyCollection { } impl SetAndVerifyCollection { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(8); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.metadata, false, @@ -65,6 +71,9 @@ impl SetAndVerifyCollection { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = SetAndVerifyCollectionInstructionData::new() .try_to_vec() .unwrap(); @@ -99,6 +108,7 @@ pub struct SetAndVerifyCollectionBuilder { collection: Option, collection_master_edition_account: Option, collection_authority_record: Option, + __remaining_accounts: Vec, } impl SetAndVerifyCollectionBuilder { @@ -164,13 +174,23 @@ impl SetAndVerifyCollectionBuilder { #[inline(always)] pub fn collection_authority_record( &mut self, - collection_authority_record: solana_program::pubkey::Pubkey, + collection_authority_record: Option, ) -> &mut Self { - self.collection_authority_record = Some(collection_authority_record); + self.collection_authority_record = collection_authority_record; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = SetAndVerifyCollection { metadata: self.metadata.expect("metadata is not set"), collection_authority: self @@ -186,10 +206,30 @@ impl SetAndVerifyCollectionBuilder { collection_authority_record: self.collection_authority_record, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `set_and_verify_collection` CPI accounts. +pub struct SetAndVerifyCollectionCpiAccounts<'a> { + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Collection Update authority + pub collection_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// Update Authority of Collection NFT and NFT + pub update_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of the Collection + pub collection_mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata Account of the Collection + pub collection: &'a solana_program::account_info::AccountInfo<'a>, + /// MasterEdition2 Account of the Collection Token + pub collection_master_edition_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Collection Authority Record PDA + pub collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `set_and_verify_collection` CPI instruction. pub struct SetAndVerifyCollectionCpi<'a> { /// The program to invoke. @@ -213,16 +253,48 @@ pub struct SetAndVerifyCollectionCpi<'a> { } impl<'a> SetAndVerifyCollectionCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: SetAndVerifyCollectionCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + metadata: accounts.metadata, + collection_authority: accounts.collection_authority, + payer: accounts.payer, + update_authority: accounts.update_authority, + collection_mint: accounts.collection_mint, + collection: accounts.collection, + collection_master_edition_account: accounts.collection_master_edition_account, + collection_authority_record: accounts.collection_authority_record, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8); + let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.metadata.key, false, @@ -257,6 +329,9 @@ impl<'a> SetAndVerifyCollectionCpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = SetAndVerifyCollectionInstructionData::new() .try_to_vec() .unwrap(); @@ -266,7 +341,7 @@ impl<'a> SetAndVerifyCollectionCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(8 + 1); + let mut account_infos = Vec::with_capacity(8 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.metadata.clone()); account_infos.push(self.collection_authority.clone()); @@ -278,6 +353,9 @@ impl<'a> SetAndVerifyCollectionCpi<'a> { if let Some(collection_authority_record) = self.collection_authority_record { account_infos.push(collection_authority_record.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -304,6 +382,7 @@ impl<'a> SetAndVerifyCollectionCpiBuilder<'a> { collection: None, collection_master_edition_account: None, collection_authority_record: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -373,14 +452,40 @@ impl<'a> SetAndVerifyCollectionCpiBuilder<'a> { #[inline(always)] pub fn collection_authority_record( &mut self, - collection_authority_record: &'a solana_program::account_info::AccountInfo<'a>, + collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.collection_authority_record = collection_authority_record; + self + } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, ) -> &mut Self { - self.instruction.collection_authority_record = Some(collection_authority_record); + self.instruction.__remaining_accounts.push(account); self } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> SetAndVerifyCollectionCpi<'a> { - SetAndVerifyCollectionCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = SetAndVerifyCollectionCpi { __program: self.instruction.__program, metadata: self.instruction.metadata.expect("metadata is not set"), @@ -410,7 +515,11 @@ impl<'a> SetAndVerifyCollectionCpiBuilder<'a> { .expect("collection_master_edition_account is not set"), collection_authority_record: self.instruction.collection_authority_record, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -424,4 +533,5 @@ struct SetAndVerifyCollectionCpiBuilderInstruction<'a> { collection: Option<&'a solana_program::account_info::AccountInfo<'a>>, collection_master_edition_account: Option<&'a solana_program::account_info::AccountInfo<'a>>, collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/set_and_verify_sized_collection_item.rs b/clients/rust/src/generated/instructions/set_and_verify_sized_collection_item.rs index 7bd3efe4..a9fb5af5 100644 --- a/clients/rust/src/generated/instructions/set_and_verify_sized_collection_item.rs +++ b/clients/rust/src/generated/instructions/set_and_verify_sized_collection_item.rs @@ -29,9 +29,15 @@ pub struct SetAndVerifySizedCollectionItem { } impl SetAndVerifySizedCollectionItem { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(8); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.metadata, false, @@ -65,6 +71,9 @@ impl SetAndVerifySizedCollectionItem { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = SetAndVerifySizedCollectionItemInstructionData::new() .try_to_vec() .unwrap(); @@ -99,6 +108,7 @@ pub struct SetAndVerifySizedCollectionItemBuilder { collection: Option, collection_master_edition_account: Option, collection_authority_record: Option, + __remaining_accounts: Vec, } impl SetAndVerifySizedCollectionItemBuilder { @@ -164,13 +174,23 @@ impl SetAndVerifySizedCollectionItemBuilder { #[inline(always)] pub fn collection_authority_record( &mut self, - collection_authority_record: solana_program::pubkey::Pubkey, + collection_authority_record: Option, ) -> &mut Self { - self.collection_authority_record = Some(collection_authority_record); + self.collection_authority_record = collection_authority_record; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = SetAndVerifySizedCollectionItem { metadata: self.metadata.expect("metadata is not set"), collection_authority: self @@ -186,10 +206,30 @@ impl SetAndVerifySizedCollectionItemBuilder { collection_authority_record: self.collection_authority_record, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `set_and_verify_sized_collection_item` CPI accounts. +pub struct SetAndVerifySizedCollectionItemCpiAccounts<'a> { + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Collection Update authority + pub collection_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// Update Authority of Collection NFT and NFT + pub update_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of the Collection + pub collection_mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata Account of the Collection + pub collection: &'a solana_program::account_info::AccountInfo<'a>, + /// MasterEdition2 Account of the Collection Token + pub collection_master_edition_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Collection Authority Record PDA + pub collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `set_and_verify_sized_collection_item` CPI instruction. pub struct SetAndVerifySizedCollectionItemCpi<'a> { /// The program to invoke. @@ -213,16 +253,48 @@ pub struct SetAndVerifySizedCollectionItemCpi<'a> { } impl<'a> SetAndVerifySizedCollectionItemCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: SetAndVerifySizedCollectionItemCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + metadata: accounts.metadata, + collection_authority: accounts.collection_authority, + payer: accounts.payer, + update_authority: accounts.update_authority, + collection_mint: accounts.collection_mint, + collection: accounts.collection, + collection_master_edition_account: accounts.collection_master_edition_account, + collection_authority_record: accounts.collection_authority_record, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8); + let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.metadata.key, false, @@ -257,6 +329,9 @@ impl<'a> SetAndVerifySizedCollectionItemCpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = SetAndVerifySizedCollectionItemInstructionData::new() .try_to_vec() .unwrap(); @@ -266,7 +341,7 @@ impl<'a> SetAndVerifySizedCollectionItemCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(8 + 1); + let mut account_infos = Vec::with_capacity(8 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.metadata.clone()); account_infos.push(self.collection_authority.clone()); @@ -278,6 +353,9 @@ impl<'a> SetAndVerifySizedCollectionItemCpi<'a> { if let Some(collection_authority_record) = self.collection_authority_record { account_infos.push(collection_authority_record.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -304,6 +382,7 @@ impl<'a> SetAndVerifySizedCollectionItemCpiBuilder<'a> { collection: None, collection_master_edition_account: None, collection_authority_record: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -373,14 +452,40 @@ impl<'a> SetAndVerifySizedCollectionItemCpiBuilder<'a> { #[inline(always)] pub fn collection_authority_record( &mut self, - collection_authority_record: &'a solana_program::account_info::AccountInfo<'a>, + collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.collection_authority_record = collection_authority_record; + self + } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, ) -> &mut Self { - self.instruction.collection_authority_record = Some(collection_authority_record); + self.instruction.__remaining_accounts.push(account); self } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> SetAndVerifySizedCollectionItemCpi<'a> { - SetAndVerifySizedCollectionItemCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = SetAndVerifySizedCollectionItemCpi { __program: self.instruction.__program, metadata: self.instruction.metadata.expect("metadata is not set"), @@ -410,7 +515,11 @@ impl<'a> SetAndVerifySizedCollectionItemCpiBuilder<'a> { .expect("collection_master_edition_account is not set"), collection_authority_record: self.instruction.collection_authority_record, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -424,4 +533,5 @@ struct SetAndVerifySizedCollectionItemCpiBuilderInstruction<'a> { collection: Option<&'a solana_program::account_info::AccountInfo<'a>>, collection_master_edition_account: Option<&'a solana_program::account_info::AccountInfo<'a>>, collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/set_collection_size.rs b/clients/rust/src/generated/instructions/set_collection_size.rs index 5288be0f..b9c974de 100644 --- a/clients/rust/src/generated/instructions/set_collection_size.rs +++ b/clients/rust/src/generated/instructions/set_collection_size.rs @@ -22,12 +22,19 @@ pub struct SetCollectionSize { } impl SetCollectionSize { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: SetCollectionSizeInstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(4); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: SetCollectionSizeInstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.collection_metadata, false, @@ -46,6 +53,9 @@ impl SetCollectionSize { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = SetCollectionSizeInstructionData::new() .try_to_vec() .unwrap(); @@ -71,7 +81,8 @@ impl SetCollectionSizeInstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SetCollectionSizeInstructionArgs { pub set_collection_size_args: SetCollectionSizeArgs, } @@ -84,6 +95,7 @@ pub struct SetCollectionSizeBuilder { collection_mint: Option, collection_authority_record: Option, set_collection_size_args: Option, + __remaining_accounts: Vec, } impl SetCollectionSizeBuilder { @@ -122,9 +134,9 @@ impl SetCollectionSizeBuilder { #[inline(always)] pub fn collection_authority_record( &mut self, - collection_authority_record: solana_program::pubkey::Pubkey, + collection_authority_record: Option, ) -> &mut Self { - self.collection_authority_record = Some(collection_authority_record); + self.collection_authority_record = collection_authority_record; self } #[inline(always)] @@ -135,8 +147,18 @@ impl SetCollectionSizeBuilder { self.set_collection_size_args = Some(set_collection_size_args); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = SetCollectionSize { collection_metadata: self .collection_metadata @@ -154,10 +176,22 @@ impl SetCollectionSizeBuilder { .expect("set_collection_size_args is not set"), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `set_collection_size` CPI accounts. +pub struct SetCollectionSizeCpiAccounts<'a> { + /// Collection Metadata account + pub collection_metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Collection Update authority + pub collection_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of the Collection + pub collection_mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Collection Authority Record PDA + pub collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `set_collection_size` CPI instruction. pub struct SetCollectionSizeCpi<'a> { /// The program to invoke. @@ -175,16 +209,46 @@ pub struct SetCollectionSizeCpi<'a> { } impl<'a> SetCollectionSizeCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: SetCollectionSizeCpiAccounts<'a>, + args: SetCollectionSizeInstructionArgs, + ) -> Self { + Self { + __program: program, + collection_metadata: accounts.collection_metadata, + collection_authority: accounts.collection_authority, + collection_mint: accounts.collection_mint, + collection_authority_record: accounts.collection_authority_record, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4); + let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.collection_metadata.key, false, @@ -203,6 +267,9 @@ impl<'a> SetCollectionSizeCpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = SetCollectionSizeInstructionData::new() .try_to_vec() .unwrap(); @@ -214,7 +281,7 @@ impl<'a> SetCollectionSizeCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(4 + 1); + let mut account_infos = Vec::with_capacity(4 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.collection_metadata.clone()); account_infos.push(self.collection_authority.clone()); @@ -222,6 +289,9 @@ impl<'a> SetCollectionSizeCpi<'a> { if let Some(collection_authority_record) = self.collection_authority_record { account_infos.push(collection_authority_record.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -245,6 +315,7 @@ impl<'a> SetCollectionSizeCpiBuilder<'a> { collection_mint: None, collection_authority_record: None, set_collection_size_args: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -280,9 +351,9 @@ impl<'a> SetCollectionSizeCpiBuilder<'a> { #[inline(always)] pub fn collection_authority_record( &mut self, - collection_authority_record: &'a solana_program::account_info::AccountInfo<'a>, + collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.collection_authority_record = Some(collection_authority_record); + self.instruction.collection_authority_record = collection_authority_record; self } #[inline(always)] @@ -293,8 +364,34 @@ impl<'a> SetCollectionSizeCpiBuilder<'a> { self.instruction.set_collection_size_args = Some(set_collection_size_args); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> SetCollectionSizeCpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = SetCollectionSizeInstructionArgs { set_collection_size_args: self .instruction @@ -302,8 +399,7 @@ impl<'a> SetCollectionSizeCpiBuilder<'a> { .clone() .expect("set_collection_size_args is not set"), }; - - SetCollectionSizeCpi { + let instruction = SetCollectionSizeCpi { __program: self.instruction.__program, collection_metadata: self @@ -323,7 +419,11 @@ impl<'a> SetCollectionSizeCpiBuilder<'a> { collection_authority_record: self.instruction.collection_authority_record, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -334,4 +434,5 @@ struct SetCollectionSizeCpiBuilderInstruction<'a> { collection_mint: Option<&'a solana_program::account_info::AccountInfo<'a>>, collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, set_collection_size_args: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/set_token_standard.rs b/clients/rust/src/generated/instructions/set_token_standard.rs index 9be7820a..39b69c0b 100644 --- a/clients/rust/src/generated/instructions/set_token_standard.rs +++ b/clients/rust/src/generated/instructions/set_token_standard.rs @@ -21,9 +21,15 @@ pub struct SetTokenStandard { } impl SetTokenStandard { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(4); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.metadata, false, @@ -40,6 +46,9 @@ impl SetTokenStandard { edition, false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = SetTokenStandardInstructionData::new().try_to_vec().unwrap(); solana_program::instruction::Instruction { @@ -68,6 +77,7 @@ pub struct SetTokenStandardBuilder { update_authority: Option, mint: Option, edition: Option, + __remaining_accounts: Vec, } impl SetTokenStandardBuilder { @@ -98,12 +108,22 @@ impl SetTokenStandardBuilder { /// `[optional account]` /// Edition account #[inline(always)] - pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.edition = Some(edition); + pub fn edition(&mut self, edition: Option) -> &mut Self { + self.edition = edition; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = SetTokenStandard { metadata: self.metadata.expect("metadata is not set"), update_authority: self.update_authority.expect("update_authority is not set"), @@ -111,10 +131,22 @@ impl SetTokenStandardBuilder { edition: self.edition, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `set_token_standard` CPI accounts. +pub struct SetTokenStandardCpiAccounts<'a> { + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata update authority + pub update_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint account + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition account + pub edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `set_token_standard` CPI instruction. pub struct SetTokenStandardCpi<'a> { /// The program to invoke. @@ -130,16 +162,44 @@ pub struct SetTokenStandardCpi<'a> { } impl<'a> SetTokenStandardCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: SetTokenStandardCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + metadata: accounts.metadata, + update_authority: accounts.update_authority, + mint: accounts.mint, + edition: accounts.edition, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4); + let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.metadata.key, false, @@ -158,6 +218,9 @@ impl<'a> SetTokenStandardCpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = SetTokenStandardInstructionData::new().try_to_vec().unwrap(); let instruction = solana_program::instruction::Instruction { @@ -165,7 +228,7 @@ impl<'a> SetTokenStandardCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(4 + 1); + let mut account_infos = Vec::with_capacity(4 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.metadata.clone()); account_infos.push(self.update_authority.clone()); @@ -173,6 +236,9 @@ impl<'a> SetTokenStandardCpi<'a> { if let Some(edition) = self.edition { account_infos.push(edition.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -195,6 +261,7 @@ impl<'a> SetTokenStandardCpiBuilder<'a> { update_authority: None, mint: None, edition: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -227,14 +294,40 @@ impl<'a> SetTokenStandardCpiBuilder<'a> { #[inline(always)] pub fn edition( &mut self, - edition: &'a solana_program::account_info::AccountInfo<'a>, + edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.edition = Some(edition); + self.instruction.edition = edition; self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> SetTokenStandardCpi<'a> { - SetTokenStandardCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = SetTokenStandardCpi { __program: self.instruction.__program, metadata: self.instruction.metadata.expect("metadata is not set"), @@ -247,7 +340,11 @@ impl<'a> SetTokenStandardCpiBuilder<'a> { mint: self.instruction.mint.expect("mint is not set"), edition: self.instruction.edition, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -257,4 +354,5 @@ struct SetTokenStandardCpiBuilderInstruction<'a> { update_authority: Option<&'a solana_program::account_info::AccountInfo<'a>>, mint: Option<&'a solana_program::account_info::AccountInfo<'a>>, edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/sign_metadata.rs b/clients/rust/src/generated/instructions/sign_metadata.rs index 05d00f69..1bdbfa77 100644 --- a/clients/rust/src/generated/instructions/sign_metadata.rs +++ b/clients/rust/src/generated/instructions/sign_metadata.rs @@ -17,9 +17,15 @@ pub struct SignMetadata { } impl SignMetadata { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(2); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.metadata, false, @@ -28,6 +34,9 @@ impl SignMetadata { self.creator, true, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = SignMetadataInstructionData::new().try_to_vec().unwrap(); solana_program::instruction::Instruction { @@ -54,6 +63,7 @@ impl SignMetadataInstructionData { pub struct SignMetadataBuilder { metadata: Option, creator: Option, + __remaining_accounts: Vec, } impl SignMetadataBuilder { @@ -72,17 +82,35 @@ impl SignMetadataBuilder { self.creator = Some(creator); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = SignMetadata { metadata: self.metadata.expect("metadata is not set"), creator: self.creator.expect("creator is not set"), }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `sign_metadata` CPI accounts. +pub struct SignMetadataCpiAccounts<'a> { + /// Metadata (pda of ['metadata', program id, mint id]) + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Creator + pub creator: &'a solana_program::account_info::AccountInfo<'a>, +} + /// `sign_metadata` CPI instruction. pub struct SignMetadataCpi<'a> { /// The program to invoke. @@ -94,16 +122,42 @@ pub struct SignMetadataCpi<'a> { } impl<'a> SignMetadataCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: SignMetadataCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + metadata: accounts.metadata, + creator: accounts.creator, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2); + let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.metadata.key, false, @@ -112,6 +166,9 @@ impl<'a> SignMetadataCpi<'a> { *self.creator.key, true, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = SignMetadataInstructionData::new().try_to_vec().unwrap(); let instruction = solana_program::instruction::Instruction { @@ -119,10 +176,13 @@ impl<'a> SignMetadataCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(2 + 1); + let mut account_infos = Vec::with_capacity(2 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.metadata.clone()); account_infos.push(self.creator.clone()); + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -143,6 +203,7 @@ impl<'a> SignMetadataCpiBuilder<'a> { __program: program, metadata: None, creator: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -164,15 +225,45 @@ impl<'a> SignMetadataCpiBuilder<'a> { self.instruction.creator = Some(creator); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> SignMetadataCpi<'a> { - SignMetadataCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = SignMetadataCpi { __program: self.instruction.__program, metadata: self.instruction.metadata.expect("metadata is not set"), creator: self.instruction.creator.expect("creator is not set"), - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -180,4 +271,5 @@ struct SignMetadataCpiBuilderInstruction<'a> { __program: &'a solana_program::account_info::AccountInfo<'a>, metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, creator: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/thaw_delegated_account.rs b/clients/rust/src/generated/instructions/thaw_delegated_account.rs index e322f6a8..39bd62f9 100644 --- a/clients/rust/src/generated/instructions/thaw_delegated_account.rs +++ b/clients/rust/src/generated/instructions/thaw_delegated_account.rs @@ -23,9 +23,15 @@ pub struct ThawDelegatedAccount { } impl ThawDelegatedAccount { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(5); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.delegate, true, @@ -45,6 +51,9 @@ impl ThawDelegatedAccount { self.token_program, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = ThawDelegatedAccountInstructionData::new() .try_to_vec() .unwrap(); @@ -76,6 +85,7 @@ pub struct ThawDelegatedAccountBuilder { edition: Option, mint: Option, token_program: Option, + __remaining_accounts: Vec, } impl ThawDelegatedAccountBuilder { @@ -106,14 +116,25 @@ impl ThawDelegatedAccountBuilder { self.mint = Some(mint); self } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` /// Token Program #[inline(always)] pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self { self.token_program = Some(token_program); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = ThawDelegatedAccount { delegate: self.delegate.expect("delegate is not set"), token_account: self.token_account.expect("token_account is not set"), @@ -124,10 +145,24 @@ impl ThawDelegatedAccountBuilder { )), }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `thaw_delegated_account` CPI accounts. +pub struct ThawDelegatedAccountCpiAccounts<'a> { + /// Delegate + pub delegate: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account to thaw + pub token_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition + pub edition: &'a solana_program::account_info::AccountInfo<'a>, + /// Token mint + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token Program + pub token_program: &'a solana_program::account_info::AccountInfo<'a>, +} + /// `thaw_delegated_account` CPI instruction. pub struct ThawDelegatedAccountCpi<'a> { /// The program to invoke. @@ -145,16 +180,45 @@ pub struct ThawDelegatedAccountCpi<'a> { } impl<'a> ThawDelegatedAccountCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: ThawDelegatedAccountCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + delegate: accounts.delegate, + token_account: accounts.token_account, + edition: accounts.edition, + mint: accounts.mint, + token_program: accounts.token_program, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5); + let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.delegate.key, true, @@ -175,6 +239,9 @@ impl<'a> ThawDelegatedAccountCpi<'a> { *self.token_program.key, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = ThawDelegatedAccountInstructionData::new() .try_to_vec() .unwrap(); @@ -184,13 +251,16 @@ impl<'a> ThawDelegatedAccountCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(5 + 1); + let mut account_infos = Vec::with_capacity(5 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.delegate.clone()); account_infos.push(self.token_account.clone()); account_infos.push(self.edition.clone()); account_infos.push(self.mint.clone()); account_infos.push(self.token_program.clone()); + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -214,6 +284,7 @@ impl<'a> ThawDelegatedAccountCpiBuilder<'a> { edition: None, mint: None, token_program: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -259,9 +330,35 @@ impl<'a> ThawDelegatedAccountCpiBuilder<'a> { self.instruction.token_program = Some(token_program); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> ThawDelegatedAccountCpi<'a> { - ThawDelegatedAccountCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = ThawDelegatedAccountCpi { __program: self.instruction.__program, delegate: self.instruction.delegate.expect("delegate is not set"), @@ -279,7 +376,11 @@ impl<'a> ThawDelegatedAccountCpiBuilder<'a> { .instruction .token_program .expect("token_program is not set"), - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -290,4 +391,5 @@ struct ThawDelegatedAccountCpiBuilderInstruction<'a> { edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, mint: Option<&'a solana_program::account_info::AccountInfo<'a>>, token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/transfer_out_of_escrow.rs b/clients/rust/src/generated/instructions/transfer_out_of_escrow.rs index f642b00e..59010acc 100644 --- a/clients/rust/src/generated/instructions/transfer_out_of_escrow.rs +++ b/clients/rust/src/generated/instructions/transfer_out_of_escrow.rs @@ -39,12 +39,19 @@ pub struct TransferOutOfEscrow { } impl TransferOutOfEscrow { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: TransferOutOfEscrowInstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(13); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: TransferOutOfEscrowInstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.escrow, false, @@ -97,6 +104,9 @@ impl TransferOutOfEscrow { authority, true, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = TransferOutOfEscrowInstructionData::new() .try_to_vec() .unwrap(); @@ -122,7 +132,8 @@ impl TransferOutOfEscrowInstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TransferOutOfEscrowInstructionArgs { pub amount: u64, } @@ -144,6 +155,7 @@ pub struct TransferOutOfEscrowBuilder { sysvar_instructions: Option, authority: Option, amount: Option, + __remaining_accounts: Vec, } impl TransferOutOfEscrowBuilder { @@ -198,24 +210,28 @@ impl TransferOutOfEscrowBuilder { self.escrow_account = Some(escrow_account); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` /// Associated Token program #[inline(always)] pub fn ata_program(&mut self, ata_program: solana_program::pubkey::Pubkey) -> &mut Self { self.ata_program = Some(ata_program); self } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` /// Token program #[inline(always)] pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self { self.token_program = Some(token_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -228,8 +244,8 @@ impl TransferOutOfEscrowBuilder { /// `[optional account]` /// Authority/creator of the escrow account #[inline(always)] - pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { - self.authority = Some(authority); + pub fn authority(&mut self, authority: Option) -> &mut Self { + self.authority = authority; self } /// `[optional argument, defaults to '1']` @@ -238,8 +254,18 @@ impl TransferOutOfEscrowBuilder { self.amount = Some(amount); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = TransferOutOfEscrow { escrow: self.escrow.expect("escrow is not set"), metadata: self.metadata.expect("metadata is not set"), @@ -267,10 +293,40 @@ impl TransferOutOfEscrowBuilder { amount: self.amount.clone().unwrap_or(1), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `transfer_out_of_escrow` CPI accounts. +pub struct TransferOutOfEscrowCpiAccounts<'a> { + /// Escrow account + pub escrow: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Wallet paying for the transaction and new account + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint account for the new attribute + pub attribute_mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account source for the new attribute + pub attribute_src: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account, owned by TM, destination for the new attribute + pub attribute_dst: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint account that the escrow is attached + pub escrow_mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account that holds the token the escrow is attached to + pub escrow_account: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Associated Token program + pub ata_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Token program + pub token_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// Authority/creator of the escrow account + pub authority: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `transfer_out_of_escrow` CPI instruction. pub struct TransferOutOfEscrowCpi<'a> { /// The program to invoke. @@ -306,16 +362,55 @@ pub struct TransferOutOfEscrowCpi<'a> { } impl<'a> TransferOutOfEscrowCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: TransferOutOfEscrowCpiAccounts<'a>, + args: TransferOutOfEscrowInstructionArgs, + ) -> Self { + Self { + __program: program, + escrow: accounts.escrow, + metadata: accounts.metadata, + payer: accounts.payer, + attribute_mint: accounts.attribute_mint, + attribute_src: accounts.attribute_src, + attribute_dst: accounts.attribute_dst, + escrow_mint: accounts.escrow_mint, + escrow_account: accounts.escrow_account, + system_program: accounts.system_program, + ata_program: accounts.ata_program, + token_program: accounts.token_program, + sysvar_instructions: accounts.sysvar_instructions, + authority: accounts.authority, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(13); + let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.escrow.key, false, @@ -370,6 +465,9 @@ impl<'a> TransferOutOfEscrowCpi<'a> { true, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = TransferOutOfEscrowInstructionData::new() .try_to_vec() .unwrap(); @@ -381,7 +479,7 @@ impl<'a> TransferOutOfEscrowCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(13 + 1); + let mut account_infos = Vec::with_capacity(13 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.escrow.clone()); account_infos.push(self.metadata.clone()); @@ -398,6 +496,9 @@ impl<'a> TransferOutOfEscrowCpi<'a> { if let Some(authority) = self.authority { account_infos.push(authority.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -430,6 +531,7 @@ impl<'a> TransferOutOfEscrowCpiBuilder<'a> { sysvar_instructions: None, authority: None, amount: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -543,9 +645,9 @@ impl<'a> TransferOutOfEscrowCpiBuilder<'a> { #[inline(always)] pub fn authority( &mut self, - authority: &'a solana_program::account_info::AccountInfo<'a>, + authority: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authority = Some(authority); + self.instruction.authority = authority; self } /// `[optional argument, defaults to '1']` @@ -554,13 +656,38 @@ impl<'a> TransferOutOfEscrowCpiBuilder<'a> { self.instruction.amount = Some(amount); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> TransferOutOfEscrowCpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = TransferOutOfEscrowInstructionArgs { amount: self.instruction.amount.clone().unwrap_or(1), }; - - TransferOutOfEscrowCpi { + let instruction = TransferOutOfEscrowCpi { __program: self.instruction.__program, escrow: self.instruction.escrow.expect("escrow is not set"), @@ -616,7 +743,11 @@ impl<'a> TransferOutOfEscrowCpiBuilder<'a> { authority: self.instruction.authority, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -636,4 +767,5 @@ struct TransferOutOfEscrowCpiBuilderInstruction<'a> { sysvar_instructions: Option<&'a solana_program::account_info::AccountInfo<'a>>, authority: Option<&'a solana_program::account_info::AccountInfo<'a>>, amount: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/transfer_v1.rs b/clients/rust/src/generated/instructions/transfer_v1.rs index 2256c740..135dcf0d 100644 --- a/clients/rust/src/generated/instructions/transfer_v1.rs +++ b/clients/rust/src/generated/instructions/transfer_v1.rs @@ -48,12 +48,19 @@ pub struct TransferV1 { } impl TransferV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: TransferV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(17); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: TransferV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(17 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.token, false, )); @@ -153,6 +160,9 @@ impl TransferV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = TransferV1InstructionData::new().try_to_vec().unwrap(); let mut args = args.try_to_vec().unwrap(); data.append(&mut args); @@ -180,7 +190,8 @@ impl TransferV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct TransferV1InstructionArgs { pub amount: u64, pub authorization_data: Option, @@ -208,6 +219,7 @@ pub struct TransferV1Builder { authorization_rules: Option, amount: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl TransferV1Builder { @@ -259,15 +271,18 @@ impl TransferV1Builder { /// `[optional account]` /// Edition of token asset #[inline(always)] - pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.edition = Some(edition); + pub fn edition(&mut self, edition: Option) -> &mut Self { + self.edition = edition; self } /// `[optional account]` /// Owner token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// `[optional account]` @@ -275,9 +290,9 @@ impl TransferV1Builder { #[inline(always)] pub fn destination_token_record( &mut self, - destination_token_record: solana_program::pubkey::Pubkey, + destination_token_record: Option, ) -> &mut Self { - self.destination_token_record = Some(destination_token_record); + self.destination_token_record = destination_token_record; self } /// Transfer authority (token owner or delegate) @@ -292,12 +307,14 @@ impl TransferV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System Program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -307,6 +324,7 @@ impl TransferV1Builder { self.sysvar_instructions = Some(sysvar_instructions); self } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` /// SPL Token Program #[inline(always)] pub fn spl_token_program( @@ -316,6 +334,7 @@ impl TransferV1Builder { self.spl_token_program = Some(spl_token_program); self } + /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` /// SPL Associated Token Account program #[inline(always)] pub fn spl_ata_program( @@ -330,9 +349,9 @@ impl TransferV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -340,9 +359,9 @@ impl TransferV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to '1']` @@ -357,8 +376,18 @@ impl TransferV1Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = TransferV1 { token: self.token.expect("token is not set"), token_owner: self.token_owner.expect("token_owner is not set"), @@ -395,10 +424,48 @@ impl TransferV1Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `transfer_v1` CPI accounts. +pub struct TransferV1CpiAccounts<'a> { + /// Token account + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Token account owner + pub token_owner: &'a solana_program::account_info::AccountInfo<'a>, + /// Destination token account + pub destination_token: &'a solana_program::account_info::AccountInfo<'a>, + /// Destination token account owner + pub destination_owner: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of token asset + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata (pda of ['metadata', program id, mint id]) + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition of token asset + pub edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Owner token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Destination token record account + pub destination_token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Transfer authority (token owner or delegate) + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System Program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Associated Token Account program + pub spl_ata_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `transfer_v1` CPI instruction. pub struct TransferV1Cpi<'a> { /// The program to invoke. @@ -442,16 +509,59 @@ pub struct TransferV1Cpi<'a> { } impl<'a> TransferV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: TransferV1CpiAccounts<'a>, + args: TransferV1InstructionArgs, + ) -> Self { + Self { + __program: program, + token: accounts.token, + token_owner: accounts.token_owner, + destination_token: accounts.destination_token, + destination_owner: accounts.destination_owner, + mint: accounts.mint, + metadata: accounts.metadata, + edition: accounts.edition, + token_record: accounts.token_record, + destination_token_record: accounts.destination_token_record, + authority: accounts.authority, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + spl_ata_program: accounts.spl_ata_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(17); + let mut accounts = Vec::with_capacity(17 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.token.key, false, @@ -555,6 +665,9 @@ impl<'a> TransferV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = TransferV1InstructionData::new().try_to_vec().unwrap(); let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); @@ -564,7 +677,7 @@ impl<'a> TransferV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(17 + 1); + let mut account_infos = Vec::with_capacity(17 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.token.clone()); account_infos.push(self.token_owner.clone()); @@ -593,6 +706,9 @@ impl<'a> TransferV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -630,6 +746,7 @@ impl<'a> TransferV1CpiBuilder<'a> { authorization_rules: None, amount: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -686,9 +803,9 @@ impl<'a> TransferV1CpiBuilder<'a> { #[inline(always)] pub fn edition( &mut self, - edition: &'a solana_program::account_info::AccountInfo<'a>, + edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.edition = Some(edition); + self.instruction.edition = edition; self } /// `[optional account]` @@ -696,9 +813,9 @@ impl<'a> TransferV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// `[optional account]` @@ -706,9 +823,9 @@ impl<'a> TransferV1CpiBuilder<'a> { #[inline(always)] pub fn destination_token_record( &mut self, - destination_token_record: &'a solana_program::account_info::AccountInfo<'a>, + destination_token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.destination_token_record = Some(destination_token_record); + self.instruction.destination_token_record = destination_token_record; self } /// Transfer authority (token owner or delegate) @@ -767,9 +884,9 @@ impl<'a> TransferV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -777,9 +894,9 @@ impl<'a> TransferV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to '1']` @@ -794,14 +911,39 @@ impl<'a> TransferV1CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> TransferV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = TransferV1InstructionArgs { amount: self.instruction.amount.clone().unwrap_or(1), authorization_data: self.instruction.authorization_data.clone(), }; - - TransferV1Cpi { + let instruction = TransferV1Cpi { __program: self.instruction.__program, token: self.instruction.token.expect("token is not set"), @@ -859,7 +1001,11 @@ impl<'a> TransferV1CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -884,4 +1030,5 @@ struct TransferV1CpiBuilderInstruction<'a> { authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, amount: Option, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/unlock_v1.rs b/clients/rust/src/generated/instructions/unlock_v1.rs index c48e2440..5c32e3cc 100644 --- a/clients/rust/src/generated/instructions/unlock_v1.rs +++ b/clients/rust/src/generated/instructions/unlock_v1.rs @@ -40,12 +40,19 @@ pub struct UnlockV1 { } impl UnlockV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: UnlockV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(13); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: UnlockV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, true, @@ -136,6 +143,9 @@ impl UnlockV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UnlockV1InstructionData::new().try_to_vec().unwrap(); let mut args = args.try_to_vec().unwrap(); data.append(&mut args); @@ -163,7 +173,8 @@ impl UnlockV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UnlockV1InstructionArgs { pub authorization_data: Option, } @@ -185,6 +196,7 @@ pub struct UnlockV1Builder { authorization_rules_program: Option, authorization_rules: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl UnlockV1Builder { @@ -200,8 +212,11 @@ impl UnlockV1Builder { /// `[optional account]` /// Token owner account #[inline(always)] - pub fn token_owner(&mut self, token_owner: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_owner = Some(token_owner); + pub fn token_owner( + &mut self, + token_owner: Option, + ) -> &mut Self { + self.token_owner = token_owner; self } /// Token account @@ -225,15 +240,18 @@ impl UnlockV1Builder { /// `[optional account]` /// Edition account #[inline(always)] - pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.edition = Some(edition); + pub fn edition(&mut self, edition: Option) -> &mut Self { + self.edition = edition; self } /// `[optional account]` /// Token record account #[inline(always)] - pub fn token_record(&mut self, token_record: solana_program::pubkey::Pubkey) -> &mut Self { - self.token_record = Some(token_record); + pub fn token_record( + &mut self, + token_record: Option, + ) -> &mut Self { + self.token_record = token_record; self } /// Payer @@ -242,12 +260,14 @@ impl UnlockV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// System program #[inline(always)] pub fn sysvar_instructions( @@ -262,9 +282,9 @@ impl UnlockV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -272,9 +292,9 @@ impl UnlockV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -282,9 +302,9 @@ impl UnlockV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -293,8 +313,18 @@ impl UnlockV1Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = UnlockV1 { authority: self.authority.expect("authority is not set"), token_owner: self.token_owner, @@ -318,10 +348,40 @@ impl UnlockV1Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `unlock_v1` CPI accounts. +pub struct UnlockV1CpiAccounts<'a> { + /// Delegate or freeze authority + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Token owner account + pub token_owner: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token account + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint account + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition account + pub edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token record account + pub token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `unlock_v1` CPI instruction. pub struct UnlockV1Cpi<'a> { /// The program to invoke. @@ -357,16 +417,55 @@ pub struct UnlockV1Cpi<'a> { } impl<'a> UnlockV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: UnlockV1CpiAccounts<'a>, + args: UnlockV1InstructionArgs, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + token_owner: accounts.token_owner, + token: accounts.token, + mint: accounts.mint, + metadata: accounts.metadata, + edition: accounts.edition, + token_record: accounts.token_record, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(13); + let mut accounts = Vec::with_capacity(13 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, true, @@ -461,6 +560,9 @@ impl<'a> UnlockV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UnlockV1InstructionData::new().try_to_vec().unwrap(); let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); @@ -470,7 +572,7 @@ impl<'a> UnlockV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(13 + 1); + let mut account_infos = Vec::with_capacity(13 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.authority.clone()); if let Some(token_owner) = self.token_owner { @@ -497,6 +599,9 @@ impl<'a> UnlockV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -529,6 +634,7 @@ impl<'a> UnlockV1CpiBuilder<'a> { authorization_rules_program: None, authorization_rules: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -546,9 +652,9 @@ impl<'a> UnlockV1CpiBuilder<'a> { #[inline(always)] pub fn token_owner( &mut self, - token_owner: &'a solana_program::account_info::AccountInfo<'a>, + token_owner: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_owner = Some(token_owner); + self.instruction.token_owner = token_owner; self } /// Token account @@ -577,9 +683,9 @@ impl<'a> UnlockV1CpiBuilder<'a> { #[inline(always)] pub fn edition( &mut self, - edition: &'a solana_program::account_info::AccountInfo<'a>, + edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.edition = Some(edition); + self.instruction.edition = edition; self } /// `[optional account]` @@ -587,9 +693,9 @@ impl<'a> UnlockV1CpiBuilder<'a> { #[inline(always)] pub fn token_record( &mut self, - token_record: &'a solana_program::account_info::AccountInfo<'a>, + token_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.token_record = Some(token_record); + self.instruction.token_record = token_record; self } /// Payer @@ -621,9 +727,9 @@ impl<'a> UnlockV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -631,9 +737,9 @@ impl<'a> UnlockV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -641,9 +747,9 @@ impl<'a> UnlockV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -652,13 +758,38 @@ impl<'a> UnlockV1CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> UnlockV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = UnlockV1InstructionArgs { authorization_data: self.instruction.authorization_data.clone(), }; - - UnlockV1Cpi { + let instruction = UnlockV1Cpi { __program: self.instruction.__program, authority: self.instruction.authority.expect("authority is not set"), @@ -693,7 +824,11 @@ impl<'a> UnlockV1CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -713,4 +848,5 @@ struct UnlockV1CpiBuilderInstruction<'a> { authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/unverify_collection.rs b/clients/rust/src/generated/instructions/unverify_collection.rs index 822c79e8..8876a92a 100644 --- a/clients/rust/src/generated/instructions/unverify_collection.rs +++ b/clients/rust/src/generated/instructions/unverify_collection.rs @@ -25,9 +25,15 @@ pub struct UnverifyCollection { } impl UnverifyCollection { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(6); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.metadata, false, @@ -54,6 +60,9 @@ impl UnverifyCollection { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = UnverifyCollectionInstructionData::new() .try_to_vec() .unwrap(); @@ -86,6 +95,7 @@ pub struct UnverifyCollectionBuilder { collection: Option, collection_master_edition_account: Option, collection_authority_record: Option, + __remaining_accounts: Vec, } impl UnverifyCollectionBuilder { @@ -136,13 +146,23 @@ impl UnverifyCollectionBuilder { #[inline(always)] pub fn collection_authority_record( &mut self, - collection_authority_record: solana_program::pubkey::Pubkey, + collection_authority_record: Option, ) -> &mut Self { - self.collection_authority_record = Some(collection_authority_record); + self.collection_authority_record = collection_authority_record; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = UnverifyCollection { metadata: self.metadata.expect("metadata is not set"), collection_authority: self @@ -156,10 +176,26 @@ impl UnverifyCollectionBuilder { collection_authority_record: self.collection_authority_record, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `unverify_collection` CPI accounts. +pub struct UnverifyCollectionCpiAccounts<'a> { + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Collection Authority + pub collection_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of the Collection + pub collection_mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata Account of the Collection + pub collection: &'a solana_program::account_info::AccountInfo<'a>, + /// MasterEdition2 Account of the Collection Token + pub collection_master_edition_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Collection Authority Record PDA + pub collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `unverify_collection` CPI instruction. pub struct UnverifyCollectionCpi<'a> { /// The program to invoke. @@ -179,16 +215,46 @@ pub struct UnverifyCollectionCpi<'a> { } impl<'a> UnverifyCollectionCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: UnverifyCollectionCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + metadata: accounts.metadata, + collection_authority: accounts.collection_authority, + collection_mint: accounts.collection_mint, + collection: accounts.collection, + collection_master_edition_account: accounts.collection_master_edition_account, + collection_authority_record: accounts.collection_authority_record, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(6); + let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.metadata.key, false, @@ -215,6 +281,9 @@ impl<'a> UnverifyCollectionCpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = UnverifyCollectionInstructionData::new() .try_to_vec() .unwrap(); @@ -224,7 +293,7 @@ impl<'a> UnverifyCollectionCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(6 + 1); + let mut account_infos = Vec::with_capacity(6 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.metadata.clone()); account_infos.push(self.collection_authority.clone()); @@ -234,6 +303,9 @@ impl<'a> UnverifyCollectionCpi<'a> { if let Some(collection_authority_record) = self.collection_authority_record { account_infos.push(collection_authority_record.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -258,6 +330,7 @@ impl<'a> UnverifyCollectionCpiBuilder<'a> { collection: None, collection_master_edition_account: None, collection_authority_record: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -312,14 +385,40 @@ impl<'a> UnverifyCollectionCpiBuilder<'a> { #[inline(always)] pub fn collection_authority_record( &mut self, - collection_authority_record: &'a solana_program::account_info::AccountInfo<'a>, + collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.collection_authority_record = collection_authority_record; + self + } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, ) -> &mut Self { - self.instruction.collection_authority_record = Some(collection_authority_record); + self.instruction.__remaining_accounts.push(account); self } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> UnverifyCollectionCpi<'a> { - UnverifyCollectionCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = UnverifyCollectionCpi { __program: self.instruction.__program, metadata: self.instruction.metadata.expect("metadata is not set"), @@ -342,7 +441,11 @@ impl<'a> UnverifyCollectionCpiBuilder<'a> { .expect("collection_master_edition_account is not set"), collection_authority_record: self.instruction.collection_authority_record, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -354,4 +457,5 @@ struct UnverifyCollectionCpiBuilderInstruction<'a> { collection: Option<&'a solana_program::account_info::AccountInfo<'a>>, collection_master_edition_account: Option<&'a solana_program::account_info::AccountInfo<'a>>, collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/unverify_collection_v1.rs b/clients/rust/src/generated/instructions/unverify_collection_v1.rs index 6711c6ef..1ff309d4 100644 --- a/clients/rust/src/generated/instructions/unverify_collection_v1.rs +++ b/clients/rust/src/generated/instructions/unverify_collection_v1.rs @@ -27,9 +27,15 @@ pub struct UnverifyCollectionV1 { } impl UnverifyCollectionV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(7); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, true, @@ -72,6 +78,9 @@ impl UnverifyCollectionV1 { self.sysvar_instructions, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = UnverifyCollectionV1InstructionData::new() .try_to_vec() .unwrap(); @@ -109,6 +118,7 @@ pub struct UnverifyCollectionV1Builder { collection_metadata: Option, system_program: Option, sysvar_instructions: Option, + __remaining_accounts: Vec, } impl UnverifyCollectionV1Builder { @@ -126,9 +136,9 @@ impl UnverifyCollectionV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Metadata account @@ -151,17 +161,19 @@ impl UnverifyCollectionV1Builder { #[inline(always)] pub fn collection_metadata( &mut self, - collection_metadata: solana_program::pubkey::Pubkey, + collection_metadata: Option, ) -> &mut Self { - self.collection_metadata = Some(collection_metadata); + self.collection_metadata = collection_metadata; self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -171,8 +183,18 @@ impl UnverifyCollectionV1Builder { self.sysvar_instructions = Some(sysvar_instructions); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = UnverifyCollectionV1 { authority: self.authority.expect("authority is not set"), delegate_record: self.delegate_record, @@ -187,10 +209,28 @@ impl UnverifyCollectionV1Builder { )), }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `unverify_collection_v1` CPI accounts. +pub struct UnverifyCollectionV1CpiAccounts<'a> { + /// Creator to verify, collection (or metadata if parent burned) update authority or delegate + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Delegate record PDA + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of the Collection + pub collection_mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata Account of the Collection + pub collection_metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, +} + /// `unverify_collection_v1` CPI instruction. pub struct UnverifyCollectionV1Cpi<'a> { /// The program to invoke. @@ -212,16 +252,47 @@ pub struct UnverifyCollectionV1Cpi<'a> { } impl<'a> UnverifyCollectionV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: UnverifyCollectionV1CpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + delegate_record: accounts.delegate_record, + metadata: accounts.metadata, + collection_mint: accounts.collection_mint, + collection_metadata: accounts.collection_metadata, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7); + let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, true, @@ -264,6 +335,9 @@ impl<'a> UnverifyCollectionV1Cpi<'a> { *self.sysvar_instructions.key, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = UnverifyCollectionV1InstructionData::new() .try_to_vec() .unwrap(); @@ -273,7 +347,7 @@ impl<'a> UnverifyCollectionV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(7 + 1); + let mut account_infos = Vec::with_capacity(7 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.authority.clone()); if let Some(delegate_record) = self.delegate_record { @@ -286,6 +360,9 @@ impl<'a> UnverifyCollectionV1Cpi<'a> { } account_infos.push(self.system_program.clone()); account_infos.push(self.sysvar_instructions.clone()); + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -311,6 +388,7 @@ impl<'a> UnverifyCollectionV1CpiBuilder<'a> { collection_metadata: None, system_program: None, sysvar_instructions: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -328,9 +406,9 @@ impl<'a> UnverifyCollectionV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Metadata account @@ -356,9 +434,9 @@ impl<'a> UnverifyCollectionV1CpiBuilder<'a> { #[inline(always)] pub fn collection_metadata( &mut self, - collection_metadata: &'a solana_program::account_info::AccountInfo<'a>, + collection_metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.collection_metadata = Some(collection_metadata); + self.instruction.collection_metadata = collection_metadata; self } /// System program @@ -379,9 +457,35 @@ impl<'a> UnverifyCollectionV1CpiBuilder<'a> { self.instruction.sysvar_instructions = Some(sysvar_instructions); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> UnverifyCollectionV1Cpi<'a> { - UnverifyCollectionV1Cpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = UnverifyCollectionV1Cpi { __program: self.instruction.__program, authority: self.instruction.authority.expect("authority is not set"), @@ -406,7 +510,11 @@ impl<'a> UnverifyCollectionV1CpiBuilder<'a> { .instruction .sysvar_instructions .expect("sysvar_instructions is not set"), - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -419,4 +527,5 @@ struct UnverifyCollectionV1CpiBuilderInstruction<'a> { collection_metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, system_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, sysvar_instructions: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/unverify_creator_v1.rs b/clients/rust/src/generated/instructions/unverify_creator_v1.rs index 89469179..f93a3da5 100644 --- a/clients/rust/src/generated/instructions/unverify_creator_v1.rs +++ b/clients/rust/src/generated/instructions/unverify_creator_v1.rs @@ -27,9 +27,15 @@ pub struct UnverifyCreatorV1 { } impl UnverifyCreatorV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(7); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, true, @@ -79,6 +85,9 @@ impl UnverifyCreatorV1 { self.sysvar_instructions, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = UnverifyCreatorV1InstructionData::new() .try_to_vec() .unwrap(); @@ -116,6 +125,7 @@ pub struct UnverifyCreatorV1Builder { collection_metadata: Option, system_program: Option, sysvar_instructions: Option, + __remaining_accounts: Vec, } impl UnverifyCreatorV1Builder { @@ -133,9 +143,9 @@ impl UnverifyCreatorV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Metadata account @@ -149,9 +159,9 @@ impl UnverifyCreatorV1Builder { #[inline(always)] pub fn collection_mint( &mut self, - collection_mint: solana_program::pubkey::Pubkey, + collection_mint: Option, ) -> &mut Self { - self.collection_mint = Some(collection_mint); + self.collection_mint = collection_mint; self } /// `[optional account]` @@ -159,17 +169,19 @@ impl UnverifyCreatorV1Builder { #[inline(always)] pub fn collection_metadata( &mut self, - collection_metadata: solana_program::pubkey::Pubkey, + collection_metadata: Option, ) -> &mut Self { - self.collection_metadata = Some(collection_metadata); + self.collection_metadata = collection_metadata; self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -179,8 +191,18 @@ impl UnverifyCreatorV1Builder { self.sysvar_instructions = Some(sysvar_instructions); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = UnverifyCreatorV1 { authority: self.authority.expect("authority is not set"), delegate_record: self.delegate_record, @@ -195,10 +217,28 @@ impl UnverifyCreatorV1Builder { )), }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `unverify_creator_v1` CPI accounts. +pub struct UnverifyCreatorV1CpiAccounts<'a> { + /// Creator to verify, collection (or metadata if parent burned) update authority or delegate + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Delegate record PDA + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of the Collection + pub collection_mint: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Metadata Account of the Collection + pub collection_metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, +} + /// `unverify_creator_v1` CPI instruction. pub struct UnverifyCreatorV1Cpi<'a> { /// The program to invoke. @@ -220,16 +260,47 @@ pub struct UnverifyCreatorV1Cpi<'a> { } impl<'a> UnverifyCreatorV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: UnverifyCreatorV1CpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + delegate_record: accounts.delegate_record, + metadata: accounts.metadata, + collection_mint: accounts.collection_mint, + collection_metadata: accounts.collection_metadata, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7); + let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, true, @@ -279,6 +350,9 @@ impl<'a> UnverifyCreatorV1Cpi<'a> { *self.sysvar_instructions.key, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = UnverifyCreatorV1InstructionData::new() .try_to_vec() .unwrap(); @@ -288,7 +362,7 @@ impl<'a> UnverifyCreatorV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(7 + 1); + let mut account_infos = Vec::with_capacity(7 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.authority.clone()); if let Some(delegate_record) = self.delegate_record { @@ -303,6 +377,9 @@ impl<'a> UnverifyCreatorV1Cpi<'a> { } account_infos.push(self.system_program.clone()); account_infos.push(self.sysvar_instructions.clone()); + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -328,6 +405,7 @@ impl<'a> UnverifyCreatorV1CpiBuilder<'a> { collection_metadata: None, system_program: None, sysvar_instructions: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -345,9 +423,9 @@ impl<'a> UnverifyCreatorV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Metadata account @@ -364,9 +442,9 @@ impl<'a> UnverifyCreatorV1CpiBuilder<'a> { #[inline(always)] pub fn collection_mint( &mut self, - collection_mint: &'a solana_program::account_info::AccountInfo<'a>, + collection_mint: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.collection_mint = Some(collection_mint); + self.instruction.collection_mint = collection_mint; self } /// `[optional account]` @@ -374,9 +452,9 @@ impl<'a> UnverifyCreatorV1CpiBuilder<'a> { #[inline(always)] pub fn collection_metadata( &mut self, - collection_metadata: &'a solana_program::account_info::AccountInfo<'a>, + collection_metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.collection_metadata = Some(collection_metadata); + self.instruction.collection_metadata = collection_metadata; self } /// System program @@ -397,9 +475,35 @@ impl<'a> UnverifyCreatorV1CpiBuilder<'a> { self.instruction.sysvar_instructions = Some(sysvar_instructions); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> UnverifyCreatorV1Cpi<'a> { - UnverifyCreatorV1Cpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = UnverifyCreatorV1Cpi { __program: self.instruction.__program, authority: self.instruction.authority.expect("authority is not set"), @@ -421,7 +525,11 @@ impl<'a> UnverifyCreatorV1CpiBuilder<'a> { .instruction .sysvar_instructions .expect("sysvar_instructions is not set"), - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -434,4 +542,5 @@ struct UnverifyCreatorV1CpiBuilderInstruction<'a> { collection_metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, system_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, sysvar_instructions: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/unverify_sized_collection_item.rs b/clients/rust/src/generated/instructions/unverify_sized_collection_item.rs index 1b237d05..c743afc2 100644 --- a/clients/rust/src/generated/instructions/unverify_sized_collection_item.rs +++ b/clients/rust/src/generated/instructions/unverify_sized_collection_item.rs @@ -27,9 +27,15 @@ pub struct UnverifySizedCollectionItem { } impl UnverifySizedCollectionItem { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(7); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.metadata, false, @@ -59,6 +65,9 @@ impl UnverifySizedCollectionItem { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = UnverifySizedCollectionItemInstructionData::new() .try_to_vec() .unwrap(); @@ -92,6 +101,7 @@ pub struct UnverifySizedCollectionItemBuilder { collection: Option, collection_master_edition_account: Option, collection_authority_record: Option, + __remaining_accounts: Vec, } impl UnverifySizedCollectionItemBuilder { @@ -148,13 +158,23 @@ impl UnverifySizedCollectionItemBuilder { #[inline(always)] pub fn collection_authority_record( &mut self, - collection_authority_record: solana_program::pubkey::Pubkey, + collection_authority_record: Option, ) -> &mut Self { - self.collection_authority_record = Some(collection_authority_record); + self.collection_authority_record = collection_authority_record; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = UnverifySizedCollectionItem { metadata: self.metadata.expect("metadata is not set"), collection_authority: self @@ -169,10 +189,28 @@ impl UnverifySizedCollectionItemBuilder { collection_authority_record: self.collection_authority_record, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `unverify_sized_collection_item` CPI accounts. +pub struct UnverifySizedCollectionItemCpiAccounts<'a> { + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Collection Authority + pub collection_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of the Collection + pub collection_mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata Account of the Collection + pub collection: &'a solana_program::account_info::AccountInfo<'a>, + /// MasterEdition2 Account of the Collection Token + pub collection_master_edition_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Collection Authority Record PDA + pub collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `unverify_sized_collection_item` CPI instruction. pub struct UnverifySizedCollectionItemCpi<'a> { /// The program to invoke. @@ -194,16 +232,47 @@ pub struct UnverifySizedCollectionItemCpi<'a> { } impl<'a> UnverifySizedCollectionItemCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: UnverifySizedCollectionItemCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + metadata: accounts.metadata, + collection_authority: accounts.collection_authority, + payer: accounts.payer, + collection_mint: accounts.collection_mint, + collection: accounts.collection, + collection_master_edition_account: accounts.collection_master_edition_account, + collection_authority_record: accounts.collection_authority_record, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7); + let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.metadata.key, false, @@ -234,6 +303,9 @@ impl<'a> UnverifySizedCollectionItemCpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = UnverifySizedCollectionItemInstructionData::new() .try_to_vec() .unwrap(); @@ -243,7 +315,7 @@ impl<'a> UnverifySizedCollectionItemCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(7 + 1); + let mut account_infos = Vec::with_capacity(7 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.metadata.clone()); account_infos.push(self.collection_authority.clone()); @@ -254,6 +326,9 @@ impl<'a> UnverifySizedCollectionItemCpi<'a> { if let Some(collection_authority_record) = self.collection_authority_record { account_infos.push(collection_authority_record.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -279,6 +354,7 @@ impl<'a> UnverifySizedCollectionItemCpiBuilder<'a> { collection: None, collection_master_edition_account: None, collection_authority_record: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -339,14 +415,40 @@ impl<'a> UnverifySizedCollectionItemCpiBuilder<'a> { #[inline(always)] pub fn collection_authority_record( &mut self, - collection_authority_record: &'a solana_program::account_info::AccountInfo<'a>, + collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.collection_authority_record = collection_authority_record; + self + } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, ) -> &mut Self { - self.instruction.collection_authority_record = Some(collection_authority_record); + self.instruction.__remaining_accounts.push(account); self } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> UnverifySizedCollectionItemCpi<'a> { - UnverifySizedCollectionItemCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = UnverifySizedCollectionItemCpi { __program: self.instruction.__program, metadata: self.instruction.metadata.expect("metadata is not set"), @@ -371,7 +473,11 @@ impl<'a> UnverifySizedCollectionItemCpiBuilder<'a> { .expect("collection_master_edition_account is not set"), collection_authority_record: self.instruction.collection_authority_record, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -384,4 +490,5 @@ struct UnverifySizedCollectionItemCpiBuilderInstruction<'a> { collection: Option<&'a solana_program::account_info::AccountInfo<'a>>, collection_master_edition_account: Option<&'a solana_program::account_info::AccountInfo<'a>>, collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/update_as_authority_item_delegate_v2.rs b/clients/rust/src/generated/instructions/update_as_authority_item_delegate_v2.rs index 2858d93b..d648989d 100644 --- a/clients/rust/src/generated/instructions/update_as_authority_item_delegate_v2.rs +++ b/clients/rust/src/generated/instructions/update_as_authority_item_delegate_v2.rs @@ -38,12 +38,19 @@ pub struct UpdateAsAuthorityItemDelegateV2 { } impl UpdateAsAuthorityItemDelegateV2 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: UpdateAsAuthorityItemDelegateV2InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(11); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: UpdateAsAuthorityItemDelegateV2InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, true, @@ -119,6 +126,9 @@ impl UpdateAsAuthorityItemDelegateV2 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateAsAuthorityItemDelegateV2InstructionData::new() .try_to_vec() .unwrap(); @@ -148,7 +158,8 @@ impl UpdateAsAuthorityItemDelegateV2InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UpdateAsAuthorityItemDelegateV2InstructionArgs { pub new_update_authority: Option, pub primary_sale_happened: Option, @@ -176,6 +187,7 @@ pub struct UpdateAsAuthorityItemDelegateV2Builder { is_mutable: Option, token_standard: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl UpdateAsAuthorityItemDelegateV2Builder { @@ -193,16 +205,16 @@ impl UpdateAsAuthorityItemDelegateV2Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// `[optional account]` /// Token account #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Mint account @@ -220,8 +232,8 @@ impl UpdateAsAuthorityItemDelegateV2Builder { /// `[optional account]` /// Edition account #[inline(always)] - pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.edition = Some(edition); + pub fn edition(&mut self, edition: Option) -> &mut Self { + self.edition = edition; self } /// Payer @@ -230,12 +242,14 @@ impl UpdateAsAuthorityItemDelegateV2Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -250,9 +264,9 @@ impl UpdateAsAuthorityItemDelegateV2Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -260,9 +274,9 @@ impl UpdateAsAuthorityItemDelegateV2Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -295,8 +309,18 @@ impl UpdateAsAuthorityItemDelegateV2Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = UpdateAsAuthorityItemDelegateV2 { authority: self.authority.expect("authority is not set"), delegate_record: self.delegate_record, @@ -322,10 +346,36 @@ impl UpdateAsAuthorityItemDelegateV2Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `update_as_authority_item_delegate_v2` CPI accounts. +pub struct UpdateAsAuthorityItemDelegateV2CpiAccounts<'a> { + /// Update authority or delegate + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Delegate record PDA + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token account + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint account + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition account + pub edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `update_as_authority_item_delegate_v2` CPI instruction. pub struct UpdateAsAuthorityItemDelegateV2Cpi<'a> { /// The program to invoke. @@ -357,16 +407,53 @@ pub struct UpdateAsAuthorityItemDelegateV2Cpi<'a> { } impl<'a> UpdateAsAuthorityItemDelegateV2Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: UpdateAsAuthorityItemDelegateV2CpiAccounts<'a>, + args: UpdateAsAuthorityItemDelegateV2InstructionArgs, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + delegate_record: accounts.delegate_record, + token: accounts.token, + mint: accounts.mint, + metadata: accounts.metadata, + edition: accounts.edition, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11); + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, true, @@ -445,6 +532,9 @@ impl<'a> UpdateAsAuthorityItemDelegateV2Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateAsAuthorityItemDelegateV2InstructionData::new() .try_to_vec() .unwrap(); @@ -456,7 +546,7 @@ impl<'a> UpdateAsAuthorityItemDelegateV2Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(11 + 1); + let mut account_infos = Vec::with_capacity(11 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.authority.clone()); if let Some(delegate_record) = self.delegate_record { @@ -479,6 +569,9 @@ impl<'a> UpdateAsAuthorityItemDelegateV2Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -513,6 +606,7 @@ impl<'a> UpdateAsAuthorityItemDelegateV2CpiBuilder<'a> { is_mutable: None, token_standard: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -530,16 +624,19 @@ impl<'a> UpdateAsAuthorityItemDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// `[optional account]` /// Token account #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Mint account @@ -562,9 +659,9 @@ impl<'a> UpdateAsAuthorityItemDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn edition( &mut self, - edition: &'a solana_program::account_info::AccountInfo<'a>, + edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.edition = Some(edition); + self.instruction.edition = edition; self } /// Payer @@ -596,9 +693,9 @@ impl<'a> UpdateAsAuthorityItemDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -606,9 +703,9 @@ impl<'a> UpdateAsAuthorityItemDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -641,8 +738,34 @@ impl<'a> UpdateAsAuthorityItemDelegateV2CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> UpdateAsAuthorityItemDelegateV2Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = UpdateAsAuthorityItemDelegateV2InstructionArgs { new_update_authority: self.instruction.new_update_authority.clone(), primary_sale_happened: self.instruction.primary_sale_happened.clone(), @@ -650,8 +773,7 @@ impl<'a> UpdateAsAuthorityItemDelegateV2CpiBuilder<'a> { token_standard: self.instruction.token_standard.clone(), authorization_data: self.instruction.authorization_data.clone(), }; - - UpdateAsAuthorityItemDelegateV2Cpi { + let instruction = UpdateAsAuthorityItemDelegateV2Cpi { __program: self.instruction.__program, authority: self.instruction.authority.expect("authority is not set"), @@ -682,7 +804,11 @@ impl<'a> UpdateAsAuthorityItemDelegateV2CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -704,4 +830,5 @@ struct UpdateAsAuthorityItemDelegateV2CpiBuilderInstruction<'a> { is_mutable: Option, token_standard: Option, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/update_as_collection_delegate_v2.rs b/clients/rust/src/generated/instructions/update_as_collection_delegate_v2.rs index fbc84643..52338c00 100644 --- a/clients/rust/src/generated/instructions/update_as_collection_delegate_v2.rs +++ b/clients/rust/src/generated/instructions/update_as_collection_delegate_v2.rs @@ -37,12 +37,19 @@ pub struct UpdateAsCollectionDelegateV2 { } impl UpdateAsCollectionDelegateV2 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: UpdateAsCollectionDelegateV2InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(11); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: UpdateAsCollectionDelegateV2InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, true, @@ -118,6 +125,9 @@ impl UpdateAsCollectionDelegateV2 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateAsCollectionDelegateV2InstructionData::new() .try_to_vec() .unwrap(); @@ -147,7 +157,8 @@ impl UpdateAsCollectionDelegateV2InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UpdateAsCollectionDelegateV2InstructionArgs { pub collection: CollectionToggle, pub authorization_data: Option, @@ -169,6 +180,7 @@ pub struct UpdateAsCollectionDelegateV2Builder { authorization_rules: Option, collection: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl UpdateAsCollectionDelegateV2Builder { @@ -186,16 +198,16 @@ impl UpdateAsCollectionDelegateV2Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// `[optional account]` /// Token account #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Mint account @@ -213,8 +225,8 @@ impl UpdateAsCollectionDelegateV2Builder { /// `[optional account]` /// Edition account #[inline(always)] - pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.edition = Some(edition); + pub fn edition(&mut self, edition: Option) -> &mut Self { + self.edition = edition; self } /// Payer @@ -223,12 +235,14 @@ impl UpdateAsCollectionDelegateV2Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -243,9 +257,9 @@ impl UpdateAsCollectionDelegateV2Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -253,9 +267,9 @@ impl UpdateAsCollectionDelegateV2Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to 'CollectionToggle::None']` @@ -270,8 +284,18 @@ impl UpdateAsCollectionDelegateV2Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = UpdateAsCollectionDelegateV2 { authority: self.authority.expect("authority is not set"), delegate_record: self.delegate_record, @@ -294,10 +318,36 @@ impl UpdateAsCollectionDelegateV2Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `update_as_collection_delegate_v2` CPI accounts. +pub struct UpdateAsCollectionDelegateV2CpiAccounts<'a> { + /// Update authority or delegate + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Delegate record PDA + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token account + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint account + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition account + pub edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `update_as_collection_delegate_v2` CPI instruction. pub struct UpdateAsCollectionDelegateV2Cpi<'a> { /// The program to invoke. @@ -329,16 +379,53 @@ pub struct UpdateAsCollectionDelegateV2Cpi<'a> { } impl<'a> UpdateAsCollectionDelegateV2Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: UpdateAsCollectionDelegateV2CpiAccounts<'a>, + args: UpdateAsCollectionDelegateV2InstructionArgs, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + delegate_record: accounts.delegate_record, + token: accounts.token, + mint: accounts.mint, + metadata: accounts.metadata, + edition: accounts.edition, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11); + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, true, @@ -417,6 +504,9 @@ impl<'a> UpdateAsCollectionDelegateV2Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateAsCollectionDelegateV2InstructionData::new() .try_to_vec() .unwrap(); @@ -428,7 +518,7 @@ impl<'a> UpdateAsCollectionDelegateV2Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(11 + 1); + let mut account_infos = Vec::with_capacity(11 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.authority.clone()); if let Some(delegate_record) = self.delegate_record { @@ -451,6 +541,9 @@ impl<'a> UpdateAsCollectionDelegateV2Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -482,6 +575,7 @@ impl<'a> UpdateAsCollectionDelegateV2CpiBuilder<'a> { authorization_rules: None, collection: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -499,16 +593,19 @@ impl<'a> UpdateAsCollectionDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// `[optional account]` /// Token account #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Mint account @@ -531,9 +628,9 @@ impl<'a> UpdateAsCollectionDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn edition( &mut self, - edition: &'a solana_program::account_info::AccountInfo<'a>, + edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.edition = Some(edition); + self.instruction.edition = edition; self } /// Payer @@ -565,9 +662,9 @@ impl<'a> UpdateAsCollectionDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -575,9 +672,9 @@ impl<'a> UpdateAsCollectionDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to 'CollectionToggle::None']` @@ -592,8 +689,34 @@ impl<'a> UpdateAsCollectionDelegateV2CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> UpdateAsCollectionDelegateV2Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = UpdateAsCollectionDelegateV2InstructionArgs { collection: self .instruction @@ -602,8 +725,7 @@ impl<'a> UpdateAsCollectionDelegateV2CpiBuilder<'a> { .unwrap_or(CollectionToggle::None), authorization_data: self.instruction.authorization_data.clone(), }; - - UpdateAsCollectionDelegateV2Cpi { + let instruction = UpdateAsCollectionDelegateV2Cpi { __program: self.instruction.__program, authority: self.instruction.authority.expect("authority is not set"), @@ -634,7 +756,11 @@ impl<'a> UpdateAsCollectionDelegateV2CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -653,4 +779,5 @@ struct UpdateAsCollectionDelegateV2CpiBuilderInstruction<'a> { authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, collection: Option, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/update_as_collection_item_delegate_v2.rs b/clients/rust/src/generated/instructions/update_as_collection_item_delegate_v2.rs index 0015f284..2efbf832 100644 --- a/clients/rust/src/generated/instructions/update_as_collection_item_delegate_v2.rs +++ b/clients/rust/src/generated/instructions/update_as_collection_item_delegate_v2.rs @@ -37,12 +37,19 @@ pub struct UpdateAsCollectionItemDelegateV2 { } impl UpdateAsCollectionItemDelegateV2 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: UpdateAsCollectionItemDelegateV2InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(11); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: UpdateAsCollectionItemDelegateV2InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, true, @@ -118,6 +125,9 @@ impl UpdateAsCollectionItemDelegateV2 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateAsCollectionItemDelegateV2InstructionData::new() .try_to_vec() .unwrap(); @@ -147,7 +157,8 @@ impl UpdateAsCollectionItemDelegateV2InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UpdateAsCollectionItemDelegateV2InstructionArgs { pub collection: CollectionToggle, pub authorization_data: Option, @@ -169,6 +180,7 @@ pub struct UpdateAsCollectionItemDelegateV2Builder { authorization_rules: Option, collection: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl UpdateAsCollectionItemDelegateV2Builder { @@ -186,16 +198,16 @@ impl UpdateAsCollectionItemDelegateV2Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// `[optional account]` /// Token account #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Mint account @@ -213,8 +225,8 @@ impl UpdateAsCollectionItemDelegateV2Builder { /// `[optional account]` /// Edition account #[inline(always)] - pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.edition = Some(edition); + pub fn edition(&mut self, edition: Option) -> &mut Self { + self.edition = edition; self } /// Payer @@ -223,12 +235,14 @@ impl UpdateAsCollectionItemDelegateV2Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -243,9 +257,9 @@ impl UpdateAsCollectionItemDelegateV2Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -253,9 +267,9 @@ impl UpdateAsCollectionItemDelegateV2Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to 'CollectionToggle::None']` @@ -270,8 +284,18 @@ impl UpdateAsCollectionItemDelegateV2Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = UpdateAsCollectionItemDelegateV2 { authority: self.authority.expect("authority is not set"), delegate_record: self.delegate_record, @@ -294,10 +318,36 @@ impl UpdateAsCollectionItemDelegateV2Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `update_as_collection_item_delegate_v2` CPI accounts. +pub struct UpdateAsCollectionItemDelegateV2CpiAccounts<'a> { + /// Update authority or delegate + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Delegate record PDA + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token account + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint account + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition account + pub edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `update_as_collection_item_delegate_v2` CPI instruction. pub struct UpdateAsCollectionItemDelegateV2Cpi<'a> { /// The program to invoke. @@ -329,16 +379,53 @@ pub struct UpdateAsCollectionItemDelegateV2Cpi<'a> { } impl<'a> UpdateAsCollectionItemDelegateV2Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: UpdateAsCollectionItemDelegateV2CpiAccounts<'a>, + args: UpdateAsCollectionItemDelegateV2InstructionArgs, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + delegate_record: accounts.delegate_record, + token: accounts.token, + mint: accounts.mint, + metadata: accounts.metadata, + edition: accounts.edition, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11); + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, true, @@ -417,6 +504,9 @@ impl<'a> UpdateAsCollectionItemDelegateV2Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateAsCollectionItemDelegateV2InstructionData::new() .try_to_vec() .unwrap(); @@ -428,7 +518,7 @@ impl<'a> UpdateAsCollectionItemDelegateV2Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(11 + 1); + let mut account_infos = Vec::with_capacity(11 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.authority.clone()); if let Some(delegate_record) = self.delegate_record { @@ -451,6 +541,9 @@ impl<'a> UpdateAsCollectionItemDelegateV2Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -482,6 +575,7 @@ impl<'a> UpdateAsCollectionItemDelegateV2CpiBuilder<'a> { authorization_rules: None, collection: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -499,16 +593,19 @@ impl<'a> UpdateAsCollectionItemDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// `[optional account]` /// Token account #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Mint account @@ -531,9 +628,9 @@ impl<'a> UpdateAsCollectionItemDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn edition( &mut self, - edition: &'a solana_program::account_info::AccountInfo<'a>, + edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.edition = Some(edition); + self.instruction.edition = edition; self } /// Payer @@ -565,9 +662,9 @@ impl<'a> UpdateAsCollectionItemDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -575,9 +672,9 @@ impl<'a> UpdateAsCollectionItemDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to 'CollectionToggle::None']` @@ -592,8 +689,34 @@ impl<'a> UpdateAsCollectionItemDelegateV2CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> UpdateAsCollectionItemDelegateV2Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = UpdateAsCollectionItemDelegateV2InstructionArgs { collection: self .instruction @@ -602,8 +725,7 @@ impl<'a> UpdateAsCollectionItemDelegateV2CpiBuilder<'a> { .unwrap_or(CollectionToggle::None), authorization_data: self.instruction.authorization_data.clone(), }; - - UpdateAsCollectionItemDelegateV2Cpi { + let instruction = UpdateAsCollectionItemDelegateV2Cpi { __program: self.instruction.__program, authority: self.instruction.authority.expect("authority is not set"), @@ -634,7 +756,11 @@ impl<'a> UpdateAsCollectionItemDelegateV2CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -653,4 +779,5 @@ struct UpdateAsCollectionItemDelegateV2CpiBuilderInstruction<'a> { authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, collection: Option, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/update_as_data_delegate_v2.rs b/clients/rust/src/generated/instructions/update_as_data_delegate_v2.rs index 3be2310f..c7a1488d 100644 --- a/clients/rust/src/generated/instructions/update_as_data_delegate_v2.rs +++ b/clients/rust/src/generated/instructions/update_as_data_delegate_v2.rs @@ -37,12 +37,19 @@ pub struct UpdateAsDataDelegateV2 { } impl UpdateAsDataDelegateV2 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: UpdateAsDataDelegateV2InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(11); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: UpdateAsDataDelegateV2InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, true, @@ -118,6 +125,9 @@ impl UpdateAsDataDelegateV2 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateAsDataDelegateV2InstructionData::new() .try_to_vec() .unwrap(); @@ -147,7 +157,8 @@ impl UpdateAsDataDelegateV2InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UpdateAsDataDelegateV2InstructionArgs { pub data: Option, pub authorization_data: Option, @@ -169,6 +180,7 @@ pub struct UpdateAsDataDelegateV2Builder { authorization_rules: Option, data: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl UpdateAsDataDelegateV2Builder { @@ -186,16 +198,16 @@ impl UpdateAsDataDelegateV2Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// `[optional account]` /// Token account #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Mint account @@ -213,8 +225,8 @@ impl UpdateAsDataDelegateV2Builder { /// `[optional account]` /// Edition account #[inline(always)] - pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.edition = Some(edition); + pub fn edition(&mut self, edition: Option) -> &mut Self { + self.edition = edition; self } /// Payer @@ -223,12 +235,14 @@ impl UpdateAsDataDelegateV2Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -243,9 +257,9 @@ impl UpdateAsDataDelegateV2Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -253,9 +267,9 @@ impl UpdateAsDataDelegateV2Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -270,8 +284,18 @@ impl UpdateAsDataDelegateV2Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = UpdateAsDataDelegateV2 { authority: self.authority.expect("authority is not set"), delegate_record: self.delegate_record, @@ -294,10 +318,36 @@ impl UpdateAsDataDelegateV2Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `update_as_data_delegate_v2` CPI accounts. +pub struct UpdateAsDataDelegateV2CpiAccounts<'a> { + /// Update authority or delegate + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Delegate record PDA + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token account + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint account + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition account + pub edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `update_as_data_delegate_v2` CPI instruction. pub struct UpdateAsDataDelegateV2Cpi<'a> { /// The program to invoke. @@ -329,16 +379,53 @@ pub struct UpdateAsDataDelegateV2Cpi<'a> { } impl<'a> UpdateAsDataDelegateV2Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: UpdateAsDataDelegateV2CpiAccounts<'a>, + args: UpdateAsDataDelegateV2InstructionArgs, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + delegate_record: accounts.delegate_record, + token: accounts.token, + mint: accounts.mint, + metadata: accounts.metadata, + edition: accounts.edition, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11); + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, true, @@ -417,6 +504,9 @@ impl<'a> UpdateAsDataDelegateV2Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateAsDataDelegateV2InstructionData::new() .try_to_vec() .unwrap(); @@ -428,7 +518,7 @@ impl<'a> UpdateAsDataDelegateV2Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(11 + 1); + let mut account_infos = Vec::with_capacity(11 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.authority.clone()); if let Some(delegate_record) = self.delegate_record { @@ -451,6 +541,9 @@ impl<'a> UpdateAsDataDelegateV2Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -482,6 +575,7 @@ impl<'a> UpdateAsDataDelegateV2CpiBuilder<'a> { authorization_rules: None, data: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -499,16 +593,19 @@ impl<'a> UpdateAsDataDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// `[optional account]` /// Token account #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Mint account @@ -531,9 +628,9 @@ impl<'a> UpdateAsDataDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn edition( &mut self, - edition: &'a solana_program::account_info::AccountInfo<'a>, + edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.edition = Some(edition); + self.instruction.edition = edition; self } /// Payer @@ -565,9 +662,9 @@ impl<'a> UpdateAsDataDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -575,9 +672,9 @@ impl<'a> UpdateAsDataDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -592,14 +689,39 @@ impl<'a> UpdateAsDataDelegateV2CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> UpdateAsDataDelegateV2Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = UpdateAsDataDelegateV2InstructionArgs { data: self.instruction.data.clone(), authorization_data: self.instruction.authorization_data.clone(), }; - - UpdateAsDataDelegateV2Cpi { + let instruction = UpdateAsDataDelegateV2Cpi { __program: self.instruction.__program, authority: self.instruction.authority.expect("authority is not set"), @@ -630,7 +752,11 @@ impl<'a> UpdateAsDataDelegateV2CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -649,4 +775,5 @@ struct UpdateAsDataDelegateV2CpiBuilderInstruction<'a> { authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, data: Option, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/update_as_data_item_delegate_v2.rs b/clients/rust/src/generated/instructions/update_as_data_item_delegate_v2.rs index 57ff3805..d4578e7a 100644 --- a/clients/rust/src/generated/instructions/update_as_data_item_delegate_v2.rs +++ b/clients/rust/src/generated/instructions/update_as_data_item_delegate_v2.rs @@ -37,12 +37,19 @@ pub struct UpdateAsDataItemDelegateV2 { } impl UpdateAsDataItemDelegateV2 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: UpdateAsDataItemDelegateV2InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(11); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: UpdateAsDataItemDelegateV2InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, true, @@ -118,6 +125,9 @@ impl UpdateAsDataItemDelegateV2 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateAsDataItemDelegateV2InstructionData::new() .try_to_vec() .unwrap(); @@ -147,7 +157,8 @@ impl UpdateAsDataItemDelegateV2InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UpdateAsDataItemDelegateV2InstructionArgs { pub data: Option, pub authorization_data: Option, @@ -169,6 +180,7 @@ pub struct UpdateAsDataItemDelegateV2Builder { authorization_rules: Option, data: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl UpdateAsDataItemDelegateV2Builder { @@ -186,16 +198,16 @@ impl UpdateAsDataItemDelegateV2Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// `[optional account]` /// Token account #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Mint account @@ -213,8 +225,8 @@ impl UpdateAsDataItemDelegateV2Builder { /// `[optional account]` /// Edition account #[inline(always)] - pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.edition = Some(edition); + pub fn edition(&mut self, edition: Option) -> &mut Self { + self.edition = edition; self } /// Payer @@ -223,12 +235,14 @@ impl UpdateAsDataItemDelegateV2Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -243,9 +257,9 @@ impl UpdateAsDataItemDelegateV2Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -253,9 +267,9 @@ impl UpdateAsDataItemDelegateV2Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -270,8 +284,18 @@ impl UpdateAsDataItemDelegateV2Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = UpdateAsDataItemDelegateV2 { authority: self.authority.expect("authority is not set"), delegate_record: self.delegate_record, @@ -294,10 +318,36 @@ impl UpdateAsDataItemDelegateV2Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `update_as_data_item_delegate_v2` CPI accounts. +pub struct UpdateAsDataItemDelegateV2CpiAccounts<'a> { + /// Update authority or delegate + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Delegate record PDA + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token account + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint account + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition account + pub edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `update_as_data_item_delegate_v2` CPI instruction. pub struct UpdateAsDataItemDelegateV2Cpi<'a> { /// The program to invoke. @@ -329,16 +379,53 @@ pub struct UpdateAsDataItemDelegateV2Cpi<'a> { } impl<'a> UpdateAsDataItemDelegateV2Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: UpdateAsDataItemDelegateV2CpiAccounts<'a>, + args: UpdateAsDataItemDelegateV2InstructionArgs, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + delegate_record: accounts.delegate_record, + token: accounts.token, + mint: accounts.mint, + metadata: accounts.metadata, + edition: accounts.edition, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11); + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, true, @@ -417,6 +504,9 @@ impl<'a> UpdateAsDataItemDelegateV2Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateAsDataItemDelegateV2InstructionData::new() .try_to_vec() .unwrap(); @@ -428,7 +518,7 @@ impl<'a> UpdateAsDataItemDelegateV2Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(11 + 1); + let mut account_infos = Vec::with_capacity(11 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.authority.clone()); if let Some(delegate_record) = self.delegate_record { @@ -451,6 +541,9 @@ impl<'a> UpdateAsDataItemDelegateV2Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -482,6 +575,7 @@ impl<'a> UpdateAsDataItemDelegateV2CpiBuilder<'a> { authorization_rules: None, data: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -499,16 +593,19 @@ impl<'a> UpdateAsDataItemDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// `[optional account]` /// Token account #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Mint account @@ -531,9 +628,9 @@ impl<'a> UpdateAsDataItemDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn edition( &mut self, - edition: &'a solana_program::account_info::AccountInfo<'a>, + edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.edition = Some(edition); + self.instruction.edition = edition; self } /// Payer @@ -565,9 +662,9 @@ impl<'a> UpdateAsDataItemDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -575,9 +672,9 @@ impl<'a> UpdateAsDataItemDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -592,14 +689,39 @@ impl<'a> UpdateAsDataItemDelegateV2CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> UpdateAsDataItemDelegateV2Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = UpdateAsDataItemDelegateV2InstructionArgs { data: self.instruction.data.clone(), authorization_data: self.instruction.authorization_data.clone(), }; - - UpdateAsDataItemDelegateV2Cpi { + let instruction = UpdateAsDataItemDelegateV2Cpi { __program: self.instruction.__program, authority: self.instruction.authority.expect("authority is not set"), @@ -630,7 +752,11 @@ impl<'a> UpdateAsDataItemDelegateV2CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -649,4 +775,5 @@ struct UpdateAsDataItemDelegateV2CpiBuilderInstruction<'a> { authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, data: Option, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/update_as_programmable_config_delegate_v2.rs b/clients/rust/src/generated/instructions/update_as_programmable_config_delegate_v2.rs index 96cdb19c..5acce773 100644 --- a/clients/rust/src/generated/instructions/update_as_programmable_config_delegate_v2.rs +++ b/clients/rust/src/generated/instructions/update_as_programmable_config_delegate_v2.rs @@ -37,12 +37,19 @@ pub struct UpdateAsProgrammableConfigDelegateV2 { } impl UpdateAsProgrammableConfigDelegateV2 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: UpdateAsProgrammableConfigDelegateV2InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(11); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: UpdateAsProgrammableConfigDelegateV2InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, true, @@ -111,6 +118,9 @@ impl UpdateAsProgrammableConfigDelegateV2 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateAsProgrammableConfigDelegateV2InstructionData::new() .try_to_vec() .unwrap(); @@ -140,7 +150,8 @@ impl UpdateAsProgrammableConfigDelegateV2InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UpdateAsProgrammableConfigDelegateV2InstructionArgs { pub rule_set: RuleSetToggle, pub authorization_data: Option, @@ -162,6 +173,7 @@ pub struct UpdateAsProgrammableConfigDelegateV2Builder { authorization_rules: Option, rule_set: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl UpdateAsProgrammableConfigDelegateV2Builder { @@ -179,9 +191,9 @@ impl UpdateAsProgrammableConfigDelegateV2Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Token account @@ -205,8 +217,8 @@ impl UpdateAsProgrammableConfigDelegateV2Builder { /// `[optional account]` /// Edition account #[inline(always)] - pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.edition = Some(edition); + pub fn edition(&mut self, edition: Option) -> &mut Self { + self.edition = edition; self } /// Payer @@ -215,12 +227,14 @@ impl UpdateAsProgrammableConfigDelegateV2Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -235,9 +249,9 @@ impl UpdateAsProgrammableConfigDelegateV2Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -245,9 +259,9 @@ impl UpdateAsProgrammableConfigDelegateV2Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to 'RuleSetToggle::None']` @@ -262,8 +276,18 @@ impl UpdateAsProgrammableConfigDelegateV2Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = UpdateAsProgrammableConfigDelegateV2 { authority: self.authority.expect("authority is not set"), delegate_record: self.delegate_record, @@ -286,10 +310,36 @@ impl UpdateAsProgrammableConfigDelegateV2Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `update_as_programmable_config_delegate_v2` CPI accounts. +pub struct UpdateAsProgrammableConfigDelegateV2CpiAccounts<'a> { + /// Update authority or delegate + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Delegate record PDA + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token account + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint account + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition account + pub edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `update_as_programmable_config_delegate_v2` CPI instruction. pub struct UpdateAsProgrammableConfigDelegateV2Cpi<'a> { /// The program to invoke. @@ -321,16 +371,53 @@ pub struct UpdateAsProgrammableConfigDelegateV2Cpi<'a> { } impl<'a> UpdateAsProgrammableConfigDelegateV2Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: UpdateAsProgrammableConfigDelegateV2CpiAccounts<'a>, + args: UpdateAsProgrammableConfigDelegateV2InstructionArgs, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + delegate_record: accounts.delegate_record, + token: accounts.token, + mint: accounts.mint, + metadata: accounts.metadata, + edition: accounts.edition, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11); + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, true, @@ -403,6 +490,9 @@ impl<'a> UpdateAsProgrammableConfigDelegateV2Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateAsProgrammableConfigDelegateV2InstructionData::new() .try_to_vec() .unwrap(); @@ -414,7 +504,7 @@ impl<'a> UpdateAsProgrammableConfigDelegateV2Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(11 + 1); + let mut account_infos = Vec::with_capacity(11 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.authority.clone()); if let Some(delegate_record) = self.delegate_record { @@ -435,6 +525,9 @@ impl<'a> UpdateAsProgrammableConfigDelegateV2Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -466,6 +559,7 @@ impl<'a> UpdateAsProgrammableConfigDelegateV2CpiBuilder<'a> { authorization_rules: None, rule_set: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -483,9 +577,9 @@ impl<'a> UpdateAsProgrammableConfigDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Token account @@ -514,9 +608,9 @@ impl<'a> UpdateAsProgrammableConfigDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn edition( &mut self, - edition: &'a solana_program::account_info::AccountInfo<'a>, + edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.edition = Some(edition); + self.instruction.edition = edition; self } /// Payer @@ -548,9 +642,9 @@ impl<'a> UpdateAsProgrammableConfigDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -558,9 +652,9 @@ impl<'a> UpdateAsProgrammableConfigDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to 'RuleSetToggle::None']` @@ -575,8 +669,34 @@ impl<'a> UpdateAsProgrammableConfigDelegateV2CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> UpdateAsProgrammableConfigDelegateV2Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = UpdateAsProgrammableConfigDelegateV2InstructionArgs { rule_set: self .instruction @@ -585,8 +705,7 @@ impl<'a> UpdateAsProgrammableConfigDelegateV2CpiBuilder<'a> { .unwrap_or(RuleSetToggle::None), authorization_data: self.instruction.authorization_data.clone(), }; - - UpdateAsProgrammableConfigDelegateV2Cpi { + let instruction = UpdateAsProgrammableConfigDelegateV2Cpi { __program: self.instruction.__program, authority: self.instruction.authority.expect("authority is not set"), @@ -617,7 +736,11 @@ impl<'a> UpdateAsProgrammableConfigDelegateV2CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -636,4 +759,5 @@ struct UpdateAsProgrammableConfigDelegateV2CpiBuilderInstruction<'a> { authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, rule_set: Option, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/update_as_programmable_config_item_delegate_v2.rs b/clients/rust/src/generated/instructions/update_as_programmable_config_item_delegate_v2.rs index 0c5c2c03..645e6956 100644 --- a/clients/rust/src/generated/instructions/update_as_programmable_config_item_delegate_v2.rs +++ b/clients/rust/src/generated/instructions/update_as_programmable_config_item_delegate_v2.rs @@ -37,12 +37,19 @@ pub struct UpdateAsProgrammableConfigItemDelegateV2 { } impl UpdateAsProgrammableConfigItemDelegateV2 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: UpdateAsProgrammableConfigItemDelegateV2InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(11); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: UpdateAsProgrammableConfigItemDelegateV2InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, true, @@ -111,6 +118,9 @@ impl UpdateAsProgrammableConfigItemDelegateV2 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateAsProgrammableConfigItemDelegateV2InstructionData::new() .try_to_vec() .unwrap(); @@ -140,7 +150,8 @@ impl UpdateAsProgrammableConfigItemDelegateV2InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UpdateAsProgrammableConfigItemDelegateV2InstructionArgs { pub rule_set: RuleSetToggle, pub authorization_data: Option, @@ -162,6 +173,7 @@ pub struct UpdateAsProgrammableConfigItemDelegateV2Builder { authorization_rules: Option, rule_set: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl UpdateAsProgrammableConfigItemDelegateV2Builder { @@ -179,9 +191,9 @@ impl UpdateAsProgrammableConfigItemDelegateV2Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Token account @@ -205,8 +217,8 @@ impl UpdateAsProgrammableConfigItemDelegateV2Builder { /// `[optional account]` /// Edition account #[inline(always)] - pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.edition = Some(edition); + pub fn edition(&mut self, edition: Option) -> &mut Self { + self.edition = edition; self } /// Payer @@ -215,12 +227,14 @@ impl UpdateAsProgrammableConfigItemDelegateV2Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -235,9 +249,9 @@ impl UpdateAsProgrammableConfigItemDelegateV2Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -245,9 +259,9 @@ impl UpdateAsProgrammableConfigItemDelegateV2Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to 'RuleSetToggle::None']` @@ -262,8 +276,18 @@ impl UpdateAsProgrammableConfigItemDelegateV2Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = UpdateAsProgrammableConfigItemDelegateV2 { authority: self.authority.expect("authority is not set"), delegate_record: self.delegate_record, @@ -286,10 +310,36 @@ impl UpdateAsProgrammableConfigItemDelegateV2Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `update_as_programmable_config_item_delegate_v2` CPI accounts. +pub struct UpdateAsProgrammableConfigItemDelegateV2CpiAccounts<'a> { + /// Update authority or delegate + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Delegate record PDA + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token account + pub token: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint account + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition account + pub edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `update_as_programmable_config_item_delegate_v2` CPI instruction. pub struct UpdateAsProgrammableConfigItemDelegateV2Cpi<'a> { /// The program to invoke. @@ -321,16 +371,53 @@ pub struct UpdateAsProgrammableConfigItemDelegateV2Cpi<'a> { } impl<'a> UpdateAsProgrammableConfigItemDelegateV2Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: UpdateAsProgrammableConfigItemDelegateV2CpiAccounts<'a>, + args: UpdateAsProgrammableConfigItemDelegateV2InstructionArgs, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + delegate_record: accounts.delegate_record, + token: accounts.token, + mint: accounts.mint, + metadata: accounts.metadata, + edition: accounts.edition, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11); + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, true, @@ -403,6 +490,9 @@ impl<'a> UpdateAsProgrammableConfigItemDelegateV2Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateAsProgrammableConfigItemDelegateV2InstructionData::new() .try_to_vec() .unwrap(); @@ -414,7 +504,7 @@ impl<'a> UpdateAsProgrammableConfigItemDelegateV2Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(11 + 1); + let mut account_infos = Vec::with_capacity(11 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.authority.clone()); if let Some(delegate_record) = self.delegate_record { @@ -435,6 +525,9 @@ impl<'a> UpdateAsProgrammableConfigItemDelegateV2Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -467,6 +560,7 @@ impl<'a> UpdateAsProgrammableConfigItemDelegateV2CpiBuilder<'a> { authorization_rules: None, rule_set: None, authorization_data: None, + __remaining_accounts: Vec::new(), }, ); Self { instruction } @@ -485,9 +579,9 @@ impl<'a> UpdateAsProgrammableConfigItemDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Token account @@ -516,9 +610,9 @@ impl<'a> UpdateAsProgrammableConfigItemDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn edition( &mut self, - edition: &'a solana_program::account_info::AccountInfo<'a>, + edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.edition = Some(edition); + self.instruction.edition = edition; self } /// Payer @@ -550,9 +644,9 @@ impl<'a> UpdateAsProgrammableConfigItemDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -560,9 +654,9 @@ impl<'a> UpdateAsProgrammableConfigItemDelegateV2CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument, defaults to 'RuleSetToggle::None']` @@ -577,8 +671,34 @@ impl<'a> UpdateAsProgrammableConfigItemDelegateV2CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> UpdateAsProgrammableConfigItemDelegateV2Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = UpdateAsProgrammableConfigItemDelegateV2InstructionArgs { rule_set: self .instruction @@ -587,8 +707,7 @@ impl<'a> UpdateAsProgrammableConfigItemDelegateV2CpiBuilder<'a> { .unwrap_or(RuleSetToggle::None), authorization_data: self.instruction.authorization_data.clone(), }; - - UpdateAsProgrammableConfigItemDelegateV2Cpi { + let instruction = UpdateAsProgrammableConfigItemDelegateV2Cpi { __program: self.instruction.__program, authority: self.instruction.authority.expect("authority is not set"), @@ -619,7 +738,11 @@ impl<'a> UpdateAsProgrammableConfigItemDelegateV2CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -638,4 +761,5 @@ struct UpdateAsProgrammableConfigItemDelegateV2CpiBuilderInstruction<'a> { authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, rule_set: Option, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/update_as_update_authority_v2.rs b/clients/rust/src/generated/instructions/update_as_update_authority_v2.rs index d08fdf11..6384f07c 100644 --- a/clients/rust/src/generated/instructions/update_as_update_authority_v2.rs +++ b/clients/rust/src/generated/instructions/update_as_update_authority_v2.rs @@ -43,12 +43,19 @@ pub struct UpdateAsUpdateAuthorityV2 { } impl UpdateAsUpdateAuthorityV2 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: UpdateAsUpdateAuthorityV2InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(11); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: UpdateAsUpdateAuthorityV2InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, true, @@ -124,6 +131,9 @@ impl UpdateAsUpdateAuthorityV2 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateAsUpdateAuthorityV2InstructionData::new() .try_to_vec() .unwrap(); @@ -153,7 +163,8 @@ impl UpdateAsUpdateAuthorityV2InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UpdateAsUpdateAuthorityV2InstructionArgs { pub new_update_authority: Option, pub data: Option, @@ -191,6 +202,7 @@ pub struct UpdateAsUpdateAuthorityV2Builder { rule_set: Option, token_standard: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl UpdateAsUpdateAuthorityV2Builder { @@ -208,16 +220,16 @@ impl UpdateAsUpdateAuthorityV2Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// `[optional account]` /// Token account #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Mint account @@ -235,8 +247,8 @@ impl UpdateAsUpdateAuthorityV2Builder { /// `[optional account]` /// Edition account #[inline(always)] - pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.edition = Some(edition); + pub fn edition(&mut self, edition: Option) -> &mut Self { + self.edition = edition; self } /// Payer @@ -245,12 +257,14 @@ impl UpdateAsUpdateAuthorityV2Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -265,9 +279,9 @@ impl UpdateAsUpdateAuthorityV2Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -275,9 +289,9 @@ impl UpdateAsUpdateAuthorityV2Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -340,8 +354,18 @@ impl UpdateAsUpdateAuthorityV2Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = UpdateAsUpdateAuthorityV2 { authority: self.authority.expect("authority is not set"), delegate_record: self.delegate_record, @@ -375,10 +399,36 @@ impl UpdateAsUpdateAuthorityV2Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `update_as_update_authority_v2` CPI accounts. +pub struct UpdateAsUpdateAuthorityV2CpiAccounts<'a> { + /// Update authority or delegate + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Delegate record PDA + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token account + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint account + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition account + pub edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `update_as_update_authority_v2` CPI instruction. pub struct UpdateAsUpdateAuthorityV2Cpi<'a> { /// The program to invoke. @@ -410,16 +460,53 @@ pub struct UpdateAsUpdateAuthorityV2Cpi<'a> { } impl<'a> UpdateAsUpdateAuthorityV2Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: UpdateAsUpdateAuthorityV2CpiAccounts<'a>, + args: UpdateAsUpdateAuthorityV2InstructionArgs, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + delegate_record: accounts.delegate_record, + token: accounts.token, + mint: accounts.mint, + metadata: accounts.metadata, + edition: accounts.edition, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11); + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, true, @@ -498,6 +585,9 @@ impl<'a> UpdateAsUpdateAuthorityV2Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateAsUpdateAuthorityV2InstructionData::new() .try_to_vec() .unwrap(); @@ -509,7 +599,7 @@ impl<'a> UpdateAsUpdateAuthorityV2Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(11 + 1); + let mut account_infos = Vec::with_capacity(11 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.authority.clone()); if let Some(delegate_record) = self.delegate_record { @@ -532,6 +622,9 @@ impl<'a> UpdateAsUpdateAuthorityV2Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -571,6 +664,7 @@ impl<'a> UpdateAsUpdateAuthorityV2CpiBuilder<'a> { rule_set: None, token_standard: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -588,16 +682,19 @@ impl<'a> UpdateAsUpdateAuthorityV2CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// `[optional account]` /// Token account #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Mint account @@ -620,9 +717,9 @@ impl<'a> UpdateAsUpdateAuthorityV2CpiBuilder<'a> { #[inline(always)] pub fn edition( &mut self, - edition: &'a solana_program::account_info::AccountInfo<'a>, + edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.edition = Some(edition); + self.instruction.edition = edition; self } /// Payer @@ -654,9 +751,9 @@ impl<'a> UpdateAsUpdateAuthorityV2CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -664,9 +761,9 @@ impl<'a> UpdateAsUpdateAuthorityV2CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -729,8 +826,34 @@ impl<'a> UpdateAsUpdateAuthorityV2CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> UpdateAsUpdateAuthorityV2Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = UpdateAsUpdateAuthorityV2InstructionArgs { new_update_authority: self.instruction.new_update_authority.clone(), data: self.instruction.data.clone(), @@ -755,8 +878,7 @@ impl<'a> UpdateAsUpdateAuthorityV2CpiBuilder<'a> { token_standard: self.instruction.token_standard.clone(), authorization_data: self.instruction.authorization_data.clone(), }; - - UpdateAsUpdateAuthorityV2Cpi { + let instruction = UpdateAsUpdateAuthorityV2Cpi { __program: self.instruction.__program, authority: self.instruction.authority.expect("authority is not set"), @@ -787,7 +909,11 @@ impl<'a> UpdateAsUpdateAuthorityV2CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -814,4 +940,5 @@ struct UpdateAsUpdateAuthorityV2CpiBuilderInstruction<'a> { rule_set: Option, token_standard: Option, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/update_metadata_account_v2.rs b/clients/rust/src/generated/instructions/update_metadata_account_v2.rs index 6fb291ea..a5f93380 100644 --- a/clients/rust/src/generated/instructions/update_metadata_account_v2.rs +++ b/clients/rust/src/generated/instructions/update_metadata_account_v2.rs @@ -19,12 +19,19 @@ pub struct UpdateMetadataAccountV2 { } impl UpdateMetadataAccountV2 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: UpdateMetadataAccountV2InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(2); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: UpdateMetadataAccountV2InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.metadata, false, @@ -33,6 +40,9 @@ impl UpdateMetadataAccountV2 { self.update_authority, true, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateMetadataAccountV2InstructionData::new() .try_to_vec() .unwrap(); @@ -58,7 +68,8 @@ impl UpdateMetadataAccountV2InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UpdateMetadataAccountV2InstructionArgs { pub data: Option, pub new_update_authority: Option, @@ -75,6 +86,7 @@ pub struct UpdateMetadataAccountV2Builder { new_update_authority: Option, primary_sale_happened: Option, is_mutable: Option, + __remaining_accounts: Vec, } impl UpdateMetadataAccountV2Builder { @@ -120,8 +132,18 @@ impl UpdateMetadataAccountV2Builder { self.is_mutable = Some(is_mutable); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = UpdateMetadataAccountV2 { metadata: self.metadata.expect("metadata is not set"), update_authority: self.update_authority.expect("update_authority is not set"), @@ -133,10 +155,18 @@ impl UpdateMetadataAccountV2Builder { is_mutable: self.is_mutable.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `update_metadata_account_v2` CPI accounts. +pub struct UpdateMetadataAccountV2CpiAccounts<'a> { + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Update authority key + pub update_authority: &'a solana_program::account_info::AccountInfo<'a>, +} + /// `update_metadata_account_v2` CPI instruction. pub struct UpdateMetadataAccountV2Cpi<'a> { /// The program to invoke. @@ -150,16 +180,44 @@ pub struct UpdateMetadataAccountV2Cpi<'a> { } impl<'a> UpdateMetadataAccountV2Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: UpdateMetadataAccountV2CpiAccounts<'a>, + args: UpdateMetadataAccountV2InstructionArgs, + ) -> Self { + Self { + __program: program, + metadata: accounts.metadata, + update_authority: accounts.update_authority, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2); + let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.metadata.key, false, @@ -168,6 +226,9 @@ impl<'a> UpdateMetadataAccountV2Cpi<'a> { *self.update_authority.key, true, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateMetadataAccountV2InstructionData::new() .try_to_vec() .unwrap(); @@ -179,10 +240,13 @@ impl<'a> UpdateMetadataAccountV2Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(2 + 1); + let mut account_infos = Vec::with_capacity(2 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.metadata.clone()); account_infos.push(self.update_authority.clone()); + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -207,6 +271,7 @@ impl<'a> UpdateMetadataAccountV2CpiBuilder<'a> { new_update_authority: None, primary_sale_happened: None, is_mutable: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -252,16 +317,41 @@ impl<'a> UpdateMetadataAccountV2CpiBuilder<'a> { self.instruction.is_mutable = Some(is_mutable); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> UpdateMetadataAccountV2Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = UpdateMetadataAccountV2InstructionArgs { data: self.instruction.data.clone(), new_update_authority: self.instruction.new_update_authority.clone(), primary_sale_happened: self.instruction.primary_sale_happened.clone(), is_mutable: self.instruction.is_mutable.clone(), }; - - UpdateMetadataAccountV2Cpi { + let instruction = UpdateMetadataAccountV2Cpi { __program: self.instruction.__program, metadata: self.instruction.metadata.expect("metadata is not set"), @@ -271,7 +361,11 @@ impl<'a> UpdateMetadataAccountV2CpiBuilder<'a> { .update_authority .expect("update_authority is not set"), __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -283,4 +377,5 @@ struct UpdateMetadataAccountV2CpiBuilderInstruction<'a> { new_update_authority: Option, primary_sale_happened: Option, is_mutable: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/update_primary_sale_happened_via_token.rs b/clients/rust/src/generated/instructions/update_primary_sale_happened_via_token.rs index 10554170..c7b1f13b 100644 --- a/clients/rust/src/generated/instructions/update_primary_sale_happened_via_token.rs +++ b/clients/rust/src/generated/instructions/update_primary_sale_happened_via_token.rs @@ -19,9 +19,15 @@ pub struct UpdatePrimarySaleHappenedViaToken { } impl UpdatePrimarySaleHappenedViaToken { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(3); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.metadata, false, @@ -32,6 +38,9 @@ impl UpdatePrimarySaleHappenedViaToken { accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.token, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = UpdatePrimarySaleHappenedViaTokenInstructionData::new() .try_to_vec() .unwrap(); @@ -61,6 +70,7 @@ pub struct UpdatePrimarySaleHappenedViaTokenBuilder { metadata: Option, owner: Option, token: Option, + __remaining_accounts: Vec, } impl UpdatePrimarySaleHappenedViaTokenBuilder { @@ -85,18 +95,38 @@ impl UpdatePrimarySaleHappenedViaTokenBuilder { self.token = Some(token); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = UpdatePrimarySaleHappenedViaToken { metadata: self.metadata.expect("metadata is not set"), owner: self.owner.expect("owner is not set"), token: self.token.expect("token is not set"), }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `update_primary_sale_happened_via_token` CPI accounts. +pub struct UpdatePrimarySaleHappenedViaTokenCpiAccounts<'a> { + /// Metadata key (pda of ['metadata', program id, mint id]) + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Owner on the token account + pub owner: &'a solana_program::account_info::AccountInfo<'a>, + /// Account containing tokens from the metadata's mint + pub token: &'a solana_program::account_info::AccountInfo<'a>, +} + /// `update_primary_sale_happened_via_token` CPI instruction. pub struct UpdatePrimarySaleHappenedViaTokenCpi<'a> { /// The program to invoke. @@ -110,16 +140,43 @@ pub struct UpdatePrimarySaleHappenedViaTokenCpi<'a> { } impl<'a> UpdatePrimarySaleHappenedViaTokenCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: UpdatePrimarySaleHappenedViaTokenCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + metadata: accounts.metadata, + owner: accounts.owner, + token: accounts.token, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3); + let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.metadata.key, false, @@ -132,6 +189,9 @@ impl<'a> UpdatePrimarySaleHappenedViaTokenCpi<'a> { *self.token.key, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = UpdatePrimarySaleHappenedViaTokenInstructionData::new() .try_to_vec() .unwrap(); @@ -141,11 +201,14 @@ impl<'a> UpdatePrimarySaleHappenedViaTokenCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(3 + 1); + let mut account_infos = Vec::with_capacity(3 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.metadata.clone()); account_infos.push(self.owner.clone()); account_infos.push(self.token.clone()); + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -167,6 +230,7 @@ impl<'a> UpdatePrimarySaleHappenedViaTokenCpiBuilder<'a> { metadata: None, owner: None, token: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -191,9 +255,35 @@ impl<'a> UpdatePrimarySaleHappenedViaTokenCpiBuilder<'a> { self.instruction.token = Some(token); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> UpdatePrimarySaleHappenedViaTokenCpi<'a> { - UpdatePrimarySaleHappenedViaTokenCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = UpdatePrimarySaleHappenedViaTokenCpi { __program: self.instruction.__program, metadata: self.instruction.metadata.expect("metadata is not set"), @@ -201,7 +291,11 @@ impl<'a> UpdatePrimarySaleHappenedViaTokenCpiBuilder<'a> { owner: self.instruction.owner.expect("owner is not set"), token: self.instruction.token.expect("token is not set"), - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -210,4 +304,5 @@ struct UpdatePrimarySaleHappenedViaTokenCpiBuilderInstruction<'a> { metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, owner: Option<&'a solana_program::account_info::AccountInfo<'a>>, token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/update_v1.rs b/clients/rust/src/generated/instructions/update_v1.rs index 39a9f547..d3a2ad61 100644 --- a/clients/rust/src/generated/instructions/update_v1.rs +++ b/clients/rust/src/generated/instructions/update_v1.rs @@ -42,12 +42,19 @@ pub struct UpdateV1 { } impl UpdateV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: UpdateV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(11); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: UpdateV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, true, @@ -123,6 +130,9 @@ impl UpdateV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateV1InstructionData::new().try_to_vec().unwrap(); let mut args = args.try_to_vec().unwrap(); data.append(&mut args); @@ -150,7 +160,8 @@ impl UpdateV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UpdateV1InstructionArgs { pub new_update_authority: Option, pub data: Option, @@ -186,6 +197,7 @@ pub struct UpdateV1Builder { uses: Option, rule_set: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl UpdateV1Builder { @@ -203,16 +215,16 @@ impl UpdateV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// `[optional account]` /// Token account #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Mint account @@ -230,8 +242,8 @@ impl UpdateV1Builder { /// `[optional account]` /// Edition account #[inline(always)] - pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.edition = Some(edition); + pub fn edition(&mut self, edition: Option) -> &mut Self { + self.edition = edition; self } /// Payer @@ -240,12 +252,14 @@ impl UpdateV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -260,9 +274,9 @@ impl UpdateV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -270,9 +284,9 @@ impl UpdateV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -329,8 +343,18 @@ impl UpdateV1Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = UpdateV1 { authority: self.authority.expect("authority is not set"), delegate_record: self.delegate_record, @@ -363,10 +387,36 @@ impl UpdateV1Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `update_v1` CPI accounts. +pub struct UpdateV1CpiAccounts<'a> { + /// Update authority or delegate + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Delegate record PDA + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token account + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint account + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition account + pub edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `update_v1` CPI instruction. pub struct UpdateV1Cpi<'a> { /// The program to invoke. @@ -398,16 +448,53 @@ pub struct UpdateV1Cpi<'a> { } impl<'a> UpdateV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: UpdateV1CpiAccounts<'a>, + args: UpdateV1InstructionArgs, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + delegate_record: accounts.delegate_record, + token: accounts.token, + mint: accounts.mint, + metadata: accounts.metadata, + edition: accounts.edition, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11); + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, true, @@ -486,6 +573,9 @@ impl<'a> UpdateV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UpdateV1InstructionData::new().try_to_vec().unwrap(); let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); @@ -495,7 +585,7 @@ impl<'a> UpdateV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(11 + 1); + let mut account_infos = Vec::with_capacity(11 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.authority.clone()); if let Some(delegate_record) = self.delegate_record { @@ -518,6 +608,9 @@ impl<'a> UpdateV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -556,6 +649,7 @@ impl<'a> UpdateV1CpiBuilder<'a> { uses: None, rule_set: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -573,16 +667,19 @@ impl<'a> UpdateV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// `[optional account]` /// Token account #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Mint account @@ -605,9 +702,9 @@ impl<'a> UpdateV1CpiBuilder<'a> { #[inline(always)] pub fn edition( &mut self, - edition: &'a solana_program::account_info::AccountInfo<'a>, + edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.edition = Some(edition); + self.instruction.edition = edition; self } /// Payer @@ -639,9 +736,9 @@ impl<'a> UpdateV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -649,9 +746,9 @@ impl<'a> UpdateV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -708,8 +805,34 @@ impl<'a> UpdateV1CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> UpdateV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = UpdateV1InstructionArgs { new_update_authority: self.instruction.new_update_authority.clone(), data: self.instruction.data.clone(), @@ -733,8 +856,7 @@ impl<'a> UpdateV1CpiBuilder<'a> { .unwrap_or(RuleSetToggle::None), authorization_data: self.instruction.authorization_data.clone(), }; - - UpdateV1Cpi { + let instruction = UpdateV1Cpi { __program: self.instruction.__program, authority: self.instruction.authority.expect("authority is not set"), @@ -765,7 +887,11 @@ impl<'a> UpdateV1CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -791,4 +917,5 @@ struct UpdateV1CpiBuilderInstruction<'a> { uses: Option, rule_set: Option, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/use_v1.rs b/clients/rust/src/generated/instructions/use_v1.rs index 709466ca..e53dd523 100644 --- a/clients/rust/src/generated/instructions/use_v1.rs +++ b/clients/rust/src/generated/instructions/use_v1.rs @@ -38,12 +38,19 @@ pub struct UseV1 { } impl UseV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: UseV1InstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(12); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: UseV1InstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, true, @@ -128,6 +135,9 @@ impl UseV1 { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UseV1InstructionData::new().try_to_vec().unwrap(); let mut args = args.try_to_vec().unwrap(); data.append(&mut args); @@ -155,7 +165,8 @@ impl UseV1InstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UseV1InstructionArgs { pub authorization_data: Option, } @@ -176,6 +187,7 @@ pub struct UseV1Builder { authorization_rules_program: Option, authorization_rules: Option, authorization_data: Option, + __remaining_accounts: Vec, } impl UseV1Builder { @@ -193,16 +205,16 @@ impl UseV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// `[optional account]` /// Token account #[inline(always)] - pub fn token(&mut self, token: solana_program::pubkey::Pubkey) -> &mut Self { - self.token = Some(token); + pub fn token(&mut self, token: Option) -> &mut Self { + self.token = token; self } /// Mint account @@ -220,8 +232,8 @@ impl UseV1Builder { /// `[optional account]` /// Edition account #[inline(always)] - pub fn edition(&mut self, edition: solana_program::pubkey::Pubkey) -> &mut Self { - self.edition = Some(edition); + pub fn edition(&mut self, edition: Option) -> &mut Self { + self.edition = edition; self } /// Payer @@ -230,12 +242,14 @@ impl UseV1Builder { self.payer = Some(payer); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// System program #[inline(always)] pub fn sysvar_instructions( @@ -250,9 +264,9 @@ impl UseV1Builder { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: solana_program::pubkey::Pubkey, + spl_token_program: Option, ) -> &mut Self { - self.spl_token_program = Some(spl_token_program); + self.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -260,9 +274,9 @@ impl UseV1Builder { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: solana_program::pubkey::Pubkey, + authorization_rules_program: Option, ) -> &mut Self { - self.authorization_rules_program = Some(authorization_rules_program); + self.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -270,9 +284,9 @@ impl UseV1Builder { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: solana_program::pubkey::Pubkey, + authorization_rules: Option, ) -> &mut Self { - self.authorization_rules = Some(authorization_rules); + self.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -281,8 +295,18 @@ impl UseV1Builder { self.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = UseV1 { authority: self.authority.expect("authority is not set"), delegate_record: self.delegate_record, @@ -305,10 +329,38 @@ impl UseV1Builder { authorization_data: self.authorization_data.clone(), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `use_v1` CPI accounts. +pub struct UseV1CpiAccounts<'a> { + /// Token owner or delegate + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Delegate record PDA + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token account + pub token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Mint account + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Edition account + pub edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, + /// SPL Token Program + pub spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules Program + pub authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Token Authorization Rules account + pub authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `use_v1` CPI instruction. pub struct UseV1Cpi<'a> { /// The program to invoke. @@ -342,16 +394,54 @@ pub struct UseV1Cpi<'a> { } impl<'a> UseV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: UseV1CpiAccounts<'a>, + args: UseV1InstructionArgs, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + delegate_record: accounts.delegate_record, + token: accounts.token, + mint: accounts.mint, + metadata: accounts.metadata, + edition: accounts.edition, + payer: accounts.payer, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + spl_token_program: accounts.spl_token_program, + authorization_rules_program: accounts.authorization_rules_program, + authorization_rules: accounts.authorization_rules, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(12); + let mut accounts = Vec::with_capacity(12 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, true, @@ -441,6 +531,9 @@ impl<'a> UseV1Cpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UseV1InstructionData::new().try_to_vec().unwrap(); let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); @@ -450,7 +543,7 @@ impl<'a> UseV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(12 + 1); + let mut account_infos = Vec::with_capacity(12 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.authority.clone()); if let Some(delegate_record) = self.delegate_record { @@ -476,6 +569,9 @@ impl<'a> UseV1Cpi<'a> { if let Some(authorization_rules) = self.authorization_rules { account_infos.push(authorization_rules.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -507,6 +603,7 @@ impl<'a> UseV1CpiBuilder<'a> { authorization_rules_program: None, authorization_rules: None, authorization_data: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -524,16 +621,19 @@ impl<'a> UseV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// `[optional account]` /// Token account #[inline(always)] - pub fn token(&mut self, token: &'a solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.token = Some(token); + pub fn token( + &mut self, + token: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.token = token; self } /// Mint account @@ -556,9 +656,9 @@ impl<'a> UseV1CpiBuilder<'a> { #[inline(always)] pub fn edition( &mut self, - edition: &'a solana_program::account_info::AccountInfo<'a>, + edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.edition = Some(edition); + self.instruction.edition = edition; self } /// Payer @@ -590,9 +690,9 @@ impl<'a> UseV1CpiBuilder<'a> { #[inline(always)] pub fn spl_token_program( &mut self, - spl_token_program: &'a solana_program::account_info::AccountInfo<'a>, + spl_token_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.spl_token_program = Some(spl_token_program); + self.instruction.spl_token_program = spl_token_program; self } /// `[optional account]` @@ -600,9 +700,9 @@ impl<'a> UseV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules_program( &mut self, - authorization_rules_program: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules_program = Some(authorization_rules_program); + self.instruction.authorization_rules_program = authorization_rules_program; self } /// `[optional account]` @@ -610,9 +710,9 @@ impl<'a> UseV1CpiBuilder<'a> { #[inline(always)] pub fn authorization_rules( &mut self, - authorization_rules: &'a solana_program::account_info::AccountInfo<'a>, + authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.authorization_rules = Some(authorization_rules); + self.instruction.authorization_rules = authorization_rules; self } /// `[optional argument]` @@ -621,13 +721,38 @@ impl<'a> UseV1CpiBuilder<'a> { self.instruction.authorization_data = Some(authorization_data); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> UseV1Cpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = UseV1InstructionArgs { authorization_data: self.instruction.authorization_data.clone(), }; - - UseV1Cpi { + let instruction = UseV1Cpi { __program: self.instruction.__program, authority: self.instruction.authority.expect("authority is not set"), @@ -660,7 +785,11 @@ impl<'a> UseV1CpiBuilder<'a> { authorization_rules: self.instruction.authorization_rules, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -679,4 +808,5 @@ struct UseV1CpiBuilderInstruction<'a> { authorization_rules_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_rules: Option<&'a solana_program::account_info::AccountInfo<'a>>, authorization_data: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/utilize.rs b/clients/rust/src/generated/instructions/utilize.rs index c14c1973..26587a7a 100644 --- a/clients/rust/src/generated/instructions/utilize.rs +++ b/clients/rust/src/generated/instructions/utilize.rs @@ -35,12 +35,19 @@ pub struct Utilize { } impl Utilize { - #[allow(clippy::vec_init_then_push)] pub fn instruction( &self, args: UtilizeInstructionArgs, ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(11); + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: UtilizeInstructionArgs, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.metadata, false, @@ -85,6 +92,9 @@ impl Utilize { burner, false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UtilizeInstructionData::new().try_to_vec().unwrap(); let mut args = args.try_to_vec().unwrap(); data.append(&mut args); @@ -108,7 +118,8 @@ impl UtilizeInstructionData { } } -#[derive(BorshSerialize, BorshDeserialize, Debug)] +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UtilizeInstructionArgs { pub number_of_uses: u64, } @@ -128,6 +139,7 @@ pub struct UtilizeBuilder { use_authority_record: Option, burner: Option, number_of_uses: Option, + __remaining_accounts: Vec, } impl UtilizeBuilder { @@ -164,24 +176,28 @@ impl UtilizeBuilder { self.owner = Some(owner); self } + /// `[optional account, default to 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA']` /// Token program #[inline(always)] pub fn token_program(&mut self, token_program: solana_program::pubkey::Pubkey) -> &mut Self { self.token_program = Some(token_program); self } + /// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']` /// Associated Token program #[inline(always)] pub fn ata_program(&mut self, ata_program: solana_program::pubkey::Pubkey) -> &mut Self { self.ata_program = Some(ata_program); self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` /// Rent info #[inline(always)] pub fn rent(&mut self, rent: solana_program::pubkey::Pubkey) -> &mut Self { @@ -193,16 +209,16 @@ impl UtilizeBuilder { #[inline(always)] pub fn use_authority_record( &mut self, - use_authority_record: solana_program::pubkey::Pubkey, + use_authority_record: Option, ) -> &mut Self { - self.use_authority_record = Some(use_authority_record); + self.use_authority_record = use_authority_record; self } /// `[optional account]` /// Program As Signer (Burner) #[inline(always)] - pub fn burner(&mut self, burner: solana_program::pubkey::Pubkey) -> &mut Self { - self.burner = Some(burner); + pub fn burner(&mut self, burner: Option) -> &mut Self { + self.burner = burner; self } #[inline(always)] @@ -210,8 +226,18 @@ impl UtilizeBuilder { self.number_of_uses = Some(number_of_uses); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = Utilize { metadata: self.metadata.expect("metadata is not set"), token_account: self.token_account.expect("token_account is not set"), @@ -240,10 +266,36 @@ impl UtilizeBuilder { .expect("number_of_uses is not set"), }; - accounts.instruction(args) + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) } } +/// `utilize` CPI accounts. +pub struct UtilizeCpiAccounts<'a> { + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Token Account Of NFT + pub token_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of the Metadata + pub mint: &'a solana_program::account_info::AccountInfo<'a>, + /// A Use Authority / Can be the current Owner of the NFT + pub use_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Owner + pub owner: &'a solana_program::account_info::AccountInfo<'a>, + /// Token program + pub token_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Associated Token program + pub ata_program: &'a solana_program::account_info::AccountInfo<'a>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Rent info + pub rent: &'a solana_program::account_info::AccountInfo<'a>, + /// Use Authority Record PDA If present the program Assumes a delegated use authority + pub use_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Program As Signer (Burner) + pub burner: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `utilize` CPI instruction. pub struct UtilizeCpi<'a> { /// The program to invoke. @@ -275,16 +327,53 @@ pub struct UtilizeCpi<'a> { } impl<'a> UtilizeCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: UtilizeCpiAccounts<'a>, + args: UtilizeInstructionArgs, + ) -> Self { + Self { + __program: program, + metadata: accounts.metadata, + token_account: accounts.token_account, + mint: accounts.mint, + use_authority: accounts.use_authority, + owner: accounts.owner, + token_program: accounts.token_program, + ata_program: accounts.ata_program, + system_program: accounts.system_program, + rent: accounts.rent, + use_authority_record: accounts.use_authority_record, + burner: accounts.burner, + __args: args, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(11); + let mut accounts = Vec::with_capacity(11 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.metadata.key, false, @@ -333,6 +422,9 @@ impl<'a> UtilizeCpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let mut data = UtilizeInstructionData::new().try_to_vec().unwrap(); let mut args = self.__args.try_to_vec().unwrap(); data.append(&mut args); @@ -342,7 +434,7 @@ impl<'a> UtilizeCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(11 + 1); + let mut account_infos = Vec::with_capacity(11 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.metadata.clone()); account_infos.push(self.token_account.clone()); @@ -359,6 +451,9 @@ impl<'a> UtilizeCpi<'a> { if let Some(burner) = self.burner { account_infos.push(burner.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -389,6 +484,7 @@ impl<'a> UtilizeCpiBuilder<'a> { use_authority_record: None, burner: None, number_of_uses: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -469,9 +565,9 @@ impl<'a> UtilizeCpiBuilder<'a> { #[inline(always)] pub fn use_authority_record( &mut self, - use_authority_record: &'a solana_program::account_info::AccountInfo<'a>, + use_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.use_authority_record = Some(use_authority_record); + self.instruction.use_authority_record = use_authority_record; self } /// `[optional account]` @@ -479,9 +575,9 @@ impl<'a> UtilizeCpiBuilder<'a> { #[inline(always)] pub fn burner( &mut self, - burner: &'a solana_program::account_info::AccountInfo<'a>, + burner: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.burner = Some(burner); + self.instruction.burner = burner; self } #[inline(always)] @@ -489,8 +585,34 @@ impl<'a> UtilizeCpiBuilder<'a> { self.instruction.number_of_uses = Some(number_of_uses); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> UtilizeCpi<'a> { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { let args = UtilizeInstructionArgs { number_of_uses: self .instruction @@ -498,8 +620,7 @@ impl<'a> UtilizeCpiBuilder<'a> { .clone() .expect("number_of_uses is not set"), }; - - UtilizeCpi { + let instruction = UtilizeCpi { __program: self.instruction.__program, metadata: self.instruction.metadata.expect("metadata is not set"), @@ -539,7 +660,11 @@ impl<'a> UtilizeCpiBuilder<'a> { burner: self.instruction.burner, __args: args, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -557,4 +682,5 @@ struct UtilizeCpiBuilderInstruction<'a> { use_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, burner: Option<&'a solana_program::account_info::AccountInfo<'a>>, number_of_uses: Option, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/verify_collection.rs b/clients/rust/src/generated/instructions/verify_collection.rs index c9a7039e..4bb43e21 100644 --- a/clients/rust/src/generated/instructions/verify_collection.rs +++ b/clients/rust/src/generated/instructions/verify_collection.rs @@ -27,9 +27,15 @@ pub struct VerifyCollection { } impl VerifyCollection { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(7); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.metadata, false, @@ -59,6 +65,9 @@ impl VerifyCollection { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = VerifyCollectionInstructionData::new().try_to_vec().unwrap(); solana_program::instruction::Instruction { @@ -90,6 +99,7 @@ pub struct VerifyCollectionBuilder { collection: Option, collection_master_edition_account: Option, collection_authority_record: Option, + __remaining_accounts: Vec, } impl VerifyCollectionBuilder { @@ -146,13 +156,23 @@ impl VerifyCollectionBuilder { #[inline(always)] pub fn collection_authority_record( &mut self, - collection_authority_record: solana_program::pubkey::Pubkey, + collection_authority_record: Option, ) -> &mut Self { - self.collection_authority_record = Some(collection_authority_record); + self.collection_authority_record = collection_authority_record; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = VerifyCollection { metadata: self.metadata.expect("metadata is not set"), collection_authority: self @@ -167,10 +187,28 @@ impl VerifyCollectionBuilder { collection_authority_record: self.collection_authority_record, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `verify_collection` CPI accounts. +pub struct VerifyCollectionCpiAccounts<'a> { + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Collection Update authority + pub collection_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of the Collection + pub collection_mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata Account of the Collection + pub collection: &'a solana_program::account_info::AccountInfo<'a>, + /// MasterEdition2 Account of the Collection Token + pub collection_master_edition_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Collection Authority Record PDA + pub collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `verify_collection` CPI instruction. pub struct VerifyCollectionCpi<'a> { /// The program to invoke. @@ -192,16 +230,47 @@ pub struct VerifyCollectionCpi<'a> { } impl<'a> VerifyCollectionCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: VerifyCollectionCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + metadata: accounts.metadata, + collection_authority: accounts.collection_authority, + payer: accounts.payer, + collection_mint: accounts.collection_mint, + collection: accounts.collection, + collection_master_edition_account: accounts.collection_master_edition_account, + collection_authority_record: accounts.collection_authority_record, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7); + let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.metadata.key, false, @@ -232,6 +301,9 @@ impl<'a> VerifyCollectionCpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = VerifyCollectionInstructionData::new().try_to_vec().unwrap(); let instruction = solana_program::instruction::Instruction { @@ -239,7 +311,7 @@ impl<'a> VerifyCollectionCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(7 + 1); + let mut account_infos = Vec::with_capacity(7 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.metadata.clone()); account_infos.push(self.collection_authority.clone()); @@ -250,6 +322,9 @@ impl<'a> VerifyCollectionCpi<'a> { if let Some(collection_authority_record) = self.collection_authority_record { account_infos.push(collection_authority_record.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -275,6 +350,7 @@ impl<'a> VerifyCollectionCpiBuilder<'a> { collection: None, collection_master_edition_account: None, collection_authority_record: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -335,14 +411,40 @@ impl<'a> VerifyCollectionCpiBuilder<'a> { #[inline(always)] pub fn collection_authority_record( &mut self, - collection_authority_record: &'a solana_program::account_info::AccountInfo<'a>, + collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.collection_authority_record = collection_authority_record; + self + } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, ) -> &mut Self { - self.instruction.collection_authority_record = Some(collection_authority_record); + self.instruction.__remaining_accounts.push(account); self } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> VerifyCollectionCpi<'a> { - VerifyCollectionCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = VerifyCollectionCpi { __program: self.instruction.__program, metadata: self.instruction.metadata.expect("metadata is not set"), @@ -367,7 +469,11 @@ impl<'a> VerifyCollectionCpiBuilder<'a> { .expect("collection_master_edition_account is not set"), collection_authority_record: self.instruction.collection_authority_record, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -380,4 +486,5 @@ struct VerifyCollectionCpiBuilderInstruction<'a> { collection: Option<&'a solana_program::account_info::AccountInfo<'a>>, collection_master_edition_account: Option<&'a solana_program::account_info::AccountInfo<'a>>, collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/verify_collection_v1.rs b/clients/rust/src/generated/instructions/verify_collection_v1.rs index 7076c707..cba703eb 100644 --- a/clients/rust/src/generated/instructions/verify_collection_v1.rs +++ b/clients/rust/src/generated/instructions/verify_collection_v1.rs @@ -29,9 +29,15 @@ pub struct VerifyCollectionV1 { } impl VerifyCollectionV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(8); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, true, @@ -85,6 +91,9 @@ impl VerifyCollectionV1 { self.sysvar_instructions, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = VerifyCollectionV1InstructionData::new() .try_to_vec() .unwrap(); @@ -123,6 +132,7 @@ pub struct VerifyCollectionV1Builder { collection_master_edition: Option, system_program: Option, sysvar_instructions: Option, + __remaining_accounts: Vec, } impl VerifyCollectionV1Builder { @@ -140,9 +150,9 @@ impl VerifyCollectionV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Metadata account @@ -165,9 +175,9 @@ impl VerifyCollectionV1Builder { #[inline(always)] pub fn collection_metadata( &mut self, - collection_metadata: solana_program::pubkey::Pubkey, + collection_metadata: Option, ) -> &mut Self { - self.collection_metadata = Some(collection_metadata); + self.collection_metadata = collection_metadata; self } /// `[optional account]` @@ -175,17 +185,19 @@ impl VerifyCollectionV1Builder { #[inline(always)] pub fn collection_master_edition( &mut self, - collection_master_edition: solana_program::pubkey::Pubkey, + collection_master_edition: Option, ) -> &mut Self { - self.collection_master_edition = Some(collection_master_edition); + self.collection_master_edition = collection_master_edition; self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -195,8 +207,18 @@ impl VerifyCollectionV1Builder { self.sysvar_instructions = Some(sysvar_instructions); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = VerifyCollectionV1 { authority: self.authority.expect("authority is not set"), delegate_record: self.delegate_record, @@ -212,10 +234,30 @@ impl VerifyCollectionV1Builder { )), }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `verify_collection_v1` CPI accounts. +pub struct VerifyCollectionV1CpiAccounts<'a> { + /// Creator to verify, collection update authority or delegate + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Delegate record PDA + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of the Collection + pub collection_mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata Account of the Collection + pub collection_metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Master Edition Account of the Collection Token + pub collection_master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, +} + /// `verify_collection_v1` CPI instruction. pub struct VerifyCollectionV1Cpi<'a> { /// The program to invoke. @@ -239,16 +281,48 @@ pub struct VerifyCollectionV1Cpi<'a> { } impl<'a> VerifyCollectionV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: VerifyCollectionV1CpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + delegate_record: accounts.delegate_record, + metadata: accounts.metadata, + collection_mint: accounts.collection_mint, + collection_metadata: accounts.collection_metadata, + collection_master_edition: accounts.collection_master_edition, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8); + let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, true, @@ -302,6 +376,9 @@ impl<'a> VerifyCollectionV1Cpi<'a> { *self.sysvar_instructions.key, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = VerifyCollectionV1InstructionData::new() .try_to_vec() .unwrap(); @@ -311,7 +388,7 @@ impl<'a> VerifyCollectionV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(8 + 1); + let mut account_infos = Vec::with_capacity(8 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.authority.clone()); if let Some(delegate_record) = self.delegate_record { @@ -327,6 +404,9 @@ impl<'a> VerifyCollectionV1Cpi<'a> { } account_infos.push(self.system_program.clone()); account_infos.push(self.sysvar_instructions.clone()); + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -353,6 +433,7 @@ impl<'a> VerifyCollectionV1CpiBuilder<'a> { collection_master_edition: None, system_program: None, sysvar_instructions: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -370,9 +451,9 @@ impl<'a> VerifyCollectionV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Metadata account @@ -398,9 +479,9 @@ impl<'a> VerifyCollectionV1CpiBuilder<'a> { #[inline(always)] pub fn collection_metadata( &mut self, - collection_metadata: &'a solana_program::account_info::AccountInfo<'a>, + collection_metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.collection_metadata = Some(collection_metadata); + self.instruction.collection_metadata = collection_metadata; self } /// `[optional account]` @@ -408,9 +489,9 @@ impl<'a> VerifyCollectionV1CpiBuilder<'a> { #[inline(always)] pub fn collection_master_edition( &mut self, - collection_master_edition: &'a solana_program::account_info::AccountInfo<'a>, + collection_master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.collection_master_edition = Some(collection_master_edition); + self.instruction.collection_master_edition = collection_master_edition; self } /// System program @@ -431,9 +512,35 @@ impl<'a> VerifyCollectionV1CpiBuilder<'a> { self.instruction.sysvar_instructions = Some(sysvar_instructions); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> VerifyCollectionV1Cpi<'a> { - VerifyCollectionV1Cpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = VerifyCollectionV1Cpi { __program: self.instruction.__program, authority: self.instruction.authority.expect("authority is not set"), @@ -460,7 +567,11 @@ impl<'a> VerifyCollectionV1CpiBuilder<'a> { .instruction .sysvar_instructions .expect("sysvar_instructions is not set"), - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -474,4 +585,5 @@ struct VerifyCollectionV1CpiBuilderInstruction<'a> { collection_master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, system_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, sysvar_instructions: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/verify_creator_v1.rs b/clients/rust/src/generated/instructions/verify_creator_v1.rs index 016cb424..d3787c19 100644 --- a/clients/rust/src/generated/instructions/verify_creator_v1.rs +++ b/clients/rust/src/generated/instructions/verify_creator_v1.rs @@ -29,9 +29,15 @@ pub struct VerifyCreatorV1 { } impl VerifyCreatorV1 { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(8); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, true, @@ -92,6 +98,9 @@ impl VerifyCreatorV1 { self.sysvar_instructions, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = VerifyCreatorV1InstructionData::new().try_to_vec().unwrap(); solana_program::instruction::Instruction { @@ -128,6 +137,7 @@ pub struct VerifyCreatorV1Builder { collection_master_edition: Option, system_program: Option, sysvar_instructions: Option, + __remaining_accounts: Vec, } impl VerifyCreatorV1Builder { @@ -145,9 +155,9 @@ impl VerifyCreatorV1Builder { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: solana_program::pubkey::Pubkey, + delegate_record: Option, ) -> &mut Self { - self.delegate_record = Some(delegate_record); + self.delegate_record = delegate_record; self } /// Metadata account @@ -161,9 +171,9 @@ impl VerifyCreatorV1Builder { #[inline(always)] pub fn collection_mint( &mut self, - collection_mint: solana_program::pubkey::Pubkey, + collection_mint: Option, ) -> &mut Self { - self.collection_mint = Some(collection_mint); + self.collection_mint = collection_mint; self } /// `[optional account]` @@ -171,9 +181,9 @@ impl VerifyCreatorV1Builder { #[inline(always)] pub fn collection_metadata( &mut self, - collection_metadata: solana_program::pubkey::Pubkey, + collection_metadata: Option, ) -> &mut Self { - self.collection_metadata = Some(collection_metadata); + self.collection_metadata = collection_metadata; self } /// `[optional account]` @@ -181,17 +191,19 @@ impl VerifyCreatorV1Builder { #[inline(always)] pub fn collection_master_edition( &mut self, - collection_master_edition: solana_program::pubkey::Pubkey, + collection_master_edition: Option, ) -> &mut Self { - self.collection_master_edition = Some(collection_master_edition); + self.collection_master_edition = collection_master_edition; self } + /// `[optional account, default to '11111111111111111111111111111111']` /// System program #[inline(always)] pub fn system_program(&mut self, system_program: solana_program::pubkey::Pubkey) -> &mut Self { self.system_program = Some(system_program); self } + /// `[optional account, default to 'Sysvar1nstructions1111111111111111111111111']` /// Instructions sysvar account #[inline(always)] pub fn sysvar_instructions( @@ -201,8 +213,18 @@ impl VerifyCreatorV1Builder { self.sysvar_instructions = Some(sysvar_instructions); self } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = VerifyCreatorV1 { authority: self.authority.expect("authority is not set"), delegate_record: self.delegate_record, @@ -218,10 +240,30 @@ impl VerifyCreatorV1Builder { )), }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `verify_creator_v1` CPI accounts. +pub struct VerifyCreatorV1CpiAccounts<'a> { + /// Creator to verify, collection update authority or delegate + pub authority: &'a solana_program::account_info::AccountInfo<'a>, + /// Delegate record PDA + pub delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of the Collection + pub collection_mint: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Metadata Account of the Collection + pub collection_metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// Master Edition Account of the Collection Token + pub collection_master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, + /// System program + pub system_program: &'a solana_program::account_info::AccountInfo<'a>, + /// Instructions sysvar account + pub sysvar_instructions: &'a solana_program::account_info::AccountInfo<'a>, +} + /// `verify_creator_v1` CPI instruction. pub struct VerifyCreatorV1Cpi<'a> { /// The program to invoke. @@ -245,16 +287,48 @@ pub struct VerifyCreatorV1Cpi<'a> { } impl<'a> VerifyCreatorV1Cpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: VerifyCreatorV1CpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + authority: accounts.authority, + delegate_record: accounts.delegate_record, + metadata: accounts.metadata, + collection_mint: accounts.collection_mint, + collection_metadata: accounts.collection_metadata, + collection_master_edition: accounts.collection_master_edition, + system_program: accounts.system_program, + sysvar_instructions: accounts.sysvar_instructions, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(8); + let mut accounts = Vec::with_capacity(8 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, true, @@ -315,6 +389,9 @@ impl<'a> VerifyCreatorV1Cpi<'a> { *self.sysvar_instructions.key, false, )); + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = VerifyCreatorV1InstructionData::new().try_to_vec().unwrap(); let instruction = solana_program::instruction::Instruction { @@ -322,7 +399,7 @@ impl<'a> VerifyCreatorV1Cpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(8 + 1); + let mut account_infos = Vec::with_capacity(8 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.authority.clone()); if let Some(delegate_record) = self.delegate_record { @@ -340,6 +417,9 @@ impl<'a> VerifyCreatorV1Cpi<'a> { } account_infos.push(self.system_program.clone()); account_infos.push(self.sysvar_instructions.clone()); + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -366,6 +446,7 @@ impl<'a> VerifyCreatorV1CpiBuilder<'a> { collection_master_edition: None, system_program: None, sysvar_instructions: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -383,9 +464,9 @@ impl<'a> VerifyCreatorV1CpiBuilder<'a> { #[inline(always)] pub fn delegate_record( &mut self, - delegate_record: &'a solana_program::account_info::AccountInfo<'a>, + delegate_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.delegate_record = Some(delegate_record); + self.instruction.delegate_record = delegate_record; self } /// Metadata account @@ -402,9 +483,9 @@ impl<'a> VerifyCreatorV1CpiBuilder<'a> { #[inline(always)] pub fn collection_mint( &mut self, - collection_mint: &'a solana_program::account_info::AccountInfo<'a>, + collection_mint: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.collection_mint = Some(collection_mint); + self.instruction.collection_mint = collection_mint; self } /// `[optional account]` @@ -412,9 +493,9 @@ impl<'a> VerifyCreatorV1CpiBuilder<'a> { #[inline(always)] pub fn collection_metadata( &mut self, - collection_metadata: &'a solana_program::account_info::AccountInfo<'a>, + collection_metadata: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.collection_metadata = Some(collection_metadata); + self.instruction.collection_metadata = collection_metadata; self } /// `[optional account]` @@ -422,9 +503,9 @@ impl<'a> VerifyCreatorV1CpiBuilder<'a> { #[inline(always)] pub fn collection_master_edition( &mut self, - collection_master_edition: &'a solana_program::account_info::AccountInfo<'a>, + collection_master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, ) -> &mut Self { - self.instruction.collection_master_edition = Some(collection_master_edition); + self.instruction.collection_master_edition = collection_master_edition; self } /// System program @@ -445,9 +526,35 @@ impl<'a> VerifyCreatorV1CpiBuilder<'a> { self.instruction.sysvar_instructions = Some(sysvar_instructions); self } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, + ) -> &mut Self { + self.instruction.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> VerifyCreatorV1Cpi<'a> { - VerifyCreatorV1Cpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = VerifyCreatorV1Cpi { __program: self.instruction.__program, authority: self.instruction.authority.expect("authority is not set"), @@ -471,7 +578,11 @@ impl<'a> VerifyCreatorV1CpiBuilder<'a> { .instruction .sysvar_instructions .expect("sysvar_instructions is not set"), - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -485,4 +596,5 @@ struct VerifyCreatorV1CpiBuilderInstruction<'a> { collection_master_edition: Option<&'a solana_program::account_info::AccountInfo<'a>>, system_program: Option<&'a solana_program::account_info::AccountInfo<'a>>, sysvar_instructions: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/instructions/verify_sized_collection_item.rs b/clients/rust/src/generated/instructions/verify_sized_collection_item.rs index 74f97809..c61955e1 100644 --- a/clients/rust/src/generated/instructions/verify_sized_collection_item.rs +++ b/clients/rust/src/generated/instructions/verify_sized_collection_item.rs @@ -27,9 +27,15 @@ pub struct VerifySizedCollectionItem { } impl VerifySizedCollectionItem { - #[allow(clippy::vec_init_then_push)] pub fn instruction(&self) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(7); + self.instruction_with_remaining_accounts(&[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccount], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.metadata, false, @@ -59,6 +65,9 @@ impl VerifySizedCollectionItem { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = VerifySizedCollectionItemInstructionData::new() .try_to_vec() .unwrap(); @@ -92,6 +101,7 @@ pub struct VerifySizedCollectionItemBuilder { collection: Option, collection_master_edition_account: Option, collection_authority_record: Option, + __remaining_accounts: Vec, } impl VerifySizedCollectionItemBuilder { @@ -148,13 +158,23 @@ impl VerifySizedCollectionItemBuilder { #[inline(always)] pub fn collection_authority_record( &mut self, - collection_authority_record: solana_program::pubkey::Pubkey, + collection_authority_record: Option, ) -> &mut Self { - self.collection_authority_record = Some(collection_authority_record); + self.collection_authority_record = collection_authority_record; + self + } + #[inline(always)] + pub fn add_remaining_account(&mut self, account: super::InstructionAccount) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + #[inline(always)] + pub fn add_remaining_accounts(&mut self, accounts: &[super::InstructionAccount]) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); self } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> solana_program::instruction::Instruction { + pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = VerifySizedCollectionItem { metadata: self.metadata.expect("metadata is not set"), collection_authority: self @@ -169,10 +189,28 @@ impl VerifySizedCollectionItemBuilder { collection_authority_record: self.collection_authority_record, }; - accounts.instruction() + accounts.instruction_with_remaining_accounts(&self.__remaining_accounts) } } +/// `verify_sized_collection_item` CPI accounts. +pub struct VerifySizedCollectionItemCpiAccounts<'a> { + /// Metadata account + pub metadata: &'a solana_program::account_info::AccountInfo<'a>, + /// Collection Update authority + pub collection_authority: &'a solana_program::account_info::AccountInfo<'a>, + /// payer + pub payer: &'a solana_program::account_info::AccountInfo<'a>, + /// Mint of the Collection + pub collection_mint: &'a solana_program::account_info::AccountInfo<'a>, + /// Metadata Account of the Collection + pub collection: &'a solana_program::account_info::AccountInfo<'a>, + /// MasterEdition2 Account of the Collection Token + pub collection_master_edition_account: &'a solana_program::account_info::AccountInfo<'a>, + /// Collection Authority Record PDA + pub collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, +} + /// `verify_sized_collection_item` CPI instruction. pub struct VerifySizedCollectionItemCpi<'a> { /// The program to invoke. @@ -194,16 +232,47 @@ pub struct VerifySizedCollectionItemCpi<'a> { } impl<'a> VerifySizedCollectionItemCpi<'a> { + pub fn new( + program: &'a solana_program::account_info::AccountInfo<'a>, + accounts: VerifySizedCollectionItemCpiAccounts<'a>, + ) -> Self { + Self { + __program: program, + metadata: accounts.metadata, + collection_authority: accounts.collection_authority, + payer: accounts.payer, + collection_mint: accounts.collection_mint, + collection: accounts.collection, + collection_master_edition_account: accounts.collection_master_edition_account, + collection_authority_record: accounts.collection_authority_record, + } + } + #[inline(always)] pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { - self.invoke_signed(&[]) + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[super::InstructionAccountInfo<'a>], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) } #[allow(clippy::clone_on_copy)] #[allow(clippy::vec_init_then_push)] - pub fn invoke_signed( + pub fn invoke_signed_with_remaining_accounts( &self, signers_seeds: &[&[&[u8]]], + remaining_accounts: &[super::InstructionAccountInfo<'a>], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(7); + let mut accounts = Vec::with_capacity(7 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.metadata.key, false, @@ -234,6 +303,9 @@ impl<'a> VerifySizedCollectionItemCpi<'a> { false, )); } + remaining_accounts + .iter() + .for_each(|remaining_account| accounts.push(remaining_account.to_account_meta())); let data = VerifySizedCollectionItemInstructionData::new() .try_to_vec() .unwrap(); @@ -243,7 +315,7 @@ impl<'a> VerifySizedCollectionItemCpi<'a> { accounts, data, }; - let mut account_infos = Vec::with_capacity(7 + 1); + let mut account_infos = Vec::with_capacity(7 + 1 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.metadata.clone()); account_infos.push(self.collection_authority.clone()); @@ -254,6 +326,9 @@ impl<'a> VerifySizedCollectionItemCpi<'a> { if let Some(collection_authority_record) = self.collection_authority_record { account_infos.push(collection_authority_record.clone()); } + remaining_accounts.iter().for_each(|remaining_account| { + account_infos.push(remaining_account.account_info().clone()) + }); if signers_seeds.is_empty() { solana_program::program::invoke(&instruction, &account_infos) @@ -279,6 +354,7 @@ impl<'a> VerifySizedCollectionItemCpiBuilder<'a> { collection: None, collection_master_edition_account: None, collection_authority_record: None, + __remaining_accounts: Vec::new(), }); Self { instruction } } @@ -339,14 +415,40 @@ impl<'a> VerifySizedCollectionItemCpiBuilder<'a> { #[inline(always)] pub fn collection_authority_record( &mut self, - collection_authority_record: &'a solana_program::account_info::AccountInfo<'a>, + collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.collection_authority_record = collection_authority_record; + self + } + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: super::InstructionAccountInfo<'a>, ) -> &mut Self { - self.instruction.collection_authority_record = Some(collection_authority_record); + self.instruction.__remaining_accounts.push(account); self } + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[super::InstructionAccountInfo<'a>], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } #[allow(clippy::clone_on_copy)] - pub fn build(&self) -> VerifySizedCollectionItemCpi<'a> { - VerifySizedCollectionItemCpi { + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let instruction = VerifySizedCollectionItemCpi { __program: self.instruction.__program, metadata: self.instruction.metadata.expect("metadata is not set"), @@ -371,7 +473,11 @@ impl<'a> VerifySizedCollectionItemCpiBuilder<'a> { .expect("collection_master_edition_account is not set"), collection_authority_record: self.instruction.collection_authority_record, - } + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) } } @@ -384,4 +490,5 @@ struct VerifySizedCollectionItemCpiBuilderInstruction<'a> { collection: Option<&'a solana_program::account_info::AccountInfo<'a>>, collection_master_edition_account: Option<&'a solana_program::account_info::AccountInfo<'a>>, collection_authority_record: Option<&'a solana_program::account_info::AccountInfo<'a>>, + __remaining_accounts: Vec>, } diff --git a/clients/rust/src/generated/types/authority_type.rs b/clients/rust/src/generated/types/authority_type.rs index 81fae4a4..e3032c9a 100644 --- a/clients/rust/src/generated/types/authority_type.rs +++ b/clients/rust/src/generated/types/authority_type.rs @@ -9,6 +9,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum AuthorityType { None, Metadata, diff --git a/clients/rust/src/generated/types/authorization_data.rs b/clients/rust/src/generated/types/authorization_data.rs index abc517cb..efeb12b0 100644 --- a/clients/rust/src/generated/types/authorization_data.rs +++ b/clients/rust/src/generated/types/authorization_data.rs @@ -10,6 +10,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizationData { pub payload: Payload, } diff --git a/clients/rust/src/generated/types/burn_args.rs b/clients/rust/src/generated/types/burn_args.rs index 074c861f..bb86e1a9 100644 --- a/clients/rust/src/generated/types/burn_args.rs +++ b/clients/rust/src/generated/types/burn_args.rs @@ -9,6 +9,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum BurnArgs { V1 { amount: u64 }, } diff --git a/clients/rust/src/generated/types/collection.rs b/clients/rust/src/generated/types/collection.rs index 7594da63..a3201493 100644 --- a/clients/rust/src/generated/types/collection.rs +++ b/clients/rust/src/generated/types/collection.rs @@ -10,7 +10,12 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Collection { pub verified: bool, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] pub key: Pubkey, } diff --git a/clients/rust/src/generated/types/collection_details.rs b/clients/rust/src/generated/types/collection_details.rs index 1a059b62..d08715e0 100644 --- a/clients/rust/src/generated/types/collection_details.rs +++ b/clients/rust/src/generated/types/collection_details.rs @@ -9,6 +9,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum CollectionDetails { V1 { size: u64 }, } diff --git a/clients/rust/src/generated/types/collection_details_toggle.rs b/clients/rust/src/generated/types/collection_details_toggle.rs index 86ad4733..5679c8f6 100644 --- a/clients/rust/src/generated/types/collection_details_toggle.rs +++ b/clients/rust/src/generated/types/collection_details_toggle.rs @@ -10,6 +10,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum CollectionDetailsToggle { None, Clear, diff --git a/clients/rust/src/generated/types/collection_toggle.rs b/clients/rust/src/generated/types/collection_toggle.rs index c032e79f..d33fd34a 100644 --- a/clients/rust/src/generated/types/collection_toggle.rs +++ b/clients/rust/src/generated/types/collection_toggle.rs @@ -10,6 +10,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum CollectionToggle { None, Clear, diff --git a/clients/rust/src/generated/types/create_args.rs b/clients/rust/src/generated/types/create_args.rs index 0c35f5b9..7b62e966 100644 --- a/clients/rust/src/generated/types/create_args.rs +++ b/clients/rust/src/generated/types/create_args.rs @@ -16,6 +16,7 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum CreateArgs { V1 { name: String, diff --git a/clients/rust/src/generated/types/creator.rs b/clients/rust/src/generated/types/creator.rs index 7c7eb67a..3c91102d 100644 --- a/clients/rust/src/generated/types/creator.rs +++ b/clients/rust/src/generated/types/creator.rs @@ -10,7 +10,12 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Creator { + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] pub address: Pubkey, pub verified: bool, pub share: u8, diff --git a/clients/rust/src/generated/types/data.rs b/clients/rust/src/generated/types/data.rs index 4189f43d..aab7a86e 100644 --- a/clients/rust/src/generated/types/data.rs +++ b/clients/rust/src/generated/types/data.rs @@ -10,6 +10,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Data { pub name: String, pub symbol: String, diff --git a/clients/rust/src/generated/types/data_v2.rs b/clients/rust/src/generated/types/data_v2.rs index f56842a3..74290566 100644 --- a/clients/rust/src/generated/types/data_v2.rs +++ b/clients/rust/src/generated/types/data_v2.rs @@ -12,6 +12,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DataV2 { pub name: String, pub symbol: String, diff --git a/clients/rust/src/generated/types/delegate_args.rs b/clients/rust/src/generated/types/delegate_args.rs index 1f72db30..65095696 100644 --- a/clients/rust/src/generated/types/delegate_args.rs +++ b/clients/rust/src/generated/types/delegate_args.rs @@ -11,6 +11,7 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum DelegateArgs { CollectionV1 { authorization_data: Option, @@ -39,6 +40,10 @@ pub enum DelegateArgs { }, LockedTransferV1 { amount: u64, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] locked_address: Pubkey, authorization_data: Option, }, diff --git a/clients/rust/src/generated/types/escrow_authority.rs b/clients/rust/src/generated/types/escrow_authority.rs index 22d11bc8..6b7a6e31 100644 --- a/clients/rust/src/generated/types/escrow_authority.rs +++ b/clients/rust/src/generated/types/escrow_authority.rs @@ -10,6 +10,7 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum EscrowAuthority { TokenOwner, Creator(Pubkey), diff --git a/clients/rust/src/generated/types/key.rs b/clients/rust/src/generated/types/key.rs index be3c0150..efb2269c 100644 --- a/clients/rust/src/generated/types/key.rs +++ b/clients/rust/src/generated/types/key.rs @@ -9,6 +9,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Key { Uninitialized, EditionV1, diff --git a/clients/rust/src/generated/types/leaf_info.rs b/clients/rust/src/generated/types/leaf_info.rs index a049bf8c..14e3cf56 100644 --- a/clients/rust/src/generated/types/leaf_info.rs +++ b/clients/rust/src/generated/types/leaf_info.rs @@ -9,6 +9,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct LeafInfo { pub leaf: [u8; 32], pub proof: Vec<[u8; 32]>, diff --git a/clients/rust/src/generated/types/lock_args.rs b/clients/rust/src/generated/types/lock_args.rs index be307f2e..0717d675 100644 --- a/clients/rust/src/generated/types/lock_args.rs +++ b/clients/rust/src/generated/types/lock_args.rs @@ -10,6 +10,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum LockArgs { V1 { authorization_data: Option, diff --git a/clients/rust/src/generated/types/metadata_delegate_role.rs b/clients/rust/src/generated/types/metadata_delegate_role.rs index ff51d00c..99580e8c 100644 --- a/clients/rust/src/generated/types/metadata_delegate_role.rs +++ b/clients/rust/src/generated/types/metadata_delegate_role.rs @@ -9,6 +9,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum MetadataDelegateRole { AuthorityItem, Collection, diff --git a/clients/rust/src/generated/types/migration_type.rs b/clients/rust/src/generated/types/migration_type.rs index f070abaf..5bf1ac13 100644 --- a/clients/rust/src/generated/types/migration_type.rs +++ b/clients/rust/src/generated/types/migration_type.rs @@ -9,6 +9,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum MigrationType { CollectionV1, ProgrammableV1, diff --git a/clients/rust/src/generated/types/mint_args.rs b/clients/rust/src/generated/types/mint_args.rs index 32a9a1f9..87b1d9b1 100644 --- a/clients/rust/src/generated/types/mint_args.rs +++ b/clients/rust/src/generated/types/mint_args.rs @@ -10,6 +10,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum MintArgs { V1 { amount: u64, diff --git a/clients/rust/src/generated/types/mint_new_edition_from_master_edition_via_token_args.rs b/clients/rust/src/generated/types/mint_new_edition_from_master_edition_via_token_args.rs index 7843f89a..4e13406f 100644 --- a/clients/rust/src/generated/types/mint_new_edition_from_master_edition_via_token_args.rs +++ b/clients/rust/src/generated/types/mint_new_edition_from_master_edition_via_token_args.rs @@ -9,6 +9,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MintNewEditionFromMasterEditionViaTokenArgs { pub edition: u64, } diff --git a/clients/rust/src/generated/types/mod.rs b/clients/rust/src/generated/types/mod.rs index d636ae58..0f03f091 100644 --- a/clients/rust/src/generated/types/mod.rs +++ b/clients/rust/src/generated/types/mod.rs @@ -5,49 +5,49 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -pub mod authority_type; -pub mod authorization_data; -pub mod burn_args; -pub mod collection; -pub mod collection_details; -pub mod collection_details_toggle; -pub mod collection_toggle; -pub mod create_args; -pub mod creator; -pub mod data; -pub mod data_v2; -pub mod delegate_args; -pub mod escrow_authority; -pub mod key; -pub mod leaf_info; -pub mod lock_args; -pub mod metadata_delegate_role; -pub mod migration_type; -pub mod mint_args; -pub mod mint_new_edition_from_master_edition_via_token_args; -pub mod payload; -pub mod payload_key; -pub mod payload_type; -pub mod print_args; -pub mod print_supply; -pub mod programmable_config; -pub mod reservation; -pub mod reservation_v1; -pub mod revoke_args; -pub mod rule_set_toggle; -pub mod seeds_vec; -pub mod set_collection_size_args; -pub mod token_delegate_role; -pub mod token_standard; -pub mod token_state; -pub mod transfer_args; -pub mod unlock_args; -pub mod update_args; -pub mod use_args; -pub mod use_method; -pub mod uses; -pub mod uses_toggle; -pub mod verification_args; +pub(crate) mod authority_type; +pub(crate) mod authorization_data; +pub(crate) mod burn_args; +pub(crate) mod collection; +pub(crate) mod collection_details; +pub(crate) mod collection_details_toggle; +pub(crate) mod collection_toggle; +pub(crate) mod create_args; +pub(crate) mod creator; +pub(crate) mod data; +pub(crate) mod data_v2; +pub(crate) mod delegate_args; +pub(crate) mod escrow_authority; +pub(crate) mod key; +pub(crate) mod leaf_info; +pub(crate) mod lock_args; +pub(crate) mod metadata_delegate_role; +pub(crate) mod migration_type; +pub(crate) mod mint_args; +pub(crate) mod mint_new_edition_from_master_edition_via_token_args; +pub(crate) mod payload; +pub(crate) mod payload_key; +pub(crate) mod payload_type; +pub(crate) mod print_args; +pub(crate) mod print_supply; +pub(crate) mod programmable_config; +pub(crate) mod reservation; +pub(crate) mod reservation_v1; +pub(crate) mod revoke_args; +pub(crate) mod rule_set_toggle; +pub(crate) mod seeds_vec; +pub(crate) mod set_collection_size_args; +pub(crate) mod token_delegate_role; +pub(crate) mod token_standard; +pub(crate) mod token_state; +pub(crate) mod transfer_args; +pub(crate) mod unlock_args; +pub(crate) mod update_args; +pub(crate) mod use_args; +pub(crate) mod use_method; +pub(crate) mod uses; +pub(crate) mod uses_toggle; +pub(crate) mod verification_args; pub use self::authority_type::*; pub use self::authorization_data::*; diff --git a/clients/rust/src/generated/types/payload.rs b/clients/rust/src/generated/types/payload.rs index c64092c3..a190829c 100644 --- a/clients/rust/src/generated/types/payload.rs +++ b/clients/rust/src/generated/types/payload.rs @@ -11,6 +11,7 @@ use borsh::BorshSerialize; use std::collections::HashMap; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Payload { pub map: HashMap, } diff --git a/clients/rust/src/generated/types/payload_key.rs b/clients/rust/src/generated/types/payload_key.rs index 7a0e3287..43345220 100644 --- a/clients/rust/src/generated/types/payload_key.rs +++ b/clients/rust/src/generated/types/payload_key.rs @@ -9,6 +9,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum PayloadKey { Amount, Authority, diff --git a/clients/rust/src/generated/types/payload_type.rs b/clients/rust/src/generated/types/payload_type.rs index ab281ff2..afe93cdf 100644 --- a/clients/rust/src/generated/types/payload_type.rs +++ b/clients/rust/src/generated/types/payload_type.rs @@ -12,6 +12,7 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum PayloadType { Pubkey(Pubkey), Seeds(SeedsVec), diff --git a/clients/rust/src/generated/types/print_args.rs b/clients/rust/src/generated/types/print_args.rs index 7b013479..a9dbfede 100644 --- a/clients/rust/src/generated/types/print_args.rs +++ b/clients/rust/src/generated/types/print_args.rs @@ -9,6 +9,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum PrintArgs { V1 { edition: u64 }, } diff --git a/clients/rust/src/generated/types/print_supply.rs b/clients/rust/src/generated/types/print_supply.rs index 71c85fa2..ff2aedbf 100644 --- a/clients/rust/src/generated/types/print_supply.rs +++ b/clients/rust/src/generated/types/print_supply.rs @@ -9,6 +9,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum PrintSupply { Zero, Limited(u64), diff --git a/clients/rust/src/generated/types/programmable_config.rs b/clients/rust/src/generated/types/programmable_config.rs index 9d2f51ec..3782e7b1 100644 --- a/clients/rust/src/generated/types/programmable_config.rs +++ b/clients/rust/src/generated/types/programmable_config.rs @@ -10,6 +10,7 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum ProgrammableConfig { V1 { rule_set: Option }, } diff --git a/clients/rust/src/generated/types/reservation.rs b/clients/rust/src/generated/types/reservation.rs index 8cdb53e5..8c7c64fe 100644 --- a/clients/rust/src/generated/types/reservation.rs +++ b/clients/rust/src/generated/types/reservation.rs @@ -10,7 +10,12 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Reservation { + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] pub address: Pubkey, pub spots_remaining: u64, pub total_spots: u64, diff --git a/clients/rust/src/generated/types/reservation_v1.rs b/clients/rust/src/generated/types/reservation_v1.rs index 77c4fce5..64471bfe 100644 --- a/clients/rust/src/generated/types/reservation_v1.rs +++ b/clients/rust/src/generated/types/reservation_v1.rs @@ -10,7 +10,12 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ReservationV1 { + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] pub address: Pubkey, pub spots_remaining: u8, pub total_spots: u8, diff --git a/clients/rust/src/generated/types/revoke_args.rs b/clients/rust/src/generated/types/revoke_args.rs index 51ff5ee5..5b4e928d 100644 --- a/clients/rust/src/generated/types/revoke_args.rs +++ b/clients/rust/src/generated/types/revoke_args.rs @@ -9,6 +9,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum RevokeArgs { CollectionV1, SaleV1, diff --git a/clients/rust/src/generated/types/rule_set_toggle.rs b/clients/rust/src/generated/types/rule_set_toggle.rs index 338e0296..9a2fea4f 100644 --- a/clients/rust/src/generated/types/rule_set_toggle.rs +++ b/clients/rust/src/generated/types/rule_set_toggle.rs @@ -10,6 +10,7 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum RuleSetToggle { None, Clear, diff --git a/clients/rust/src/generated/types/seeds_vec.rs b/clients/rust/src/generated/types/seeds_vec.rs index 3fff94e6..060e7ab8 100644 --- a/clients/rust/src/generated/types/seeds_vec.rs +++ b/clients/rust/src/generated/types/seeds_vec.rs @@ -9,6 +9,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SeedsVec { pub seeds: Vec>, } diff --git a/clients/rust/src/generated/types/set_collection_size_args.rs b/clients/rust/src/generated/types/set_collection_size_args.rs index 7e42fdf8..fdddeb74 100644 --- a/clients/rust/src/generated/types/set_collection_size_args.rs +++ b/clients/rust/src/generated/types/set_collection_size_args.rs @@ -9,6 +9,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SetCollectionSizeArgs { pub size: u64, } diff --git a/clients/rust/src/generated/types/token_delegate_role.rs b/clients/rust/src/generated/types/token_delegate_role.rs index 5bdf99bd..2eea7548 100644 --- a/clients/rust/src/generated/types/token_delegate_role.rs +++ b/clients/rust/src/generated/types/token_delegate_role.rs @@ -9,6 +9,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum TokenDelegateRole { Sale, Transfer, diff --git a/clients/rust/src/generated/types/token_standard.rs b/clients/rust/src/generated/types/token_standard.rs index 6846a51d..8ec8ab1e 100644 --- a/clients/rust/src/generated/types/token_standard.rs +++ b/clients/rust/src/generated/types/token_standard.rs @@ -9,6 +9,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum TokenStandard { NonFungible, FungibleAsset, diff --git a/clients/rust/src/generated/types/token_state.rs b/clients/rust/src/generated/types/token_state.rs index 8995fb59..1f561a9e 100644 --- a/clients/rust/src/generated/types/token_state.rs +++ b/clients/rust/src/generated/types/token_state.rs @@ -9,6 +9,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum TokenState { Unlocked, Locked, diff --git a/clients/rust/src/generated/types/transfer_args.rs b/clients/rust/src/generated/types/transfer_args.rs index 4f6c17df..f3f18c95 100644 --- a/clients/rust/src/generated/types/transfer_args.rs +++ b/clients/rust/src/generated/types/transfer_args.rs @@ -10,6 +10,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum TransferArgs { V1 { amount: u64, diff --git a/clients/rust/src/generated/types/unlock_args.rs b/clients/rust/src/generated/types/unlock_args.rs index ea911a08..9db939ff 100644 --- a/clients/rust/src/generated/types/unlock_args.rs +++ b/clients/rust/src/generated/types/unlock_args.rs @@ -10,6 +10,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum UnlockArgs { V1 { authorization_data: Option, diff --git a/clients/rust/src/generated/types/update_args.rs b/clients/rust/src/generated/types/update_args.rs index 0a35b70b..33b53973 100644 --- a/clients/rust/src/generated/types/update_args.rs +++ b/clients/rust/src/generated/types/update_args.rs @@ -17,6 +17,7 @@ use borsh::BorshSerialize; use solana_program::pubkey::Pubkey; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum UpdateArgs { V1 { new_update_authority: Option, diff --git a/clients/rust/src/generated/types/use_args.rs b/clients/rust/src/generated/types/use_args.rs index 0ace0ef9..4c0777ec 100644 --- a/clients/rust/src/generated/types/use_args.rs +++ b/clients/rust/src/generated/types/use_args.rs @@ -10,6 +10,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum UseArgs { V1 { authorization_data: Option, diff --git a/clients/rust/src/generated/types/use_method.rs b/clients/rust/src/generated/types/use_method.rs index 9b6abd42..fa514a54 100644 --- a/clients/rust/src/generated/types/use_method.rs +++ b/clients/rust/src/generated/types/use_method.rs @@ -9,6 +9,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum UseMethod { Burn, Multiple, diff --git a/clients/rust/src/generated/types/uses.rs b/clients/rust/src/generated/types/uses.rs index 3f5a8e79..a37db10a 100644 --- a/clients/rust/src/generated/types/uses.rs +++ b/clients/rust/src/generated/types/uses.rs @@ -10,6 +10,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Uses { pub use_method: UseMethod, pub remaining: u64, diff --git a/clients/rust/src/generated/types/uses_toggle.rs b/clients/rust/src/generated/types/uses_toggle.rs index f35c7ad8..d6899c2c 100644 --- a/clients/rust/src/generated/types/uses_toggle.rs +++ b/clients/rust/src/generated/types/uses_toggle.rs @@ -10,6 +10,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum UsesToggle { None, Clear, diff --git a/clients/rust/src/generated/types/verification_args.rs b/clients/rust/src/generated/types/verification_args.rs index e830b1c2..148749ee 100644 --- a/clients/rust/src/generated/types/verification_args.rs +++ b/clients/rust/src/generated/types/verification_args.rs @@ -9,6 +9,7 @@ use borsh::BorshDeserialize; use borsh::BorshSerialize; #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum VerificationArgs { CreatorV1, CollectionV1, diff --git a/clients/rust/src/hooked/metadata_delegate_role_seed.rs b/clients/rust/src/hooked/metadata_delegate_role_seed.rs index 7524c1fc..510a18c2 100644 --- a/clients/rust/src/hooked/metadata_delegate_role_seed.rs +++ b/clients/rust/src/hooked/metadata_delegate_role_seed.rs @@ -2,11 +2,11 @@ use std::fmt::{Display, Formatter, Result}; use crate::types::MetadataDelegateRole; -pub struct MetadataDelegateRoleSeed(MetadataDelegateRole); +pub type MetadataDelegateRoleSeed = MetadataDelegateRole; -impl Display for MetadataDelegateRoleSeed { +impl Display for MetadataDelegateRole { fn fmt(&self, f: &mut Formatter) -> Result { - let message = match self.0 { + let message = match self { MetadataDelegateRole::AuthorityItem => "authority_item_delegate".to_string(), MetadataDelegateRole::Collection => "collection_delegate".to_string(), MetadataDelegateRole::Use => "use_delegate".to_string(), @@ -20,9 +20,3 @@ impl Display for MetadataDelegateRoleSeed { write!(f, "{message}") } } - -impl From for MetadataDelegateRoleSeed { - fn from(role: MetadataDelegateRole) -> Self { - MetadataDelegateRoleSeed(role) - } -} diff --git a/clients/rust/tests/create.rs b/clients/rust/tests/create.rs index 5e7b7c0f..97ee637a 100644 --- a/clients/rust/tests/create.rs +++ b/clients/rust/tests/create.rs @@ -23,8 +23,6 @@ use mpl_token_metadata::{instructions::CreateV1Builder, types::TokenStandard}; mod create { - use borsh::BorshDeserialize; - use super::*; #[tokio::test] @@ -44,7 +42,7 @@ mod create { let create_ix = CreateV1Builder::new() .metadata(metadata) - .master_edition(master_edition) + .master_edition(Some(master_edition)) .mint(mint_pubkey, true) .authority(payer_pubkey) .payer(payer_pubkey) @@ -57,7 +55,7 @@ mod create { .seller_fee_basis_points(500) .token_standard(TokenStandard::NonFungible) .print_supply(PrintSupply::Zero) - .build(); + .instruction(); let tx = Transaction::new_signed_with_payer( &[create_ix], @@ -71,7 +69,7 @@ mod create { // then the metadata is created with the correct values let metadata_account = get_account(&mut context, &metadata).await; - let metadata: Metadata = Metadata::deserialize(&mut &metadata_account.data[..]).unwrap(); + let metadata = Metadata::from_bytes(&metadata_account.data).unwrap(); assert!(!metadata.primary_sale_happened); assert!(metadata.is_mutable); @@ -152,7 +150,7 @@ mod create { // then the metadata is created with the correct values let metadata_account = get_account(&mut context, &metadata).await; - let metadata: Metadata = Metadata::deserialize(&mut &metadata_account.data[..]).unwrap(); + let metadata = Metadata::from_bytes(&metadata_account.data).unwrap(); assert!(!metadata.primary_sale_happened); assert!(metadata.is_mutable); diff --git a/clients/rust/tests/lock.rs b/clients/rust/tests/lock.rs index d575f6e1..917b3578 100644 --- a/clients/rust/tests/lock.rs +++ b/clients/rust/tests/lock.rs @@ -46,14 +46,14 @@ mod lock { let delegate_ix = DelegateStandardV1Builder::new() .token(asset.token) .metadata(asset.metadata) - .master_edition(asset.master_edition) + .master_edition(Some(asset.master_edition)) .mint(asset.mint.pubkey()) .delegate(delegate.pubkey()) .authority(token_owner.pubkey()) - .spl_token_program(spl_token::ID) + .spl_token_program(Some(spl_token::ID)) .payer(payer.pubkey()) .amount(1) - .build(); + .instruction(); let tx = Transaction::new_signed_with_payer( &[delegate_ix], @@ -68,12 +68,12 @@ mod lock { let lock_ix = LockV1Builder::new() .authority(delegate.pubkey()) .metadata(asset.metadata) - .edition(asset.master_edition) + .edition(Some(asset.master_edition)) .mint(asset.mint.pubkey()) .token(asset.token) - .spl_token_program(spl_token::ID) + .spl_token_program(Some(spl_token::ID)) .payer(payer.pubkey()) - .build(); + .instruction(); let tx = Transaction::new_signed_with_payer( &[lock_ix], diff --git a/clients/rust/tests/setup/digital_asset.rs b/clients/rust/tests/setup/digital_asset.rs index cf5ec4c9..201f12b5 100644 --- a/clients/rust/tests/setup/digital_asset.rs +++ b/clients/rust/tests/setup/digital_asset.rs @@ -43,7 +43,7 @@ impl DigitalAsset { let create_ix = CreateV1Builder::new() .metadata(self.metadata) - .master_edition(self.master_edition) + .master_edition(Some(self.master_edition)) .mint(self.mint.pubkey(), true) .authority(update_authority.pubkey()) .payer(payer.pubkey()) @@ -55,7 +55,7 @@ impl DigitalAsset { .name(name) .uri(uri) .token_standard(token_standard) - .build(); + .instruction(); let tx = Transaction::new_signed_with_payer( &[create_ix], @@ -82,14 +82,14 @@ impl DigitalAsset { let mint_ix = MintV1Builder::new() .token(self.token) - .token_owner(*token_owner) + .token_owner(Some(*token_owner)) .metadata(self.metadata) - .master_edition(self.master_edition) + .master_edition(Some(self.master_edition)) .mint(self.mint.pubkey()) .authority(update_authority.pubkey()) .payer(payer.pubkey()) .amount(amount) - .build(); + .instruction(); let tx = Transaction::new_signed_with_payer( &[mint_ix], diff --git a/package.json b/package.json index 72c9c8fa..55de9d8d 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ }, "devDependencies": { "@metaplex-foundation/amman": "^0.12.1", - "@metaplex-foundation/kinobi": "^0.14.0", + "@metaplex-foundation/kinobi": "^0.15.0", "@metaplex-foundation/shank-js": "^0.1.0", "typescript": "^4.9.4" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a9763d72..8a445146 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,8 +5,8 @@ devDependencies: specifier: ^0.12.1 version: 0.12.1(typescript@4.9.5) '@metaplex-foundation/kinobi': - specifier: ^0.14.0 - version: 0.14.0 + specifier: ^0.15.0 + version: 0.15.0 '@metaplex-foundation/shank-js': specifier: ^0.1.0 version: 0.1.0 @@ -85,8 +85,8 @@ packages: resolution: {integrity: sha512-S9RulC2fFCFOQraz61bij+5YCHhSO9llJegK8c8Y6731fSi6snUSQJdCUqYS8AIgR0TKbQvdvgSyIIdbDFZbBA==} dev: true - /@metaplex-foundation/kinobi@0.14.0: - resolution: {integrity: sha512-8mtyxjNs4gPcs9VA+NrWaLdlRhBy+wSmQ+wsxoCGIb5u9H5l8yHgl0WefDoesNpd02y2660Ki9XFiY6BDNY0dA==} + /@metaplex-foundation/kinobi@0.15.0: + resolution: {integrity: sha512-wIkuZd04qM1UwmV1/vNN9fmze0YE/uWn7iOhBNsU+j/wQJSJn2sYrNYcMGDzJCDS9bZmZPDp6K9N7jaEtSdMRA==} dependencies: '@noble/hashes': 1.2.0 chalk: 4.1.2