diff --git a/src/airdrop/process.rs b/src/airdrop/process.rs index d34a481c..fcb65b4d 100644 --- a/src/airdrop/process.rs +++ b/src/airdrop/process.rs @@ -28,6 +28,7 @@ pub struct AirdropArgs { pub cache: String, pub candy_machine: Option, pub airdrop_list: String, + pub priority_fee: u64, } pub async fn process_airdrop(args: AirdropArgs) -> Result<()> { @@ -125,6 +126,7 @@ pub async fn process_airdrop(args: AirdropArgs) -> Result<()> { candy_machine_state, collection_update_authority, target, + args.priority_fee, ) .await; pb.inc(1); diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 84da0eb5..3e404794 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -4,7 +4,7 @@ use crate::{ config::TokenStandard, constants::{ DEFAULT_AIRDROP_LIST, DEFAULT_AIRDROP_LIST_HELP, DEFAULT_ASSETS, DEFAULT_CACHE, - DEFAULT_CONFIG, + DEFAULT_CONFIG, DEFAULT_PRIORITY_FEE, }, }; @@ -61,6 +61,10 @@ pub enum Commands { #[clap(short, long)] rpc_url: Option, + /// Priority fee value + #[clap(short, long, default_value_t = DEFAULT_PRIORITY_FEE)] + priority_fee: u64, + /// Path to the cache file, defaults to "cache.json" #[clap(long, default_value = DEFAULT_CACHE)] cache: String, @@ -115,6 +119,10 @@ pub enum Commands { #[clap(short, long)] rpc_url: Option, + /// Priority fee value + #[clap(short, long, default_value_t = DEFAULT_PRIORITY_FEE)] + priority_fee: u64, + /// Path to the cache file #[clap(long, default_value = DEFAULT_CACHE)] cache: String, @@ -142,6 +150,10 @@ pub enum Commands { #[clap(long, default_value = DEFAULT_CACHE)] cache: String, + /// Priority fee value + #[clap(short, long, default_value_t = DEFAULT_PRIORITY_FEE)] + priority_fee: u64, + /// Amount of NFTs to be minted in bulk #[clap(short, long)] number: Option, @@ -168,6 +180,10 @@ pub enum Commands { #[clap(long, default_value = DEFAULT_CACHE)] cache: String, + /// Priority fee value + #[clap(short, long, default_value_t = DEFAULT_PRIORITY_FEE)] + priority_fee: u64, + /// Address of candy machine to mint from. #[clap(long)] candy_machine: Option, @@ -259,6 +275,10 @@ pub enum Commands { #[clap(short, long)] keypair: Option, + /// Priority fee value + #[clap(short, long, default_value_t = DEFAULT_PRIORITY_FEE)] + priority_fee: u64, + /// RPC Url #[clap(short, long)] rpc_url: Option, @@ -312,6 +332,10 @@ pub enum Commands { #[clap(short, long)] rpc_url: Option, + /// Priority fee value + #[clap(short, long, default_value_t = DEFAULT_PRIORITY_FEE)] + priority_fee: u64, + /// List available candy machines, no withdraw performed #[clap(long)] list: bool, @@ -366,6 +390,10 @@ pub enum ConfigSubcommands { #[clap(short, long)] rpc_url: Option, + /// Priority fee value + #[clap(short, long, default_value_t = DEFAULT_PRIORITY_FEE)] + priority_fee: u64, + /// Path to the cache file, defaults to "cache.json" #[clap(long, default_value = DEFAULT_CACHE)] cache: String, @@ -392,6 +420,10 @@ pub enum ConfigSubcommands { #[clap(long, default_value = DEFAULT_CACHE)] cache: String, + /// Priority fee value + #[clap(short, long, default_value_t = DEFAULT_PRIORITY_FEE)] + priority_fee: u64, + /// Token Standard to set. #[clap(short, long)] token_standard: Option, @@ -422,6 +454,10 @@ pub enum CollectionSubcommands { #[clap(long, default_value = DEFAULT_CACHE)] cache: String, + /// Priority fee value + #[clap(short, long, default_value_t = DEFAULT_PRIORITY_FEE)] + priority_fee: u64, + /// Path to the config file #[clap(short, long, default_value = DEFAULT_CONFIG)] config: String, @@ -455,6 +491,10 @@ pub enum GuardCommand { #[clap(short, long, default_value = DEFAULT_CONFIG)] config: String, + /// Priority fee value + #[clap(short, long, default_value_t = DEFAULT_PRIORITY_FEE)] + priority_fee: u64, + /// Address of the candy machine. #[clap(long)] candy_machine: Option, @@ -477,6 +517,10 @@ pub enum GuardCommand { #[clap(long, default_value = DEFAULT_CACHE)] cache: String, + /// Priority fee value + #[clap(short, long, default_value_t = DEFAULT_PRIORITY_FEE)] + priority_fee: u64, + /// Address of the candy machine. #[clap(long)] candy_machine: Option, @@ -517,6 +561,10 @@ pub enum GuardCommand { #[clap(long, default_value = DEFAULT_CACHE)] cache: String, + /// Priority fee value + #[clap(short, long, default_value_t = DEFAULT_PRIORITY_FEE)] + priority_fee: u64, + /// Path to the config file #[clap(short, long, default_value = DEFAULT_CONFIG)] config: String, @@ -535,6 +583,10 @@ pub enum GuardCommand { #[clap(short, long)] rpc_url: Option, + /// Priority fee value + #[clap(short, long, default_value_t = DEFAULT_PRIORITY_FEE)] + priority_fee: u64, + /// Path to the cache file, defaults to "cache.json" #[clap(long, default_value = DEFAULT_CACHE)] cache: String, @@ -573,6 +625,10 @@ pub enum FreezeCommand { #[clap(long)] candy_machine: Option, + /// Priority fee value + #[clap(short, long, default_value_t = DEFAULT_PRIORITY_FEE)] + priority_fee: u64, + /// Candy guard group label. #[clap(long)] label: Option, @@ -610,6 +666,10 @@ pub enum FreezeCommand { #[clap(long)] candy_guard: Option, + /// Priority fee value + #[clap(short, long, default_value_t = DEFAULT_PRIORITY_FEE)] + priority_fee: u64, + /// Address of candy machine to update [defaults to cache value]. #[clap(long)] candy_machine: Option, @@ -652,6 +712,10 @@ pub enum FreezeCommand { #[clap(short, long, default_value = DEFAULT_CONFIG)] config: String, + /// Priority fee value + #[clap(short, long, default_value_t = DEFAULT_PRIORITY_FEE)] + priority_fee: u64, + /// Address of candy guard to update [defaults to cache value]. #[clap(long)] candy_guard: Option, diff --git a/src/collections/set.rs b/src/collections/set.rs index 81bb3564..b0fd3ba9 100644 --- a/src/collections/set.rs +++ b/src/collections/set.rs @@ -1,6 +1,8 @@ use std::{ops::Deref, str::FromStr}; -use anchor_client::solana_sdk::{pubkey::Pubkey, system_program}; +use anchor_client::solana_sdk::{ + compute_budget::ComputeBudgetInstruction, pubkey::Pubkey, system_program, +}; use anyhow::Result; use console::style; use mpl_candy_machine_core::{ @@ -31,6 +33,7 @@ pub struct SetCollectionArgs { pub cache: String, pub config: String, pub candy_machine: Option, + pub priority_fee: u64, } pub fn process_set_collection(args: SetCollectionArgs) -> Result<()> { @@ -109,6 +112,7 @@ pub fn process_set_collection(args: SetCollectionArgs) -> Result<()> { &collection_mint_pubkey, &collection_metadata_info, &collection_edition_info, + &args, )?; pb.finish_with_message(format!( @@ -146,6 +150,7 @@ pub fn process_set_collection(args: SetCollectionArgs) -> Result<()> { new_authority: None, config: args.config, candy_machine: Some(candy_machine_id), + priority_fee: args.priority_fee, }; process_update(update_args)?; @@ -162,6 +167,7 @@ pub fn set_collection + Clone>( new_collection_mint_pubkey: &Pubkey, new_collection_metadata_info: &PdaInfo, new_collection_edition_info: &PdaInfo, + args: &SetCollectionArgs, ) -> Result { let payer = program.payer(); @@ -214,8 +220,11 @@ pub fn set_collection + Clone>( let collection_update_authority = collection_metadata.update_authority; let collection_metadata = find_metadata_pda(&collection_mint); + let priority_fee = ComputeBudgetInstruction::set_compute_unit_price(args.priority_fee); + let builder = program .request() + .instruction(priority_fee) .accounts(nft_accounts::SetCollectionV2 { candy_machine: *candy_pubkey, authority: payer, diff --git a/src/constants.rs b/src/constants.rs index 4dcc6b39..09e928c1 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -97,3 +97,5 @@ pub const UNWRAP_EMOJI: Emoji<'_, '_> = Emoji("🔩 ", ""); pub const MAX_FREEZE_DAYS: u8 = 31; pub const COMPUTE_UNITS: u32 = 400_000; + +pub const DEFAULT_PRIORITY_FEE: u64 = 500; diff --git a/src/deploy/collection.rs b/src/deploy/collection.rs index 5bdbb17b..890378f8 100644 --- a/src/deploy/collection.rs +++ b/src/deploy/collection.rs @@ -1,4 +1,4 @@ -use anchor_client::solana_sdk::pubkey::Pubkey; +use anchor_client::solana_sdk::{compute_budget::ComputeBudgetInstruction, pubkey::Pubkey}; use anyhow::Result; use mpl_token_metadata::{ instruction::{create_master_edition_v3, create_metadata_accounts_v3}, @@ -16,6 +16,7 @@ use crate::{ candy_machine::CANDY_MACHINE_ID, common::*, config::ConfigData, + deploy::DeployArgs, pdas::{find_master_edition_pda, find_metadata_pda}, setup::SugarClient, }; @@ -25,6 +26,7 @@ pub fn create_collection( _candy_machine: Pubkey, cache: &mut Cache, config_data: &ConfigData, + args: &DeployArgs, ) -> Result<(Signature, Pubkey)> { let program = client.program(CANDY_MACHINE_ID); let payer = program.payer(); @@ -114,9 +116,11 @@ pub fn create_collection( payer, Some(0), ); + let priority_fee = ComputeBudgetInstruction::set_compute_unit_price(args.priority_fee); let builder = program .request() + .instruction(priority_fee) .instruction(create_mint_account_ix) .instruction(init_mint_ix) .instruction(create_assoc_account_ix) diff --git a/src/deploy/config_lines.rs b/src/deploy/config_lines.rs index 2f25fa3b..63fa8755 100644 --- a/src/deploy/config_lines.rs +++ b/src/deploy/config_lines.rs @@ -6,7 +6,9 @@ use std::{ }, }; -use anchor_client::solana_sdk::{pubkey::Pubkey, signature::Keypair}; +use anchor_client::solana_sdk::{ + compute_budget::ComputeBudgetInstruction, pubkey::Pubkey, signature::Keypair, +}; use anyhow::Result; use console::style; use futures::future::select_all; @@ -23,7 +25,7 @@ use crate::{ }; /// The maximum config line bytes per transaction. -const MAX_TRANSACTION_BYTES: usize = 1000; +const MAX_TRANSACTION_BYTES: usize = 966; /// The maximum number of config lines per transaction. const MAX_TRANSACTION_LINES: usize = 17; @@ -106,6 +108,7 @@ pub async fn upload_config_lines( cache: &mut Cache, config_lines: Vec>, interrupted: Arc, + priority_fee: u64, ) -> Result> { println!( "Sending config line(s) in {} transaction(s): (Ctrl+C to abort)", @@ -134,9 +137,9 @@ pub async fn upload_config_lines( for tx in transactions.drain(0..cmp::min(transactions.len(), PARALLEL_LIMIT)) { let config = sugar_config.clone(); - handles.push(tokio::spawn( - async move { add_config_lines(config, tx).await }, - )); + handles.push(tokio::spawn(async move { + add_config_lines(config, tx, priority_fee).await + })); } let mut errors = Vec::new(); @@ -184,9 +187,9 @@ pub async fn upload_config_lines( for tx in transactions.drain(0..cmp::min(transactions.len(), PARALLEL_LIMIT / 2)) { let config = sugar_config.clone(); - handles.push(tokio::spawn( - async move { add_config_lines(config, tx).await }, - )); + handles.push(tokio::spawn(async move { + add_config_lines(config, tx, priority_fee).await + })); } } } @@ -214,12 +217,17 @@ pub async fn upload_config_lines( } /// Send the `add_config_lines` instruction to the candy machine program. -pub async fn add_config_lines(config: Arc, tx_info: TxInfo) -> Result> { +pub async fn add_config_lines( + config: Arc, + tx_info: TxInfo, + priority_fee: u64, +) -> Result> { let client = setup_client(&config)?; let program = client.program(CANDY_MACHINE_ID); // this will be used to update the cache let mut indices: Vec = Vec::new(); + // configLine does not implement clone, so we have to do this let mut config_lines: Vec = Vec::new(); // start index @@ -230,8 +238,11 @@ pub async fn add_config_lines(config: Arc, tx_info: TxInfo) -> Resu config_lines.push(line); } + let priority_fee = ComputeBudgetInstruction::set_compute_unit_price(priority_fee); + let _sig = program .request() + .instruction(priority_fee) .accounts(nft_accounts::AddConfigLines { candy_machine: tx_info.candy_pubkey, authority: program.payer(), diff --git a/src/deploy/initialize.rs b/src/deploy/initialize.rs index 8df8e0aa..51af0a26 100644 --- a/src/deploy/initialize.rs +++ b/src/deploy/initialize.rs @@ -1,6 +1,7 @@ use std::ops::Deref; use anchor_client::solana_sdk::{ + compute_budget::ComputeBudgetInstruction, pubkey::Pubkey, signature::{Keypair, Signature, Signer}, system_instruction, system_program, @@ -133,12 +134,12 @@ pub fn create_candy_machine_data( /// Send the `initialize_candy_machine` instruction to the candy machine program. pub fn initialize_candy_machine + Clone>( config_data: &ConfigData, - candy_account: &Keypair, candy_machine_data: CandyMachineData, collection_mint: Pubkey, collection_update_authority: Pubkey, program: Program, + priority_fee: &u64, ) -> Result { let payer = program.payer(); let candy_account_size = candy_machine_data.get_space_for_candy()?; @@ -176,8 +177,11 @@ pub fn initialize_candy_machine + Clone>( &authority_pda, ); + let priority_fee_ix = ComputeBudgetInstruction::set_compute_unit_price(*priority_fee); + let tx = program .request() + .instruction(priority_fee_ix) .instruction(system_instruction::create_account( &payer, &candy_account.pubkey(), diff --git a/src/deploy/process.rs b/src/deploy/process.rs index 2f3347a1..1e74b52e 100644 --- a/src/deploy/process.rs +++ b/src/deploy/process.rs @@ -40,6 +40,7 @@ pub struct DeployArgs { pub rpc_url: Option, pub interrupted: Arc, pub collection_mint: Option, + pub priority_fee: u64, } pub async fn process_deploy(args: DeployArgs) -> Result<()> { @@ -145,7 +146,7 @@ pub async fn process_deploy(args: DeployArgs) -> Result<()> { pb.set_message("Creating NFT..."); let (_, collection_mint) = - create_collection(&client, candy_pubkey, &mut cache, &config_data)?; + create_collection(&client, candy_pubkey, &mut cache, &config_data, &args)?; pb.finish_and_clear(); println!( @@ -183,6 +184,7 @@ pub async fn process_deploy(args: DeployArgs) -> Result<()> { collection_mint, metadata.update_authority, program, + &args.priority_fee, )?; info!("Candy machine initialized with sig: {}", sig); info!( @@ -273,6 +275,7 @@ pub async fn process_deploy(args: DeployArgs) -> Result<()> { &mut cache, config_lines, args.interrupted, + args.priority_fee, ) .await?; @@ -316,6 +319,7 @@ pub async fn process_deploy(args: DeployArgs) -> Result<()> { new_authority: None, config: args.config, candy_machine: Some(candy_pubkey.to_string()), + priority_fee: args.priority_fee, }; process_update(update_args)?; diff --git a/src/freeze/initialize.rs b/src/freeze/initialize.rs index 1f36d197..addc0b64 100644 --- a/src/freeze/initialize.rs +++ b/src/freeze/initialize.rs @@ -1,5 +1,8 @@ +#![allow(clippy::too_many_arguments)] + use std::ops::Deref; +use anchor_client::solana_sdk::compute_budget::ComputeBudgetInstruction; use mpl_candy_guard::{ accounts::Route as RouteAccount, guards::FreezeInstruction, instruction::Route, instructions::RouteArgs, state::GuardType, @@ -16,6 +19,7 @@ pub struct InitializeArgs { pub candy_machine: Option, pub label: Option, pub period: u64, + pub priority_fee: u64, } pub fn process_initialize(args: InitializeArgs) -> Result<()> { @@ -83,6 +87,7 @@ pub fn process_initialize(args: InitializeArgs) -> Result<()> { &args.label, args.period, mint, + args.priority_fee, )?; pb.finish_with_message(format!("{} {}", style("Signature:").bold(), signature)); @@ -98,6 +103,7 @@ pub fn initialize + Clone>( label: &Option, period: u64, mint: Option, + priority_fee: u64, ) -> Result { let mut remaining_accounts = Vec::with_capacity(4); let (freeze_pda, _) = find_freeze_pda(candy_guard_id, candy_machine_id, destination); @@ -152,8 +158,11 @@ pub fn initialize + Clone>( let mut data = vec![FreezeInstruction::Initialize as u8]; data.extend_from_slice(&period.to_le_bytes()); + let priority_fee_ix = ComputeBudgetInstruction::set_compute_unit_price(priority_fee); + let builder = program .request() + .instruction(priority_fee_ix) .accounts(RouteAccount { candy_guard: *candy_guard_id, candy_machine: *candy_machine_id, diff --git a/src/freeze/thaw.rs b/src/freeze/thaw.rs index 273a4fee..208a7e87 100644 --- a/src/freeze/thaw.rs +++ b/src/freeze/thaw.rs @@ -1,5 +1,8 @@ +#![allow(clippy::too_many_arguments)] + use std::{fmt::Display, time::Duration}; +use anchor_client::solana_sdk::compute_budget::ComputeBudgetInstruction; use mpl_candy_guard::{ accounts::Route as RouteAccount, guards::FreezeInstruction, instruction::Route, instructions::RouteArgs, state::GuardType, @@ -26,6 +29,7 @@ pub struct ThawArgs { pub use_cache: bool, pub timeout: Option, pub token: bool, + pub priority_fee: u64, } #[derive(Debug, Clone, Deserialize, Serialize)] @@ -292,6 +296,7 @@ pub async fn process_thaw(args: ThawArgs) -> Result<()> { &nft, &args.label, freeze_guard, + &args.priority_fee, )?; pb.finish_with_message(format!( @@ -538,6 +543,7 @@ pub async fn process_thaw(args: ThawArgs) -> Result<()> { &nft, &label, guard, + &args.priority_fee, ) .map_err(|e| { failed_thaws.lock().unwrap().push(FailedThaw { @@ -593,6 +599,7 @@ fn thaw_nft( nft: &ThawNft, label: &Option, freeze_guard: GuardType, + priority_fee: &u64, ) -> Result { let client = setup_client(&config)?; let program = client.program(mpl_candy_guard::ID); @@ -691,8 +698,11 @@ fn thaw_nft( }); } + let priority_fee_ix = ComputeBudgetInstruction::set_compute_unit_price(*priority_fee); + let builder = program .request() + .instruction(priority_fee_ix) .accounts(RouteAccount { candy_guard: *candy_guard_id, candy_machine: *candy_machine_id, diff --git a/src/freeze/unlock_funds.rs b/src/freeze/unlock_funds.rs index c8f2fd1b..ad99d5cb 100644 --- a/src/freeze/unlock_funds.rs +++ b/src/freeze/unlock_funds.rs @@ -1,3 +1,4 @@ +use anchor_client::solana_sdk::compute_budget::ComputeBudgetInstruction; use mpl_candy_guard::{ accounts::Route as RouteAccount, guards::FreezeInstruction, instruction::Route, instructions::RouteArgs, state::GuardType, @@ -15,6 +16,7 @@ pub struct UnlockFundsArgs { pub destination: Option, pub label: Option, pub token: bool, + pub priority_fee: u64, } pub fn process_unlock_funds(args: UnlockFundsArgs) -> Result<()> { @@ -120,6 +122,7 @@ pub fn process_unlock_funds(args: UnlockFundsArgs) -> Result<()> { &destination_address, &args.label, freeze_guard, + &args.priority_fee, )?; pb.finish_with_message(format!( @@ -138,6 +141,7 @@ pub fn unlock_funds + Clone>( destination: &Pubkey, label: &Option, freeze_guard: GuardType, + priority_fee: &u64, ) -> Result { let mut remaining_accounts = Vec::with_capacity(4); let (freeze_pda, _) = find_freeze_pda(candy_guard_id, candy_machine_id, destination); @@ -197,8 +201,11 @@ pub fn unlock_funds + Clone>( _ => return Err(anyhow!("Invalid freeze guard type: {freeze_guard:?}")), }; + let priority_fee_ix = ComputeBudgetInstruction::set_compute_unit_price(*priority_fee); + let builder = program .request() + .instruction(priority_fee_ix) .accounts(RouteAccount { candy_guard: *candy_guard_id, candy_machine: *candy_machine_id, diff --git a/src/guard/add.rs b/src/guard/add.rs index dd75ad08..d66d2dad 100644 --- a/src/guard/add.rs +++ b/src/guard/add.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use anchor_client::solana_sdk::pubkey::Pubkey; +use anchor_client::solana_sdk::{compute_budget::ComputeBudgetInstruction, pubkey::Pubkey}; use anyhow::Result; use console::style; use mpl_candy_guard::{ @@ -18,6 +18,7 @@ pub struct GuardAddArgs { pub config: String, pub candy_machine: Option, pub candy_guard: Option, + pub priority_fee: u64, } pub fn process_guard_add(args: GuardAddArgs) -> Result<()> { @@ -92,8 +93,11 @@ pub fn process_guard_add(args: GuardAddArgs) -> Result<()> { let mut serialized_data = vec![0; data.size()]; data.save(&mut serialized_data)?; + let priority_fee = ComputeBudgetInstruction::set_compute_unit_price(args.priority_fee); + let tx = program .request() + .instruction(priority_fee) .accounts(InitializeAccount { candy_guard, base: base.pubkey(), @@ -139,9 +143,12 @@ pub fn process_guard_add(args: GuardAddArgs) -> Result<()> { let mut serialized_data = vec![0; data.size()]; data.save(&mut serialized_data)?; + let priority_fee = ComputeBudgetInstruction::set_compute_unit_price(args.priority_fee); + // synchronizes the guards config with the on-chain account let tx = program .request() + .instruction(priority_fee) .accounts(UpdateAccount { candy_guard: candy_guard_id, authority: payer.pubkey(), @@ -168,8 +175,11 @@ pub fn process_guard_add(args: GuardAddArgs) -> Result<()> { let pb = spinner_with_style(); pb.set_message("Connecting..."); + let priority_fee = ComputeBudgetInstruction::set_compute_unit_price(args.priority_fee); + let tx = program .request() + .instruction(priority_fee) .accounts(WrapAccount { candy_guard, authority: payer.pubkey(), diff --git a/src/guard/remove.rs b/src/guard/remove.rs index 8634f93d..e3a12db5 100644 --- a/src/guard/remove.rs +++ b/src/guard/remove.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use anchor_client::solana_sdk::pubkey::Pubkey; +use anchor_client::solana_sdk::{compute_budget::ComputeBudgetInstruction, pubkey::Pubkey}; use anyhow::Result; use console::style; use mpl_candy_guard::{accounts::Unwrap as UnwrapAccount, instruction::Unwrap}; @@ -13,6 +13,7 @@ pub struct GuardRemoveArgs { pub cache: String, pub candy_machine: Option, pub candy_guard: Option, + pub priority_fee: u64, } pub fn process_guard_remove(args: GuardRemoveArgs) -> Result<()> { @@ -63,9 +64,11 @@ pub fn process_guard_remove(args: GuardRemoveArgs) -> Result<()> { let pb = spinner_with_style(); pb.set_message("Connecting..."); + let priority_fee = ComputeBudgetInstruction::set_compute_unit_price(args.priority_fee); let tx = program .request() + .instruction(priority_fee) .accounts(UnwrapAccount { candy_guard: candy_guard_id, authority: payer.pubkey(), diff --git a/src/guard/update.rs b/src/guard/update.rs index 3637c3cc..27747856 100644 --- a/src/guard/update.rs +++ b/src/guard/update.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use anchor_client::solana_sdk::pubkey::Pubkey; +use anchor_client::solana_sdk::{compute_budget::ComputeBudgetInstruction, pubkey::Pubkey}; use anyhow::Result; use console::style; use mpl_candy_guard::{accounts::Update as UpdateAccount, instruction::Update}; @@ -13,6 +13,7 @@ pub struct GuardUpdateArgs { pub cache: String, pub config: String, pub candy_guard: Option, + pub priority_fee: u64, } pub fn process_guard_update(args: GuardUpdateArgs) -> Result<()> { @@ -76,8 +77,11 @@ pub fn process_guard_update(args: GuardUpdateArgs) -> Result<()> { let pb = spinner_with_style(); pb.set_message("Connecting..."); + let priority_fee = ComputeBudgetInstruction::set_compute_unit_price(args.priority_fee); + let tx = program .request() + .instruction(priority_fee) .accounts(UpdateAccount { candy_guard: candy_guard_id, authority: payer.pubkey(), diff --git a/src/guard/withdraw.rs b/src/guard/withdraw.rs index 2f3771c9..54d8d754 100644 --- a/src/guard/withdraw.rs +++ b/src/guard/withdraw.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use anchor_client::solana_sdk::pubkey::Pubkey; +use anchor_client::solana_sdk::{compute_budget::ComputeBudgetInstruction, pubkey::Pubkey}; use anyhow::Result; use console::style; use mpl_candy_guard::{accounts::Withdraw as WithdrawAccount, instruction::Withdraw}; @@ -13,6 +13,7 @@ pub struct GuardWithdrawArgs { pub rpc_url: Option, pub cache: String, pub candy_guard: Option, + pub priority_fee: u64, } pub fn process_guard_withdraw(args: GuardWithdrawArgs) -> Result<()> { @@ -57,8 +58,11 @@ pub fn process_guard_withdraw(args: GuardWithdrawArgs) -> Result<()> { let pb = spinner_with_style(); pb.set_message("Connecting..."); + let priority_fee = ComputeBudgetInstruction::set_compute_unit_price(args.priority_fee); + let tx = program .request() + .instruction(priority_fee) .accounts(WithdrawAccount { candy_guard: candy_guard_id, authority: payer.pubkey(), diff --git a/src/launch/process.rs b/src/launch/process.rs index 27102330..480a888b 100644 --- a/src/launch/process.rs +++ b/src/launch/process.rs @@ -23,6 +23,7 @@ pub struct LaunchArgs { pub strict: bool, pub skip_collection_prompt: bool, pub interrupted: Arc, + pub priority_fee: u64, } pub async fn process_launch(args: LaunchArgs) -> Result<()> { @@ -74,6 +75,7 @@ pub async fn process_launch(args: LaunchArgs) -> Result<()> { rpc_url: args.rpc_url.clone(), cache: args.cache.clone(), interrupted: args.interrupted.clone(), + priority_fee: args.priority_fee, }; process_upload(upload_args).await?; @@ -87,6 +89,7 @@ pub async fn process_launch(args: LaunchArgs) -> Result<()> { cache: args.cache.clone(), interrupted: args.interrupted.clone(), collection_mint: None, + priority_fee: args.priority_fee, }; process_deploy(deploy_args).await?; diff --git a/src/main.rs b/src/main.rs index 1f300f10..3cb87a4c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -162,6 +162,7 @@ async fn run() -> Result<()> { config, candy_machine, collection_mint, + priority_fee, } => process_set_collection(SetCollectionArgs { collection_mint, keypair, @@ -169,6 +170,7 @@ async fn run() -> Result<()> { cache, config, candy_machine, + priority_fee, })?, }, Commands::Config { command } => match command { @@ -190,6 +192,7 @@ async fn run() -> Result<()> { cache, new_authority, candy_machine, + priority_fee, } => process_update(UpdateArgs { config, keypair, @@ -197,6 +200,7 @@ async fn run() -> Result<()> { cache, new_authority, candy_machine, + priority_fee, })?, ConfigSubcommands::Set { keypair, @@ -205,6 +209,7 @@ async fn run() -> Result<()> { token_standard, candy_machine, rule_set, + priority_fee, } => process_set_token_stardard(SetTokenStandardArgs { keypair, rpc_url, @@ -212,6 +217,7 @@ async fn run() -> Result<()> { token_standard, candy_machine, rule_set, + priority_fee, })?, }, Commands::Deploy { @@ -220,6 +226,7 @@ async fn run() -> Result<()> { rpc_url, cache, collection_mint, + priority_fee, } => { process_deploy(DeployArgs { config, @@ -228,6 +235,7 @@ async fn run() -> Result<()> { cache, interrupted: interrupted.clone(), collection_mint, + priority_fee, }) .await? } @@ -241,6 +249,7 @@ async fn run() -> Result<()> { candy_machine, label, period, + priority_fee, } => process_initialize(InitializeArgs { keypair, rpc_url, @@ -250,6 +259,7 @@ async fn run() -> Result<()> { candy_machine, label, period, + priority_fee, })?, FreezeCommand::Thaw { keypair, @@ -265,6 +275,7 @@ async fn run() -> Result<()> { use_cache, timeout, token, + priority_fee, } => { process_thaw(ThawArgs { keypair, @@ -280,6 +291,7 @@ async fn run() -> Result<()> { use_cache, timeout, token, + priority_fee, }) .await? } @@ -293,6 +305,7 @@ async fn run() -> Result<()> { destination, label, token, + priority_fee, } => process_unlock_funds(UnlockFundsArgs { keypair, rpc_url, @@ -303,6 +316,7 @@ async fn run() -> Result<()> { destination, label, token, + priority_fee, })?, }, Commands::Guard { command } => match command { @@ -313,6 +327,7 @@ async fn run() -> Result<()> { config, candy_machine, candy_guard, + priority_fee, } => process_guard_add(GuardAddArgs { keypair, rpc_url, @@ -320,6 +335,7 @@ async fn run() -> Result<()> { config, candy_machine, candy_guard, + priority_fee, })?, GuardCommand::Remove { keypair, @@ -327,12 +343,14 @@ async fn run() -> Result<()> { cache, candy_machine, candy_guard, + priority_fee, } => process_guard_remove(GuardRemoveArgs { keypair, rpc_url, cache, candy_machine, candy_guard, + priority_fee, })?, GuardCommand::Show { keypair, @@ -351,23 +369,27 @@ async fn run() -> Result<()> { cache, config, candy_guard, + priority_fee, } => process_guard_update(GuardUpdateArgs { keypair, rpc_url, cache, config, candy_guard, + priority_fee, })?, GuardCommand::Withdraw { keypair, rpc_url, cache, candy_guard, + priority_fee, } => process_guard_withdraw(GuardWithdrawArgs { keypair, rpc_url, cache, candy_guard, + priority_fee, })?, }, Commands::Hash { @@ -387,6 +409,7 @@ async fn run() -> Result<()> { cache, strict, skip_collection_prompt, + priority_fee, } => { process_launch(LaunchArgs { assets_dir, @@ -397,6 +420,7 @@ async fn run() -> Result<()> { strict, skip_collection_prompt, interrupted: interrupted.clone(), + priority_fee, }) .await? } @@ -407,6 +431,7 @@ async fn run() -> Result<()> { number, receiver, candy_machine, + priority_fee, } => { process_mint(MintArgs { keypair, @@ -415,6 +440,7 @@ async fn run() -> Result<()> { number, receiver, candy_machine, + priority_fee, }) .await? } @@ -424,6 +450,7 @@ async fn run() -> Result<()> { cache, candy_machine, airdrop_list, + priority_fee, } => { process_airdrop(AirdropArgs { keypair, @@ -431,6 +458,7 @@ async fn run() -> Result<()> { cache, candy_machine, airdrop_list, + priority_fee, }) .await? } @@ -469,6 +497,7 @@ async fn run() -> Result<()> { keypair, rpc_url, cache, + priority_fee, } => { process_upload(UploadArgs { assets_dir, @@ -477,6 +506,7 @@ async fn run() -> Result<()> { rpc_url, cache, interrupted: interrupted.clone(), + priority_fee, }) .await? } @@ -504,12 +534,14 @@ async fn run() -> Result<()> { rpc_url, list, authority, + priority_fee, } => process_withdraw(WithdrawArgs { candy_machine, keypair, rpc_url, list, authority, + priority_fee, })?, Commands::Sign { keypair, diff --git a/src/mint/process.rs b/src/mint/process.rs index 1e393e8a..8eb5adc3 100644 --- a/src/mint/process.rs +++ b/src/mint/process.rs @@ -40,6 +40,7 @@ pub struct MintArgs { pub number: Option, pub receiver: Option, pub candy_machine: Option, + pub priority_fee: u64, } pub async fn process_mint(args: MintArgs) -> Result<()> { @@ -122,6 +123,7 @@ pub async fn process_mint(args: MintArgs) -> Result<()> { Arc::clone(&candy_machine_state), collection_update_authority, receiver_pubkey, + args.priority_fee, ) .await { @@ -160,6 +162,7 @@ pub async fn process_mint(args: MintArgs) -> Result<()> { candy_machine_state, collection_update_authority, receiver_pubkey, + args.priority_fee, ) .await; pb.inc(1); @@ -204,6 +207,7 @@ pub async fn mint( candy_machine_state: Arc, collection_update_authority: Pubkey, receiver: Pubkey, + priority_fee: u64, ) -> Result<(Signature, Pubkey)> { let client = setup_client(&config)?; let program = client.program(CANDY_MACHINE_ID); @@ -251,8 +255,11 @@ pub async fn mint( let metadata_pda = find_metadata_pda(&nft_mint.pubkey()); let master_edition_pda = find_master_edition_pda(&nft_mint.pubkey()); + let priority_fee_ix = ComputeBudgetInstruction::set_compute_unit_price(priority_fee); + let mint_ix = program .request() + .instruction(priority_fee_ix) .accounts(nft_accounts::MintV2 { candy_machine: candy_machine_id, authority_pda, @@ -294,10 +301,12 @@ pub async fn mint( // need to increase the number of compute units let compute_ix = ComputeBudgetInstruction::set_compute_unit_limit(COMPUTE_UNITS); + let priority_fee_ix = ComputeBudgetInstruction::set_compute_unit_price(priority_fee); let builder = program .request() .instruction(compute_ix) + .instruction(priority_fee_ix) .instruction(mint_ix[0].clone()) .signer(&nft_mint); diff --git a/src/update/process.rs b/src/update/process.rs index 93632aa4..eee93c71 100644 --- a/src/update/process.rs +++ b/src/update/process.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use anchor_client::solana_sdk::pubkey::Pubkey; +use anchor_client::solana_sdk::{compute_budget::ComputeBudgetInstruction, pubkey::Pubkey}; use anyhow::Result; use console::style; use mpl_candy_machine_core::{ @@ -22,6 +22,7 @@ pub struct UpdateArgs { pub new_authority: Option, pub config: String, pub candy_machine: Option, + pub priority_fee: u64, } pub fn process_update(args: UpdateArgs) -> Result<()> { @@ -74,8 +75,11 @@ pub fn process_update(args: UpdateArgs) -> Result<()> { ); let program = client.program(CANDY_MACHINE_ID); + let priority_fee = ComputeBudgetInstruction::set_compute_unit_price(args.priority_fee); + let builder = program .request() + .instruction(priority_fee) .accounts(nft_accounts::Update { candy_machine: candy_pubkey, authority: program.payer(), @@ -100,8 +104,12 @@ pub fn process_update(args: UpdateArgs) -> Result<()> { pb.set_message("Sending update authority transaction..."); let new_authority_pubkey = Pubkey::from_str(&new_authority)?; + + let priority_fee = ComputeBudgetInstruction::set_compute_unit_price(args.priority_fee); + let builder = program .request() + .instruction(priority_fee) .accounts(nft_accounts::SetAuthority { candy_machine: candy_pubkey, authority: program.payer(), diff --git a/src/update/set_token_standard.rs b/src/update/set_token_standard.rs index 9f85c6b6..1cf3ca01 100644 --- a/src/update/set_token_standard.rs +++ b/src/update/set_token_standard.rs @@ -1,6 +1,6 @@ use std::str::FromStr; -use anchor_client::solana_sdk::pubkey::Pubkey; +use anchor_client::solana_sdk::{compute_budget::ComputeBudgetInstruction, pubkey::Pubkey}; use anyhow::Result; use console::style; use mpl_candy_machine_core::{accounts::SetTokenStandard, AccountVersion}; @@ -25,6 +25,7 @@ pub struct SetTokenStandardArgs { pub token_standard: Option, pub candy_machine: Option, pub rule_set: Option, + pub priority_fee: u64, } pub fn process_set_token_stardard(args: SetTokenStandardArgs) -> Result<()> { @@ -118,8 +119,11 @@ pub fn process_set_token_stardard(args: SetTokenStandardArgs) -> Result<()> { let payer = sugar_config.keypair; + let priority_fee = ComputeBudgetInstruction::set_compute_unit_price(args.priority_fee); + let tx = program .request() + .instruction(priority_fee) .accounts(SetTokenStandard { candy_machine: candy_machine_id, authority_pda, diff --git a/src/upload/process.rs b/src/upload/process.rs index 691b374e..9944b6b4 100644 --- a/src/upload/process.rs +++ b/src/upload/process.rs @@ -28,6 +28,7 @@ pub struct UploadArgs { pub rpc_url: Option, pub cache: String, pub interrupted: Arc, + pub priority_fee: u64, } pub struct AssetType { diff --git a/src/withdraw/process.rs b/src/withdraw/process.rs index cec08c37..4a84c89d 100644 --- a/src/withdraw/process.rs +++ b/src/withdraw/process.rs @@ -3,6 +3,7 @@ use std::{ops::Deref, rc::Rc, str::FromStr}; pub use anchor_client::{ solana_sdk::{ commitment_config::{CommitmentConfig, CommitmentLevel}, + compute_budget::ComputeBudgetInstruction, native_token::LAMPORTS_PER_SOL, pubkey::Pubkey, signature::{Keypair, Signature, Signer}, @@ -34,6 +35,7 @@ pub struct WithdrawArgs { pub rpc_url: Option, pub list: bool, pub authority: Option, + pub priority_fee: u64, } #[derive(Debug)] @@ -82,7 +84,7 @@ pub fn process_withdraw(args: WithdrawArgs) -> Result<()> { let pb = spinner_with_style(); pb.set_message("Draining candy machine..."); - do_withdraw(Rc::new(program), candy_machine, payer)?; + do_withdraw(Rc::new(program), candy_machine, payer, args.priority_fee)?; pb.finish_with_message("Done"); } @@ -168,15 +170,16 @@ pub fn process_withdraw(args: WithdrawArgs) -> Result<()> { accounts.iter().for_each(|account| { let (candy_machine, _account) = account; - do_withdraw(program.clone(), *candy_machine, payer).unwrap_or_else(|e| { - not_drained += 1; - error!("Error: {}", e); - let error_message = parse_sugar_errors(&e.to_string()); - error_messages.push(WithdrawError { - candy_machine: candy_machine.to_string(), - error_message, + do_withdraw(program.clone(), *candy_machine, payer, args.priority_fee) + .unwrap_or_else(|e| { + not_drained += 1; + error!("Error: {}", e); + let error_message = parse_sugar_errors(&e.to_string()); + error_messages.push(WithdrawError { + candy_machine: candy_machine.to_string(), + error_message, + }); }); - }); pb.inc(1); }); @@ -231,9 +234,12 @@ fn do_withdraw + Clone>( program: Rc>, candy_machine: Pubkey, payer: Pubkey, + priority_fee: u64, ) -> Result<()> { + let priority_fee_ix = ComputeBudgetInstruction::set_compute_unit_price(priority_fee); program .request() + .instruction(priority_fee_ix) .accounts(nft_accounts::Withdraw { candy_machine, authority: payer,