Skip to content

Commit

Permalink
refactor: add frozen host zone check
Browse files Browse the repository at this point in the history
  • Loading branch information
minhngoc274 authored and Duong Minh Ngoc committed Jan 17, 2024
1 parent 3a24c8e commit defce33
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions x/feeabs/ante/decorate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions x/feeabs/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)

0 comments on commit defce33

Please sign in to comment.