Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP of making ATA program optional #83

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clients/js/src/generated/instructions/mintV1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export function mintV1(
}
if (!resolvedAccounts.splAtaProgram.value) {
resolvedAccounts.splAtaProgram.value = context.programs.getPublicKey(
'splAssociatedToken',
'splAssociatedTokenProgram',
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'
);
resolvedAccounts.splAtaProgram.isWritable = false;
Expand Down
2 changes: 1 addition & 1 deletion clients/js/src/generated/instructions/printV1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export function printV1(
}
if (!resolvedAccounts.splAtaProgram.value) {
resolvedAccounts.splAtaProgram.value = context.programs.getPublicKey(
'splAssociatedToken',
'splAssociatedTokenProgram',
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'
);
resolvedAccounts.splAtaProgram.isWritable = false;
Expand Down
2 changes: 1 addition & 1 deletion clients/js/src/generated/instructions/transferV1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export function transferV1(
}
if (!resolvedAccounts.splAtaProgram.value) {
resolvedAccounts.splAtaProgram.value = context.programs.getPublicKey(
'splAssociatedToken',
'splAssociatedTokenProgram',
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'
);
resolvedAccounts.splAtaProgram.isWritable = false;
Expand Down
12 changes: 0 additions & 12 deletions clients/rust/src/generated/accounts/collection_authority_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,6 @@ pub struct CollectionAuthorityRecord {
}

impl CollectionAuthorityRecord {
/// Prefix values used to generate a PDA for this account.
///
/// Values are positional and appear in the following order:
///
/// 0. `CollectionAuthorityRecord::PREFIX.0`
/// 1. `crate::MPL_TOKEN_METADATA_ID`
/// 2. mint (`Pubkey`)
/// 3. `CollectionAuthorityRecord::PREFIX.1`
/// 4. collection_authority (`Pubkey`)
pub const PREFIX: (&'static [u8], &'static [u8]) =
("metadata".as_bytes(), "collection_authority".as_bytes());

pub fn create_pda(
mint: Pubkey,
collection_authority: Pubkey,
Expand Down
11 changes: 0 additions & 11 deletions clients/rust/src/generated/accounts/edition_marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@ pub struct EditionMarker {

impl EditionMarker {
pub const LEN: usize = 32;
/// Prefix values used to generate a PDA for this account.
///
/// Values are positional and appear in the following order:
///
/// 0. `EditionMarker::PREFIX.0`
/// 1. `crate::MPL_TOKEN_METADATA_ID`
/// 2. mint (`Pubkey`)
/// 3. `EditionMarker::PREFIX.1`
/// 4. edition_marker (`&str`)
pub const PREFIX: (&'static [u8], &'static [u8]) =
("metadata".as_bytes(), "edition".as_bytes());

pub fn create_pda(
mint: Pubkey,
Expand Down
15 changes: 0 additions & 15 deletions clients/rust/src/generated/accounts/edition_marker_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,6 @@ pub struct EditionMarkerV2 {
}

impl EditionMarkerV2 {
/// Prefix values used to generate a PDA for this account.
///
/// Values are positional and appear in the following order:
///
/// 0. `EditionMarkerV2::PREFIX.0`
/// 1. `crate::MPL_TOKEN_METADATA_ID`
/// 2. mint (`Pubkey`)
/// 3. `EditionMarkerV2::PREFIX.1`
/// 4. `EditionMarkerV2::PREFIX.2`
pub const PREFIX: (&'static [u8], &'static [u8], &'static [u8]) = (
"metadata".as_bytes(),
"edition".as_bytes(),
"marker".as_bytes(),
);

pub fn create_pda(
mint: Pubkey,
bump: u8,
Expand Down
11 changes: 0 additions & 11 deletions clients/rust/src/generated/accounts/master_edition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@ pub struct MasterEdition {
}

impl MasterEdition {
/// Prefix values used to generate a PDA for this account.
///
/// Values are positional and appear in the following order:
///
/// 0. `MasterEdition::PREFIX.0`
/// 1. `crate::MPL_TOKEN_METADATA_ID`
/// 2. mint (`Pubkey`)
/// 3. `MasterEdition::PREFIX.1`
pub const PREFIX: (&'static [u8], &'static [u8]) =
("metadata".as_bytes(), "edition".as_bytes());

pub fn create_pda(
mint: Pubkey,
bump: u8,
Expand Down
9 changes: 0 additions & 9 deletions clients/rust/src/generated/accounts/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@ pub struct Metadata {
}

impl Metadata {
/// Prefix values used to generate a PDA for this account.
///
/// Values are positional and appear in the following order:
///
/// 0. `Metadata::PREFIX`
/// 1. `crate::MPL_TOKEN_METADATA_ID`
/// 2. mint (`Pubkey`)
pub const PREFIX: &'static [u8] = "metadata".as_bytes();

pub fn create_pda(
mint: Pubkey,
bump: u8,
Expand Down
11 changes: 0 additions & 11 deletions clients/rust/src/generated/accounts/metadata_delegate_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,6 @@ pub struct MetadataDelegateRecord {

impl MetadataDelegateRecord {
pub const LEN: usize = 98;
/// Prefix values used to generate a PDA for this account.
///
/// Values are positional and appear in the following order:
///
/// 0. `MetadataDelegateRecord::PREFIX`
/// 1. `crate::MPL_TOKEN_METADATA_ID`
/// 2. mint (`Pubkey`)
/// 3. delegate_role (`MetadataDelegateRoleSeed`)
/// 4. update_authority (`Pubkey`)
/// 5. delegate (`Pubkey`)
pub const PREFIX: &'static [u8] = "metadata".as_bytes();

pub fn create_pda(
mint: Pubkey,
Expand Down
40 changes: 20 additions & 20 deletions clients/rust/src/generated/accounts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
//! [https://github.com/metaplex-foundation/kinobi]
//!

pub(crate) mod r#collection_authority_record;
pub(crate) mod r#edition;
pub(crate) mod r#edition_marker;
pub(crate) mod r#edition_marker_v2;
pub(crate) mod r#master_edition;
pub(crate) mod r#metadata;
pub(crate) mod r#metadata_delegate_record;
pub(crate) mod r#token_owned_escrow;
pub(crate) mod r#token_record;
pub(crate) mod r#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::r#collection_authority_record::*;
pub use self::r#edition::*;
pub use self::r#edition_marker::*;
pub use self::r#edition_marker_v2::*;
pub use self::r#master_edition::*;
pub use self::r#metadata::*;
pub use self::r#metadata_delegate_record::*;
pub use self::r#token_owned_escrow::*;
pub use self::r#token_record::*;
pub use self::r#use_authority_record::*;
pub use self::collection_authority_record::*;
pub use self::edition::*;
pub use self::edition_marker::*;
pub use self::edition_marker_v2::*;
pub use self::master_edition::*;
pub use self::metadata::*;
pub use self::metadata_delegate_record::*;
pub use self::token_owned_escrow::*;
pub use self::token_record::*;
pub use self::use_authority_record::*;
11 changes: 0 additions & 11 deletions clients/rust/src/generated/accounts/token_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,6 @@ pub struct TokenRecord {

impl TokenRecord {
pub const LEN: usize = 80;
/// Prefix values used to generate a PDA for this account.
///
/// Values are positional and appear in the following order:
///
/// 0. `TokenRecord::PREFIX.0`
/// 1. `crate::MPL_TOKEN_METADATA_ID`
/// 2. mint (`Pubkey`)
/// 3. `TokenRecord::PREFIX.1`
/// 4. token (`Pubkey`)
pub const PREFIX: (&'static [u8], &'static [u8]) =
("metadata".as_bytes(), "token_record".as_bytes());

pub fn create_pda(
mint: Pubkey,
Expand Down
10 changes: 0 additions & 10 deletions clients/rust/src/generated/accounts/use_authority_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ pub struct UseAuthorityRecord {

impl UseAuthorityRecord {
pub const LEN: usize = 10;
/// Prefix values used to generate a PDA for this account.
///
/// Values are positional and appear in the following order:
///
/// 0. `UseAuthorityRecord::PREFIX.0`
/// 1. `crate::MPL_TOKEN_METADATA_ID`
/// 2. mint (`Pubkey`)
/// 3. `UseAuthorityRecord::PREFIX.1`
/// 4. use_authority (`Pubkey`)
pub const PREFIX: (&'static [u8], &'static [u8]) = ("metadata".as_bytes(), "user".as_bytes());

pub fn create_pda(
mint: Pubkey,
Expand Down
62 changes: 37 additions & 25 deletions clients/rust/src/generated/instructions/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct Mint {
/// SPL Token program
pub spl_token_program: solana_program::pubkey::Pubkey,
/// SPL Associated Token Account program
pub spl_ata_program: solana_program::pubkey::Pubkey,
pub spl_ata_program: Option<solana_program::pubkey::Pubkey>,
/// Token Authorization Rules program
pub authorization_rules_program: Option<solana_program::pubkey::Pubkey>,
/// Token Authorization Rules account
Expand Down Expand Up @@ -130,10 +130,17 @@ impl Mint {
self.spl_token_program,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
self.spl_ata_program,
false,
));
if let Some(spl_ata_program) = self.spl_ata_program {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
spl_ata_program,
false,
));
} else {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
crate::MPL_TOKEN_METADATA_ID,
false,
));
}
if let Some(authorization_rules_program) = self.authorization_rules_program {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
authorization_rules_program,
Expand Down Expand Up @@ -327,14 +334,14 @@ impl MintBuilder {
self.spl_token_program = Some(spl_token_program);
self
}
/// `[optional account, default to 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL']`
/// `[optional account]`
/// SPL Associated Token Account program
#[inline(always)]
pub fn spl_ata_program(
&mut self,
spl_ata_program: solana_program::pubkey::Pubkey,
spl_ata_program: Option<solana_program::pubkey::Pubkey>,
) -> &mut Self {
self.spl_ata_program = Some(spl_ata_program);
self.spl_ata_program = spl_ata_program;
self
}
/// `[optional account]`
Expand Down Expand Up @@ -401,9 +408,7 @@ impl MintBuilder {
spl_token_program: self.spl_token_program.unwrap_or(solana_program::pubkey!(
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
)),
spl_ata_program: self.spl_ata_program.unwrap_or(solana_program::pubkey!(
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
)),
spl_ata_program: self.spl_ata_program,
authorization_rules_program: self.authorization_rules_program,
authorization_rules: self.authorization_rules,
};
Expand Down Expand Up @@ -442,7 +447,7 @@ pub struct MintCpiAccounts<'a, 'b> {
/// SPL Token program
pub spl_token_program: &'b solana_program::account_info::AccountInfo<'a>,
/// SPL Associated Token Account program
pub spl_ata_program: &'b solana_program::account_info::AccountInfo<'a>,
pub spl_ata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
/// Token Authorization Rules program
pub authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
/// Token Authorization Rules account
Expand Down Expand Up @@ -478,7 +483,7 @@ pub struct MintCpi<'a, 'b> {
/// SPL Token program
pub spl_token_program: &'b solana_program::account_info::AccountInfo<'a>,
/// SPL Associated Token Account program
pub spl_ata_program: &'b solana_program::account_info::AccountInfo<'a>,
pub spl_ata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
/// Token Authorization Rules program
pub authorization_rules_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
/// Token Authorization Rules account
Expand Down Expand Up @@ -623,10 +628,17 @@ impl<'a, 'b> MintCpi<'a, 'b> {
*self.spl_token_program.key,
false,
));
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*self.spl_ata_program.key,
false,
));
if let Some(spl_ata_program) = self.spl_ata_program {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*spl_ata_program.key,
false,
));
} else {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
crate::MPL_TOKEN_METADATA_ID,
false,
));
}
if let Some(authorization_rules_program) = self.authorization_rules_program {
accounts.push(solana_program::instruction::AccountMeta::new_readonly(
*authorization_rules_program.key,
Expand Down Expand Up @@ -687,7 +699,9 @@ impl<'a, 'b> MintCpi<'a, 'b> {
account_infos.push(self.system_program.clone());
account_infos.push(self.sysvar_instructions.clone());
account_infos.push(self.spl_token_program.clone());
account_infos.push(self.spl_ata_program.clone());
if let Some(spl_ata_program) = self.spl_ata_program {
account_infos.push(spl_ata_program.clone());
}
if let Some(authorization_rules_program) = self.authorization_rules_program {
account_infos.push(authorization_rules_program.clone());
}
Expand Down Expand Up @@ -722,7 +736,7 @@ impl<'a, 'b> MintCpi<'a, 'b> {
/// 9. `[]` system_program
/// 10. `[]` sysvar_instructions
/// 11. `[]` spl_token_program
/// 12. `[]` spl_ata_program
/// 12. `[optional]` spl_ata_program
/// 13. `[optional]` authorization_rules_program
/// 14. `[optional]` authorization_rules
pub struct MintCpiBuilder<'a, 'b> {
Expand Down Expand Up @@ -856,13 +870,14 @@ impl<'a, 'b> MintCpiBuilder<'a, 'b> {
self.instruction.spl_token_program = Some(spl_token_program);
self
}
/// `[optional account]`
/// SPL Associated Token Account program
#[inline(always)]
pub fn spl_ata_program(
&mut self,
spl_ata_program: &'b solana_program::account_info::AccountInfo<'a>,
spl_ata_program: Option<&'b solana_program::account_info::AccountInfo<'a>>,
) -> &mut Self {
self.instruction.spl_ata_program = Some(spl_ata_program);
self.instruction.spl_ata_program = spl_ata_program;
self
}
/// `[optional account]`
Expand Down Expand Up @@ -974,10 +989,7 @@ impl<'a, 'b> MintCpiBuilder<'a, 'b> {
.spl_token_program
.expect("spl_token_program is not set"),

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

authorization_rules_program: self.instruction.authorization_rules_program,

Expand Down
Loading
Loading