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 1/3] 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; From a23b60212fa4c0706ebbe967577e7b93b61cb79c Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Fri, 30 Aug 2024 11:12:22 +0100 Subject: [PATCH 2/3] chore: fix cspell --- .cspell.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.cspell.json b/.cspell.json index fd192d49..216070ff 100644 --- a/.cspell.json +++ b/.cspell.json @@ -41,7 +41,8 @@ "URLSAFE", "WXDAI", "XDAI", - "xmark" + "xmark", + "outfile" ], "dictionaries": ["typescript", "node", "software-terms", "html"], "import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"], From cba5b51e801eea74594d50b34fb7019b9f8692ee Mon Sep 17 00:00:00 2001 From: Keyrxng <106303466+Keyrxng@users.noreply.github.com> Date: Sat, 7 Sep 2024 05:09:00 +0100 Subject: [PATCH 3/3] Update erc20-permit.ts --- static/scripts/rewards/web3/erc20-permit.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/static/scripts/rewards/web3/erc20-permit.ts b/static/scripts/rewards/web3/erc20-permit.ts index d5522eee..fcce270d 100644 --- a/static/scripts/rewards/web3/erc20-permit.ts +++ b/static/scripts/rewards/web3/erc20-permit.ts @@ -137,9 +137,7 @@ export function claimErc20PermitHandlerWrapper(app: AppState) { const tx: TransactionResponse = await transferFromPermit(permit2Contract, app); if (!tx) return; - viewClaimButton.onclick = () => { - window.open(`https://blockscan.com/tx/${tx.hash}`, "_blank"); - }; + viewClaimButton.onclick = () => window.open(`https://blockscan.com/tx/${tx.hash}`, "_blank"); buttonController.showViewClaim(); buttonController.hideLoader();