Skip to content

Commit

Permalink
Stop checking for rent exemption (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
juchiast authored Nov 16, 2023
1 parent 3e8deee commit 14f068b
Show file tree
Hide file tree
Showing 41 changed files with 28 additions and 297 deletions.
7 changes: 0 additions & 7 deletions crates/cmds-solana/src/associated_token_account.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::prelude::*;
use solana_program::program_pack::Pack;
use spl_associated_token_account::instruction::create_associated_token_account;

const SOLANA_ASSOCIATED_TOKEN_ACCOUNT: &str = "associated_token_account";
Expand Down Expand Up @@ -39,11 +38,6 @@ pub struct Output {
}

async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
let minimum_balance_for_rent_exemption = ctx
.solana_client
.get_minimum_balance_for_rent_exemption(spl_token::state::Account::LEN)
.await?;

let instruction = create_associated_token_account(
&input.fee_payer.pubkey(),
&input.owner,
Expand All @@ -57,7 +51,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
Instructions {
fee_payer: input.fee_payer.pubkey(),
signers: [input.fee_payer.clone_keypair()].into(),
minimum_balance_for_rent_exemption,
instructions: [instruction].into(),
}
} else {
Expand Down
12 changes: 2 additions & 10 deletions crates/cmds-solana/src/compression/create_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use std::mem::size_of;
// Command Name
const CREATE_TREE: &str = "create_tree";

const DEFINITION: &str =
flow_lib::node_definition!("solana/compression/create_tree.json");
const DEFINITION: &str = flow_lib::node_definition!("solana/compression/create_tree.json");

fn build() -> BuildResult {
use once_cell::sync::Lazy;
Expand Down Expand Up @@ -254,13 +253,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
}
.data();

let minimum_balance_for_rent_exemption = ctx
.solana_client
.get_minimum_balance_for_rent_exemption(std::mem::size_of::<
mpl_bubblegum::accounts::CreateTree,
>())
.await?;

let ins = Instructions {
fee_payer: input.payer.pubkey(),
signers: [
Expand All @@ -278,7 +270,7 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
},
]
.into(),
minimum_balance_for_rent_exemption,

};

let ins = input.submit.then_some(ins).unwrap_or_default();
Expand Down
5 changes: 2 additions & 3 deletions crates/cmds-solana/src/create_mint_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct Output {
}

async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
let minimum_balance_for_rent_exemption = ctx
let lamports = ctx
.solana_client
.get_minimum_balance_for_rent_exemption(Mint::LEN)
.await?;
Expand All @@ -61,7 +61,7 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
system_instruction::create_account(
&input.fee_payer.pubkey(),
&input.mint_account.pubkey(),
minimum_balance_for_rent_exemption,
lamports,
Mint::LEN as u64,
&spl_token::id(),
),
Expand All @@ -75,7 +75,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
spl_memo::build_memo(input.memo.as_bytes(), &[&input.fee_payer.pubkey()]),
]
.into(),
minimum_balance_for_rent_exemption,
};

let ins = input.submit.then_some(ins).unwrap_or_default();
Expand Down
2 changes: 1 addition & 1 deletion crates/cmds-solana/src/create_token_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
input.token_account.clone_keypair(),
]
.into(),
minimum_balance_for_rent_exemption,

instructions,
}
} else {
Expand Down
1 change: 0 additions & 1 deletion crates/cmds-solana/src/mint_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
decimals,
)?]
.into(),
minimum_balance_for_rent_exemption: 0,
};

let ins = input.submit.then_some(ins).unwrap_or_default();
Expand Down
2 changes: 1 addition & 1 deletion crates/cmds-solana/src/nft/arweave_nft_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ impl Uploader {
let instruction =
solana_sdk::system_instruction::transfer(&self.fee_payer.pubkey(), &recipient, amount);
let (mut tx, recent_blockhash) =
execute(&self.client, &self.fee_payer.pubkey(), &[instruction], 0).await?;
execute(&self.client, &self.fee_payer.pubkey(), &[instruction]).await?;

try_sign_wallet(signer, &mut tx, &[&self.fee_payer], recent_blockhash).await?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
}
.data();

let minimum_balance_for_rent_exemption = ctx
.solana_client
.get_minimum_balance_for_rent_exemption(std::mem::size_of::<
mpl_candy_machine_core::accounts::AddConfigLines,
>())
.await?;

