From 607b890db4421ffda92b5832d00fd034504a617a Mon Sep 17 00:00:00 2001 From: Hardhat Chad Date: Wed, 12 Jun 2024 09:56:03 -0700 Subject: [PATCH] frontend fixes --- .../solana-extra/src/program/spl_token/mod.rs | 2 +- .../src/program/vote/vote_state/mod.rs | 34 ++++++++----------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/wasm/utils/solana-extra/src/program/spl_token/mod.rs b/wasm/utils/solana-extra/src/program/spl_token/mod.rs index ea885042..f63d784c 100644 --- a/wasm/utils/solana-extra/src/program/spl_token/mod.rs +++ b/wasm/utils/solana-extra/src/program/spl_token/mod.rs @@ -16,7 +16,7 @@ pub fn ui_amount_to_amount(ui_amount: f64, decimals: u8) -> u64 { /// Convert a raw amount to its UI representation (using the decimals field defined in its mint) pub fn amount_to_ui_amount(amount: u64, decimals: u8) -> f64 { - amount as f64 / 10_usize.pow(decimals as u32) as f64 + amount as f64 / 10f64.powf(decimals as f64) } /// Convert a raw amount to its UI representation (using the decimals field defined in its mint) diff --git a/wasm/utils/solana-extra/src/program/vote/vote_state/mod.rs b/wasm/utils/solana-extra/src/program/vote/vote_state/mod.rs index f5d1dc91..29432f75 100644 --- a/wasm/utils/solana-extra/src/program/vote/vote_state/mod.rs +++ b/wasm/utils/solana-extra/src/program/vote/vote_state/mod.rs @@ -1212,7 +1212,7 @@ pub fn authorize( } } - vote_account.set_state(&VoteStateVersions::new_current(vote_state), feature_set) + vote_account.set_state(&VoteStateVersions::new_current(vote_state)) } /// Update the node_pubkey, requires signature of the authorized voter @@ -1220,7 +1220,7 @@ pub fn update_validator_identity( vote_account: &mut BorrowedAccount, node_pubkey: &Pubkey, signers: &HashSet, - feature_set: &FeatureSet, + _feature_set: &FeatureSet, ) -> Result<(), InstructionError> { let mut vote_state: VoteState = vote_account .get_state::()? @@ -1234,7 +1234,7 @@ pub fn update_validator_identity( vote_state.node_pubkey = *node_pubkey; - vote_account.set_state(&VoteStateVersions::new_current(vote_state), feature_set) + vote_account.set_state(&VoteStateVersions::new_current(vote_state)) } /// Update the vote account's commission @@ -1242,7 +1242,7 @@ pub fn update_commission( vote_account: &mut BorrowedAccount, commission: u8, signers: &HashSet, - feature_set: &FeatureSet, + _feature_set: &FeatureSet, ) -> Result<(), InstructionError> { let mut vote_state: VoteState = vote_account .get_state::()? @@ -1253,7 +1253,7 @@ pub fn update_commission( vote_state.commission = commission; - vote_account.set_state(&VoteStateVersions::new_current(vote_state), feature_set) + vote_account.set_state(&VoteStateVersions::new_current(vote_state)) } fn verify_authorized_signer( @@ -1278,7 +1278,7 @@ pub fn withdraw( signers: &HashSet, rent_sysvar: Option<&Rent>, clock: Option<&Clock>, - feature_set: &FeatureSet, + _feature_set: &FeatureSet, ) -> Result<(), InstructionError> { // NOTE: solana-sdk 1.11 `try_borrow_account` is private(this lib was written in 1.10.29) // We use `try_borrow_instruction_account` to fix it. @@ -1315,10 +1315,7 @@ pub fn withdraw( // Deinitialize upon zero-balance // TODO: // datapoint_debug!("vote-account-close", ("allow", 1, i64)); - vote_account.set_state( - &VoteStateVersions::new_current(VoteState::default()), - feature_set, - )?; + vote_account.set_state(&VoteStateVersions::new_current(VoteState::default()))?; } } else if let Some(rent_sysvar) = rent_sysvar { let min_rent_exempt_balance = rent_sysvar.minimum_balance(vote_account.get_data().len()); @@ -1327,13 +1324,13 @@ pub fn withdraw( } } - vote_account.checked_sub_lamports(lamports, feature_set)?; + vote_account.checked_sub_lamports(lamports)?; drop(vote_account); // NOTE: solana-sdk 1.11 `try_borrow_account` is private(this lib was written in 1.10.29) // We use `try_borrow_instruction_account` to fix it. let mut to_account = instruction_context .try_borrow_instruction_account(transaction_context, to_account_index)?; - to_account.checked_add_lamports(lamports, feature_set)?; + to_account.checked_add_lamports(lamports)?; Ok(()) } @@ -1345,7 +1342,7 @@ pub fn initialize_account( vote_init: &VoteInit, signers: &HashSet, clock: &Clock, - feature_set: &FeatureSet, + _feature_set: &FeatureSet, ) -> Result<(), InstructionError> { if vote_account.get_data().len() != VoteState::size_of() { return Err(InstructionError::InvalidAccountData); @@ -1359,10 +1356,9 @@ pub fn initialize_account( // node must agree to accept this vote account verify_authorized_signer(&vote_init.node_pubkey, signers)?; - vote_account.set_state( - &VoteStateVersions::new_current(VoteState::new(vote_init, clock)), - feature_set, - ) + vote_account.set_state(&VoteStateVersions::new_current(VoteState::new( + vote_init, clock, + ))) } fn verify_and_get_vote_state( @@ -1401,7 +1397,7 @@ pub fn process_vote( .ok_or(VoteError::EmptySlots) .and_then(|slot| vote_state.process_timestamp(*slot, timestamp))?; } - vote_account.set_state(&VoteStateVersions::new_current(vote_state), feature_set) + vote_account.set_state(&VoteStateVersions::new_current(vote_state)) } pub fn process_vote_state_update( @@ -1421,7 +1417,7 @@ pub fn process_vote_state_update( clock.epoch, Some(feature_set), )?; - vote_account.set_state(&VoteStateVersions::new_current(vote_state), feature_set) + vote_account.set_state(&VoteStateVersions::new_current(vote_state)) } pub fn create_account_with_authorized(