From 39cdf54f6943f1c76724291ddec26c4b2d168502 Mon Sep 17 00:00:00 2001 From: colmazia Date: Tue, 15 Aug 2023 17:51:09 +0700 Subject: [PATCH] fix typo --- x/globalfee/keeper/keeper.go | 4 +-- x/globalfee/keeper/migrator.go | 29 ---------------- x/globalfee/module.go | 2 +- x/oracle/migrations/v2/migrate.go | 35 ------------------- x/oracle/migrations/v2/migrator_test.go | 45 ------------------------- 5 files changed, 3 insertions(+), 112 deletions(-) delete mode 100644 x/globalfee/keeper/migrator.go delete mode 100644 x/oracle/migrations/v2/migrate.go delete mode 100644 x/oracle/migrations/v2/migrator_test.go diff --git a/x/globalfee/keeper/keeper.go b/x/globalfee/keeper/keeper.go index 4fc8971e8..e5dac72fb 100644 --- a/x/globalfee/keeper/keeper.go +++ b/x/globalfee/keeper/keeper.go @@ -26,7 +26,7 @@ func (k *Keeper) GetAuthority() string { return k.authority } -// SetParams sets the x/mint module parameters. +// SetParams sets the x/globalfee module parameters. func (k Keeper) SetParams(ctx sdk.Context, p types.Params) error { if err := p.Validate(); err != nil { return err @@ -39,7 +39,7 @@ func (k Keeper) SetParams(ctx sdk.Context, p types.Params) error { return nil } -// GetParams returns the current x/mint module parameters. +// GetParams returns the current x/globalfee module parameters. func (k Keeper) GetParams(ctx sdk.Context) (p types.Params) { store := ctx.KVStore(k.storeKey) bz := store.Get(types.ParamsKeyPrefix) diff --git a/x/globalfee/keeper/migrator.go b/x/globalfee/keeper/migrator.go deleted file mode 100644 index 8a1ebe58a..000000000 --- a/x/globalfee/keeper/migrator.go +++ /dev/null @@ -1,29 +0,0 @@ -package keeper - -import ( - "github.com/bandprotocol/chain/v2/x/globalfee/exported" - v2 "github.com/bandprotocol/chain/v2/x/globalfee/migrations/v2" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// Migrator is a struct for handling in-place state migrations. -type Migrator struct { - keeper Keeper - legacySubspace exported.Subspace -} - -// NewMigrator returns Migrator instance for the state migration. -func NewMigrator(k Keeper, ss exported.Subspace) Migrator { - return Migrator{ - keeper: k, - legacySubspace: ss, - } -} - -// Migrate1to2 migrates the x/mint module state from the consensus version 1 to -// version 2. Specifically, it takes the parameters that are currently stored -// and managed by the x/params modules and stores them directly into the x/mint -// module state. -func (m Migrator) Migrate1to2(ctx sdk.Context) error { - return v2.Migrate(ctx, ctx.KVStore(m.keeper.storeKey), m.legacySubspace, m.keeper.cdc) -} diff --git a/x/globalfee/module.go b/x/globalfee/module.go index 4989eef4e..4138f9e55 100644 --- a/x/globalfee/module.go +++ b/x/globalfee/module.go @@ -20,7 +20,7 @@ import ( "github.com/bandprotocol/chain/v2/x/globalfee/types" ) -// ConsensusVersion defines the current x/mint module consensus version. +// ConsensusVersion defines the current x/globalfee module consensus version. const ConsensusVersion = 2 var ( diff --git a/x/oracle/migrations/v2/migrate.go b/x/oracle/migrations/v2/migrate.go deleted file mode 100644 index d567f6d90..000000000 --- a/x/oracle/migrations/v2/migrate.go +++ /dev/null @@ -1,35 +0,0 @@ -package v2 - -import ( - "github.com/bandprotocol/chain/v2/x/oracle/exported" - "github.com/bandprotocol/chain/v2/x/oracle/types" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -const ( - ModuleName = "oracle" -) - -// Migrate migrates the x/oracle module state from the consensus version 1 to -// version 2. Specifically, it takes the parameters that are currently stored -// and managed by the x/params modules and stores them directly into the x/oracle -// 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) - - if err := currParams.Validate(); err != nil { - return err - } - - bz := cdc.MustMarshal(&currParams) - store.Set(types.ParamsKeyPrefix, bz) - - return nil -} diff --git a/x/oracle/migrations/v2/migrator_test.go b/x/oracle/migrations/v2/migrator_test.go deleted file mode 100644 index d029ff35d..000000000 --- a/x/oracle/migrations/v2/migrator_test.go +++ /dev/null @@ -1,45 +0,0 @@ -package v2_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/bandprotocol/chain/v2/x/oracle" - "github.com/bandprotocol/chain/v2/x/oracle/exported" - v2 "github.com/bandprotocol/chain/v2/x/oracle/migrations/v2" - "github.com/bandprotocol/chain/v2/x/oracle/types" - "github.com/cosmos/cosmos-sdk/testutil" - sdk "github.com/cosmos/cosmos-sdk/types" - moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" -) - -type mockSubspace struct { - ps types.Params -} - -func newMockSubspace(ps types.Params) mockSubspace { - return mockSubspace{ps: ps} -} - -func (ms mockSubspace) GetParamSet(ctx sdk.Context, ps exported.ParamSet) { - *ps.(*types.Params) = ms.ps -} - -func TestMigrate(t *testing.T) { - encCfg := moduletestutil.MakeTestEncodingConfig(oracle.AppModuleBasic{}) - cdc := encCfg.Codec - - storeKey := sdk.NewKVStoreKey(v2.ModuleName) - tKey := sdk.NewTransientStoreKey("transient_test") - ctx := testutil.DefaultContext(storeKey, tKey) - store := ctx.KVStore(storeKey) - - legacySubspace := newMockSubspace(types.DefaultParams()) - require.NoError(t, v2.Migrate(ctx, store, legacySubspace, cdc)) - - var res types.Params - bz := store.Get(types.ParamsKeyPrefix) - require.NoError(t, cdc.Unmarshal(bz, &res)) - require.Equal(t, legacySubspace.ps, res) -}