Skip to content

Commit

Permalink
bring changes from #193
Browse files Browse the repository at this point in the history
  • Loading branch information
tuantran1702 committed May 28, 2024
1 parent 65bf377 commit 9e1b55e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions x/feeabs/ante/decorate.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ func (fadfd FeeAbstractionDeductFeeDecorate) abstractionDeductFeeHandler(ctx sdk
return ctx, sdkerrors.Wrap(feeabstypes.ErrHostZoneFrozen, "cannot deduct fee as host zone is frozen")
}

if hostChainConfig.Status == feeabstypes.HostChainFeeAbsStatus_OUTDATED {
return ctx, sdkerrors.Wrap(feeabstypes.ErrHostZoneOutdated, "cannot deduct fee as host zone is outdated")
}
// if hostChainConfig.Status == feeabstypes.HostChainFeeAbsStatus_OUTDATED {
// return ctx, sdkerrors.Wrap(feeabstypes.ErrHostZoneOutdated, "cannot deduct fee as host zone is outdated")
// }

fee := feeTx.GetFee()
feePayer := feeTx.FeePayer()
Expand Down Expand Up @@ -278,15 +278,17 @@ func (famfd FeeAbstrationMempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk
return ctx, sdkerrors.Wrapf(feeabstypes.ErrHostZoneFrozen, "cannot deduct fee as host zone is frozen")
}

if hostChainConfig.Status == feeabstypes.HostChainFeeAbsStatus_OUTDATED {
return ctx, sdkerrors.Wrapf(feeabstypes.ErrHostZoneOutdated, "cannot deduct fee as host zone is outdated")
}
// if hostChainConfig.Status == feeabstypes.HostChainFeeAbsStatus_OUTDATED {
// return ctx, sdkerrors.Wrapf(feeabstypes.ErrHostZoneOutdated, "cannot deduct fee as host zone is outdated")
// }

nativeCoinsFees, err := famfd.feeabsKeeper.CalculateNativeFromIBCCoins(ctx, feeCoinsNonZeroDenom, hostChainConfig)
if err != nil {
return ctx, sdkerrors.Wrapf(errorstypes.ErrInsufficientFee, "insufficient fees")
return ctx, sdkerrors.Wrapf(errorstypes.ErrInsufficientFee, "unable to calculate native fees from ibc fees: %s", err)
}
feeCoinsNonZeroDenom = nativeCoinsFees
} else if feeCoinsNonZeroDenom.Len() > 1 {
return ctx, sdkerrors.Wrapf(errorstypes.ErrNotSupported, "should have only one fee denom in feeCoinsNonZeroDenom, got %d", feeCoinsNonZeroDenom.Len())
}
}

Expand All @@ -307,8 +309,9 @@ func (famfd FeeAbstrationMempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk
}

if feeCoinsLen == 0 {
return ctx, sdkerrors.Wrapf(errorstypes.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, feeRequired)
return ctx, sdkerrors.Wrapf(errorstypes.ErrInsufficientFee, "no fee provided, required: %s", feeRequired)
}

// After all the checks, the tx is confirmed:
// feeCoins denoms subset off feeRequired (or replaced with fee-abstraction)
// Not bypass
Expand Down

0 comments on commit 9e1b55e

Please sign in to comment.