From 66e720d685b21294919c73cb94f4e3fda7478920 Mon Sep 17 00:00:00 2001 From: MadReza <48837654+madrezaz@users.noreply.github.com> Date: Tue, 12 Sep 2023 09:45:00 +0330 Subject: [PATCH] fix: set name, display and symbol of denom metadata in tokenfactory's CreateDenom (#6344) * fix: set name, display and symbol of denom metadata in tokenfactory's CreateDenom * docs: add changelog entry --- CHANGELOG.md | 4 ++++ x/tokenfactory/keeper/createdenom.go | 5 +++- x/tokenfactory/keeper/createdenom_test.go | 5 +++- x/tokenfactory/keeper/genesis_test.go | 28 ++++++++++++++++++++--- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56ab25d6d15..1a470b16155 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### State Breaking + +* [#6344](https://github.com/osmosis-labs/osmosis/pull/6344) fix: set name, display and symbol of denom metadata in tokenfactory's CreateDenom + ### Bug Fixes * [#6334](https://github.com/osmosis-labs/osmosis/pull/6334) fix: enable taker fee cli diff --git a/x/tokenfactory/keeper/createdenom.go b/x/tokenfactory/keeper/createdenom.go index 8ec1b6b83cf..cc07e453ab0 100644 --- a/x/tokenfactory/keeper/createdenom.go +++ b/x/tokenfactory/keeper/createdenom.go @@ -35,7 +35,10 @@ func (k Keeper) createDenomAfterValidation(ctx sdk.Context, creatorAddr string, Denom: denom, Exponent: 0, }}, - Base: denom, + Base: denom, + Name: denom, + Symbol: denom, + Display: denom, } k.bankKeeper.SetDenomMetaData(ctx, denomMetaData) diff --git a/x/tokenfactory/keeper/createdenom_test.go b/x/tokenfactory/keeper/createdenom_test.go index 2d3bc7c1dd1..48697a50650 100644 --- a/x/tokenfactory/keeper/createdenom_test.go +++ b/x/tokenfactory/keeper/createdenom_test.go @@ -175,7 +175,10 @@ func (s *KeeperTestSuite) TestCreateDenom() { Denom: res.GetNewTokenDenom(), Exponent: 0, }}, - Base: res.GetNewTokenDenom(), + Base: res.GetNewTokenDenom(), + Display: res.GetNewTokenDenom(), + Name: res.GetNewTokenDenom(), + Symbol: res.GetNewTokenDenom(), }, metadata) } else { s.Require().Error(err) diff --git a/x/tokenfactory/keeper/genesis_test.go b/x/tokenfactory/keeper/genesis_test.go index 28f223c4986..9862f14a32a 100644 --- a/x/tokenfactory/keeper/genesis_test.go +++ b/x/tokenfactory/keeper/genesis_test.go @@ -38,7 +38,16 @@ func (s *KeeperTestSuite) TestGenesis() { for i, denom := range genesisState.FactoryDenoms { // hacky, sets bank metadata to exist if i != 0, to cover both cases. if i != 0 { - app.BankKeeper.SetDenomMetaData(s.Ctx, banktypes.Metadata{Base: denom.GetDenom(), Display: "test"}) + app.BankKeeper.SetDenomMetaData(s.Ctx, banktypes.Metadata{ + DenomUnits: []*banktypes.DenomUnit{{ + Denom: denom.GetDenom(), + Exponent: 0, + }}, + Base: denom.GetDenom(), + Display: denom.GetDenom(), + Name: denom.GetDenom(), + Symbol: denom.GetDenom(), + }) } } @@ -57,14 +66,27 @@ func (s *KeeperTestSuite) TestGenesis() { s.Require().NotNil(exportedGenesis) s.Require().Equal(genesisState, *exportedGenesis) + // verify that the exported bank genesis is valid app.BankKeeper.SetParams(s.Ctx, banktypes.DefaultParams()) - app.BankKeeper.InitGenesis(s.Ctx, app.BankKeeper.ExportGenesis(s.Ctx)) + exportedBankGenesis := app.BankKeeper.ExportGenesis(s.Ctx) + s.Require().NoError(exportedBankGenesis.Validate()) + + app.BankKeeper.InitGenesis(s.Ctx, exportedBankGenesis) for i, denom := range genesisState.FactoryDenoms { // hacky, check whether bank metadata is not replaced if i != 0, to cover both cases. if i != 0 { metadata, found := app.BankKeeper.GetDenomMetaData(s.Ctx, denom.GetDenom()) s.Require().True(found) - s.Require().Equal(metadata, banktypes.Metadata{Base: denom.GetDenom(), Display: "test"}) + s.Require().EqualValues(metadata, banktypes.Metadata{ + DenomUnits: []*banktypes.DenomUnit{{ + Denom: denom.GetDenom(), + Exponent: 0, + }}, + Base: denom.GetDenom(), + Display: denom.GetDenom(), + Name: denom.GetDenom(), + Symbol: denom.GetDenom(), + }) } } }