diff --git a/cypress/e2e/claim-portal-success.cy.ts b/cypress/e2e/claim-portal-success.cy.ts index 16f13255..9f0b1bb5 100644 --- a/cypress/e2e/claim-portal-success.cy.ts +++ b/cypress/e2e/claim-portal-success.cy.ts @@ -2,7 +2,6 @@ import { JsonRpcProvider, JsonRpcSigner } from "@ethersproject/providers"; import { Wallet } from "ethers"; -const beneficiary = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"; // anvil const SENDER_PRIVATE_KEY = "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"; // anvil describe("Claims Portal Success", () => { @@ -11,7 +10,6 @@ describe("Claims Portal Success", () => { cy.clearAllLocalStorage(); cy.clearAllSessionStorage(); setupStubs(); - setupIntercepts(); cy.visit(`/${claimUrl}`); @@ -61,11 +59,33 @@ describe("Claims Portal Success", () => { cy.get("body").should("contain.text", "This reward is not for you"); }); }); + + describe("Invalidate nonce", () => { + beforeEach(() => { + setupStubs(1); + }); + + it("should successfully invalidate a nonce", () => { + cy.visit(`/${notMeantForYouPermit}`).then(() => { + cy.wait(2000); + }); + cy.get("#additionalDetails", { timeout: 15000 }).should("be.visible").invoke("click"); + + cy.get('table[data-make-claim="ok"]').should("exist"); + + cy.get("#invalidator").should("be.visible").invoke("click"); + + cy.get("#claim-loader").should("not.be.visible"); + cy.get("#view-claim").should("not.be.visible"); + + cy.get("body").should("contain.text", "Nonce invalidation transaction sent"); + }); + }); }); -function setupStubs() { +function setupStubs(walletIndex = 0) { const provider = new JsonRpcProvider("http://localhost:8545"); - const signer = provider.getSigner(beneficiary); + const signer = provider.getSigner(walletIndex); const wallet = new Wallet(SENDER_PRIVATE_KEY, provider); stubEthereum(signer); diff --git a/static/scripts/rewards/render-transaction/read-claim-data-from-url.ts b/static/scripts/rewards/render-transaction/read-claim-data-from-url.ts index fefdcc15..fb911825 100644 --- a/static/scripts/rewards/render-transaction/read-claim-data-from-url.ts +++ b/static/scripts/rewards/render-transaction/read-claim-data-from-url.ts @@ -2,7 +2,6 @@ import { createClient } from "@supabase/supabase-js"; import { decodePermits } from "@ubiquibot/permit-generation/handlers"; import { Permit } from "@ubiquibot/permit-generation/types"; import { app, AppState } from "../app-state"; -import { useFastestRpc } from "../rpc-optimization/get-optimal-provider"; import { toaster } from "../toaster"; import { connectWallet } from "../web3/connect-wallet"; import { checkRenderInvalidatePermitAdminControl, checkRenderMakeClaimControl } from "../web3/erc20-permit"; diff --git a/static/scripts/rewards/web3/erc20-permit.ts b/static/scripts/rewards/web3/erc20-permit.ts index dfc3de2c..90f1b199 100644 --- a/static/scripts/rewards/web3/erc20-permit.ts +++ b/static/scripts/rewards/web3/erc20-permit.ts @@ -255,7 +255,7 @@ invalidateButton.addEventListener("click", async function invalidateButtonClickH } if (!app.signer) return; - await invalidateNonce(app.signer, app.reward.permit.nonce); + await invalidateNonce(app.signer, app.reward.nonce); } catch (error: unknown) { if (error instanceof Error) { const e = error as unknown as MetaMaskError;