From bf9844934a76d93f062f6ceed63f45771fbad0f6 Mon Sep 17 00:00:00 2001 From: stackman27 Date: Mon, 6 Feb 2023 23:50:51 -0800 Subject: [PATCH 1/4] added metadata --- app/upgrades/v15/upgrades.go | 51 ++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/app/upgrades/v15/upgrades.go b/app/upgrades/v15/upgrades.go index c08f126a3e2..30f4917a470 100644 --- a/app/upgrades/v15/upgrades.go +++ b/app/upgrades/v15/upgrades.go @@ -5,12 +5,16 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + "github.com/osmosis-labs/osmosis/v14/app/keepers" + appParams "github.com/osmosis-labs/osmosis/v14/app/params" "github.com/osmosis-labs/osmosis/v14/app/upgrades" + gammkeeper "github.com/osmosis-labs/osmosis/v14/x/gamm/keeper" "github.com/osmosis-labs/osmosis/v14/x/poolmanager" poolmanagertypes "github.com/osmosis-labs/osmosis/v14/x/poolmanager/types" - - gammkeeper "github.com/osmosis-labs/osmosis/v14/x/gamm/keeper" ) func CreateUpgradeHandler( @@ -33,6 +37,9 @@ func CreateUpgradeHandler( // See RunMigrations() for details. fromVM[poolmanagertypes.ModuleName] = 0 + // add metadata for uosmo and uion + registerOsmoIonMetadata(ctx, keepers.BankKeeper) + return mm.RunMigrations(ctx, configurator, fromVM) } } @@ -53,3 +60,43 @@ func migrateNextPoolId(ctx sdk.Context, gammKeeper *gammkeeper.Keeper, poolmanag poolmanagerKeeper.SetPoolRoute(ctx, poolId, poolType) } } + +func registerOsmoIonMetadata(ctx sdk.Context, bankKeeper bankkeeper.Keeper) { + uosmoMetadata := banktypes.Metadata{ + Description: "The native token of Osmosis", + DenomUnits: []*banktypes.DenomUnit{ + { + Denom: appParams.BaseCoinUnit, + Exponent: 0, + Aliases: nil, + }, + { + Denom: appParams.HumanCoinUnit, + Exponent: appParams.OsmoExponent, + Aliases: nil, + }, + }, + Base: appParams.BaseCoinUnit, + Display: appParams.HumanCoinUnit, + } + + uionMetadata := banktypes.Metadata{ + DenomUnits: []*banktypes.DenomUnit{ + { + Denom: "uion", + Exponent: 0, + Aliases: nil, + }, + { + Denom: "ion", + Exponent: 6, + Aliases: nil, + }, + }, + Base: "uion", + Display: "ion", + } + + bankKeeper.SetDenomMetaData(ctx, uosmoMetadata) + bankKeeper.SetDenomMetaData(ctx, uionMetadata) +} From 2df445fb37791d16276fd7c2e066b30a2935c104 Mon Sep 17 00:00:00 2001 From: stackman27 Date: Tue, 7 Feb 2023 12:56:08 -0800 Subject: [PATCH 2/4] added tests for metadata --- app/upgrades/v15/export_test.go | 6 ++++++ app/upgrades/v15/upgrade_test.go | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/app/upgrades/v15/export_test.go b/app/upgrades/v15/export_test.go index 9fbcdaddefb..a7145c6d386 100644 --- a/app/upgrades/v15/export_test.go +++ b/app/upgrades/v15/export_test.go @@ -3,6 +3,8 @@ package v15 import ( sdk "github.com/cosmos/cosmos-sdk/types" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + gammkeeper "github.com/osmosis-labs/osmosis/v14/x/gamm/keeper" poolmanagerkeeper "github.com/osmosis-labs/osmosis/v14/x/poolmanager" ) @@ -10,3 +12,7 @@ import ( func MigrateNextPoolId(ctx sdk.Context, gammKeeper *gammkeeper.Keeper, poolmanagerKeeper *poolmanagerkeeper.Keeper) { migrateNextPoolId(ctx, gammKeeper, poolmanagerKeeper) } + +func RegisterOsmoIonMetadata(ctx sdk.Context, bankKeeper bankkeeper.Keeper) { + registerOsmoIonMetadata(ctx, bankKeeper) +} diff --git a/app/upgrades/v15/upgrade_test.go b/app/upgrades/v15/upgrade_test.go index 3dbff808bc6..2ae4b0b78aa 100644 --- a/app/upgrades/v15/upgrade_test.go +++ b/app/upgrades/v15/upgrade_test.go @@ -66,3 +66,25 @@ func (suite *UpgradeTestSuite) TestMigrateNextPoolIdAndCreatePool() { poolmanagerPoolCreationFee := poolmanagerKeeper.GetParams(ctx).PoolCreationFee suite.Require().Equal(gammPoolCreationFee, poolmanagerPoolCreationFee) } + +func (suite *UpgradeTestSuite) TestRegisterOsmoIonMetadata() { + suite.SetupTest() // reset + + expectedUosmodenom := "uosmo" + expectedUiondenom := "uion" + + ctx := suite.Ctx + bankKeeper := suite.App.BankKeeper + + // system under test. + v15.RegisterOsmoIonMetadata(ctx, *bankKeeper) + + uosmoMetadata, found := suite.App.BankKeeper.GetDenomMetaData(ctx, "uosmo") + suite.Require().True(found) + + uionMetadata, found := suite.App.BankKeeper.GetDenomMetaData(ctx, "uion") + suite.Require().True(found) + + suite.Require().Equal(expectedUosmodenom, uosmoMetadata.Base) + suite.Require().Equal(expectedUiondenom, uionMetadata.Base) +} From 1db904eba3f07effd7e31537c1d730d6cfc7709a Mon Sep 17 00:00:00 2001 From: stackman27 Date: Wed, 8 Feb 2023 15:45:51 -0800 Subject: [PATCH 3/4] matt and dev feedback --- CHANGELOG.md | 1 + app/upgrades/v15/upgrade_test.go | 10 ++++++++-- app/upgrades/v15/upgrades.go | 3 ++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 695fe066510..d59760f6f1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#3905](https://github.com/osmosis-labs/osmosis/pull/3905) Deprecate gamm queries `NumPools`, `EstimateSwapExactAmountIn` and `EstimateSwapExactAmountOut`. * [#3907](https://github.com/osmosis-labs/osmosis/pull/3907) Add `NumPools`, `EstimateSwapExactAmountIn` and `EstimateSwapExactAmountOut` query in poolmanager module to stargate whitelist. * [#3880](https://github.com/osmosis-labs/osmosis/pull/3880) Switch usage of proto-generated SwapAmountInRoute and SwapAmountOutRoute in x/gamm to import the structs from x/poolmanager module. +* [#4250](https://github.com/osmosis-labs/osmosis/pull/4250) Add denom metadata for uosmo, uion ### Bug Fix diff --git a/app/upgrades/v15/upgrade_test.go b/app/upgrades/v15/upgrade_test.go index 2ae4b0b78aa..4e64b1f3c94 100644 --- a/app/upgrades/v15/upgrade_test.go +++ b/app/upgrades/v15/upgrade_test.go @@ -76,13 +76,19 @@ func (suite *UpgradeTestSuite) TestRegisterOsmoIonMetadata() { ctx := suite.Ctx bankKeeper := suite.App.BankKeeper + uosmoMetadata, found := suite.App.BankKeeper.GetDenomMetaData(ctx, "uosmo") + suite.Require().True(!found) + + uionMetadata, found := suite.App.BankKeeper.GetDenomMetaData(ctx, "uion") + suite.Require().True(!found) + // system under test. v15.RegisterOsmoIonMetadata(ctx, *bankKeeper) - uosmoMetadata, found := suite.App.BankKeeper.GetDenomMetaData(ctx, "uosmo") + uosmoMetadata, found = suite.App.BankKeeper.GetDenomMetaData(ctx, "uosmo") suite.Require().True(found) - uionMetadata, found := suite.App.BankKeeper.GetDenomMetaData(ctx, "uion") + uionMetadata, found = suite.App.BankKeeper.GetDenomMetaData(ctx, "uion") suite.Require().True(found) suite.Require().Equal(expectedUosmodenom, uosmoMetadata.Base) diff --git a/app/upgrades/v15/upgrades.go b/app/upgrades/v15/upgrades.go index 30f4917a470..4fc25cf1c33 100644 --- a/app/upgrades/v15/upgrades.go +++ b/app/upgrades/v15/upgrades.go @@ -37,7 +37,8 @@ func CreateUpgradeHandler( // See RunMigrations() for details. fromVM[poolmanagertypes.ModuleName] = 0 - // add metadata for uosmo and uion + // Metadata for uosmo and uion were missing prior to this upgrade. + // They are added in this upgrade. registerOsmoIonMetadata(ctx, keepers.BankKeeper) return mm.RunMigrations(ctx, configurator, fromVM) From f40b0a706c34ed10b7c707d946b08776223ce1fe Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Thu, 9 Feb 2023 06:52:36 +0100 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Matt, Park <45252226+mattverse@users.noreply.github.com> --- app/upgrades/v15/upgrade_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/upgrades/v15/upgrade_test.go b/app/upgrades/v15/upgrade_test.go index 4e64b1f3c94..8909c959179 100644 --- a/app/upgrades/v15/upgrade_test.go +++ b/app/upgrades/v15/upgrade_test.go @@ -76,11 +76,12 @@ func (suite *UpgradeTestSuite) TestRegisterOsmoIonMetadata() { ctx := suite.Ctx bankKeeper := suite.App.BankKeeper + // meta data should not be found pre-registration of meta data uosmoMetadata, found := suite.App.BankKeeper.GetDenomMetaData(ctx, "uosmo") - suite.Require().True(!found) + suite.Require().False(found) uionMetadata, found := suite.App.BankKeeper.GetDenomMetaData(ctx, "uion") - suite.Require().True(!found) + suite.Require().False(found) // system under test. v15.RegisterOsmoIonMetadata(ctx, *bankKeeper)