Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/view claim #251

Merged
merged 3 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading