Skip to content

Commit

Permalink
Merge pull request #251 from ubq-testing/fix/view-claim
Browse files Browse the repository at this point in the history
Fix/view claim
  • Loading branch information
0x4007 authored Jun 17, 2024
2 parents 114e59a + f703fb6 commit aa003e2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
9 changes: 9 additions & 0 deletions cypress/e2e/claim-portal-success.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ describe("Claims Portal Success", () => {
// anvil confirms it instantly so there is two notifications
cy.get("body").should("contain.text", "Transaction sent");
cy.get("body").should("contain.text", "Claim Complete");

cy.window().then((win) => {
win.open = cy.stub().as("open");
});

cy.get("#view-claim").invoke("click")
.then(() => {
cy.get("@open").should("be.calledWithMatch", /https:\/\/blockscan.com\/tx/);
});
});
});

Expand Down
1 change: 0 additions & 1 deletion static/scripts/rewards/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { grid } from "./the-grid";

displayCommitHash(); // @DEV: display commit hash in footer
grid(document.getElementById("grid") as HTMLElement, gridLoadedCallback); // @DEV: display grid background

readClaimDataFromUrl(app).catch(console.error); // @DEV: read claim data from URL

declare const commitHash: string; // @DEV: passed in at build time check build/esbuild-build.ts
Expand Down
7 changes: 6 additions & 1 deletion static/scripts/rewards/web3/erc20-permit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { erc20Abi, permit2Abi } from "../abis";
import { app, AppState } from "../app-state";
import { permit2Address } from "@ubiquity-dao/rpc-handler";
import { supabase } from "../render-transaction/read-claim-data-from-url";
import { MetaMaskError, buttonController, errorToast, getMakeClaimButton, toaster } from "../toaster";
import { MetaMaskError, buttonController, errorToast, getMakeClaimButton, toaster, viewClaimButton } from "../toaster";
import { connectWallet } from "./connect-wallet";

export async function fetchTreasury(permit: Permit): Promise<{ balance: BigNumber; allowance: BigNumber; decimals: number; symbol: string }> {
Expand Down Expand Up @@ -100,12 +100,17 @@ 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);


return receipt;
} catch (error: unknown) {
if (error instanceof Error) {
Expand Down

0 comments on commit aa003e2

Please sign in to comment.