From 8c3f27e76d5ffdfca3d06b26bd3017f46d51161f Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Mon, 3 Jun 2024 09:18:38 +0200 Subject: [PATCH] updates --- x/authz/simulation/operations.go | 34 +++++++++++++++++++++++++++++++- x/bank/CHANGELOG.md | 1 + 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/x/authz/simulation/operations.go b/x/authz/simulation/operations.go index 9e25d14aa6ea..ec62f5196b2f 100644 --- a/x/authz/simulation/operations.go +++ b/x/authz/simulation/operations.go @@ -1,10 +1,15 @@ package simulation import ( + "context" "math/rand" "time" "cosmossdk.io/core/address" + "cosmossdk.io/core/appmodule" + corecontext "cosmossdk.io/core/context" + coregas "cosmossdk.io/core/gas" + coreheader "cosmossdk.io/core/header" "cosmossdk.io/x/authz" "cosmossdk.io/x/authz/keeper" banktype "cosmossdk.io/x/bank/types" @@ -315,7 +320,12 @@ func SimulateMsgExec( msg := []sdk.Msg{banktype.NewMsgSend(graStr, greStr, coins)} - _, err = sendAuth.Accept(ctx, msg[0]) + goCtx := context.WithValue(ctx.Context(), corecontext.EnvironmentContextKey, appmodule.Environment{ + HeaderService: headerService{}, + GasService: mockGasService{}, + }) + + _, err = sendAuth.Accept(goCtx, msg[0]) if err != nil { if sdkerrors.ErrInsufficientFunds.Is(err) { return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, err.Error()), nil, nil @@ -359,3 +369,25 @@ func SimulateMsgExec( return simtypes.NewOperationMsg(&msgExec, true, "success"), nil, nil } } + +type headerService struct{} + +func (h headerService) HeaderInfo(ctx context.Context) coreheader.Info { + return sdk.UnwrapSDKContext(ctx).HeaderInfo() +} + +type mockGasService struct { + coregas.Service +} + +func (m mockGasService) GasMeter(ctx context.Context) coregas.Meter { + return mockGasMeter{} +} + +type mockGasMeter struct { + coregas.Meter +} + +func (m mockGasMeter) Consume(amount coregas.Gas, descriptor string) error { + return nil +} diff --git a/x/bank/CHANGELOG.md b/x/bank/CHANGELOG.md index 22f1637fbfb7..6d170d270963 100644 --- a/x/bank/CHANGELOG.md +++ b/x/bank/CHANGELOG.md @@ -37,6 +37,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### API Breaking Changes +* [#20502](https://github.com/cosmos/cosmos-sdk/pull/20502) `Accept` on the `Authorization` interface now expects the authz environment in the `context.Context`. This is already done when `Accept` is called by `k.DispatchActions`, but should be done manually if `Accept` is called directly. * [#19954](https://github.com/cosmos/cosmos-sdk/pull/19954) Removal of the Address.String() method and related changes: * Changed `NewInput`, `NewOutput`, `NewQueryBalanceRequest`, `NewQueryAllBalancesRequest`, `NewQuerySpendableBalancesRequest` to accept a string instead of an `AccAddress`. * Added an address codec as an argument to `NewSendAuthorization`.