diff --git a/x/crosschain/keeper/msg_server_vote_inbound_tx.go b/x/crosschain/keeper/msg_server_vote_inbound_tx.go index 675051dc45..bc4b9ae8d2 100644 --- a/x/crosschain/keeper/msg_server_vote_inbound_tx.go +++ b/x/crosschain/keeper/msg_server_vote_inbound_tx.go @@ -194,6 +194,7 @@ func (k msgServer) VoteOnObservedInboundTx(goCtx context.Context, msg *types.Msg // gas payment for erc20 type might fail because no liquidity pool is defined to swap the zrc20 token into the gas token // in this gas we should refund the sender on ZetaChain if cctx.InboundTxParams.CoinType == common.CoinType_ERC20 && ethcommon.IsHexAddress(cctx.InboundTxParams.Sender) { + // Sender is verified to be a valid ethereum address if err := k.RefundAbortedAmountOnZetaChain(ctx, cctx, ethcommon.HexToAddress(cctx.InboundTxParams.Sender)); err != nil { // log the error k.Logger(ctx).Error("failed to refund amount of aborted cctx on ZetaChain", diff --git a/x/crosschain/keeper/refund.go b/x/crosschain/keeper/refund.go index e331d7acba..749fbcd2ff 100644 --- a/x/crosschain/keeper/refund.go +++ b/x/crosschain/keeper/refund.go @@ -9,7 +9,6 @@ import ( ethcommon "github.com/ethereum/go-ethereum/common" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/x/crosschain/types" - zetaObserverTypes "github.com/zeta-chain/zetacore/x/observer/types" ) func (k Keeper) RefundAbortedAmountOnZetaChain(ctx sdk.Context, cctx types.CrossChainTx, refundAddress ethcommon.Address) error { @@ -34,10 +33,6 @@ func (k Keeper) RefundAmountOnZetaChainGas(ctx sdk.Context, cctx types.CrossChai } chainID := cctx.InboundTxParams.SenderChainId amountOfGasTokenLocked := cctx.InboundTxParams.Amount - // check if chain is supported - if chain := k.zetaObserverKeeper.GetSupportedChainFromChainID(ctx, chainID); chain == nil { - return zetaObserverTypes.ErrSupportedChains - } // get the zrc20 contract address fcSenderChain, found := k.fungibleKeeper.GetGasCoinForForeignCoin(ctx, chainID) if !found { @@ -57,11 +52,10 @@ func (k Keeper) RefundAmountOnZetaChainGas(ctx sdk.Context, cctx types.CrossChai // RefundAmountOnZetaChainGas refunds the amount of the cctx on ZetaChain in case of aborted cctx with cointype zeta func (k Keeper) RefundAmountOnZetaChainZeta(ctx sdk.Context, cctx types.CrossChainTx, refundAddress ethcommon.Address) error { // if coin type is Zeta, handle this as a deposit ZETA to zEVM. - // deposit the amount to the tx origin instead of receiver as this is a refund chainID := cctx.InboundTxParams.SenderChainId - // check if chain is supported - if chain := k.zetaObserverKeeper.GetSupportedChainFromChainID(ctx, chainID); chain == nil { - return zetaObserverTypes.ErrSupportedChains + // check if chain is an EVM chain + if !common.IsEVMChain(chainID) { + return errors.New("only EVM chains are supported for refund when coin type is Zeta") } if cctx.InboundTxParams.Amount.IsNil() || cctx.InboundTxParams.Amount.IsZero() { return errors.New("no amount to refund")