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: fix x/tokenfactory genesis import denoms reset x/bank existing denom metadata #5532

Merged
merged 4 commits into from
Jun 19, 2023
Merged

fix: fix x/tokenfactory genesis import denoms reset x/bank existing denom metadata #5532

merged 4 commits into from
Jun 19, 2023

Conversation

dadamu
Copy link
Contributor

@dadamu dadamu commented Jun 15, 2023

What is the purpose of the change

This pull request fixes the x/tokenfactory genesis import reset x/bank existing denom metadata, say, x/bank genesis has the metadata of facotory/osmos1.../testtoken with {Display: test}, x/tokenfactory init genesis phase will replace it with the empty disply, more details as follows:

Before x/tokenfactory init genesis, the x/bank set metadata as:

{
  Name:        "Mint Token",
  Symbol:      "MTK",
  Description: "The custom token of the test subspace.",
  DenomUnits: []*banktypes.DenomUnit{
	{Denom: "factory/cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47/uminttoken", Exponent: uint32(0), Aliases: nil},
	{Denom: "minttoken", Exponent: uint32(6), Aliases: []string{"minttoken"}},
  },
  Base:    "factory/cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47/uminttoken",
  Display: "minttoken",
}

After x/tokenfactory init genesis, the metadata is replaced into:

{
  DenomUnits: []*banktypes.DenomUnit{
	{Denom: "factory/cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47/uminttoken", Exponent: uint32(0)},
  },
  Base:    "factory/cosmos1y54exmx84cqtasvjnskf9f63djuuj68p7hqf47/uminttoken",
}

Testing and Verifying

This change added tests and can be verified as follows:

  • Added unit test that validates the x/bank imported metadata won't be reset by x/tokenfactory

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes?
  • Changelog entry added to Unreleased section of CHANGELOG.md?

Where is the change documented?

  • Specification (x/{module}/README.md)
  • Osmosis documentation site
  • Code comments?
  • N/A

Copy link
Member

@mattverse mattverse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Logic change lgtm, requesting some test additions before we can merge this

Comment on lines +31 to +41
_, exists := k.bankKeeper.GetDenomMetaData(ctx, denom)
if !exists {
denomMetaData := banktypes.Metadata{
DenomUnits: []*banktypes.DenomUnit{{
Denom: denom,
Exponent: 0,
}},
Base: denom,
}

k.bankKeeper.SetDenomMetaData(ctx, denomMetaData)
k.bankKeeper.SetDenomMetaData(ctx, denomMetaData)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can unit tests for CreateDenom be added to confirm the new logic introduced as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the unit test to check CreateDenom if the metadata is set correctly, the metadata existing case is already covered by this test

@mattverse
Copy link
Member

@dadamu Would you also be able to add CHANGELOG entry?

@mattverse mattverse added the V:state/breaking State machine breaking PR label Jun 15, 2023
@dadamu
Copy link
Contributor Author

dadamu commented Jun 15, 2023

@mattverse Added the CHANGELOG entry

@dadamu dadamu requested a review from mattverse June 15, 2023 09:58
Copy link
Member

@mattverse mattverse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the PR!

@mattverse mattverse merged commit de18b81 into osmosis-labs:main Jun 19, 2023
@dadamu dadamu deleted the paul/fix-replace-denom-metadata branch June 19, 2023 05:52
@github-actions github-actions bot mentioned this pull request Jan 15, 2024
@github-actions github-actions bot mentioned this pull request Apr 1, 2024
@github-actions github-actions bot mentioned this pull request May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C:x/tokenfactory V:state/breaking State machine breaking PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants