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

Fixes Sync not working for transfer_transaction #375

Merged
merged 1 commit into from
Jun 14, 2024
Merged
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
18 changes: 9 additions & 9 deletions helium-lib/src/hotspot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
is_zero,
keypair::{pubkey, serde_pubkey, GetPubkey, Keypair, Pubkey},
kta, onboarding,
priority_fee::{self, SetPriorityFees},
priority_fee::{self, compute_budget_instruction, compute_price_instruction, SetPriorityFees},
programs::{SPL_ACCOUNT_COMPRESSION_PROGRAM_ID, SPL_NOOP_PROGRAM_ID},
result::{DecodeError, EncodeError, Error, Result},
settings::{DasClient, DasSearchAssetsParams, Settings},
Expand Down Expand Up @@ -431,16 +431,16 @@ pub async fn transfer_transaction(
let mut priority_fee_accounts = transfer_ix.accounts.clone();
priority_fee_accounts.extend_from_slice(&remaining_accounts);

let ixs = program
.request()
.compute_budget(200_000)
.compute_price(
let ixs = &[
compute_budget_instruction(200_000),
compute_price_instruction(
priority_fee::get_estimate(&program.async_rpc(), &priority_fee_accounts).await?,
)
.instruction(transfer_ix)
.instructions()?;
),
transfer_ix,
];

let tx =
solana_sdk::transaction::Transaction::new_with_payer(&ixs, Some(&asset.ownership.owner));
solana_sdk::transaction::Transaction::new_with_payer(ixs, Some(&asset.ownership.owner));
Ok(tx)
}

Expand Down
20 changes: 10 additions & 10 deletions helium-lib/src/priority_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ pub trait SetPriorityFees {
fn compute_price(self, priority_fee: u64) -> Self;
}

pub fn compute_budget_instruction(compute_limit: u32) -> solana_sdk::instruction::Instruction {
solana_sdk::compute_budget::ComputeBudgetInstruction::set_compute_unit_limit(compute_limit)
}

pub fn compute_price_instruction(priority_fee: u64) -> solana_sdk::instruction::Instruction {
solana_sdk::compute_budget::ComputeBudgetInstruction::set_compute_unit_price(priority_fee)
}

impl<'a, C: Deref<Target = impl Signer> + Clone> SetPriorityFees for RequestBuilder<'a, C> {
fn compute_budget(self, compute_limit: u32) -> Self {
let compute_ix =
solana_sdk::compute_budget::ComputeBudgetInstruction::set_compute_unit_limit(
compute_limit,
);
self.instruction(compute_ix)
self.instruction(compute_budget_instruction(compute_limit))
}

fn compute_price(self, priority_fee: u64) -> Self {
let compute_price_ix =
solana_sdk::compute_budget::ComputeBudgetInstruction::set_compute_unit_price(
priority_fee,
);
self.instruction(compute_price_ix)
self.instruction(compute_price_instruction(priority_fee))
}
}