Skip to content

Commit

Permalink
Merge pull request #231 from ubq-testing/fix/invalidate-nonce
Browse files Browse the repository at this point in the history
fix: prop access and added test
  • Loading branch information
rndquu authored May 31, 2024
2 parents 03ac1d3 + f6b6f85 commit eccb5f0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 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
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 eccb5f0

Please sign in to comment.