Skip to content

Test Removal of next_account_infos #1104

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

Draft
wants to merge 3 commits into
base: master
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
4 changes: 2 additions & 2 deletions token-metadata/program/src/assertions/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ pub fn assert_collection_verify_is_valid(
}

assert_derivation(
&crate::id(),
&crate::ID,
edition_account_info,
&[
PREFIX.as_bytes(),
crate::id().as_ref(),
crate::ID.as_ref(),
collection_metadata.mint.as_ref(),
EDITION.as_bytes(),
],
Expand Down
4 changes: 2 additions & 2 deletions token-metadata/program/src/assertions/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ pub fn assert_holding_amount(
amount: u64,
) -> ProgramResult {
assert_owned_by(metadata_info, program_id)?;
assert_owned_by(mint_info, &spl_token::id())?;
assert_owned_by(mint_info, &spl_token::ID)?;

let token_account: Account = assert_initialized(token_account_info)?;

assert_owned_by(token_account_info, &spl_token::id())?;
assert_owned_by(token_account_info, &spl_token::ID)?;

if token_account.owner != *owner_info.key {
return Err(MetadataError::InvalidOwner.into());
Expand Down
4 changes: 2 additions & 2 deletions token-metadata/program/src/assertions/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ pub fn assert_delegated_tokens(
mint_info: &AccountInfo,
token_account_info: &AccountInfo,
) -> ProgramResult {
assert_owned_by(mint_info, &spl_token::id())?;
assert_owned_by(mint_info, &spl_token::ID)?;

let token_account: Account = assert_initialized(token_account_info)?;

assert_owned_by(token_account_info, &spl_token::id())?;
assert_owned_by(token_account_info, &spl_token::ID)?;

if token_account.mint != *mint_info.key {
return Err(MetadataError::MintMismatch.into());
Expand Down
2 changes: 1 addition & 1 deletion token-metadata/program/src/instruction/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn approve_collection_authority(
AccountMeta::new(payer, true),
AccountMeta::new_readonly(metadata, false),
AccountMeta::new_readonly(mint, false),
AccountMeta::new_readonly(solana_program::system_program::id(), false),
AccountMeta::new_readonly(solana_program::system_program::ID, false),
],
data: MetadataInstruction::ApproveCollectionAuthority
.try_to_vec()
Expand Down
8 changes: 4 additions & 4 deletions token-metadata/program/src/instruction/edition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ pub fn create_master_edition_v3(
AccountMeta::new_readonly(mint_authority, true),
AccountMeta::new(payer, true),
AccountMeta::new(metadata, false),
AccountMeta::new_readonly(spl_token::id(), false),
AccountMeta::new_readonly(solana_program::system_program::id(), false),
AccountMeta::new_readonly(spl_token::ID, false),
AccountMeta::new_readonly(solana_program::system_program::ID, false),
];

Instruction {
Expand Down Expand Up @@ -121,8 +121,8 @@ pub fn mint_new_edition_from_master_edition_via_token(
AccountMeta::new_readonly(token_account, false),
AccountMeta::new_readonly(new_metadata_update_authority, false),
AccountMeta::new_readonly(metadata, false),
AccountMeta::new_readonly(spl_token::id(), false),
AccountMeta::new_readonly(solana_program::system_program::id(), false),
AccountMeta::new_readonly(spl_token::ID, false),
AccountMeta::new_readonly(solana_program::system_program::ID, false),
];

Instruction {
Expand Down
16 changes: 8 additions & 8 deletions token-metadata/program/src/instruction/escrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub fn close_escrow_account(
AccountMeta::new_readonly(token_account, false),
AccountMeta::new_readonly(edition_account, false),
AccountMeta::new(payer_account, true),
AccountMeta::new_readonly(system_program::id(), false),
AccountMeta::new_readonly(sysvar::instructions::id(), false),
AccountMeta::new_readonly(system_program::ID, false),
AccountMeta::new_readonly(sysvar::instructions::ID, false),
];
let data = MetadataInstruction::CloseEscrowAccount
.try_to_vec()
Expand Down Expand Up @@ -56,8 +56,8 @@ pub fn create_escrow_account(
AccountMeta::new_readonly(token_account, false),
AccountMeta::new_readonly(edition_account, false),
AccountMeta::new(payer_account, true),
AccountMeta::new_readonly(solana_program::system_program::id(), false),
AccountMeta::new_readonly(sysvar::instructions::id(), false),
AccountMeta::new_readonly(solana_program::system_program::ID, false),
AccountMeta::new_readonly(sysvar::instructions::ID, false),
];

if let Some(authority) = authority {
Expand Down Expand Up @@ -104,10 +104,10 @@ pub fn transfer_out_of_escrow(
AccountMeta::new(attribute_dst, false),
AccountMeta::new_readonly(escrow_mint, false),
AccountMeta::new_readonly(escrow_account, false),
AccountMeta::new_readonly(solana_program::system_program::id(), false),
AccountMeta::new_readonly(spl_associated_token_account::id(), false),
AccountMeta::new_readonly(spl_token::id(), false),
AccountMeta::new_readonly(sysvar::instructions::id(), false),
AccountMeta::new_readonly(solana_program::system_program::ID, false),
AccountMeta::new_readonly(spl_associated_token_account::ID, false),
AccountMeta::new_readonly(spl_token::ID, false),
AccountMeta::new_readonly(sysvar::instructions::ID, false),
];

if let Some(authority) = authority {
Expand Down
4 changes: 2 additions & 2 deletions token-metadata/program/src/instruction/freeze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn freeze_delegated_account(
AccountMeta::new(token_account, false),
AccountMeta::new_readonly(edition, false),
AccountMeta::new_readonly(mint, false),
AccountMeta::new_readonly(spl_token::id(), false),
AccountMeta::new_readonly(spl_token::ID, false),
],
data: MetadataInstruction::FreezeDelegatedAccount
.try_to_vec()
Expand Down Expand Up @@ -62,7 +62,7 @@ pub fn thaw_delegated_account(
AccountMeta::new(token_account, false),
AccountMeta::new_readonly(edition, false),
AccountMeta::new_readonly(mint, false),
AccountMeta::new_readonly(spl_token::id(), false),
AccountMeta::new_readonly(spl_token::ID, false),
],
data: MetadataInstruction::ThawDelegatedAccount
.try_to_vec()
Expand Down
2 changes: 1 addition & 1 deletion token-metadata/program/src/instruction/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ pub fn create_metadata_accounts_v3(
AccountMeta::new_readonly(mint_authority, true),
AccountMeta::new(payer, true),
AccountMeta::new_readonly(update_authority, update_authority_is_signer),
AccountMeta::new_readonly(solana_program::system_program::id(), false),
AccountMeta::new_readonly(solana_program::system_program::ID, false),
],
data: MetadataInstruction::CreateMetadataAccountV3(CreateMetadataAccountArgsV3 {
data: DataV2 {
Expand Down
4 changes: 2 additions & 2 deletions token-metadata/program/src/instruction/scratchpad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ impl UpdateAccounts {
AccountMeta::new(self.metadata_account, false),
AccountMeta::new(self.master_edition_account, false),
AccountMeta::new(self.mint_account, false),
AccountMeta::new_readonly(solana_program::system_program::id(), false),
AccountMeta::new_readonly(sysvar::instructions::id(), false),
AccountMeta::new_readonly(solana_program::system_program::ID, false),
AccountMeta::new_readonly(sysvar::instructions::ID, false),
];
if let Some(new_update_authority) = self.new_update_authority {
infos.push(AccountMeta::new_readonly(new_update_authority, false));
Expand Down
14 changes: 7 additions & 7 deletions token-metadata/program/src/instruction/uses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ pub fn approve_use_authority(
AccountMeta::new_readonly(metadata, false),
AccountMeta::new_readonly(mint, false),
AccountMeta::new_readonly(burner, false),
AccountMeta::new_readonly(spl_token::id(), false),
AccountMeta::new_readonly(solana_program::system_program::id(), false),
AccountMeta::new_readonly(spl_token::ID, false),
AccountMeta::new_readonly(solana_program::system_program::ID, false),
],
data: MetadataInstruction::ApproveUseAuthority(ApproveUseAuthorityArgs { number_of_uses })
.try_to_vec()
Expand Down Expand Up @@ -121,8 +121,8 @@ pub fn revoke_use_authority(
AccountMeta::new(owner_token_account, false),
AccountMeta::new_readonly(mint, false),
AccountMeta::new_readonly(metadata, false),
AccountMeta::new_readonly(spl_token::id(), false),
AccountMeta::new_readonly(solana_program::system_program::id(), false),
AccountMeta::new_readonly(spl_token::ID, false),
AccountMeta::new_readonly(solana_program::system_program::ID, false),
],
data: MetadataInstruction::RevokeUseAuthority
.try_to_vec()
Expand Down Expand Up @@ -166,9 +166,9 @@ pub fn utilize(
AccountMeta::new(mint, false),
AccountMeta::new(use_authority, true),
AccountMeta::new_readonly(owner, false),
AccountMeta::new_readonly(spl_token::id(), false),
AccountMeta::new_readonly(spl_associated_token_account::id(), false),
AccountMeta::new_readonly(solana_program::system_program::id(), false),
AccountMeta::new_readonly(spl_token::ID, false),
AccountMeta::new_readonly(spl_associated_token_account::ID, false),
AccountMeta::new_readonly(solana_program::system_program::ID, false),
];
if let Some(use_authority_record_pda) = use_authority_record_pda {
accounts.push(AccountMeta::new(use_authority_record_pda, false));
Expand Down
32 changes: 16 additions & 16 deletions token-metadata/program/src/pda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,64 +19,64 @@ pub fn find_edition_account(mint: &Pubkey, edition_number: String) -> (Pubkey, u
Pubkey::find_program_address(
&[
PREFIX.as_bytes(),
crate::id().as_ref(),
crate::ID.as_ref(),
mint.as_ref(),
EDITION.as_bytes(),
edition_number.as_bytes(),
],
&crate::id(),
&crate::ID,
)
}

pub fn find_master_edition_account(mint: &Pubkey) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[
PREFIX.as_bytes(),
crate::id().as_ref(),
crate::ID.as_ref(),
mint.as_ref(),
EDITION.as_bytes(),
],
&crate::id(),
&crate::ID,
)
}

pub fn find_metadata_account(mint: &Pubkey) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[PREFIX.as_bytes(), crate::id().as_ref(), mint.as_ref()],
&crate::id(),
&[PREFIX.as_bytes(), crate::ID.as_ref(), mint.as_ref()],
&crate::ID,
)
}

pub fn find_use_authority_account(mint: &Pubkey, authority: &Pubkey) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[
PREFIX.as_bytes(),
crate::id().as_ref(),
crate::ID.as_ref(),
mint.as_ref(),
USER.as_bytes(),
authority.as_ref(),
],
&crate::id(),
&crate::ID,
)
}

pub fn find_collection_authority_account(mint: &Pubkey, authority: &Pubkey) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[
PREFIX.as_bytes(),
crate::id().as_ref(),
crate::ID.as_ref(),
mint.as_ref(),
COLLECTION_AUTHORITY.as_bytes(),
authority.as_ref(),
],
&crate::id(),
&crate::ID,
)
}

pub fn find_program_as_burner_account() -> (Pubkey, u8) {
Pubkey::find_program_address(
&[PREFIX.as_bytes(), crate::id().as_ref(), BURN.as_bytes()],
&crate::id(),
&[PREFIX.as_bytes(), crate::ID.as_ref(), BURN.as_bytes()],
&crate::ID,
)
}

Expand All @@ -89,25 +89,25 @@ pub fn find_metadata_delegate_record_account(
Pubkey::find_program_address(
&[
PREFIX.as_bytes(),
crate::id().as_ref(),
crate::ID.as_ref(),
mint.as_ref(),
role.to_string().as_bytes(),
update_authority.as_ref(),
delegate.as_ref(),
],
&crate::id(),
&crate::ID,
)
}

pub fn find_token_record_account(mint: &Pubkey, token: &Pubkey) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[
PREFIX.as_bytes(),
crate::id().as_ref(),
crate::ID.as_ref(),
mint.as_ref(),
TOKEN_RECORD_SEED.as_bytes(),
token.as_ref(),
],
&crate::id(),
&crate::ID,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn bubblegum_set_collection_size(
assert_owned_by(parent_nft_metadata_account_info, program_id)?;

// Mint owned by spl token program.
assert_owned_by(collection_mint_account_info, &spl_token::id())?;
assert_owned_by(collection_mint_account_info, &spl_token::ID)?;

let mut metadata = Metadata::from_account_info(parent_nft_metadata_account_info)?;

Expand Down
41 changes: 23 additions & 18 deletions token-metadata/program/src/processor/burn/burn_edition_nft.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use mpl_utils::assert_signer;
use solana_program::{
account_info::{next_account_info, AccountInfo},
entrypoint::ProgramResult,
account_info::AccountInfo, entrypoint::ProgramResult, program_error::ProgramError,
pubkey::Pubkey,
};
use spl_token::state::Account as TokenAccount;
Expand All @@ -20,18 +19,24 @@ pub fn process_burn_edition_nft<'a>(
program_id: &Pubkey,
accounts: &'a [AccountInfo<'a>],
) -> ProgramResult {
let account_info_iter = &mut accounts.iter();

let metadata_info = next_account_info(account_info_iter)?;
let owner_info = next_account_info(account_info_iter)?;
let print_edition_mint_info = next_account_info(account_info_iter)?;
let master_edition_mint_info = next_account_info(account_info_iter)?;
let print_edition_token_info = next_account_info(account_info_iter)?;
let master_edition_token_info = next_account_info(account_info_iter)?;
let master_edition_info = next_account_info(account_info_iter)?;
let print_edition_info = next_account_info(account_info_iter)?;
let edition_marker_info = next_account_info(account_info_iter)?;
let spl_token_program_info = next_account_info(account_info_iter)?;
let [metadata_info, owner_info, print_edition_mint_info, master_edition_mint_info, print_edition_token_info, master_edition_token_info, master_edition_info, print_edition_info, edition_marker_info, spl_token_program_info] =
match accounts {
[metadata_info, owner_info, print_edition_mint_info, master_edition_mint_info, print_edition_token_info, master_edition_token_info, master_edition_info, print_edition_info, edition_marker_info, spl_token_program_info] => {
[
metadata_info,
owner_info,
print_edition_mint_info,
master_edition_mint_info,
print_edition_token_info,
master_edition_token_info,
master_edition_info,
print_edition_info,
edition_marker_info,
spl_token_program_info,
]
}
_ => return Err(ProgramError::NotEnoughAccountKeys),
};

// Validate accounts
// Owner is a signer.
Expand All @@ -44,10 +49,10 @@ pub fn process_burn_edition_nft<'a>(
assert_owned_by(edition_marker_info, program_id)?;

// Owned by spl-token program.
assert_owned_by(master_edition_mint_info, &spl_token::id())?;
assert_owned_by(master_edition_token_info, &spl_token::id())?;
assert_owned_by(print_edition_mint_info, &spl_token::id())?;
assert_owned_by(print_edition_token_info, &spl_token::id())?;
assert_owned_by(master_edition_mint_info, &spl_token::ID)?;
assert_owned_by(master_edition_token_info, &spl_token::ID)?;
assert_owned_by(print_edition_mint_info, &spl_token::ID)?;
assert_owned_by(print_edition_token_info, &spl_token::ID)?;

let metadata = Metadata::from_account_info(metadata_info)?;
let token: TokenAccount = assert_initialized(print_edition_token_info)?;
Expand Down
Loading