From 90b2ededd43013800b1fdfd69c4c7629ea665383 Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Fri, 30 Aug 2024 11:06:03 +0100 Subject: [PATCH] chore: optimistic view claim rendering --- static/scripts/rewards/web3/erc20-permit.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/static/scripts/rewards/web3/erc20-permit.ts b/static/scripts/rewards/web3/erc20-permit.ts index 9e1fe826..d5522eee 100644 --- a/static/scripts/rewards/web3/erc20-permit.ts +++ b/static/scripts/rewards/web3/erc20-permit.ts @@ -100,15 +100,9 @@ async function transferFromPermit(permit2Contract: Contract, app: AppState) { async function waitForTransaction(tx: TransactionResponse) { try { const receipt = await tx.wait(); - viewClaimButton.onclick = () => { - window.open(`https://blockscan.com/tx/${receipt.transactionHash}`, "_blank"); - }; - toaster.create("success", `Claim Complete.`); - buttonController.showViewClaim(); - buttonController.hideLoader(); - buttonController.hideMakeClaim(); console.log(receipt.transactionHash); + toaster.create("success", `Claim Complete.`); return receipt; } catch (error: unknown) { @@ -140,9 +134,17 @@ export function claimErc20PermitHandlerWrapper(app: AppState) { const permit2Contract = new ethers.Contract(permit2Address, permit2Abi, signer); if (!permit2Contract) return; - const tx = await transferFromPermit(permit2Contract, app); + const tx: TransactionResponse = await transferFromPermit(permit2Contract, app); if (!tx) return; + viewClaimButton.onclick = () => { + window.open(`https://blockscan.com/tx/${tx.hash}`, "_blank"); + }; + + buttonController.showViewClaim(); + buttonController.hideLoader(); + buttonController.hideMakeClaim(); + const receipt = await waitForTransaction(tx); if (!receipt) return;