Skip to content

Commit

Permalink
fix: set name, display and symbol of denom metadata in tokenfactory's…
Browse files Browse the repository at this point in the history
… CreateDenom (#6344)

* fix: set name, display and symbol of denom metadata in tokenfactory's CreateDenom

* docs: add changelog entry
  • Loading branch information
madrezaz authored Sep 12, 2023
1 parent 7ed9f5d commit 66e720d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion x/tokenfactory/keeper/createdenom.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion x/tokenfactory/keeper/createdenom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
28 changes: 25 additions & 3 deletions x/tokenfactory/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
})
}
}

Expand All @@ -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(),
})
}
}
}

0 comments on commit 66e720d

Please sign in to comment.