let ins = Instructions {
fee_payer: input.payer.pubkey(),
signers: [input.payer.clone_keypair(), input.authority.clone_keypair()].into(),
Expand All @@ -73,7 +66,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
data,
}]
.into(),
minimum_balance_for_rent_exemption,
};

let ins = input.submit.then_some(ins).unwrap_or_default();
Expand Down
8 changes: 0 additions & 8 deletions crates/cmds-solana/src/nft/candy_machine_v3/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
&mpl_candy_machine_core::id(),
);

let minimum_balance_for_rent_exemption = ctx
.solana_client
.get_minimum_balance_for_rent_exemption(std::mem::size_of::<
mpl_candy_machine_core::accounts::Initialize,
>())
.await?;

let ins = Instructions {
fee_payer: input.payer.pubkey(),
signers: [
Expand All @@ -159,7 +152,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
},
]
.into(),
minimum_balance_for_rent_exemption,
};

let ins = input.submit.then_some(ins).unwrap_or_default();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
}
.data();

let minimum_balance_for_rent_exemption = ctx
.solana_client
.get_minimum_balance_for_rent_exemption(std::mem::size_of::<
mpl_candy_guard::accounts::Initialize,
>())
.await?;

let ins = Instructions {
fee_payer: input.payer.pubkey(),
signers: [input.payer.clone_keypair(), input.base.clone_keypair()].into(),
Expand All @@ -85,7 +78,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
data,
}]
.into(),
minimum_balance_for_rent_exemption,
};

let ins = input.submit.then_some(ins).unwrap_or_default();
Expand Down
8 changes: 0 additions & 8 deletions crates/cmds-solana/src/nft/candy_machine_v3/mint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
}
.data();

let minimum_balance_for_rent_exemption = ctx
.solana_client
.get_minimum_balance_for_rent_exemption(std::mem::size_of::<
mpl_candy_machine_core::accounts::MintV2,
>())
.await?;

let ins = Instructions {
fee_payer: input.payer.pubkey(),
signers: [
Expand All @@ -180,7 +173,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
},
]
.into(),
minimum_balance_for_rent_exemption,
};

let ins = input.submit.then_some(ins).unwrap_or_default();
Expand Down
8 changes: 0 additions & 8 deletions crates/cmds-solana/src/nft/candy_machine_v3/wrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {

let data = mpl_candy_guard::instruction::Wrap {}.data();

let minimum_balance_for_rent_exemption = ctx
.solana_client
.get_minimum_balance_for_rent_exemption(
std::mem::size_of::<mpl_candy_guard::accounts::Wrap>(),
)
.await?;

let ins = Instructions {
fee_payer: input.payer.pubkey(),
signers: [
Expand All @@ -74,7 +67,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
data,
}]
.into(),
minimum_balance_for_rent_exemption,
};

let ins = input.submit.then_some(ins).unwrap_or_default();
Expand Down
8 changes: 0 additions & 8 deletions crates/cmds-solana/src/nft/create_master_edition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {

let (master_edition_account, _) = MasterEdition::find_pda(&input.mint_account);

let minimum_balance_for_rent_exemption = ctx
.solana_client
.get_minimum_balance_for_rent_exemption(std::mem::size_of::<
mpl_token_metadata::accounts::MasterEdition,
>())
.await?;

let create_ix = mpl_token_metadata::instructions::CreateMasterEditionV3 {
edition: master_edition_account,
mint: input.mint_account,
Expand All @@ -80,7 +73,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
]
.into(),
instructions: [create_ix].into(),
minimum_balance_for_rent_exemption,
};

let ins = input.submit.then_some(ins).unwrap_or_default();
Expand Down
8 changes: 0 additions & 8 deletions crates/cmds-solana/src/nft/create_metadata_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@ pub struct Output {
async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
let (metadata_account, _) = Metadata::find_pda(&input.mint_account);

let minimum_balance_for_rent_exemption = ctx
.solana_client
.get_minimum_balance_for_rent_exemption(std::mem::size_of::<
mpl_token_metadata::accounts::Metadata,
>())
.await?;

let create_ix = mpl_token_metadata::instructions::CreateMetadataAccountV3 {
metadata: metadata_account,
mint: input.mint_account,
Expand Down Expand Up @@ -85,7 +78,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
]
.into(),
instructions: [ins].into(),
minimum_balance_for_rent_exemption,
};

