Skip to content

Commit

Permalink
fix migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Sep 27, 2023
1 parent bcf4663 commit 7dced2b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion x/cronos/exported/exported.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ type (
//
// NOTE: This is used solely for migration of x/params managed parameters.
Subspace interface {
GetParamSet(ctx sdk.Context, ps ParamSet)
GetParamSetIfExists(ctx sdk.Context, ps ParamSet)
}
)
7 changes: 5 additions & 2 deletions x/cronos/migrations/v2/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/crypto-org-chain/cronos/v2/x/cronos/exported"
"github.com/crypto-org-chain/cronos/v2/x/cronos/types"
cronostypes "github.com/crypto-org-chain/cronos/v2/x/cronos/types"
)

// Migrate migrates the x/cronos module state from the consensus version 1 to
Expand All @@ -13,12 +14,14 @@ import (
// module state.
func Migrate(ctx sdk.Context, store sdk.KVStore, legacySubspace exported.Subspace, cdc codec.BinaryCodec) error {
var currParams types.Params
legacySubspace.GetParamSet(ctx, &currParams)
legacySubspace.GetParamSetIfExists(ctx, &currParams)

if err := currParams.Validate(); err != nil {
return err
}

if currParams.GetMaxCallbackGas() == 0 {
currParams.MaxCallbackGas = cronostypes.MaxCallbackGasDefaultValue
}
bz := cdc.MustMarshal(&currParams)
store.Set(types.ParamsKey, bz)

Expand Down

0 comments on commit 7dced2b

Please sign in to comment.