From e815844700c28ef4bad73299f69518a1c68886dc Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Fri, 22 Nov 2024 18:24:59 +0300 Subject: [PATCH] gas limit --- examples/swap/contracts/Swap.sol | 12 +++++++++--- examples/swap/contracts/SwapToAnyToken.sol | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/examples/swap/contracts/Swap.sol b/examples/swap/contracts/Swap.sol index 2165fdc..49d9aec 100644 --- a/examples/swap/contracts/Swap.sol +++ b/examples/swap/contracts/Swap.sol @@ -15,6 +15,7 @@ contract Swap is UniversalContract { address public immutable uniswapRouter; GatewayZEVM public gateway; uint256 constant BITCOIN = 18332; + uint256 public gasLimit; error InvalidAddress(); error Unauthorized(); @@ -24,11 +25,16 @@ contract Swap is UniversalContract { _; } - constructor(address payable gatewayAddress, address uniswapRouterAddress) { + constructor( + address payable gatewayAddress, + address uniswapRouterAddress, + uint256 gasLimitAmount + ) { if (gatewayAddress == address(0) || uniswapRouterAddress == address(0)) revert InvalidAddress(); uniswapRouter = uniswapRouterAddress; gateway = GatewayZEVM(gatewayAddress); + gasLimit = gasLimitAmount; } struct Params { @@ -123,7 +129,7 @@ contract Swap is UniversalContract { callOnRevert: true, abortAddress: address(0), revertMessage: abi.encode(sender, inputToken), - onRevertGasLimit: 100000 + onRevertGasLimit: gasLimit }) ); } @@ -147,7 +153,7 @@ contract Swap is UniversalContract { callOnRevert: false, abortAddress: address(0), revertMessage: "", - onRevertGasLimit: 0 + onRevertGasLimit: gasLimit }) ); } diff --git a/examples/swap/contracts/SwapToAnyToken.sol b/examples/swap/contracts/SwapToAnyToken.sol index 22c2229..4ed32d6 100644 --- a/examples/swap/contracts/SwapToAnyToken.sol +++ b/examples/swap/contracts/SwapToAnyToken.sol @@ -16,6 +16,7 @@ contract SwapToAnyToken is UniversalContract { address public immutable uniswapRouter; GatewayZEVM public gateway; uint256 constant BITCOIN = 18332; + uint256 public gasLimit; error InvalidAddress(); error Unauthorized(); @@ -25,11 +26,16 @@ contract SwapToAnyToken is UniversalContract { _; } - constructor(address payable gatewayAddress, address uniswapRouterAddress) { + constructor( + address payable gatewayAddress, + address uniswapRouterAddress, + uint256 gasLimitAmount + ) { if (gatewayAddress == address(0) || uniswapRouterAddress == address(0)) revert InvalidAddress(); uniswapRouter = uniswapRouterAddress; gateway = GatewayZEVM(gatewayAddress); + gasLimit = gasLimitAmount; } struct Params { @@ -163,7 +169,7 @@ contract SwapToAnyToken is UniversalContract { callOnRevert: true, abortAddress: address(0), revertMessage: abi.encode(sender, inputToken), - onRevertGasLimit: 0 + onRevertGasLimit: gasLimit }) ); } else { @@ -194,7 +200,7 @@ contract SwapToAnyToken is UniversalContract { callOnRevert: false, abortAddress: address(0), revertMessage: "", - onRevertGasLimit: 0 + onRevertGasLimit: gasLimit }) ); }