let ins = input.submit.then_some(ins).unwrap_or_default();
Expand Down
2 changes: 1 addition & 1 deletion crates/cmds-solana/src/nft/update_metadata_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output1, CommandError> {
input.update_authority.clone_keypair(),
]
.into(),
minimum_balance_for_rent_exemption: 0,

instructions: [
mpl_token_metadata::instruction::update_metadata_accounts_v2(
mpl_token_metadata::id(),
Expand Down
8 changes: 0 additions & 8 deletions crates/cmds-solana/src/nft/v1/create_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
// &input.mint_account.pubkey(),
// );

let minimum_balance_for_rent_exemption = ctx
.solana_client
.get_minimum_balance_for_rent_exemption(std::mem::size_of::<
mpl_token_metadata::accounts::MasterEdition,
>())
.await?;

let create_ix = mpl_token_metadata::instructions::CreateV1 {
metadata: metadata_account,
master_edition: Some(master_edition_account),
Expand Down Expand Up @@ -161,7 +154,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
]
.into(),
instructions: [create_ix].into(),
minimum_balance_for_rent_exemption,
};

let ins = input.submit.then_some(ins).unwrap_or_default();
Expand Down
6 changes: 0 additions & 6 deletions crates/cmds-solana/src/nft/v1/delegate_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
DelegateType::Token(..) => TokenRecord::find_pda(&input.mint_account, &token_account).0,
};

let minimum_balance_for_rent_exemption = ctx
.solana_client
.get_minimum_balance_for_rent_exemption(std::mem::size_of::<DelegateV1>())
.await?;

let delegate_v1 = DelegateV1 {
delegate_record: Some(delegate_record),
delegate: input.delegate.pubkey(),
Expand Down Expand Up @@ -147,7 +142,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
]
.into(),
instructions: [create_ix].into(),
minimum_balance_for_rent_exemption,
};

let ins = input.submit.then_some(ins).unwrap_or_default();
Expand Down
8 changes: 0 additions & 8 deletions crates/cmds-solana/src/nft/v1/mint_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {

let token_record = TokenRecord::find_pda(&input.mint_account, &token_account).0;

let minimum_balance_for_rent_exemption = ctx
.solana_client
.get_minimum_balance_for_rent_exemption(std::mem::size_of::<
mpl_token_metadata::accounts::MasterEdition,
>())
.await?;

let create_ix = mpl_token_metadata::instructions::MintV1 {
metadata: metadata_account,
master_edition: Some(master_edition_account),
Expand Down Expand Up @@ -104,7 +97,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
]
.into(),
instructions: [create_ix].into(),
minimum_balance_for_rent_exemption,
};

let ins = input.submit.then_some(ins).unwrap_or_default();
Expand Down
6 changes: 0 additions & 6 deletions crates/cmds-solana/src/nft/v1/update_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
.expect("update_authority field must be set")
});

let minimum_balance_for_rent_exemption = ctx
.solana_client
.get_minimum_balance_for_rent_exemption(std::mem::size_of::<UpdateAsDelegateV1>())
.await?;

let delegate_v1 = UpdateAsDelegateV1 {
authority: authority_or_delegate.pubkey(),
delegate_record: input.delegate_record,
Expand All @@ -109,7 +104,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
]
.into(),
instructions: [create_ix].into(),
minimum_balance_for_rent_exemption,
};

let ins = input.submit.then_some(ins).unwrap_or_default();
Expand Down
8 changes: 0 additions & 8 deletions crates/cmds-solana/src/nft/v1/verify_collection_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {

let (collection_master_edition, _) = MasterEdition::find_pda(&input.collection_mint_account);

let minimum_balance_for_rent_exemption = ctx
.solana_client
.get_minimum_balance_for_rent_exemption(std::mem::size_of::<
mpl_token_metadata::accounts::MasterEdition,
>())
.await?;

let accounts = mpl_token_metadata::instructions::VerifyCollectionV1 {
authority: input.collection_authority.pubkey(),
delegate_record: input.delegate_record,
Expand All @@ -74,7 +67,6 @@ async fn run(mut ctx: Context, input: Input) -> Result<Output, CommandError> {
]
.into(),
instructions: [ins].into(),
minimum_balance_for_rent_exemption,
};

let ins = input.submit.then_some(ins).unwrap_or_default();
Expand Down
Loading

0 comments on commit 14f068b

Please sign in to comment.