From d469f37aa5c939bc94131da22b2cfe31072e24be Mon Sep 17 00:00:00 2001 From: avery <> Date: Wed, 30 Oct 2024 15:34:28 +0100 Subject: [PATCH] update mt module --- modules/mt/keeper/keeper.go | 2 +- modules/mt/keeper/mt.go | 3 ++- modules/mt/module.go | 10 +--------- modules/mt/simulation/genesis.go | 4 ++-- modules/mt/simulation/operations.go | 24 ++++++++++++------------ 5 files changed, 18 insertions(+), 25 deletions(-) diff --git a/modules/mt/keeper/keeper.go b/modules/mt/keeper/keeper.go index 5c09b9fb..9c027a4b 100644 --- a/modules/mt/keeper/keeper.go +++ b/modules/mt/keeper/keeper.go @@ -4,8 +4,8 @@ import ( "fmt" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" - "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" diff --git a/modules/mt/keeper/mt.go b/modules/mt/keeper/mt.go index 4e845065..eb78136a 100644 --- a/modules/mt/keeper/mt.go +++ b/modules/mt/keeper/mt.go @@ -5,6 +5,7 @@ import ( "fmt" errorsmod "cosmossdk.io/errors" + storetypes "cosmossdk.io/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -45,7 +46,7 @@ func (k Keeper) GetMT(ctx sdk.Context, denomID, mtID string) (mt exported.MT, er func (k Keeper) GetMTs(ctx sdk.Context, denomID string) (mts []exported.MT) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.KeyMT(denomID, "")) + iterator := storetypes.KVStorePrefixIterator(store, types.KeyMT(denomID, "")) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { var baseMT types.MT diff --git a/modules/mt/module.go b/modules/mt/module.go index df3149c5..0e9d294e 100644 --- a/modules/mt/module.go +++ b/modules/mt/module.go @@ -148,14 +148,6 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw // ConsensusVersion implements AppModule/ConsensusVersion. func (AppModule) ConsensusVersion() uint64 { return 1 } -// BeginBlock performs a no-op. -func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} - -// EndBlock returns the end blocker for the MT module. It returns no validator updates. -func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - return []abci.ValidatorUpdate{} -} - // ____________________________________________________________________________ // AppModuleSimulation functions @@ -166,7 +158,7 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { } // RegisterStoreDecoder registers a decoder for MT module's types -func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { +func (am AppModule) RegisterStoreDecoder(sdr simtypes.StoreDecoderRegistry) { sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc) } diff --git a/modules/mt/simulation/genesis.go b/modules/mt/simulation/genesis.go index 2ed919c0..3f45d02c 100644 --- a/modules/mt/simulation/genesis.go +++ b/modules/mt/simulation/genesis.go @@ -101,13 +101,13 @@ func RandomizedGenState(simState *module.SimulationState) { } accs := simState.Accounts[:accLen] - simState.AppParams.GetOrGenerate(simState.Cdc, "mt", &collections, simState.Rand, + simState.AppParams.GetOrGenerate("mt", &collections, simState.Rand, func(r *rand.Rand) { collections = genCollections(r, accs) }, ) - simState.AppParams.GetOrGenerate(simState.Cdc, "mt", &owners, simState.Rand, + simState.AppParams.GetOrGenerate("mt", &owners, simState.Rand, func(r *rand.Rand) { owners = genOwners(r, collections, accs) }, diff --git a/modules/mt/simulation/operations.go b/modules/mt/simulation/operations.go index 7bd1d2bd..c9af6d45 100644 --- a/modules/mt/simulation/operations.go +++ b/modules/mt/simulation/operations.go @@ -36,41 +36,41 @@ func WeightedOperations( var weightIssueDenom, weightMint, weightEdit, weightBurn, weightTransfer, weightTransferDenom int appParams.GetOrGenerate( - cdc, OpWeightMsgIssueDenom, &weightIssueDenom, nil, + OpWeightMsgIssueDenom, &weightIssueDenom, nil, func(_ *rand.Rand) { weightIssueDenom = 50 }, ) appParams.GetOrGenerate( - cdc, OpWeightMsgMintMT, &weightMint, nil, + OpWeightMsgMintMT, &weightMint, nil, func(_ *rand.Rand) { weightMint = 100 }, ) appParams.GetOrGenerate( - cdc, OpWeightMsgEditMT, &weightEdit, nil, + OpWeightMsgEditMT, &weightEdit, nil, func(_ *rand.Rand) { weightEdit = 50 }, ) appParams.GetOrGenerate( - cdc, OpWeightMsgTransferMT, &weightTransfer, nil, + OpWeightMsgTransferMT, &weightTransfer, nil, func(_ *rand.Rand) { weightTransfer = 50 }, ) appParams.GetOrGenerate( - cdc, OpWeightMsgBurnMT, &weightBurn, nil, + OpWeightMsgBurnMT, &weightBurn, nil, func(_ *rand.Rand) { weightBurn = 10 }, ) appParams.GetOrGenerate( - cdc, OpWeightMsgTransferDenom, &weightTransferDenom, nil, + OpWeightMsgTransferDenom, &weightTransferDenom, nil, func(_ *rand.Rand) { weightTransferDenom = 10 }, @@ -170,7 +170,7 @@ func SimulateMsgIssueDenom( ), nil, err } - return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil + return simtypes.NewOperationMsg(msg, true, ""), nil, nil } } @@ -265,7 +265,7 @@ func SimulateMsgMintMT(k keeper.Keeper, ak mt.AccountKeeper, bk mt.BankKeeper) s ), nil, err } - return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil + return simtypes.NewOperationMsg(msg, true, ""), nil, nil } } @@ -353,7 +353,7 @@ func SimulateMsgEditMT(k keeper.Keeper, ak mt.AccountKeeper, bk mt.BankKeeper) s ), nil, err } - return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil + return simtypes.NewOperationMsg(msg, true, ""), nil, nil } } @@ -458,7 +458,7 @@ func SimulateMsgTransferMT( ), nil, err } - return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil + return simtypes.NewOperationMsg(msg, true, ""), nil, nil } } @@ -542,7 +542,7 @@ func SimulateMsgBurnMT(k keeper.Keeper, ak mt.AccountKeeper, bk mt.BankKeeper) s ), nil, err } - return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil + return simtypes.NewOperationMsg(msg, true, ""), nil, nil } } @@ -632,7 +632,7 @@ func SimulateMsgTransferDenom( ), nil, err } - return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil + return simtypes.NewOperationMsg(msg, true, ""), nil, nil } }