Skip to content

Commit

Permalink
add v3 upgrade handler and fix upgrade script
Browse files Browse the repository at this point in the history
  • Loading branch information
jhernandezb committed Feb 2, 2022
1 parent fe4c83d commit e59b9dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 33 deletions.
32 changes: 2 additions & 30 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,15 @@ import (
store "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/authz"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

// next upgrade name
const upgradeName = "v2"
const upgradeName = "v3"

// RegisterUpgradeHandlers returns upgrade handlers
func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {
app.UpgradeKeeper.SetUpgradeHandler(upgradeName, func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
const (
HumanCoinUnit = "stars"
BaseCoinUnit = "ustars"
StarsExponent = 6
)
denomMetadata := banktypes.Metadata{
Description: "The native token of Stargaze",
DenomUnits: []*banktypes.DenomUnit{
{
Denom: BaseCoinUnit,
Exponent: 0,
Aliases: []string{"microstars"},
},
{
Denom: HumanCoinUnit,
Exponent: StarsExponent,
Aliases: nil,
},
},
Base: BaseCoinUnit,
Display: HumanCoinUnit,
Name: "Stargaze STARS",
Symbol: "STARS",
}

app.BankKeeper.SetDenomMetaData(ctx, denomMetadata)
return app.mm.RunMigrations(ctx, cfg, vm)
})

Expand All @@ -54,7 +26,7 @@ func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {

if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := store.StoreUpgrades{
Added: []string{authz.ModuleName, wasm.ModuleName},
Added: []string{wasm.ModuleName},
}
// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
Expand Down
6 changes: 3 additions & 3 deletions scripts/ci/upgrade/proposal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ tree -L 2 /stargaze/starsd/
echo "current height $HEIGHT"
HEIGHT=$(expr $HEIGHT + 20)
echo "submit with height $HEIGHT"
starsd tx gov submit-proposal software-upgrade v2 --upgrade-height $HEIGHT \
starsd tx gov submit-proposal software-upgrade v3 --upgrade-height $HEIGHT \
--deposit 10000000ustars \
--description "Upgrade contains fix for claiming airdrop with Keplr and Ledger" \
--title "V2 Upgrade" \
--description "Add cosmwasm" \
--title "V3 Upgrade" \
--gas-prices 0.025ustars --gas auto --gas-adjustment 1.5 --from validator \
--chain-id stargaze -b block --yes --node http://stargaze:26657 --home $STARGAZE_HOME --keyring-backend test

Expand Down

0 comments on commit e59b9dd

Please sign in to comment.