Skip to content

Commit

Permalink
Tokenfactory metadata display fix (#3337)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
misko9 authored Nov 14, 2023
1 parent fcd41cf commit 7453511
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cosmwasm/contracts/ibc-translator/src/reply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ 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();
let tf_metadata = Metadata {
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),
};
Expand Down
6 changes: 3 additions & 3 deletions cosmwasm/contracts/ibc-translator/tests/reply_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,15 +495,15 @@ 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![],
};
let tf_metadata = Metadata {
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),
};
Expand Down Expand Up @@ -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
};
Expand Down

0 comments on commit 7453511

Please sign in to comment.