diff --git a/app/ante.go b/app/ante.go index e4bd0642..74e8c61a 100644 --- a/app/ante.go +++ b/app/ante.go @@ -46,7 +46,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { anteDecorators := []sdk.AnteDecorator{ ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first ante.RejectExtensionOptionsDecorator{}, - feeabsante.NewFeeAbstrationMempoolFeeDecorator(options.FeeAbsKeeper), + feeabsante.NewFeeAbstractionMempoolFeeDecorator(options.FeeAbsKeeper), ante.NewValidateBasicDecorator(), ante.NewTxTimeoutHeightDecorator(), ante.NewValidateMemoDecorator(options.AccountKeeper), diff --git a/x/feeabs/ante/ante_test.go b/x/feeabs/ante/ante_test.go index 97421996..26371915 100644 --- a/x/feeabs/ante/ante_test.go +++ b/x/feeabs/ante/ante_test.go @@ -152,7 +152,7 @@ func TestMempoolDecorator(t *testing.T) { // Construct tx and run through mempool decorator tx := suite.txBuilder.GetTx() - mempoolDecorator := ante.NewFeeAbstrationMempoolFeeDecorator(suite.feeabsKeeper) + mempoolDecorator := ante.NewFeeAbstractionMempoolFeeDecorator(suite.feeabsKeeper) antehandler := sdk.ChainAnteDecorators(mempoolDecorator) // Run the ante handler diff --git a/x/feeabs/ante/decorate.go b/x/feeabs/ante/decorate.go index 00dd9082..b801cb4a 100644 --- a/x/feeabs/ante/decorate.go +++ b/x/feeabs/ante/decorate.go @@ -195,23 +195,23 @@ func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, accAddress sdk.Acc return nil } -// FeeAbstrationMempoolFeeDecorator will check if the transaction's fee is at least as large +// FeeAbstractionMempoolFeeDecorator will check if the transaction's fee is at least as large // as the local validator's minimum gasFee (defined in validator config). // If fee is too low, decorator returns error and tx is rejected from mempool. // Note this only applies when ctx.CheckTx = true // If fee is high enough or not CheckTx, then call next AnteHandler // CONTRACT: Tx must implement FeeTx to use MempoolFeeDecorator -type FeeAbstrationMempoolFeeDecorator struct { +type FeeAbstractionMempoolFeeDecorator struct { feeabsKeeper feeabskeeper.Keeper } -func NewFeeAbstrationMempoolFeeDecorator(feeabsKeeper feeabskeeper.Keeper) FeeAbstrationMempoolFeeDecorator { - return FeeAbstrationMempoolFeeDecorator{ +func NewFeeAbstractionMempoolFeeDecorator(feeabsKeeper feeabskeeper.Keeper) FeeAbstractionMempoolFeeDecorator { + return FeeAbstractionMempoolFeeDecorator{ feeabsKeeper: feeabsKeeper, } } -func (famfd FeeAbstrationMempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { +func (famfd FeeAbstractionMempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { feeTx, ok := tx.(sdk.FeeTx) if !ok { return ctx, sdkerrors.Wrap(errorstypes.ErrTxDecode, "Tx must be a FeeTx") @@ -337,7 +337,7 @@ func (famfd FeeAbstrationMempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk return next(ctx, tx, simulate) } -func (famfd FeeAbstrationMempoolFeeDecorator) DefaultZeroFee(ctx sdk.Context) ([]sdk.DecCoin, error) { +func (famfd FeeAbstractionMempoolFeeDecorator) DefaultZeroFee(ctx sdk.Context) ([]sdk.DecCoin, error) { bondDenom, err := famfd.feeabsKeeper.GetDefaultBondDenom(ctx) if err != nil { return nil, err @@ -350,7 +350,7 @@ func (famfd FeeAbstrationMempoolFeeDecorator) DefaultZeroFee(ctx sdk.Context) ([ } // GetTxFeeRequired returns the required fees for the given FeeTx. -func (famfd FeeAbstrationMempoolFeeDecorator) GetTxFeeRequired(ctx sdk.Context, gasLimit int64) (sdk.Coins, error) { +func (famfd FeeAbstractionMempoolFeeDecorator) GetTxFeeRequired(ctx sdk.Context, gasLimit int64) (sdk.Coins, error) { var ( minGasPrices sdk.DecCoins err error diff --git a/x/feeabs/spec/Integration.md b/x/feeabs/spec/Integration.md index 6841027d..23812835 100644 --- a/x/feeabs/spec/Integration.md +++ b/x/feeabs/spec/Integration.md @@ -167,14 +167,14 @@ Projects that want to integrate the fee-abstraction module onto their Cosmos SDK To allow for this, we use modified versions of `MempoolFeeDecorator` and `DeductFeeDecorate`. In these ante handlers, IBC tokens are swapped to the native token before the next fee handler logic is executed. - If a blockchain uses the Fee Abstraction module, it is necessary to replace the `MempoolFeeDecorator` and `DeductFeeDecorate` with the `FeeAbstrationMempoolFeeDecorator` and `FeeAbstractionDeductFeeDecorate`, respectively. These can be found in `app/ante.go`, and should be implemented as below: + If a blockchain uses the Fee Abstraction module, it is necessary to replace the `MempoolFeeDecorator` and `DeductFeeDecorate` with the `FeeAbstractionMempoolFeeDecorator` and `FeeAbstractionDeductFeeDecorate`, respectively. These can be found in `app/ante.go`, and should be implemented as below: Example: ``` anteDecorators := []sdk.AnteDecorator{ ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first ante.NewRejectExtensionOptionsDecorator(), - feeabsante.NewFeeAbstrationMempoolFeeDecorator(options.FeeAbskeeper), + feeabsante.NewFeeAbstractionMempoolFeeDecorator(options.FeeAbskeeper), ante.NewValidateBasicDecorator(), ante.NewTxTimeoutHeightDecorator(), ante.NewValidateMemoDecorator(options.AccountKeeper), diff --git a/x/feeabs/spec/README.md b/x/feeabs/spec/README.md index f6149d54..c3d8aa8a 100644 --- a/x/feeabs/spec/README.md +++ b/x/feeabs/spec/README.md @@ -1,6 +1,6 @@ ## Abstract -When making a transactions, usually users need to pay fees in native token, but `Feeabs` module enable users on any Cosmos chain which implements this module with IBC connections to pay fee using ibc token. When users use an ibc denom as fees, the ``FeeAbstrationMempoolFeeDecorator`` ante handler will check whether the chain support the transactions to be paid by that ibc denom. It will calculate the amount of ibc tokens equivalent to native token when users make a normal transaction based on Osmosis ``twap`` between ibc denom and native denom. +When making a transactions, usually users need to pay fees in native token, but `Feeabs` module enable users on any Cosmos chain which implements this module with IBC connections to pay fee using ibc token. When users use an ibc denom as fees, the ``FeeAbstractionMempoolFeeDecorator`` ante handler will check whether the chain support the transactions to be paid by that ibc denom. It will calculate the amount of ibc tokens equivalent to native token when users make a normal transaction based on Osmosis ``twap`` between ibc denom and native denom. After that, the ``FeeAbstractionDeductFeeDecorate`` ante handler swaps ibc token for native token to pay for transaction fees. The accumulated ibc token will be swaped on Osmosis Dex every epoch.