diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2176fbc0..d882f0b3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,9 +2,9 @@ name: Main on: push: - branches: [main] + branches: [main, fixed-fee] pull_request: - branches: [main] + branches: [main, fixed-fee] env: CACHE: true diff --git a/programs/token-metadata/program/src/state/fee.rs b/programs/token-metadata/program/src/state/fee.rs index 07e7f76b..96b3409e 100644 --- a/programs/token-metadata/program/src/state/fee.rs +++ b/programs/token-metadata/program/src/state/fee.rs @@ -1,5 +1,4 @@ use super::*; -use solana_program::{rent::Rent, sysvar::Sysvar}; pub(crate) const FEE_AUTHORITY: Pubkey = pubkey!("Levytx9LLPzAtDJJD7q813Zsm8zg9e1pb53mGxTKpD7"); pub(crate) const OWNERLESS_CLOSE_AUTHORITY: Pubkey = @@ -10,16 +9,8 @@ pub(crate) const RESIZE_AUTHORITY: Pubkey = pubkey!("ResizebfwTEZTLbHbctTByvXYEC pub(crate) const RESIZE_DESTINATION: Pubkey = pubkey!("46mjNQBwXLCDCM7YiDQSPVdNZ4dLdZf79tTPRkT1wkF6"); -const CREATE_FEE_SCALAR: usize = 1308; -const CREATE_FEE_OFFSET: u64 = 5440; // create_metadata_accounts_v3, create, print edition commands -pub fn get_create_fee() -> Result { - let rent = Rent::get()?.minimum_balance(CREATE_FEE_SCALAR); - - Ok(rent - .checked_add(CREATE_FEE_OFFSET) - .ok_or(MetadataError::NumericalOverflowError)?) -} +pub const CREATE_FEE: u64 = 10_000_000; pub const FEE_FLAG_SET: u8 = 1; pub const FEE_FLAG_CLEARED: u8 = 0; diff --git a/programs/token-metadata/program/src/utils/fee.rs b/programs/token-metadata/program/src/utils/fee.rs index c7b2d8f7..79cd662f 100644 --- a/programs/token-metadata/program/src/utils/fee.rs +++ b/programs/token-metadata/program/src/utils/fee.rs @@ -5,7 +5,7 @@ use solana_program::{ use crate::{ error::MetadataError, - state::{get_create_fee, MAX_METADATA_LEN, METADATA_FEE_FLAG_OFFSET}, + state::{fee::CREATE_FEE, MAX_METADATA_LEN, METADATA_FEE_FLAG_OFFSET}, }; #[repr(C)] @@ -26,7 +26,7 @@ pub(crate) fn levy(args: LevyArgs) -> ProgramResult { if account_data_len > 0 { return Err(MetadataError::ExpectedUninitializedAccount.into()); } - let fee = get_create_fee()? + rent.minimum_balance(MAX_METADATA_LEN); + let fee = CREATE_FEE + rent.minimum_balance(MAX_METADATA_LEN); invoke( &solana_program::system_instruction::transfer( diff --git a/programs/token-metadata/program/tests/fees.rs b/programs/token-metadata/program/tests/fees.rs index a9aefdd9..ac0a89a0 100644 --- a/programs/token-metadata/program/tests/fees.rs +++ b/programs/token-metadata/program/tests/fees.rs @@ -13,7 +13,7 @@ mod fees { }; use token_metadata::{ instruction::{collect_fees, BurnArgs, UpdateArgs}, - state::{FEE_FLAG_CLEARED, METADATA_FEE_FLAG_OFFSET}, + state::{CREATE_FEE, FEE_FLAG_CLEARED, METADATA_FEE_FLAG_OFFSET}, }; use super::*; @@ -132,7 +132,7 @@ mod fees { println!("Transaction size: {:?}", tx.message().serialize().len()); context.banks_client.process_transaction(tx).await.unwrap(); - let expected_balance = num_accounts * SOLANA_CREATE_FEE; + let expected_balance = num_accounts * CREATE_FEE; let recipient_balance = get_account(&mut context, &recipient.pubkey()) .await @@ -206,7 +206,7 @@ mod fees { ); context.banks_client.process_transaction(tx).await.unwrap(); - let expected_balance = SOLANA_CREATE_FEE; + let expected_balance = CREATE_FEE; let recipient_balance = get_account(&mut context, &recipient.pubkey()) .await diff --git a/programs/token-metadata/program/tests/utils/digital_asset.rs b/programs/token-metadata/program/tests/utils/digital_asset.rs index 26247e11..b779d6cf 100644 --- a/programs/token-metadata/program/tests/utils/digital_asset.rs +++ b/programs/token-metadata/program/tests/utils/digital_asset.rs @@ -31,17 +31,16 @@ use token_metadata::{ state::{ AssetData, Collection, CollectionDetails, Creator, MasterEditionV2, Metadata, PrintSupply, ProgrammableConfig, TokenDelegateRole, TokenMetadataAccount, TokenRecord, TokenStandard, - EDITION, EDITION_MARKER_BIT_SIZE, FEE_FLAG_SET, METADATA_FEE_FLAG_OFFSET, PREFIX, + CREATE_FEE, EDITION, EDITION_MARKER_BIT_SIZE, FEE_FLAG_SET, METADATA_FEE_FLAG_OFFSET, + PREFIX, }, utils::unpack, ID, }; -use crate::{upsize_edition, SOLANA_CREATE_FEE}; - use super::{ - airdrop, create_mint, create_token_account, get_account, mint_tokens, upsize_master_edition, - upsize_metadata, + airdrop, create_mint, create_token_account, get_account, mint_tokens, upsize_edition, + upsize_master_edition, upsize_metadata, }; pub const DEFAULT_NAME: &str = "Digital Asset"; @@ -1493,7 +1492,7 @@ impl DigitalAsset { let rent = context.banks_client.get_rent().await.unwrap(); let rent_exempt = rent.minimum_balance(account.data.len()); - let expected_lamports = rent_exempt + SOLANA_CREATE_FEE; + let expected_lamports = rent_exempt + CREATE_FEE; assert_eq!(account.lamports, expected_lamports); let last_byte = account.data.len() - METADATA_FEE_FLAG_OFFSET; diff --git a/programs/token-metadata/program/tests/utils/metadata.rs b/programs/token-metadata/program/tests/utils/metadata.rs index e6b12369..c3218643 100644 --- a/programs/token-metadata/program/tests/utils/metadata.rs +++ b/programs/token-metadata/program/tests/utils/metadata.rs @@ -7,7 +7,8 @@ use token_metadata::{ pda::find_master_edition_account, state::{ Collection, CollectionDetails, Creator, DataV2, Metadata as TmMetadata, - TokenMetadataAccount, TokenStandard, Uses, FEE_FLAG_SET, METADATA_FEE_FLAG_OFFSET, PREFIX, + TokenMetadataAccount, TokenStandard, Uses, CREATE_FEE, FEE_FLAG_SET, + METADATA_FEE_FLAG_OFFSET, PREFIX, }, ID, }; @@ -816,7 +817,7 @@ impl Metadata { let rent = context.banks_client.get_rent().await.unwrap(); let rent_exempt = rent.minimum_balance(account.data.len()); - let expected_lamports = rent_exempt + SOLANA_CREATE_FEE; + let expected_lamports = rent_exempt + CREATE_FEE; assert_eq!(account.lamports, expected_lamports); let last_byte = account.data.len() - METADATA_FEE_FLAG_OFFSET; diff --git a/programs/token-metadata/program/tests/utils/mod.rs b/programs/token-metadata/program/tests/utils/mod.rs index 658cec17..c0d32efc 100644 --- a/programs/token-metadata/program/tests/utils/mod.rs +++ b/programs/token-metadata/program/tests/utils/mod.rs @@ -34,8 +34,6 @@ pub const DEFAULT_COLLECTION_DETAILS: Option = { Some(CollectionDetails::V1 { size: 0 }) }; -pub const SOLANA_CREATE_FEE: u64 = 10_000_000; - pub fn program_test() -> ProgramTest { let mut program_test = ProgramTest::new("token_metadata", token_metadata::ID, None); program_test.add_program("spl_token_2022", spl_token_2022::ID, None);