From 9e3742544d161a359b83b09667cb89488234992b Mon Sep 17 00:00:00 2001 From: Marc Nijdam Date: Fri, 14 Jun 2024 16:12:37 -0500 Subject: [PATCH] Fixes Sync not working for transfer_transaction Using RequestBuilder which is not Sync makes some async usecases fail very noisily. This removes the need for RequestBuilder in transfer_transaction --- helium-lib/src/hotspot.rs | 18 +++++++++--------- helium-lib/src/priority_fee.rs | 20 ++++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/helium-lib/src/hotspot.rs b/helium-lib/src/hotspot.rs index e682306b..ae84081c 100644 --- a/helium-lib/src/hotspot.rs +++ b/helium-lib/src/hotspot.rs @@ -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}, @@ -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) } diff --git a/helium-lib/src/priority_fee.rs b/helium-lib/src/priority_fee.rs index e7f0877b..1c21ea23 100644 --- a/helium-lib/src/priority_fee.rs +++ b/helium-lib/src/priority_fee.rs @@ -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 + 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)) } }