Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(),
})
}
}
}