From 7315142ad97b8bd1331f8fca60232bc0b580728a Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Mon, 19 Feb 2024 09:17:24 +0700 Subject: [PATCH 01/12] proposal for sims --- x/tokenfactory/module.go | 7 +++++++ x/tokenfactory/simulation/params.go | 0 2 files changed, 7 insertions(+) create mode 100644 x/tokenfactory/simulation/params.go diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go index 9cc05ec99..da8d67118 100644 --- a/x/tokenfactory/module.go +++ b/x/tokenfactory/module.go @@ -177,11 +177,18 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc sdkcodec.JSONCodec) json. return cdc.MustMarshalJSON(gs) } +// AppModuleSimulation functions + // GenerateGenesisState implements module.AppModuleSimulation. func (AppModule) GenerateGenesisState(simState *module.SimulationState) { simulation.RandomizedGenState(simState) } +// ProposalMsgs returns msgs used for governance proposals for simulations. +func (AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { + return []simtypes.WeightedProposalMsg{} +} + // RegisterStoreDecoder implements module.AppModuleSimulation. func (AppModule) RegisterStoreDecoder(sdk.StoreDecoderRegistry) { } diff --git a/x/tokenfactory/simulation/params.go b/x/tokenfactory/simulation/params.go new file mode 100644 index 000000000..e69de29bb From f1b8b43d645ba1baeb49def2a79fb7f03d0ff7c4 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Mon, 19 Feb 2024 09:51:52 +0700 Subject: [PATCH 02/12] add sims msg create denom --- x/tokenfactory/simulation/operations.go | 103 ++++++++++++++++++++++++ x/tokenfactory/simulation/params.go | 0 2 files changed, 103 insertions(+) create mode 100644 x/tokenfactory/simulation/operations.go delete mode 100644 x/tokenfactory/simulation/params.go diff --git a/x/tokenfactory/simulation/operations.go b/x/tokenfactory/simulation/operations.go new file mode 100644 index 000000000..09420f07a --- /dev/null +++ b/x/tokenfactory/simulation/operations.go @@ -0,0 +1,103 @@ +package simulation + +import ( + "math/rand" + + "github.com/NibiruChain/nibiru/x/tokenfactory/keeper" + "github.com/NibiruChain/nibiru/x/tokenfactory/types" + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" +) + +// Simulation parameter constants +const ( + StakePerAccount = "stake_per_account" + InitiallyBondedValidators = "initially_bonded_validators" + + DefaultWeightMsgCreateDenom int = 100 + DefaultWeightMsgMint int = 100 + DefaultWeightMsgBurn int = 100 + DefaultWeightMsgChangeAdmin int = 100 + DefaultWeightMsgSetDenomMetadata int = 100 +) + +// Simulation operation weights constants +// +//nolint:gosec +const ( + OpWeightMsgCreateDenom = "op_weight_msg_create_denom" + OpWeightMsgChangeAdmin = "op_weight_msg_change_admin" + OpWeightMsgMint = "op_weight_msg_mint" + OpWeightMsgBurn = "op_weight_msg_burn" + OpWeightMsgSetDenomMetadata = "op_weight_msg_set_denom_metadata" +) + +type BankKeeper interface { + simulation.BankKeeper + GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin +} + +func WeightedOperations( + simstate *module.SimulationState, + tfKeeper keeper.Keeper, + ak types.AccountKeeper, + bk BankKeeper, +) simulation.WeightedOperations { + + var ( + weightMsgCreateDenom int + ) + + simstate.AppParams.GetOrGenerate(simstate.Cdc, OpWeightMsgCreateDenom, &weightMsgCreateDenom, nil, + func(_ *rand.Rand) { + weightMsgCreateDenom = DefaultWeightMsgCreateDenom + }, + ) + + return simulation.WeightedOperations{ + simulation.NewWeightedOperation( + weightMsgCreateDenom, + SimulateMsgCreateDenom( + tfKeeper, + ak, + bk, + ), + ), + } +} + +// Simulate msg create denom +func SimulateMsgCreateDenom(tfKeeper keeper.Keeper, ak types.AccountKeeper, bk BankKeeper) simtypes.Operation { + return func( + r *rand.Rand, + app *baseapp.BaseApp, + ctx sdk.Context, + accs []simtypes.Account, + chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + // Get sims account + simAccount, _ := simtypes.RandomAcc(r, accs) + + // Check if sims account enough create fee + moduleParams, _ := tfKeeper.Store.ModuleParams.Get(ctx) + createFee := moduleParams.DenomCreationGasConsume + balances := bk.GetAllBalances(ctx, simAccount.Address) + _, hasNeg := balances.SafeSub(createFee) + if hasNeg { + return simtypes.NoOpMsg(types.ModuleName, types.MsgCreateDenom{}.Type(), "Creator not enough creation fee"), nil, nil + } + + // Create msg create denom + msg := types.MsgCreateDenom{ + Sender: simAccount.Address.String(), + Subdenom: simtypes.RandStringOfLength(r, 10), + } + + txCtx := BuildOperationInput(r, app, ctx, &msg, simAccount, ak, bk, createFee) + return simulation.GenAndDeliverTxWithRandFees(txCtx) + } +} diff --git a/x/tokenfactory/simulation/params.go b/x/tokenfactory/simulation/params.go deleted file mode 100644 index e69de29bb..000000000 From 4073a5b4b39adda4d84410228797f8111f832310 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Mon, 19 Feb 2024 10:25:50 +0700 Subject: [PATCH 03/12] add sims msg create denom --- app/keepers.go | 2 +- x/tokenfactory/module.go | 7 ++-- x/tokenfactory/module_test.go | 1 + x/tokenfactory/simulation/operations.go | 44 ++++++++++++++++++++----- 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/app/keepers.go b/app/keepers.go index 10418a946..dbd5816f0 100644 --- a/app/keepers.go +++ b/app/keepers.go @@ -614,7 +614,7 @@ func (app *NibiruApp) initAppModules( app.DevGasKeeper, app.AccountKeeper, app.GetSubspace(devgastypes.ModuleName)), tokenfactory.NewAppModule( - app.TokenFactoryKeeper, app.AccountKeeper, + app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper, ), crisis.NewAppModule(&app.crisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go index da8d67118..33892d938 100644 --- a/x/tokenfactory/module.go +++ b/x/tokenfactory/module.go @@ -115,17 +115,20 @@ type AppModule struct { AppModuleBasic keeper keeper.Keeper ak authkeeper.AccountKeeper + bk types.BankKeeper } // NewAppModule creates a new AppModule Object func NewAppModule( k keeper.Keeper, ak authkeeper.AccountKeeper, + bk types.BankKeeper, ) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{}, keeper: k, ak: ak, + bk: bk, } } @@ -194,6 +197,6 @@ func (AppModule) RegisterStoreDecoder(sdk.StoreDecoderRegistry) { } // WeightedOperations implements module.AppModuleSimulation. -func (AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { - return []simtypes.WeightedOperation{} +func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { + return simulation.WeightedOperations(&simState, am.keeper, am.ak, am.bk) } diff --git a/x/tokenfactory/module_test.go b/x/tokenfactory/module_test.go index f143c4296..1c1b9ec7b 100644 --- a/x/tokenfactory/module_test.go +++ b/x/tokenfactory/module_test.go @@ -23,6 +23,7 @@ func (s *ModuleTestSuite) TestAppModule() { appModule := module.NewAppModule( bapp.TokenFactoryKeeper, bapp.AccountKeeper, + bapp.BankKeeper, ) s.NotPanics(func() { diff --git a/x/tokenfactory/simulation/operations.go b/x/tokenfactory/simulation/operations.go index 09420f07a..97ebe5a9c 100644 --- a/x/tokenfactory/simulation/operations.go +++ b/x/tokenfactory/simulation/operations.go @@ -6,9 +6,12 @@ import ( "github.com/NibiruChain/nibiru/x/tokenfactory/keeper" "github.com/NibiruChain/nibiru/x/tokenfactory/types" "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/auth/tx" "github.com/cosmos/cosmos-sdk/x/simulation" ) @@ -41,6 +44,38 @@ type BankKeeper interface { GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin } +// BuildOperationInput helper to build object +func BuildOperationInput( + r *rand.Rand, + app *baseapp.BaseApp, + ctx sdk.Context, + msg interface { + sdk.Msg + Type() string + }, + simAccount simtypes.Account, + ak types.AccountKeeper, + bk BankKeeper, + deposit sdk.Coins, +) simulation.OperationInput { + interfaceRegistry := codectypes.NewInterfaceRegistry() + txConfig := tx.NewTxConfig(codec.NewProtoCodec(interfaceRegistry), tx.DefaultSignModes) + return simulation.OperationInput{ + R: r, + App: app, + TxGen: txConfig, + Cdc: nil, + Msg: msg, + MsgType: msg.Type(), + Context: ctx, + SimAccount: simAccount, + AccountKeeper: ak, + Bankkeeper: bk, + ModuleName: types.ModuleName, + CoinsSpentInMsg: deposit, + } +} + func WeightedOperations( simstate *module.SimulationState, tfKeeper keeper.Keeper, @@ -83,13 +118,6 @@ func SimulateMsgCreateDenom(tfKeeper keeper.Keeper, ak types.AccountKeeper, bk B simAccount, _ := simtypes.RandomAcc(r, accs) // Check if sims account enough create fee - moduleParams, _ := tfKeeper.Store.ModuleParams.Get(ctx) - createFee := moduleParams.DenomCreationGasConsume - balances := bk.GetAllBalances(ctx, simAccount.Address) - _, hasNeg := balances.SafeSub(createFee) - if hasNeg { - return simtypes.NoOpMsg(types.ModuleName, types.MsgCreateDenom{}.Type(), "Creator not enough creation fee"), nil, nil - } // Create msg create denom msg := types.MsgCreateDenom{ @@ -97,7 +125,7 @@ func SimulateMsgCreateDenom(tfKeeper keeper.Keeper, ak types.AccountKeeper, bk B Subdenom: simtypes.RandStringOfLength(r, 10), } - txCtx := BuildOperationInput(r, app, ctx, &msg, simAccount, ak, bk, createFee) + txCtx := BuildOperationInput(r, app, ctx, &msg, simAccount, ak, bk, nil) return simulation.GenAndDeliverTxWithRandFees(txCtx) } } From 2686df634952a6b8fdfea25d95b7668e3a5431f2 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Mon, 19 Feb 2024 10:29:48 +0700 Subject: [PATCH 04/12] nit --- x/tokenfactory/simulation/operations.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/tokenfactory/simulation/operations.go b/x/tokenfactory/simulation/operations.go index 97ebe5a9c..2efc02154 100644 --- a/x/tokenfactory/simulation/operations.go +++ b/x/tokenfactory/simulation/operations.go @@ -117,7 +117,7 @@ func SimulateMsgCreateDenom(tfKeeper keeper.Keeper, ak types.AccountKeeper, bk B // Get sims account simAccount, _ := simtypes.RandomAcc(r, accs) - // Check if sims account enough create fee + // TODO: Check if sims account enough create fee when CreateDenom Msg charge // Create msg create denom msg := types.MsgCreateDenom{ From 652e823c62df6368cf9fc4ab35ab4488e38231f2 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Mon, 19 Feb 2024 10:46:28 +0700 Subject: [PATCH 05/12] add sims msg mint --- x/tokenfactory/simulation/operations.go | 147 +++++++++++++++++++++++- 1 file changed, 146 insertions(+), 1 deletion(-) diff --git a/x/tokenfactory/simulation/operations.go b/x/tokenfactory/simulation/operations.go index 2efc02154..35931aaf1 100644 --- a/x/tokenfactory/simulation/operations.go +++ b/x/tokenfactory/simulation/operations.go @@ -85,6 +85,8 @@ func WeightedOperations( var ( weightMsgCreateDenom int + weightMsgChangeAdmin int + weightMsgMint int ) simstate.AppParams.GetOrGenerate(simstate.Cdc, OpWeightMsgCreateDenom, &weightMsgCreateDenom, nil, @@ -93,6 +95,18 @@ func WeightedOperations( }, ) + simstate.AppParams.GetOrGenerate(simstate.Cdc, OpWeightMsgChangeAdmin, &weightMsgChangeAdmin, nil, + func(_ *rand.Rand) { + weightMsgChangeAdmin = DefaultWeightMsgChangeAdmin + }, + ) + + simstate.AppParams.GetOrGenerate(simstate.Cdc, OpWeightMsgMint, &weightMsgMint, nil, + func(_ *rand.Rand) { + weightMsgMint = DefaultWeightMsgMint + }, + ) + return simulation.WeightedOperations{ simulation.NewWeightedOperation( weightMsgCreateDenom, @@ -102,11 +116,45 @@ func WeightedOperations( bk, ), ), + simulation.NewWeightedOperation( + weightMsgChangeAdmin, + SimulateMsgChangeAdmin( + tfKeeper, + ak, + bk, + DefaultSimulationDenomSelector, + ), + ), + simulation.NewWeightedOperation( + weightMsgMint, + SimulateMsgMint( + tfKeeper, + ak, + bk, + DefaultSimulationDenomSelector, + ), + ), + } +} + +type DenomSelector = func(*rand.Rand, sdk.Context, keeper.Keeper, string) (string, bool) + +func DefaultSimulationDenomSelector(r *rand.Rand, ctx sdk.Context, tfKeeper keeper.Keeper, creator string) (string, bool) { + denoms := tfKeeper.QueryDenoms(ctx, creator) + if len(denoms) == 0 { + return "", false } + randPos := r.Intn(len(denoms)) + + return denoms[randPos], true } // Simulate msg create denom -func SimulateMsgCreateDenom(tfKeeper keeper.Keeper, ak types.AccountKeeper, bk BankKeeper) simtypes.Operation { +func SimulateMsgCreateDenom( + tfKeeper keeper.Keeper, + ak types.AccountKeeper, + bk BankKeeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, @@ -129,3 +177,100 @@ func SimulateMsgCreateDenom(tfKeeper keeper.Keeper, ak types.AccountKeeper, bk B return simulation.GenAndDeliverTxWithRandFees(txCtx) } } + +func SimulateMsgChangeAdmin( + tfKeeper keeper.Keeper, + ak types.AccountKeeper, + bk BankKeeper, + denomSelector DenomSelector, +) simtypes.Operation { + return func( + r *rand.Rand, + app *baseapp.BaseApp, + ctx sdk.Context, + accs []simtypes.Account, + chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + // Get create denom account + createdDenomAccount, _ := simtypes.RandomAcc(r, accs) + + // Get demon + denom, hasDenom := denomSelector(r, ctx, tfKeeper, createdDenomAccount.Address.String()) + if !hasDenom { + return simtypes.NoOpMsg(types.ModuleName, types.MsgChangeAdmin{}.Type(), "sim account have no denom created"), nil, nil + } + + // Get admin of the denom + authData, err := tfKeeper.Store.GetDenomAuthorityMetadata(ctx, denom) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.MsgChangeAdmin{}.Type(), "err authority metadata"), nil, err + } + curAdminAccount, found := simtypes.FindAccount(accs, sdk.MustAccAddressFromBech32(authData.Admin)) + if !found { + return simtypes.NoOpMsg(types.ModuleName, types.MsgChangeAdmin{}.Type(), "admin account not found"), nil, nil + } + + // Rand new admin account + newAdmin, _ := simtypes.RandomAcc(r, accs) + if newAdmin.Address.String() == curAdminAccount.Address.String() { + return simtypes.NoOpMsg(types.ModuleName, types.MsgChangeAdmin{}.Type(), "new admin cannot be the same as current admin"), nil, nil + } + + // Create msg + msg := types.MsgChangeAdmin{ + Sender: curAdminAccount.Address.String(), + Denom: denom, + NewAdmin: newAdmin.Address.String(), + } + + txCtx := BuildOperationInput(r, app, ctx, &msg, curAdminAccount, ak, bk, nil) + return simulation.GenAndDeliverTxWithRandFees(txCtx) + } +} + +// Simulate msg mint denom +func SimulateMsgMint( + tfKeeper keeper.Keeper, + ak types.AccountKeeper, + bk BankKeeper, + denomSelector DenomSelector, +) simtypes.Operation { + return func( + r *rand.Rand, + app *baseapp.BaseApp, + ctx sdk.Context, + accs []simtypes.Account, + chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + // Get create denom account + createdDenomAccount, _ := simtypes.RandomAcc(r, accs) + + // Get demon + denom, hasDenom := denomSelector(r, ctx, tfKeeper, createdDenomAccount.Address.String()) + if !hasDenom { + return simtypes.NoOpMsg(types.ModuleName, types.MsgMint{}.Type(), "sim account have no denom created"), nil, nil + } + + // Get admin of the denom + authData, err := tfKeeper.Store.GetDenomAuthorityMetadata(ctx, denom) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.MsgMint{}.Type(), "err authority metadata"), nil, err + } + adminAccount, found := simtypes.FindAccount(accs, sdk.MustAccAddressFromBech32(authData.Admin)) + if !found { + return simtypes.NoOpMsg(types.ModuleName, types.MsgMint{}.Type(), "admin account not found"), nil, nil + } + + // Rand mint amount + mintAmount, _ := simtypes.RandPositiveInt(r, sdk.NewIntFromUint64(100_000_000)) + + // Create msg mint + msg := types.MsgMint{ + Sender: adminAccount.Address.String(), + Coin: sdk.NewCoin(denom, mintAmount), + } + + txCtx := BuildOperationInput(r, app, ctx, &msg, adminAccount, ak, bk, nil) + return simulation.GenAndDeliverTxWithRandFees(txCtx) + } +} From 6a5a9273d6f78fa96da5bdf569ede71d9e8e81b5 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Mon, 19 Feb 2024 10:50:44 +0700 Subject: [PATCH 06/12] add msg type token factory module --- x/tokenfactory/types/tx_msgs.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/x/tokenfactory/types/tx_msgs.go b/x/tokenfactory/types/tx_msgs.go index fb87e9fa8..4bf724c7f 100644 --- a/x/tokenfactory/types/tx_msgs.go +++ b/x/tokenfactory/types/tx_msgs.go @@ -6,6 +6,14 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" ) +const ( + MsgCreateDenomType = "create_denom" + MsgChangeAdminType = "change_admin" + MsgMintType = "mint" + MsgBurnType = "burn" + MsgSetDenomMetadataType = "set_denom_metadata" +) + // ---------------------------------------------------------------- // MsgCreateDenom @@ -44,7 +52,7 @@ func (m MsgCreateDenom) Route() string { return RouterKey } // Type: Impl legacytx.LegacyMsg. Returns a human-readable string for the message, // intended for utilization within tags -func (m MsgCreateDenom) Type() string { return "create_denom" } +func (m MsgCreateDenom) Type() string { return MsgCreateDenomType } // GetSignBytes: Get the canonical byte representation of the Msg. Impl // legacytx.LegacyMsg. @@ -88,7 +96,7 @@ func (m MsgChangeAdmin) Route() string { return RouterKey } // Type: Impl legacytx.LegacyMsg. Returns a human-readable string for the message, // intended for utilization within tags -func (m MsgChangeAdmin) Type() string { return "create_denom" } +func (m MsgChangeAdmin) Type() string { return MsgChangeAdminType } // GetSignBytes: Get the canonical byte representation of the Msg. Impl // legacytx.LegacyMsg. @@ -132,6 +140,10 @@ func (m MsgMint) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{sender} } +// Type: Impl legacytx.LegacyMsg. Returns a human-readable string for the message, +// intended for utilization within tags +func (m MsgMint) Type() string { return MsgMintType } + func validateCoin(coin sdk.Coin) error { if !coin.IsValid() || coin.IsZero() { return sdkerrors.ErrInvalidCoins.Wrap(coin.String()) @@ -175,6 +187,10 @@ func (m MsgBurn) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{sender} } +// Type: Impl legacytx.LegacyMsg. Returns a human-readable string for the message, +// intended for utilization within tags +func (m MsgBurn) Type() string { return MsgBurnType } + // ---------------------------------------------------------------- // MsgUpdateModuleParams @@ -215,3 +231,7 @@ func (m MsgSetDenomMetadata) GetSigners() []sdk.AccAddress { sender, _ := sdk.AccAddressFromBech32(m.Sender) return []sdk.AccAddress{sender} } + +// Type: Impl legacytx.LegacyMsg. Returns a human-readable string for the message, +// intended for utilization within tags +func (m MsgSetDenomMetadata) Type() string { return MsgSetDenomMetadataType } From b42b529ef9f90d07879b6c223ef89032ac32d2f4 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Mon, 19 Feb 2024 11:00:44 +0700 Subject: [PATCH 07/12] add msg bytes --- x/tokenfactory/types/tx_msgs.go | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/x/tokenfactory/types/tx_msgs.go b/x/tokenfactory/types/tx_msgs.go index 4bf724c7f..9d023c694 100644 --- a/x/tokenfactory/types/tx_msgs.go +++ b/x/tokenfactory/types/tx_msgs.go @@ -107,7 +107,10 @@ func (m MsgChangeAdmin) GetSignBytes() []byte { // ---------------------------------------------------------------- // MsgMint -var _ sdk.Msg = &MsgMint{} +var ( + _ sdk.Msg = &MsgMint{} + _ legacytx.LegacyMsg = &MsgMint{} +) // ValidateBasic performs stateless validation checks. Impl sdk.Msg. func (m MsgMint) ValidateBasic() error { @@ -140,10 +143,19 @@ func (m MsgMint) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{sender} } +// Route: Impl legacytx.LegacyMsg. The mesage route must be alphanumeric or empty. +func (m MsgMint) Route() string { return RouterKey } + // Type: Impl legacytx.LegacyMsg. Returns a human-readable string for the message, // intended for utilization within tags func (m MsgMint) Type() string { return MsgMintType } +// GetSignBytes: Get the canonical byte representation of the Msg. Impl +// legacytx.LegacyMsg. +func (m MsgMint) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + func validateCoin(coin sdk.Coin) error { if !coin.IsValid() || coin.IsZero() { return sdkerrors.ErrInvalidCoins.Wrap(coin.String()) @@ -187,10 +199,19 @@ func (m MsgBurn) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{sender} } +// Route: Impl legacytx.LegacyMsg. The mesage route must be alphanumeric or empty. +func (m MsgBurn) Route() string { return RouterKey } + // Type: Impl legacytx.LegacyMsg. Returns a human-readable string for the message, // intended for utilization within tags func (m MsgBurn) Type() string { return MsgBurnType } +// GetSignBytes: Get the canonical byte representation of the Msg. Impl +// legacytx.LegacyMsg. +func (m MsgBurn) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + // ---------------------------------------------------------------- // MsgUpdateModuleParams @@ -232,6 +253,15 @@ func (m MsgSetDenomMetadata) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{sender} } +// Route: Impl legacytx.LegacyMsg. The mesage route must be alphanumeric or empty. +func (m MsgSetDenomMetadata) Route() string { return RouterKey } + // Type: Impl legacytx.LegacyMsg. Returns a human-readable string for the message, // intended for utilization within tags func (m MsgSetDenomMetadata) Type() string { return MsgSetDenomMetadataType } + +// GetSignBytes: Get the canonical byte representation of the Msg. Impl +// legacytx.LegacyMsg. +func (m MsgSetDenomMetadata) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} From 3624cca50ce1b8cd5e903b3bec4f296c90fa2c43 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Mon, 19 Feb 2024 11:19:33 +0700 Subject: [PATCH 08/12] add sims msg set denom metadata --- x/tokenfactory/simulation/operations.go | 147 +++++++++++++++++++++++- 1 file changed, 144 insertions(+), 3 deletions(-) diff --git a/x/tokenfactory/simulation/operations.go b/x/tokenfactory/simulation/operations.go index 35931aaf1..eeaeff975 100644 --- a/x/tokenfactory/simulation/operations.go +++ b/x/tokenfactory/simulation/operations.go @@ -12,6 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/auth/tx" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/simulation" ) @@ -84,9 +85,11 @@ func WeightedOperations( ) simulation.WeightedOperations { var ( - weightMsgCreateDenom int - weightMsgChangeAdmin int - weightMsgMint int + weightMsgCreateDenom int + weightMsgChangeAdmin int + weightMsgMint int + weightMsgBurn int + weightMsgSetDenomMetadata int ) simstate.AppParams.GetOrGenerate(simstate.Cdc, OpWeightMsgCreateDenom, &weightMsgCreateDenom, nil, @@ -107,6 +110,18 @@ func WeightedOperations( }, ) + simstate.AppParams.GetOrGenerate(simstate.Cdc, OpWeightMsgBurn, &weightMsgBurn, nil, + func(_ *rand.Rand) { + weightMsgBurn = DefaultWeightMsgBurn + }, + ) + + simstate.AppParams.GetOrGenerate(simstate.Cdc, OpWeightMsgSetDenomMetadata, &weightMsgSetDenomMetadata, nil, + func(_ *rand.Rand) { + weightMsgSetDenomMetadata = DefaultWeightMsgSetDenomMetadata + }, + ) + return simulation.WeightedOperations{ simulation.NewWeightedOperation( weightMsgCreateDenom, @@ -134,6 +149,24 @@ func WeightedOperations( DefaultSimulationDenomSelector, ), ), + simulation.NewWeightedOperation( + weightMsgBurn, + SimulateMsgBurn( + tfKeeper, + ak, + bk, + DefaultSimulationDenomSelector, + ), + ), + simulation.NewWeightedOperation( + weightMsgSetDenomMetadata, + SimulateMsgSetDenomMetadata( + tfKeeper, + ak, + bk, + DefaultSimulationDenomSelector, + ), + ), } } @@ -274,3 +307,111 @@ func SimulateMsgMint( return simulation.GenAndDeliverTxWithRandFees(txCtx) } } + +func SimulateMsgBurn( + tfKeeper keeper.Keeper, + ak types.AccountKeeper, + bk BankKeeper, + denomSelector DenomSelector, +) simtypes.Operation { + return func( + r *rand.Rand, + app *baseapp.BaseApp, + ctx sdk.Context, + accs []simtypes.Account, + chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + // Get create denom account + createdDenomAccount, _ := simtypes.RandomAcc(r, accs) + + // Get demon + denom, hasDenom := denomSelector(r, ctx, tfKeeper, createdDenomAccount.Address.String()) + if !hasDenom { + return simtypes.NoOpMsg(types.ModuleName, types.MsgBurn{}.Type(), "sim account have no denom created"), nil, nil + } + + // Get admin of the denom + authData, err := tfKeeper.Store.GetDenomAuthorityMetadata(ctx, denom) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.MsgBurn{}.Type(), "err authority metadata"), nil, err + } + adminAccount, found := simtypes.FindAccount(accs, sdk.MustAccAddressFromBech32(authData.Admin)) + if !found { + return simtypes.NoOpMsg(types.ModuleName, types.MsgBurn{}.Type(), "admin account not found"), nil, nil + } + + // Check if admin account balance = 0 + accountBalance := bk.GetBalance(ctx, adminAccount.Address, denom) + if accountBalance.Amount.LTE(sdk.ZeroInt()) { + return simtypes.NoOpMsg(types.ModuleName, types.MsgBurn{}.Type(), "sim account have no balance"), nil, nil + } + + // Rand burn amount + amount, _ := simtypes.RandPositiveInt(r, accountBalance.Amount) + burnAmount := sdk.NewCoin(denom, amount) + + // Create msg + msg := types.MsgBurn{ + Sender: adminAccount.Address.String(), + Coin: burnAmount, + BurnFrom: adminAccount.Address.String(), + } + + txCtx := BuildOperationInput(r, app, ctx, &msg, adminAccount, ak, bk, sdk.NewCoins(burnAmount)) + return simulation.GenAndDeliverTxWithRandFees(txCtx) + } +} + +func SimulateMsgSetDenomMetadata( + tfKeeper keeper.Keeper, + ak types.AccountKeeper, + bk BankKeeper, + denomSelector DenomSelector, +) simtypes.Operation { + return func( + r *rand.Rand, + app *baseapp.BaseApp, + ctx sdk.Context, + accs []simtypes.Account, + chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + // Get create denom account + createdDenomAccount, _ := simtypes.RandomAcc(r, accs) + + // Get demon + denom, hasDenom := denomSelector(r, ctx, tfKeeper, createdDenomAccount.Address.String()) + if !hasDenom { + return simtypes.NoOpMsg(types.ModuleName, types.MsgSetDenomMetadata{}.Type(), "sim account have no denom created"), nil, nil + } + + // Get admin of the denom + authData, err := tfKeeper.Store.GetDenomAuthorityMetadata(ctx, denom) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.MsgSetDenomMetadata{}.Type(), "err authority metadata"), nil, err + } + adminAccount, found := simtypes.FindAccount(accs, sdk.MustAccAddressFromBech32(authData.Admin)) + if !found { + return simtypes.NoOpMsg(types.ModuleName, types.MsgSetDenomMetadata{}.Type(), "admin account not found"), nil, nil + } + + metadata := banktypes.Metadata{ + Description: simtypes.RandStringOfLength(r, 10), + DenomUnits: []*banktypes.DenomUnit{{ + Denom: denom, + Exponent: 0, + }}, + Base: denom, + Display: denom, + Name: simtypes.RandStringOfLength(r, 10), + Symbol: simtypes.RandStringOfLength(r, 10), + } + + msg := types.MsgSetDenomMetadata{ + Sender: adminAccount.Address.String(), + Metadata: metadata, + } + + txCtx := BuildOperationInput(r, app, ctx, &msg, adminAccount, ak, bk, nil) + return simulation.GenAndDeliverTxWithRandFees(txCtx) + } +} From 760df98ebe51cf337a4d662a35d6f588677ac267 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Mon, 19 Feb 2024 11:53:57 +0700 Subject: [PATCH 09/12] add msg sim update params --- x/tokenfactory/module.go | 2 +- x/tokenfactory/simulation/proposals.go | 44 ++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 x/tokenfactory/simulation/proposals.go diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go index 33892d938..72c1991dc 100644 --- a/x/tokenfactory/module.go +++ b/x/tokenfactory/module.go @@ -189,7 +189,7 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { // ProposalMsgs returns msgs used for governance proposals for simulations. func (AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.WeightedProposalMsg { - return []simtypes.WeightedProposalMsg{} + return simulation.ProposalMsgs() } // RegisterStoreDecoder implements module.AppModuleSimulation. diff --git a/x/tokenfactory/simulation/proposals.go b/x/tokenfactory/simulation/proposals.go new file mode 100644 index 000000000..5e27d64b0 --- /dev/null +++ b/x/tokenfactory/simulation/proposals.go @@ -0,0 +1,44 @@ +package simulation + +import ( + "math/rand" + + "github.com/NibiruChain/nibiru/x/tokenfactory/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" +) + +// Simulation operation weights constants +const ( + DefaultWeightMsgUpdateModuleParams int = 100 + + OpWeightMsgUpdateModuleParams = "op_weight_msg_update_module_params" //nolint:gosec +) + +// ProposalMsgs defines the module weighted proposals' contents +func ProposalMsgs() []simtypes.WeightedProposalMsg { + return []simtypes.WeightedProposalMsg{ + simulation.NewWeightedProposalMsg( + OpWeightMsgUpdateModuleParams, + DefaultWeightMsgUpdateModuleParams, + SimulateMsgUpdateParams, + ), + } +} + +// SimulateMsgUpdateParams returns a random MsgUpdateParams +func SimulateMsgUpdateParams(r *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk.Msg { + // use the default gov module account address as authority + var authority sdk.AccAddress = address.Module("gov") + + params := types.ModuleParams{ + DenomCreationGasConsume: r.Uint64(), + } + + return &types.MsgUpdateModuleParams{ + Authority: authority.String(), + Params: params, + } +} From 1143611d4858948b090e9f7142622bc03f126a07 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Mon, 19 Feb 2024 11:56:05 +0700 Subject: [PATCH 10/12] nit --- x/tokenfactory/simulation/operations.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/x/tokenfactory/simulation/operations.go b/x/tokenfactory/simulation/operations.go index eeaeff975..024586929 100644 --- a/x/tokenfactory/simulation/operations.go +++ b/x/tokenfactory/simulation/operations.go @@ -18,9 +18,6 @@ import ( // Simulation parameter constants const ( - StakePerAccount = "stake_per_account" - InitiallyBondedValidators = "initially_bonded_validators" - DefaultWeightMsgCreateDenom int = 100 DefaultWeightMsgMint int = 100 DefaultWeightMsgBurn int = 100 From 30d48df31382cf0e2cbb53d495d554dc5925a374 Mon Sep 17 00:00:00 2001 From: GnaD <89174180+GNaD13@users.noreply.github.com> Date: Mon, 19 Feb 2024 12:22:04 +0700 Subject: [PATCH 11/12] Update x/tokenfactory/simulation/operations.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- x/tokenfactory/simulation/operations.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/tokenfactory/simulation/operations.go b/x/tokenfactory/simulation/operations.go index 024586929..64997d629 100644 --- a/x/tokenfactory/simulation/operations.go +++ b/x/tokenfactory/simulation/operations.go @@ -233,7 +233,7 @@ func SimulateMsgChangeAdmin( // Get admin of the denom authData, err := tfKeeper.Store.GetDenomAuthorityMetadata(ctx, denom) if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.MsgChangeAdmin{}.Type(), "err authority metadata"), nil, err + return simtypes.NoOpMsg(types.ModuleName, types.MsgChangeAdmin{}.Type(), "error retrieving authority metadata: " + err.Error()), nil, err } curAdminAccount, found := simtypes.FindAccount(accs, sdk.MustAccAddressFromBech32(authData.Admin)) if !found { From 320bf94060de2db7571db546f758ca0b5508bc21 Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Thu, 22 Feb 2024 11:33:26 +0700 Subject: [PATCH 12/12] simulation change to use bank Keeper from token factory keeper --- app/keepers.go | 2 +- x/tokenfactory/keeper/grpc_query.go | 2 +- x/tokenfactory/keeper/keeper.go | 4 ++-- x/tokenfactory/keeper/msg_server.go | 14 +++++++------- x/tokenfactory/module.go | 5 +---- x/tokenfactory/module_test.go | 1 - x/tokenfactory/simulation/operations.go | 23 ++++++----------------- 7 files changed, 18 insertions(+), 33 deletions(-) diff --git a/app/keepers.go b/app/keepers.go index dbd5816f0..10418a946 100644 --- a/app/keepers.go +++ b/app/keepers.go @@ -614,7 +614,7 @@ func (app *NibiruApp) initAppModules( app.DevGasKeeper, app.AccountKeeper, app.GetSubspace(devgastypes.ModuleName)), tokenfactory.NewAppModule( - app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper, + app.TokenFactoryKeeper, app.AccountKeeper, ), crisis.NewAppModule(&app.crisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them diff --git a/x/tokenfactory/keeper/grpc_query.go b/x/tokenfactory/keeper/grpc_query.go index 98070f8a2..fdae9d452 100644 --- a/x/tokenfactory/keeper/grpc_query.go +++ b/x/tokenfactory/keeper/grpc_query.go @@ -64,7 +64,7 @@ func (k Keeper) QueryDenomInfo( return resp, err } - bankMetadata, _ := k.bankKeeper.GetDenomMetaData(ctx, denom) + bankMetadata, _ := k.BankKeeper.GetDenomMetaData(ctx, denom) return &types.QueryDenomInfoResponse{ Admin: tfMetadata.Admin, Metadata: bankMetadata, diff --git a/x/tokenfactory/keeper/keeper.go b/x/tokenfactory/keeper/keeper.go index bc2908d16..e47b377b2 100644 --- a/x/tokenfactory/keeper/keeper.go +++ b/x/tokenfactory/keeper/keeper.go @@ -23,7 +23,7 @@ type Keeper struct { Store StoreAPI // interfaces with other modules - bankKeeper tftypes.BankKeeper + BankKeeper tftypes.BankKeeper accountKeeper tftypes.AccountKeeper communityPoolKeeper tftypes.CommunityPoolKeeper @@ -61,7 +61,7 @@ func NewKeeper( bankKeeper: bk, }, cdc: cdc, - bankKeeper: bk, + BankKeeper: bk, accountKeeper: ak, communityPoolKeeper: communityPoolKeeper, authority: authority, diff --git a/x/tokenfactory/keeper/msg_server.go b/x/tokenfactory/keeper/msg_server.go index 2ef592a2e..623fabaae 100644 --- a/x/tokenfactory/keeper/msg_server.go +++ b/x/tokenfactory/keeper/msg_server.go @@ -150,7 +150,7 @@ func (k Keeper) mint( } coins := sdk.NewCoins(coin) - err := k.bankKeeper.MintCoins(ctx, types.ModuleName, coins) + err := k.BankKeeper.MintCoins(ctx, types.ModuleName, coins) if err != nil { return err } @@ -160,12 +160,12 @@ func (k Keeper) mint( return err } - if k.bankKeeper.BlockedAddr(mintToAddr) { + if k.BankKeeper.BlockedAddr(mintToAddr) { return types.ErrBlockedAddress.Wrapf( "failed to mint to %s", mintToAddr) } - return k.bankKeeper.SendCoinsFromModuleToAccount( + return k.BankKeeper.SendCoinsFromModuleToAccount( ctx, types.ModuleName, mintToAddr, coins, ) } @@ -225,19 +225,19 @@ func (k Keeper) burn( return err } - if k.bankKeeper.BlockedAddr(burnFromAddr) { + if k.BankKeeper.BlockedAddr(burnFromAddr) { return types.ErrBlockedAddress.Wrapf( "failed to burn from %s", burnFromAddr) } coins := sdk.NewCoins(coin) - if err = k.bankKeeper.SendCoinsFromAccountToModule( + if err = k.BankKeeper.SendCoinsFromAccountToModule( ctx, burnFromAddr, types.ModuleName, coins, ); err != nil { return err } - return k.bankKeeper.BurnCoins(ctx, types.ModuleName, coins) + return k.BankKeeper.BurnCoins(ctx, types.ModuleName, coins) } // SetDenomMetadata: Message handler for the abci.Msg: MsgSetDenomMetadata @@ -265,7 +265,7 @@ func (k Keeper) SetDenomMetadata( ) } - k.bankKeeper.SetDenomMetaData(ctx, txMsg.Metadata) + k.BankKeeper.SetDenomMetaData(ctx, txMsg.Metadata) return &types.MsgSetDenomMetadataResponse{}, ctx.EventManager(). EmitTypedEvent(&types.EventSetDenomMetadata{ diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go index 72c1991dc..9ede4e140 100644 --- a/x/tokenfactory/module.go +++ b/x/tokenfactory/module.go @@ -115,20 +115,17 @@ type AppModule struct { AppModuleBasic keeper keeper.Keeper ak authkeeper.AccountKeeper - bk types.BankKeeper } // NewAppModule creates a new AppModule Object func NewAppModule( k keeper.Keeper, ak authkeeper.AccountKeeper, - bk types.BankKeeper, ) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{}, keeper: k, ak: ak, - bk: bk, } } @@ -198,5 +195,5 @@ func (AppModule) RegisterStoreDecoder(sdk.StoreDecoderRegistry) { // WeightedOperations implements module.AppModuleSimulation. func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { - return simulation.WeightedOperations(&simState, am.keeper, am.ak, am.bk) + return simulation.WeightedOperations(&simState, am.keeper, am.ak) } diff --git a/x/tokenfactory/module_test.go b/x/tokenfactory/module_test.go index 1c1b9ec7b..f143c4296 100644 --- a/x/tokenfactory/module_test.go +++ b/x/tokenfactory/module_test.go @@ -23,7 +23,6 @@ func (s *ModuleTestSuite) TestAppModule() { appModule := module.NewAppModule( bapp.TokenFactoryKeeper, bapp.AccountKeeper, - bapp.BankKeeper, ) s.NotPanics(func() { diff --git a/x/tokenfactory/simulation/operations.go b/x/tokenfactory/simulation/operations.go index 024586929..a7cb24e5c 100644 --- a/x/tokenfactory/simulation/operations.go +++ b/x/tokenfactory/simulation/operations.go @@ -78,7 +78,6 @@ func WeightedOperations( simstate *module.SimulationState, tfKeeper keeper.Keeper, ak types.AccountKeeper, - bk BankKeeper, ) simulation.WeightedOperations { var ( @@ -125,7 +124,6 @@ func WeightedOperations( SimulateMsgCreateDenom( tfKeeper, ak, - bk, ), ), simulation.NewWeightedOperation( @@ -133,7 +131,6 @@ func WeightedOperations( SimulateMsgChangeAdmin( tfKeeper, ak, - bk, DefaultSimulationDenomSelector, ), ), @@ -142,7 +139,6 @@ func WeightedOperations( SimulateMsgMint( tfKeeper, ak, - bk, DefaultSimulationDenomSelector, ), ), @@ -151,7 +147,6 @@ func WeightedOperations( SimulateMsgBurn( tfKeeper, ak, - bk, DefaultSimulationDenomSelector, ), ), @@ -160,7 +155,6 @@ func WeightedOperations( SimulateMsgSetDenomMetadata( tfKeeper, ak, - bk, DefaultSimulationDenomSelector, ), ), @@ -183,7 +177,6 @@ func DefaultSimulationDenomSelector(r *rand.Rand, ctx sdk.Context, tfKeeper keep func SimulateMsgCreateDenom( tfKeeper keeper.Keeper, ak types.AccountKeeper, - bk BankKeeper, ) simtypes.Operation { return func( r *rand.Rand, @@ -203,7 +196,7 @@ func SimulateMsgCreateDenom( Subdenom: simtypes.RandStringOfLength(r, 10), } - txCtx := BuildOperationInput(r, app, ctx, &msg, simAccount, ak, bk, nil) + txCtx := BuildOperationInput(r, app, ctx, &msg, simAccount, ak, tfKeeper.BankKeeper, nil) return simulation.GenAndDeliverTxWithRandFees(txCtx) } } @@ -211,7 +204,6 @@ func SimulateMsgCreateDenom( func SimulateMsgChangeAdmin( tfKeeper keeper.Keeper, ak types.AccountKeeper, - bk BankKeeper, denomSelector DenomSelector, ) simtypes.Operation { return func( @@ -253,7 +245,7 @@ func SimulateMsgChangeAdmin( NewAdmin: newAdmin.Address.String(), } - txCtx := BuildOperationInput(r, app, ctx, &msg, curAdminAccount, ak, bk, nil) + txCtx := BuildOperationInput(r, app, ctx, &msg, curAdminAccount, ak, tfKeeper.BankKeeper, nil) return simulation.GenAndDeliverTxWithRandFees(txCtx) } } @@ -262,7 +254,6 @@ func SimulateMsgChangeAdmin( func SimulateMsgMint( tfKeeper keeper.Keeper, ak types.AccountKeeper, - bk BankKeeper, denomSelector DenomSelector, ) simtypes.Operation { return func( @@ -300,7 +291,7 @@ func SimulateMsgMint( Coin: sdk.NewCoin(denom, mintAmount), } - txCtx := BuildOperationInput(r, app, ctx, &msg, adminAccount, ak, bk, nil) + txCtx := BuildOperationInput(r, app, ctx, &msg, adminAccount, ak, tfKeeper.BankKeeper, nil) return simulation.GenAndDeliverTxWithRandFees(txCtx) } } @@ -308,7 +299,6 @@ func SimulateMsgMint( func SimulateMsgBurn( tfKeeper keeper.Keeper, ak types.AccountKeeper, - bk BankKeeper, denomSelector DenomSelector, ) simtypes.Operation { return func( @@ -338,7 +328,7 @@ func SimulateMsgBurn( } // Check if admin account balance = 0 - accountBalance := bk.GetBalance(ctx, adminAccount.Address, denom) + accountBalance := tfKeeper.BankKeeper.GetBalance(ctx, adminAccount.Address, denom) if accountBalance.Amount.LTE(sdk.ZeroInt()) { return simtypes.NoOpMsg(types.ModuleName, types.MsgBurn{}.Type(), "sim account have no balance"), nil, nil } @@ -354,7 +344,7 @@ func SimulateMsgBurn( BurnFrom: adminAccount.Address.String(), } - txCtx := BuildOperationInput(r, app, ctx, &msg, adminAccount, ak, bk, sdk.NewCoins(burnAmount)) + txCtx := BuildOperationInput(r, app, ctx, &msg, adminAccount, ak, tfKeeper.BankKeeper, sdk.NewCoins(burnAmount)) return simulation.GenAndDeliverTxWithRandFees(txCtx) } } @@ -362,7 +352,6 @@ func SimulateMsgBurn( func SimulateMsgSetDenomMetadata( tfKeeper keeper.Keeper, ak types.AccountKeeper, - bk BankKeeper, denomSelector DenomSelector, ) simtypes.Operation { return func( @@ -408,7 +397,7 @@ func SimulateMsgSetDenomMetadata( Metadata: metadata, } - txCtx := BuildOperationInput(r, app, ctx, &msg, adminAccount, ak, bk, nil) + txCtx := BuildOperationInput(r, app, ctx, &msg, adminAccount, ak, tfKeeper.BankKeeper, nil) return simulation.GenAndDeliverTxWithRandFees(txCtx) } }