Skip to content

Commit

Permalink
fix: gasLimit
Browse files Browse the repository at this point in the history
  • Loading branch information
cs1707 committed Jul 16, 2024
1 parent cb58bf3 commit 690edfa
Showing 1 changed file with 8 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,55 +40,17 @@ export const useDbkChainBridge = ({
const [payAmount, setPayAmount] = useState('');
const account = useCurrentAccount();

const buildInitiateWithdrawal = useMemoizedFn(async () => {
try {
const args = await clientL1.buildInitiateWithdrawal({
account: account!.address as any,
to: account!.address as any,
value: parseEther(payAmount),
});
return args;
} catch (e) {
console.error(e);
return {
account: account!.address as any,
request: {
data: undefined,
// https://github.com/superbridgeapp/superbridge-app/blob/main/apps/bridge/hooks/use-transaction-args/withdraw-args/use-optimism-withdraw-args.ts#L58
gas: BigInt(200_000),
to: account!.address as any,
value: parseEther(payAmount),
},
};
}
});

const buildDepositTransactionGas = useMemoizedFn(async () => {
try {
const args = await clientL2.buildDepositTransaction({
account: (account!.address as unknown) as `0x${string}`,
mint: parseEther(payAmount),
to: (account!.address as unknown) as `0x${string}`,
});
return args.request.gas;
} catch (e) {
console.error(e);
return BigInt(200_000);
}
});

const _handleDeposit = useMemoizedFn(async () => {
if (!account?.address) {
return;
}
try {
const l2Gas = await buildDepositTransactionGas();
const contract = getContract({
abi: l1StandardBridgeABI,
address: DBK_CHAIN_BRIDGE_CONTRACT,
client: clientL1,
});
const hash = await contract.write.depositETH([Number(l2Gas), '0x'], {
const hash = await contract.write.depositETH([200_000, '0x'], {
account: account.address as `0x${string}`,
value: parseEther(payAmount),
gas: undefined,
Expand Down Expand Up @@ -116,9 +78,14 @@ export const useDbkChainBridge = ({
return;
}
try {
const args = await buildInitiateWithdrawal();
const hash = await clientL2.initiateWithdrawal({
...args,
account: account.address as `0x${string}`,
request: {
// https://github.com/superbridgeapp/superbridge-app/blob/main/apps/bridge/hooks/use-transaction-args/withdraw-args/use-optimism-withdraw-args.ts#L58
gas: BigInt(200_000),
to: account.address as `0x${string}`,
value: parseEther(payAmount),
},
gas: null,
});
if (hash) {
Expand Down

0 comments on commit 690edfa

Please sign in to comment.