From 745351199bbf7cd91b464061afba3aa399945e0a Mon Sep 17 00:00:00 2001 From: Steve <1848680+misko9@users.noreply.github.com> Date: Tue, 14 Nov 2023 15:46:09 -0700 Subject: [PATCH] Tokenfactory metadata display fix (#3337) * Add tests for ibc-translator contract * Tokenfactory metadata symbol fix: if symbol is empty when registering an asset, populate tokenfactory's metadata symbol with the denom with exponent string so it is not empty. * Tokenfactory metadata display fix: use denom with exponent for this string instead of base denom. --- cosmwasm/contracts/ibc-translator/src/reply.rs | 4 ++-- cosmwasm/contracts/ibc-translator/tests/reply_test.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cosmwasm/contracts/ibc-translator/src/reply.rs b/cosmwasm/contracts/ibc-translator/src/reply.rs index 65169f4ac3..461debe555 100644 --- a/cosmwasm/contracts/ibc-translator/src/reply.rs +++ b/cosmwasm/contracts/ibc-translator/src/reply.rs @@ -136,7 +136,7 @@ pub fn convert_cw20_to_bank_and_send( let mut symbol = token_info.symbol; if symbol.is_empty() { - symbol = tf_scaled_denom; + symbol = tf_scaled_denom.clone(); } let tf_description = token_info.name.clone() + ", " + symbol.as_str() + ", " + tokenfactory_denom.as_str(); @@ -144,7 +144,7 @@ pub fn convert_cw20_to_bank_and_send( description: Some(tf_description), base: Some(tokenfactory_denom.clone()), denom_units: vec![tf_denom_unit_base, tf_denom_unit_scaled], - display: Some(tokenfactory_denom.clone()), + display: Some(tf_scaled_denom), name: Some(token_info.name), symbol: Some(symbol), }; diff --git a/cosmwasm/contracts/ibc-translator/tests/reply_test.rs b/cosmwasm/contracts/ibc-translator/tests/reply_test.rs index f7719b468e..f5b97ca5ae 100644 --- a/cosmwasm/contracts/ibc-translator/tests/reply_test.rs +++ b/cosmwasm/contracts/ibc-translator/tests/reply_test.rs @@ -495,7 +495,7 @@ fn convert_cw20_to_bank_happy_path_create_denom() { + "/" + token_info_response.decimals.to_string().as_str(); let tf_denom_unit_scaled = DenomUnit { - denom: tf_scaled_denom, + denom: tf_scaled_denom.clone(), exponent: u32::from(token_info_response.decimals), aliases: vec![], }; @@ -503,7 +503,7 @@ fn convert_cw20_to_bank_happy_path_create_denom() { description: Some(tf_description), base: Some(tokenfactory_denom.clone()), denom_units: vec![tf_denom_unit_base, tf_denom_unit_scaled], - display: Some(tokenfactory_denom.clone()), + display: Some(tf_scaled_denom), name: Some(token_info_response.name), symbol: Some(token_info_response.symbol), }; @@ -609,7 +609,7 @@ fn convert_cw20_to_bank_happy_path_create_denom_empty_symbol() { description: Some(tf_description), base: Some(tokenfactory_denom.clone()), denom_units: vec![tf_denom_unit_base, tf_denom_unit_scaled], - display: Some(tokenfactory_denom.clone()), + display: Some(tf_scaled_denom.clone()), name: Some(token_info_response.name), symbol: Some(tf_scaled_denom), // CW20 symbol is empty, use tf_scaled_denom };