From 1203f0f421a1133e4ef9d8cdeb4974b5325ef2e3 Mon Sep 17 00:00:00 2001 From: expertdicer Date: Tue, 9 Jul 2024 13:36:45 +0700 Subject: [PATCH] add comment and rename var --- x/tax2gas/post/post.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/x/tax2gas/post/post.go b/x/tax2gas/post/post.go index 1b24ff37..a477ac55 100644 --- a/x/tax2gas/post/post.go +++ b/x/tax2gas/post/post.go @@ -52,7 +52,7 @@ func (dd Tax2gasPostDecorator) PostHandle(ctx sdk.Context, tx sdk.Tx, simulate b ctx.GasMeter().ConsumeGas(taxGas, "tax gas") gasConsumed := ctx.GasMeter().GasConsumed() - taxRequired, err := dd.tax2gasKeeper.ComputeTaxOnGasConsumed(ctx, tx, dd.treasuryKeeper, gasConsumed) + gasConsumedTax, err := dd.tax2gasKeeper.ComputeTaxOnGasConsumed(ctx, tx, dd.treasuryKeeper, gasConsumed) if err != nil { return ctx, err } @@ -62,14 +62,16 @@ func (dd Tax2gasPostDecorator) PostHandle(ctx sdk.Context, tx sdk.Tx, simulate b } var requiredFees sdk.Coins - if taxRequired != nil && feeCoins != nil { - requiredFees = taxRequired.Sub(paidFeeCoins...) + if gasConsumedTax != nil && feeCoins != nil { + // Remove the paid fee coins in ante handler + requiredFees = gasConsumedTax.Sub(paidFeeCoins...) // Check if fee coins contains at least one coin that can cover required fees if !feeCoins.IsAnyGTE(requiredFees) { return ctx, errorsmod.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %q, required: %q", feeCoins, requiredFees) } + // Get fee denom identified in ante handler feeDenom, ok := ctx.Value(types.FeeDenom).(string) if !ok { return ctx, errorsmod.Wrap(types.ErrParsing, "Error parsing fee denom") @@ -79,11 +81,6 @@ func (dd Tax2gasPostDecorator) PostHandle(ctx sdk.Context, tx sdk.Tx, simulate b if !found { return ctx, errorsmod.Wrapf(types.ErrCoinNotFound, "can'f find %s in %s", feeDenom, requiredFees) } - remainingCoins := feeCoins.Sub(requiredFee) - - if !remainingCoins.IsValid() { - return ctx, errorsmod.Wrapf(sdkerrors.ErrInvalidCoins, "invalid remaining coins amount: %s", remainingCoins) - } feePayer := dd.accountKeeper.GetAccount(ctx, feeTx.FeePayer())