From 9e9fad3d43235cc810870c269bcf9c1d42745bdd Mon Sep 17 00:00:00 2001 From: Chinmay Mehta Date: Tue, 3 Oct 2023 01:05:28 +0530 Subject: [PATCH 1/2] fix: Error Context in gas_price --- x/fungible/keeper/gas_price.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x/fungible/keeper/gas_price.go b/x/fungible/keeper/gas_price.go index f492ddb2ec..16e46505f2 100644 --- a/x/fungible/keeper/gas_price.go +++ b/x/fungible/keeper/gas_price.go @@ -25,7 +25,10 @@ func (k Keeper) SetGasPrice(ctx sdk.Context, chainid *big.Int, gasPrice *big.Int return 0, sdkerrors.Wrapf(types.ErrABIGet, "SystemContractMetaData") } res, err := k.CallEVM(ctx, *abi, types.ModuleAddressEVM, oracle, BigIntZero, big.NewInt(50_000), true, false, "setGasPrice", chainid, gasPrice) - if err != nil || res.Failed() { + if err != nil { + return 0, sdkerrors.Wrapf(types.ErrABIGet, err.Error()) + } + if res.Failed() { return res.GasUsed, sdkerrors.Wrapf(types.ErrContractCall, "setGasPrice") } From bbe7985f18e50b38549a47d096fe9e214e6f6dc0 Mon Sep 17 00:00:00 2001 From: chinmaym07 Date: Sat, 14 Oct 2023 15:57:19 +0530 Subject: [PATCH 2/2] resolved comments & updated error message for setGasCoin, SetGasZetaPool Signed-off-by: chinmaym07 --- x/fungible/keeper/gas_price.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/x/fungible/keeper/gas_price.go b/x/fungible/keeper/gas_price.go index 16e46505f2..3f2ee63d28 100644 --- a/x/fungible/keeper/gas_price.go +++ b/x/fungible/keeper/gas_price.go @@ -26,10 +26,10 @@ func (k Keeper) SetGasPrice(ctx sdk.Context, chainid *big.Int, gasPrice *big.Int } res, err := k.CallEVM(ctx, *abi, types.ModuleAddressEVM, oracle, BigIntZero, big.NewInt(50_000), true, false, "setGasPrice", chainid, gasPrice) if err != nil { - return 0, sdkerrors.Wrapf(types.ErrABIGet, err.Error()) + return 0, sdkerrors.Wrapf(types.ErrContractCall, err.Error()) } if res.Failed() { - return res.GasUsed, sdkerrors.Wrapf(types.ErrContractCall, "setGasPrice") + return res.GasUsed, sdkerrors.Wrapf(types.ErrContractCall, "setGasPrice tx failed") } return res.GasUsed, nil @@ -49,8 +49,11 @@ func (k Keeper) SetGasCoin(ctx sdk.Context, chainid *big.Int, address common.Add return sdkerrors.Wrapf(types.ErrABIGet, "SystemContractMetaData") } res, err := k.CallEVM(ctx, *abi, types.ModuleAddressEVM, oracle, BigIntZero, nil, true, false, "setGasCoinZRC20", chainid, address) - if err != nil || res.Failed() { - return sdkerrors.Wrapf(types.ErrContractCall, "setGasCoinZRC20") + if err != nil { + return sdkerrors.Wrapf(types.ErrContractCall, err.Error()) + } + if res.Failed() { + return sdkerrors.Wrapf(types.ErrContractCall, "setGasCoinZRC20 tx failed") } return nil @@ -70,8 +73,11 @@ func (k Keeper) SetGasZetaPool(ctx sdk.Context, chainid *big.Int, pool common.Ad return sdkerrors.Wrapf(types.ErrABIGet, "SystemContractMetaData") } res, err := k.CallEVM(ctx, *abi, types.ModuleAddressEVM, oracle, BigIntZero, nil, true, false, "setGasZetaPool", chainid, pool) - if err != nil || res.Failed() { - return sdkerrors.Wrapf(types.ErrContractCall, "setGasZetaPool") + if err != nil { + return sdkerrors.Wrapf(types.ErrContractCall, err.Error()) + } + if res.Failed() { + return sdkerrors.Wrapf(types.ErrContractCall, "setGasZetaPool tx failed") } return nil