From 36ebe05bd237ceb445d66f57cc7f276b8dafaefd Mon Sep 17 00:00:00 2001 From: aljo242 Date: Wed, 15 Nov 2023 12:53:54 -0500 Subject: [PATCH] add ak --- x/feemarket/ante/fee.go | 3 +-- x/feemarket/keeper/keeper.go | 14 ++++++++++++++ x/feemarket/types/expected_keepers.go | 14 ++++++++++++++ x/feemarket/types/keys.go | 3 +++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 x/feemarket/types/expected_keepers.go diff --git a/x/feemarket/ante/fee.go b/x/feemarket/ante/fee.go index 4a18a53..6cd535b 100644 --- a/x/feemarket/ante/fee.go +++ b/x/feemarket/ante/fee.go @@ -55,7 +55,6 @@ func (dfd FeeMarketDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo } minGasPricesDec := sdk.NewDecCoinsFromCoins(minGasPrices...) - ctx = ctx.WithMinGasPrices(minGasPricesDec) fee := feeTx.GetFee() if !simulate { @@ -69,7 +68,7 @@ func (dfd FeeMarketDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo return ctx, err } - newCtx := ctx.WithPriority(priority) + newCtx := ctx.WithPriority(priority).WithMinGasPrices(minGasPricesDec) return next(newCtx, tx, simulate) } diff --git a/x/feemarket/keeper/keeper.go b/x/feemarket/keeper/keeper.go index fb59bcc..90a8cb7 100644 --- a/x/feemarket/keeper/keeper.go +++ b/x/feemarket/keeper/keeper.go @@ -1,6 +1,8 @@ package keeper import ( + "fmt" + "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -12,6 +14,7 @@ import ( type Keeper struct { cdc codec.BinaryCodec storeKey storetypes.StoreKey + ak types.AccountKeeper // The address that is capable of executing a MsgParams message. // Typically, this will be the governance module's address. @@ -22,11 +25,22 @@ type Keeper struct { func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, + authKeeper types.AccountKeeper, authority string, ) *Keeper { + // ensure governance module account is set + if addr := authKeeper.GetModuleAddress(types.FeeCollectorName); addr == nil { + panic(fmt.Sprintf("%s module account has not been set", types.ModuleName)) + } + + if _, err := sdk.AccAddressFromBech32(authority); err != nil { + panic(fmt.Sprintf("invalid authority address: %s", authority)) + } + k := &Keeper{ cdc, storeKey, + authKeeper, authority, } diff --git a/x/feemarket/types/expected_keepers.go b/x/feemarket/types/expected_keepers.go new file mode 100644 index 0000000..0f9f506 --- /dev/null +++ b/x/feemarket/types/expected_keepers.go @@ -0,0 +1,14 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +// AccountKeeper defines the expected account keeper (noalias) +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI + + GetModuleAddress(name string) sdk.AccAddress + GetModuleAccount(ctx sdk.Context, name string) authtypes.ModuleAccountI +} diff --git a/x/feemarket/types/keys.go b/x/feemarket/types/keys.go index a0cc483..6bf6abd 100644 --- a/x/feemarket/types/keys.go +++ b/x/feemarket/types/keys.go @@ -5,6 +5,9 @@ const ( ModuleName = "feemarket" // StoreKey is the store key string for the feemarket module. StoreKey = ModuleName + + // FeeCollectorName the root string for the fee market fee collector account address. + FeeCollectorName = "feemarket-fee-collector" ) const (