Skip to content

Commit

Permalink
fix: prop access and added test
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed May 29, 2024
1 parent f09e3da commit 25555f1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
28 changes: 24 additions & 4 deletions cypress/e2e/claim-portal-success.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand All @@ -11,7 +10,6 @@ describe("Claims Portal Success", () => {
cy.clearAllLocalStorage();
cy.clearAllSessionStorage();
setupStubs();

setupIntercepts();

cy.visit(`/${claimUrl}`);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion static/scripts/rewards/web3/erc20-permit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 25555f1

Please sign in to comment.