Skip to content

Commit

Permalink
Adds a Uni-6 part2 upgrade handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Mar 29, 2023
1 parent 51ec752 commit 434303e
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 21 deletions.
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import (
"github.com/CosmosContracts/juno/v14/app/keepers"
encparams "github.com/CosmosContracts/juno/v14/app/params"
upgrades "github.com/CosmosContracts/juno/v14/app/upgrades"
uniUpgrade "github.com/CosmosContracts/juno/v14/app/upgrades/uni"
v10 "github.com/CosmosContracts/juno/v14/app/upgrades/v10"
v11 "github.com/CosmosContracts/juno/v14/app/upgrades/v11"
v12 "github.com/CosmosContracts/juno/v14/app/upgrades/v12"
Expand All @@ -83,7 +84,7 @@ var (
// https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34
EnableSpecificProposals = ""

Upgrades = []upgrades.Upgrade{v10.Upgrade, v11.Upgrade, v12.Upgrade, v13.Upgrade, v14.Upgrade}
Upgrades = []upgrades.Upgrade{v10.Upgrade, v11.Upgrade, v12.Upgrade, v13.Upgrade, v14.Upgrade, uniUpgrade.Upgrade}
)

// These constants are derived from the above variables.
Expand Down
10 changes: 10 additions & 0 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package upgrades

import (
"strings"

"github.com/CosmosContracts/juno/v14/app/keepers"
store "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -34,3 +36,11 @@ type Upgrade struct {
// Store upgrades, should be used for any new modules introduced, new modules deleted, or store names renamed.
StoreUpgrades store.StoreUpgrades
}

// Returns "ujunox" if the chain is uni, else returns the standard ujuno token denom.
func GetChainsDenomToken(chainID string) string {
if strings.HasPrefix(chainID, "uni-") {
return "ujunox"
}
return "ujuno"
}
18 changes: 18 additions & 0 deletions app/upgrades/uni/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v14

import (
"github.com/CosmosContracts/juno/v14/app/upgrades"
store "github.com/cosmos/cosmos-sdk/store/types"
)

// UpgradeName is for temporary Uni upgrades for state breaking features
// before an official mainnet release, but after an initial alpha upgrade.
const UpgradeName = "uni14_2"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUniUpgradeHandler,
StoreUpgrades: store.StoreUpgrades{
Added: []string{},
},
}
32 changes: 32 additions & 0 deletions app/upgrades/uni/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package v14

import (
"fmt"

"github.com/CosmosContracts/juno/v14/app/keepers"

"github.com/CosmosContracts/juno/v14/app/upgrades"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"

upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateUniUpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
logger := ctx.Logger().With("upgrade", UpgradeName)
nativeDenom := upgrades.GetChainsDenomToken(ctx.ChainID())
logger.Info(fmt.Sprintf("With native denom %s", nativeDenom))

// Run migrations
logger.Info(fmt.Sprintf("pre migrate version map: %v", vm))
versionMap, err := mm.RunMigrations(ctx, cfg, vm)
logger.Info(fmt.Sprintf("post migrate version map: %v", versionMap))

return versionMap, err
}
}
12 changes: 2 additions & 10 deletions app/upgrades/v13/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package v13

import (
"fmt"
"strings"

"github.com/CosmosContracts/juno/v14/app/keepers"

"github.com/CosmosContracts/juno/v14/app/upgrades"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"

Expand All @@ -23,14 +23,6 @@ import (
packetforwardtypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types"
)

// Returns "ujunox" if the chain is uni, else returns the standard ujuno token denom.
func GetChainsDenomToken(chainID string) string {
if strings.HasPrefix(chainID, "uni-") {
return "ujunox"
}
return "ujuno"
}

func CreateV13UpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
Expand All @@ -41,7 +33,7 @@ func CreateV13UpgradeHandler(
// the above is https://github.com/cosmos/ibc-go/blob/v5.1.0/docs/migrations/v3-to-v4.md
logger := ctx.Logger().With("upgrade", UpgradeName)

nativeDenom := GetChainsDenomToken(ctx.ChainID())
nativeDenom := upgrades.GetChainsDenomToken(ctx.ChainID())
logger.Info(fmt.Sprintf("With native denom %s", nativeDenom))

// ICA - https://github.com/CosmosContracts/juno/blob/integrate_ica_changes/app/app.go#L846-L885
Expand Down
12 changes: 2 additions & 10 deletions app/upgrades/v14/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,18 @@ package v14

import (
"fmt"
"strings"

"github.com/CosmosContracts/juno/v14/app/keepers"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/CosmosContracts/juno/v14/app/upgrades"

upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

globalfeetypes "github.com/cosmos/gaia/v9/x/globalfee/types"
)

// Returns "ujunox" if the chain is uni, else returns the standard ujuno token denom.
func GetChainsDenomToken(chainID string) string {
if strings.HasPrefix(chainID, "uni-") {
return "ujunox"
}
return "ujuno"
}

func CreateV14UpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
Expand All @@ -30,7 +22,7 @@ func CreateV14UpgradeHandler(
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
logger := ctx.Logger().With("upgrade", UpgradeName)

nativeDenom := GetChainsDenomToken(ctx.ChainID())
nativeDenom := upgrades.GetChainsDenomToken(ctx.ChainID())
logger.Info(fmt.Sprintf("With native denom %s", nativeDenom))

logger.Info(fmt.Sprintf("pre migrate version map: %v", vm))
Expand Down

0 comments on commit 434303e

Please sign in to comment.