diff --git a/rust/processor/src/models/fungible_asset_models/v2_fungible_asset_balances.rs b/rust/processor/src/models/fungible_asset_models/v2_fungible_asset_balances.rs index 744518d4a..86e2bcf31 100644 --- a/rust/processor/src/models/fungible_asset_models/v2_fungible_asset_balances.rs +++ b/rust/processor/src/models/fungible_asset_models/v2_fungible_asset_balances.rs @@ -6,7 +6,8 @@ #![allow(clippy::unused_unit)] use super::{ - v2_fungible_asset_activities::EventToCoinType, v2_fungible_asset_utils::FungibleAssetStore, + v2_fungible_asset_activities::EventToCoinType, + v2_fungible_asset_utils::{ConcurrentFungibleAssetBalance, FungibleAssetStore}, v2_fungible_metadata::FungibleAssetMetadataModel, }; use crate::{ @@ -94,6 +95,15 @@ impl FungibleAssetBalance { } let is_primary = Self::is_primary(&owner_address, &asset_type, &storage_id); + let concurrent_balance: Option = + ConcurrentFungibleAssetBalance::from_write_resource( + write_resource, + txn_version, + ) + .ok() + .and_then(|balance| balance.map(|b| Some(b.balance.value.clone()))) + .unwrap_or(None); + let coin_balance = Self { transaction_version: txn_version, write_set_change_index, @@ -102,7 +112,9 @@ impl FungibleAssetBalance { asset_type: asset_type.clone(), is_primary, is_frozen: inner.frozen, - amount: inner.balance.clone(), + amount: concurrent_balance + .clone() + .unwrap_or_else(|| inner.balance.clone()), transaction_timestamp: txn_timestamp, token_standard: TokenStandard::V2.to_string(), }; @@ -112,7 +124,7 @@ impl FungibleAssetBalance { asset_type: asset_type.clone(), is_primary, is_frozen: inner.frozen, - amount: inner.balance.clone(), + amount: concurrent_balance.unwrap_or_else(|| inner.balance.clone()), last_transaction_version: txn_version, last_transaction_timestamp: txn_timestamp, token_standard: TokenStandard::V2.to_string(), diff --git a/rust/processor/src/models/fungible_asset_models/v2_fungible_asset_utils.rs b/rust/processor/src/models/fungible_asset_models/v2_fungible_asset_utils.rs index fffd5b528..e616cef12 100644 --- a/rust/processor/src/models/fungible_asset_models/v2_fungible_asset_utils.rs +++ b/rust/processor/src/models/fungible_asset_models/v2_fungible_asset_utils.rs @@ -189,7 +189,7 @@ impl FungibleAssetSupply { #[derive(Serialize, Deserialize, Debug, Clone)] pub struct ConcurrentFungibleAssetSupply { - pub aggregator: AggregatorU128, + pub current: AggregatorU128, } impl ConcurrentFungibleAssetSupply { @@ -224,7 +224,7 @@ impl ConcurrentFungibleAssetSupply { #[derive(Serialize, Deserialize, Debug, Clone)] pub struct ConcurrentFungibleAssetBalance { - pub aggregator: AggregatorU64, + pub balance: AggregatorU64, } impl ConcurrentFungibleAssetBalance { @@ -317,7 +317,7 @@ impl V2FungibleAssetResource { serde_json::from_value(data.clone()) .map(|inner| Some(Self::FungibleAssetStore(inner))) }, - x if x == format!("{}::fungible_asset::ConcurrentBalance", COIN_ADDR) => { + x if x == format!("{}::fungible_asset::ConcurrentFungibleBalance", COIN_ADDR) => { serde_json::from_value(data.clone()) .map(|inner| Some(Self::ConcurrentFungibleAssetBalance(inner))) },