diff --git a/src/components/config/src/abci/mod.rs b/src/components/config/src/abci/mod.rs index 0fecf51ed..a107418fe 100644 --- a/src/components/config/src/abci/mod.rs +++ b/src/components/config/src/abci/mod.rs @@ -204,13 +204,13 @@ lazy_static! { evm_substate_v2_height: 3351349, disable_delegate_frc20: 3401450, fix_exec_code: 3401450, - check_signatures_num: 5000_0000, - fix_deliver_tx_revert_nonce_height: 4000_0000, - utxo_asset_prefix_height: 5000_0000, - prismxx_inital_height: 5000_0000, - prism_bridge_address: String::new(), - remove_fake_staking_hash: 5000_0000, - fix_check_replay: 5000_0000 + check_signatures_num: 4033522, + fix_deliver_tx_revert_nonce_height: 4033522, + utxo_asset_prefix_height: 4033522, + prismxx_inital_height: 4033522, + prism_bridge_address: "0x4672372fDB139B7295Fc59b55b43EC5fF2761A0b".to_owned(), + remove_fake_staking_hash: 4033522, + fix_check_replay: 4033522 }; } diff --git a/src/components/finutils/src/common/mod.rs b/src/components/finutils/src/common/mod.rs index d0226f508..f80da89e2 100644 --- a/src/components/finutils/src/common/mod.rs +++ b/src/components/finutils/src/common/mod.rs @@ -587,14 +587,23 @@ fn restore_keypair_from_str_with_default(sk_str: Option<&str>) -> Result, asset: Option<&str>) -> Result<()> { +pub fn show_account(sk_str: Option<&str>, _asset: Option<&str>) -> Result<()> { let kp = restore_keypair_from_str_with_default(sk_str)?; - let token_code = asset - .map(|asset| AssetTypeCode::new_from_base64(asset).c(d!("Invalid asset code"))) - .transpose()?; - let balance = utils::get_asset_balance(&kp, token_code).c(d!())?; + // let token_code = asset + // .map(|asset| AssetTypeCode::new_from_base64(asset).c(d!("Invalid asset code"))) + // .transpose()?; + // let balance = utils::get_asset_balance(&kp, token_code).c(d!())?; + // + // println!("{}: {}", asset.unwrap_or("FRA"), balance); + + let res = utils::get_asset_all(&kp)?; + + for (k, v) in res { + let codes = k.to_base64(); + + println!("{codes}: {v}"); + } - println!("{}: {}", asset.unwrap_or("FRA"), balance); Ok(()) } diff --git a/src/components/finutils/src/common/utils.rs b/src/components/finutils/src/common/utils.rs index 51e0b156a..af1609e14 100644 --- a/src/components/finutils/src/common/utils.rs +++ b/src/components/finutils/src/common/utils.rs @@ -2,6 +2,8 @@ //! Some handful function and data structure for findora cli tools //! +use std::collections::BTreeMap; + use { crate::{ api::{DelegationInfo, ValidatorDetail}, @@ -467,6 +469,30 @@ pub fn get_asset_balance(kp: &XfrKeyPair, asset: Option) -> Resul Ok(balance) } +/// Retrieve Utxos of a findora keypair and calcultate the balance of the specified asset +/// FRA is the default asset type +pub fn get_asset_all(kp: &XfrKeyPair) -> Result> { + let info = get_owned_utxos(kp.get_pk_ref())?; + + let mut set = BTreeMap::new(); + + for (_k, v) in info { + let res = open_blind_asset_record(&v.0 .0.record, &v.1, kp)?; + + let code = AssetTypeCode { + val: res.asset_type, + }; + + if let Some(amount) = set.get_mut(&code) { + *amount += res.amount; + } else { + set.insert(code, res.amount); + } + } + + Ok(set) +} + fn get_owned_utxos( addr: &XfrPublicKey, ) -> Result)>> {