Skip to content

Commit d6ad5a1

Browse files
committed
updated gas price logic after london
1 parent 402de9c commit d6ad5a1

3 files changed

Lines changed: 394 additions & 217 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"bnc-onboard": "1.19.2",
1616
"clsx": "^1.1.1",
1717
"dayjs": "^1.9.1",
18-
"ethers": "^5.0.17",
18+
"ethers": "^5.4.4",
1919
"formik": "^2.2.0",
2020
"history": "^5.0.0",
2121
"react": "^16.13.1",

src/Contexts/ChainbridgeContext.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,15 @@ const ChainbridgeProvider = ({ children }: IChainbridgeContextProps) => {
364364
homeChain.approvalContract
365365
);
366366

367+
// NOTE: gasPrice, from web3-context doesn't work anymore
368+
const gasLimit = 500000;
369+
const currentGasPrice = await signer.getGasPrice();
370+
const txGas = BigNumber.from(
371+
homeChain.defaultGasPrice ?
372+
utils.parseUnits(homeChain.defaultGasPrice.toString(),9) :
373+
currentGasPrice
374+
).toString()
375+
367376
if (Number(utils.formatUnits(currentAllowance, erc20Decimals)) < amount) {
368377
// if (
369378
// Number(utils.formatUnits(currentAllowance, erc20Decimals)) > 0 &&
@@ -390,14 +399,7 @@ const ChainbridgeProvider = ({ children }: IChainbridgeContextProps) => {
390399
await erc20.approve(
391400
homeChain.approvalContract,
392401
BigNumber.from(utils.parseUnits(amount.toString(), erc20Decimals)),
393-
{
394-
gasPrice: BigNumber.from(
395-
utils.parseUnits(
396-
(homeChain.defaultGasPrice || gasPrice).toString(),
397-
9
398-
)
399-
).toString(),
400-
}
402+
{ gasPrice: txGas, gasLimit }
401403
)
402404
).wait(1);
403405
}
@@ -420,10 +422,8 @@ const ChainbridgeProvider = ({ children }: IChainbridgeContextProps) => {
420422
token.resourceId,
421423
data,
422424
{
423-
gasPrice: utils.parseUnits(
424-
(homeChain.defaultGasPrice || gasPrice).toString(),
425-
9
426-
),
425+
gasPrice: txGas,
426+
gasLimit,
427427
value: utils.parseUnits((bridgeFee || 0).toString(), 18),
428428
}
429429
)

0 commit comments

Comments
 (0)