Skip to content

Commit

Permalink
remove staking keeper & use "stake" for default 0 fee
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed May 3, 2024
1 parent ae0f453 commit e55e074
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
2 changes: 1 addition & 1 deletion app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
ante.NewValidateMemoDecorator(options.AccountKeeper),
ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper),
// ante.NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker),
globalfeeante.NewFeeDecorator(options.BypassMinFeeMsgTypes, options.GlobalFeeKeeper, options.StakingKeeper, maxBypassMinFeeMsgGasUsage),
globalfeeante.NewFeeDecorator(options.BypassMinFeeMsgTypes, options.GlobalFeeKeeper, maxBypassMinFeeMsgGasUsage),
ante.NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(options.AccountKeeper),
ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer),
Expand Down
23 changes: 2 additions & 21 deletions x/globalfee/ante/fee.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package ante

import (
"errors"

tmstrings "github.com/cometbft/cometbft/libs/strings"

errorsmod "cosmossdk.io/errors"
sdkmath "cosmossdk.io/math"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"

globalfeekeeper "github.com/strangelove-ventures/globalfee/x/globalfee/keeper"
)
Expand All @@ -31,15 +28,13 @@ var _ sdk.AnteDecorator = FeeDecorator{}
type FeeDecorator struct {
BypassMinFeeMsgTypes []string
GlobalFeeKeeper globalfeekeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
MaxTotalBypassMinFeeMsgGasUsage uint64
}

func NewFeeDecorator(bypassMsgTypes []string, gfk globalfeekeeper.Keeper, sk *stakingkeeper.Keeper, maxTotalBypassMinFeeMsgGasUsage uint64) FeeDecorator {
func NewFeeDecorator(bypassMsgTypes []string, gfk globalfeekeeper.Keeper, maxTotalBypassMinFeeMsgGasUsage uint64) FeeDecorator {
return FeeDecorator{
BypassMinFeeMsgTypes: bypassMsgTypes,
GlobalFeeKeeper: gfk,
StakingKeeper: sk,
MaxTotalBypassMinFeeMsgGasUsage: maxTotalBypassMinFeeMsgGasUsage,
}
}
Expand Down Expand Up @@ -169,21 +164,7 @@ func (mfd FeeDecorator) GetGlobalFee(ctx sdk.Context, feeTx sdk.FeeTx) (sdk.Coin
}

func (mfd FeeDecorator) DefaultZeroGlobalFee(ctx sdk.Context) ([]sdk.DecCoin, error) {
bondDenom := mfd.getBondDenom(ctx)
if bondDenom == "" {
return nil, errors.New("empty staking bond denomination")
}

return []sdk.DecCoin{sdk.NewDecCoinFromDec(bondDenom, sdkmath.LegacyNewDec(0))}, nil
}

func (mfd FeeDecorator) getBondDenom(ctx sdk.Context) string {
bd, err := mfd.StakingKeeper.BondDenom(ctx)
if err != nil {
return ""
}

return bd
return []sdk.DecCoin{sdk.NewDecCoinFromDec("stake", sdkmath.LegacyNewDec(0))}, nil
}

// ContainsOnlyBypassMinFeeMsgs returns true if all the given msgs type are listed
Expand Down

0 comments on commit e55e074

Please sign in to comment.