diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 6c0a28cc01..a29478f436 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - UX improvements (Ctrl+l, TAB completion/suggestions and more) during interactive account management; - `WalletCommand::SetPow` command; - Check for existing stronghold on `restore`; +- Sync native token foundries to show their metadata; ### Changed diff --git a/cli/src/command/account.rs b/cli/src/command/account.rs index 66c869cd73..f5754104f6 100644 --- a/cli/src/command/account.rs +++ b/cli/src/command/account.rs @@ -21,7 +21,7 @@ use iota_sdk::{ wallet::{ account::{ types::{AccountAddress, AccountIdentifier}, - Account, ConsolidationParams, OutputsToClaim, TransactionOptions, + Account, ConsolidationParams, OutputsToClaim, SyncOptions, TransactionOptions, }, CreateNativeTokenParams, MintNftParams, SendNativeTokensParams, SendNftParams, SendParams, }, @@ -768,7 +768,12 @@ pub async fn send_nft_command( // `sync` command pub async fn sync_command(account: &Account) -> Result<(), Error> { - let balance = account.sync(None).await?; + let balance = account + .sync(Some(SyncOptions { + sync_native_token_foundries: true, + ..Default::default() + })) + .await?; println_log_info!("Synced."); println_log_info!("{balance:#?}"); @@ -911,7 +916,7 @@ pub async fn voting_output_command(account: &Account) -> Result<(), Error> { async fn print_address(account: &Account, address: &AccountAddress) -> Result<(), Error> { let mut log = format!( - "Address {}:\n {:<10}{}\n {:<10}{:?}", + "Address: {}\n{:<9}{}\n{:<9}{:?}", address.key_index(), "Bech32:", address.address(), @@ -974,7 +979,7 @@ async fn print_address(account: &Account, address: &AccountAddress) -> Result<() } log = format!( - "{log}\n Outputs: {:#?}\n Base coin amount: {}\n Native Tokens: {:?}\n NFTs: {:?}\n Aliases: {:?}\n Foundries: {:?}\n", + "{log}\nOutputs: {:#?}\nBase coin amount: {}\nNative Tokens: {:#?}\nNFTs: {:#?}\nAliases: {:#?}\nFoundries: {:#?}\n", output_ids, amount, native_tokens.finish_vec()?, diff --git a/sdk/src/wallet/account/types/balance.rs b/sdk/src/wallet/account/types/balance.rs index 16571f0235..71b9eafe7f 100644 --- a/sdk/src/wallet/account/types/balance.rs +++ b/sdk/src/wallet/account/types/balance.rs @@ -21,12 +21,12 @@ pub struct Balance { pub(crate) required_storage_deposit: RequiredStorageDeposit, /// Native tokens pub(crate) native_tokens: Vec, - /// Nfts - pub(crate) nfts: Vec, /// Aliases pub(crate) aliases: Vec, /// Foundries pub(crate) foundries: Vec, + /// Nfts + pub(crate) nfts: Vec, /// Outputs with multiple unlock conditions and if they can currently be spent or not. If there is a /// [`TimelockUnlockCondition`](crate::types::block::output::unlock_condition::TimelockUnlockCondition) or /// [`ExpirationUnlockCondition`](crate::types::block::output::unlock_condition::ExpirationUnlockCondition) this @@ -51,9 +51,9 @@ impl std::ops::AddAssign for Balance { } } - self.nfts.extend(rhs.nfts); self.aliases.extend(rhs.aliases); self.foundries.extend(rhs.foundries); + self.nfts.extend(rhs.nfts); } } @@ -88,11 +88,11 @@ impl std::ops::AddAssign for BaseCoinBalance { #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, CopyGetters)] #[getset(get_copy = "pub")] pub struct RequiredStorageDeposit { - #[serde(with = "crate::utils::serde::string")] - pub(crate) alias: u64, #[serde(with = "crate::utils::serde::string")] pub(crate) basic: u64, #[serde(with = "crate::utils::serde::string")] + pub(crate) alias: u64, + #[serde(with = "crate::utils::serde::string")] pub(crate) foundry: u64, #[serde(with = "crate::utils::serde::string")] pub(crate) nft: u64, @@ -100,8 +100,8 @@ pub struct RequiredStorageDeposit { impl std::ops::AddAssign for RequiredStorageDeposit { fn add_assign(&mut self, rhs: Self) { - self.alias += rhs.alias; self.basic += rhs.basic; + self.alias += rhs.alias; self.foundry += rhs.foundry; self.nft += rhs.nft; } @@ -205,8 +205,8 @@ impl Balance { voting_power: total / 4, }, required_storage_deposit: RequiredStorageDeposit { - alias: total / 16, basic: total / 8, + alias: total / 16, foundry: total / 4, nft: total / 2, },