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

Add uosmo, uion denom metadata #4250

Merged
merged 4 commits into from
Feb 9, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

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")
ValarDragon marked this conversation as resolved.
Show resolved Hide resolved
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,
Comment on lines +69 to +81
Copy link
Member

Choose a reason for hiding this comment

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

Confirmed that these AppParams are const's, so no need to worry about anything in build editing them

}

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)
}