Skip to content

Commit

Permalink
fix: add no signer toast
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed May 24, 2024
1 parent fce2188 commit edad316
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/claim-portal-failure.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("Claims Portal Failures", () => {
cy.get("#claim-loader").should("not.be.visible");
cy.get("#view-claim").should("not.be.visible").and("include.text", "View Claim");

cy.get("body").should("contain.text", "This reward is not for you");
cy.get("body").should("contain.text", "Please connect your wallet to claim this reward.");
});
});

Expand Down
10 changes: 6 additions & 4 deletions static/scripts/rewards/web3/connect-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ export async function connectWallet(): Promise<JsonRpcSigner | null> {

return signer;
} catch (error: unknown) {
connectErrorHandler(error);
return connectErrorHandler(error);
}
return null;
}

function connectErrorHandler(error: unknown) {
if (window.location.href.includes("localhost") && (window as any).signer) return (window as any).signer;

if (error instanceof Error) {
console.error(error);
if (error?.message?.includes("missing provider")) {
Expand All @@ -46,4 +43,9 @@ function connectErrorHandler(error: unknown) {
} else {
toaster.create("error", "An unknown error occurred.");
}

if (window.location.href.includes("localhost")) {
return (window as unknown as { signer: ethers.providers.JsonRpcSigner }).signer;
}
return null;
}
2 changes: 2 additions & 0 deletions static/scripts/rewards/web3/erc20-permit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ export function claimErc20PermitHandlerWrapper(app: AppState) {
return async function claimErc20PermitHandler() {
const signer = await connectWallet();
if (!signer) {
buttonController.hideAll();
toaster.create("error", `Please connect your wallet to claim this reward.`);
return;
}

Expand Down

0 comments on commit edad316

Please sign in to comment.