Skip to content

Commit

Permalink
Add uosmo, uion denom metadata (#4250)
Browse files Browse the repository at this point in the history
* added metadata

* added tests for metadata

* matt and dev feedback

* Apply suggestions from code review

Co-authored-by: Matt, Park <45252226+mattverse@users.noreply.github.com>

---------

Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com>
Co-authored-by: Matt, Park <45252226+mattverse@users.noreply.github.com>
(cherry picked from commit 34a0046)
  • Loading branch information
stackman27 authored and mergify[bot] committed Feb 9, 2023
1 parent d0f8185 commit d6a5e04
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,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

Expand Down
6 changes: 6 additions & 0 deletions app/upgrades/v15/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ 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"
)

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)
}
29 changes: 29 additions & 0 deletions app/upgrades/v15/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,32 @@ 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

// meta data should not be found pre-registration of meta data
uosmoMetadata, found := suite.App.BankKeeper.GetDenomMetaData(ctx, "uosmo")
suite.Require().False(found)

uionMetadata, found := suite.App.BankKeeper.GetDenomMetaData(ctx, "uion")
suite.Require().False(found)

// 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)
}
52 changes: 50 additions & 2 deletions app/upgrades/v15/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -33,6 +37,10 @@ func CreateUpgradeHandler(
// See RunMigrations() for details.
fromVM[poolmanagertypes.ModuleName] = 0

// 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)
}
}
Expand All @@ -53,3 +61,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)
}

0 comments on commit d6a5e04

Please sign in to comment.