From f6deac30462736a48e86f4929ecae23bd394fdf5 Mon Sep 17 00:00:00 2001 From: Jeffery Walsh Date: Tue, 17 Jan 2023 06:27:51 -0800 Subject: [PATCH 1/2] bridge estimate gas --- packages/bridge-ui/src/erc20/bridge.ts | 15 ++++++++------- packages/bridge-ui/src/eth/bridge.ts | 18 +++++++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/packages/bridge-ui/src/erc20/bridge.ts b/packages/bridge-ui/src/erc20/bridge.ts index d8a79d1844..f060cc9964 100644 --- a/packages/bridge-ui/src/erc20/bridge.ts +++ b/packages/bridge-ui/src/erc20/bridge.ts @@ -39,7 +39,7 @@ class ERC20Bridge implements Bridge { callValue: 0, processingFee: opts.processingFeeInWei ?? BigNumber.from(0), gasLimit: opts.processingFeeInWei - ? BigNumber.from(100000) + ? BigNumber.from(140000) : BigNumber.from(0), memo: opts.memo ?? "", }; @@ -103,7 +103,9 @@ class ERC20Bridge implements Bridge { throw Error("token vault does not have required allowance"); } - const { contract, owner, message } = await ERC20Bridge.prepareTransaction(opts); + const { contract, owner, message } = await ERC20Bridge.prepareTransaction( + opts + ); const tx = await contract.sendERC20( message.destChainId, @@ -123,8 +125,9 @@ class ERC20Bridge implements Bridge { } async EstimateGas(opts: BridgeOpts): Promise { - - const { contract, owner, message } = await ERC20Bridge.prepareTransaction(opts); + const { contract, owner, message } = await ERC20Bridge.prepareTransaction( + opts + ); const gasEstimate = await contract.estimateGas.sendERC20( message.destChainId, @@ -178,9 +181,7 @@ class ERC20Bridge implements Bridge { chains[opts.message.destChainId.toNumber()].headerSyncAddress, }); - return await contract.processMessage(opts.message, proof, { - gasLimit: BigNumber.from(1200000), - }); + return await contract.processMessage(opts.message, proof); } else { return await contract.retryMessage(opts.message, false); } diff --git a/packages/bridge-ui/src/eth/bridge.ts b/packages/bridge-ui/src/eth/bridge.ts index a0cccdef86..bc9c0937df 100644 --- a/packages/bridge-ui/src/eth/bridge.ts +++ b/packages/bridge-ui/src/eth/bridge.ts @@ -19,7 +19,9 @@ class ETHBridge implements BridgeInterface { this.prover = prover; } - static async prepareTransaction(opts: BridgeOpts): Promise<{contract: Contract, message: any, owner: string}> { + static async prepareTransaction( + opts: BridgeOpts + ): Promise<{ contract: Contract; message: any; owner: string }> { const contract: Contract = new Contract( opts.tokenVaultAddress, TokenVault, @@ -38,7 +40,7 @@ class ETHBridge implements BridgeInterface { callValue: 0, processingFee: opts.processingFeeInWei ?? BigNumber.from(0), gasLimit: opts.processingFeeInWei - ? BigNumber.from(100000) + ? BigNumber.from(140000) : BigNumber.from(0), memo: opts.memo ?? "", }; @@ -56,7 +58,9 @@ class ETHBridge implements BridgeInterface { } async Bridge(opts: BridgeOpts): Promise { - const { contract, owner, message } = await ETHBridge.prepareTransaction(opts); + const { contract, owner, message } = await ETHBridge.prepareTransaction( + opts + ); const tx = await contract.sendEther( message.destChainId, @@ -76,7 +80,9 @@ class ETHBridge implements BridgeInterface { } async EstimateGas(opts: BridgeOpts): Promise { - const { contract, owner, message } = await ETHBridge.prepareTransaction(opts); + const { contract, owner, message } = await ETHBridge.prepareTransaction( + opts + ); const gasEstimate = await contract.estimateGas.sendEther( message.destChainId, @@ -129,9 +135,7 @@ class ETHBridge implements BridgeInterface { const proof = await this.prover.GenerateProof(proofOpts); - return await contract.processMessage(opts.message, proof, { - gasLimit: BigNumber.from(1000000), - }); + return await contract.processMessage(opts.message, proof); } else { return await contract.retryMessage(opts.message); } From d8ec071b3065a58391d62efde71e15c5ad609db8 Mon Sep 17 00:00:00 2001 From: Jeffery Walsh Date: Tue, 17 Jan 2023 06:31:45 -0800 Subject: [PATCH 2/2] test --- packages/bridge-ui/src/erc20/bridge.spec.ts | 2 +- packages/bridge-ui/src/eth/bridge.spec.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/bridge-ui/src/erc20/bridge.spec.ts b/packages/bridge-ui/src/erc20/bridge.spec.ts index f9c94170a7..d618661223 100644 --- a/packages/bridge-ui/src/erc20/bridge.spec.ts +++ b/packages/bridge-ui/src/erc20/bridge.spec.ts @@ -199,7 +199,7 @@ describe("bridge tests", () => { "0xfake", opts.tokenAddress, opts.amountInWei, - BigNumber.from(100000), + BigNumber.from(140000), opts.processingFeeInWei, "0xfake", opts.memo, diff --git a/packages/bridge-ui/src/eth/bridge.spec.ts b/packages/bridge-ui/src/eth/bridge.spec.ts index f398f5ef1b..043b5286e6 100644 --- a/packages/bridge-ui/src/eth/bridge.spec.ts +++ b/packages/bridge-ui/src/eth/bridge.spec.ts @@ -88,7 +88,7 @@ describe("bridge tests", () => { expect(mockContract.sendEther).toHaveBeenCalledWith( opts.toChainId, wallet.getAddress(), - BigNumber.from(100000), + BigNumber.from(140000), opts.processingFeeInWei, wallet.getAddress(), "memo",