From bb4b8375aa3bb717837418134e0fd0a8d39b7c52 Mon Sep 17 00:00:00 2001 From: Duong Minh Ngoc <153509244+minhngoc274@users.noreply.github.com> Date: Fri, 19 Jan 2024 10:12:16 +0700 Subject: [PATCH] refactor: add frozen host zone check (#124) Co-authored-by: Duong Minh Ngoc <153509244+Ngoc-Notional@users.noreply.github.com> --- x/feeabs/ante/decorate.go | 6 ++++++ x/feeabs/types/errors.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) 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 ce593e52..806e31f0 100644 --- a/x/feeabs/types/errors.go +++ b/x/feeabs/types/errors.go @@ -11,5 +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 frozen") + ErrHostZoneFrozen = sdkerrors.Register(ModuleName, 7, "host zone is frozen") )