From defce33c7491727c0c581b81c37432f961f5db6c Mon Sep 17 00:00:00 2001 From: Duong Minh Ngoc <153509244+Ngoc-Notional@users.noreply.github.com> Date: Thu, 4 Jan 2024 15:14:59 +0700 Subject: [PATCH] refactor: add frozen host zone check --- x/feeabs/ante/decorate.go | 6 ++++++ x/feeabs/types/errors.go | 1 + 2 files changed, 7 insertions(+) diff --git a/x/feeabs/ante/decorate.go b/x/feeabs/ante/decorate.go index f2fcd8b1..d22ca119 100644 --- a/x/feeabs/ante/decorate.go +++ b/x/feeabs/ante/decorate.go @@ -99,6 +99,9 @@ func (fadfd FeeAbstractionDeductFeeDecorate) normalDeductFeeAnteHandle(ctx sdk.C } func (fadfd FeeAbstractionDeductFeeDecorate) abstractionDeductFeeHandler(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler, feeTx sdk.FeeTx, hostChainConfig feeabstypes.HostChainFeeAbsConfig) (newCtx sdk.Context, err error) { + if hostChainConfig.Frozen { + return ctx, sdkerrors.Wrap(feeabstypes.ErrHostZoneFrozen, "cannot deduct fee as host zone is frozen") + } fee := feeTx.GetFee() feePayer := feeTx.FeePayer() feeGranter := feeTx.FeeGranter() @@ -251,6 +254,9 @@ func (famfd FeeAbstrationMempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk hasHostChainConfig := famfd.feeabsKeeper.HasHostZoneConfig(ctx, feeDenom) if hasHostChainConfig { hostChainConfig, _ := famfd.feeabsKeeper.GetHostZoneConfig(ctx, feeDenom) + if hostChainConfig.Frozen { + return ctx, sdkerrors.Wrapf(feeabstypes.ErrHostZoneFrozen, "cannot deduct fee as host zone is frozen") + } nativeCoinsFees, err := famfd.feeabsKeeper.CalculateNativeFromIBCCoins(ctx, feeCoins, hostChainConfig) if err != nil { return ctx, sdkerrors.Wrapf(errorstypes.ErrInsufficientFee, "insufficient fees") diff --git a/x/feeabs/types/errors.go b/x/feeabs/types/errors.go index cd456af4..806e31f0 100644 --- a/x/feeabs/types/errors.go +++ b/x/feeabs/types/errors.go @@ -11,4 +11,5 @@ var ( ErrDuplicateHostZoneConfig = sdkerrors.Register(ModuleName, 4, "duplicate host zone config") ErrNotEnoughFundInModuleAddress = sdkerrors.Register(ModuleName, 5, "not have funding yet") ErrUnsupportedDenom = sdkerrors.Register(ModuleName, 6, "unsupported denom") + ErrHostZoneFrozen = sdkerrors.Register(ModuleName, 7, "host zone is frozen") )