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

[UN-1615] incorrect network error displayed on loading #137

Merged
merged 2 commits into from
Mar 14, 2023
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
16 changes: 12 additions & 4 deletions src/helpers/__tests__/validPayment.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ describe("Valid payments function", () => {
...params,
seller: "0x7bD733DBc10A1cD04e1e51cC89450941c928",
}),
).rejects.toThrow("seller is invalid: 0x7bD733DBc10A1cD04e1e51cC89450941c928.");
).rejects.toThrow(
"seller is invalid: 0x7bD733DBc10A1cD04e1e51cC89450941c928.",
);
});

it("Should throw an error given an invalid marketplace address ", async () => {
Expand All @@ -34,7 +36,9 @@ describe("Valid payments function", () => {
...params,
marketplace: "0x7bD733DBc10A1cD04e1e51cC89450941c928",
}),
).rejects.toThrow("marketplace is invalid: 0x7bD733DBc10A1cD04e1e51cC89450941c928.");
).rejects.toThrow(
"marketplace is invalid: 0x7bD733DBc10A1cD04e1e51cC89450941c928.",
);
});

it("Should throw an error given an invalid arbitrator address ", async () => {
Expand All @@ -43,7 +47,9 @@ describe("Valid payments function", () => {
...params,
marketplace: "0x7bD733DBc10A1cD04e1e51cC89450941c928",
}),
).rejects.toThrow("marketplace is invalid: 0x7bD733DBc10A1cD04e1e51cC89450941c928.");
).rejects.toThrow(
"marketplace is invalid: 0x7bD733DBc10A1cD04e1e51cC89450941c928.",
);
});

it("Should throw an error given an invalid token address ", async () => {
Expand All @@ -52,7 +58,9 @@ describe("Valid payments function", () => {
...params,
marketplace: "0x7bD733DBc10A1cD04e1e51cC89450941c928",
}),
).rejects.toThrow("marketplace is invalid: 0x7bD733DBc10A1cD04e1e51cC89450941c928.");
).rejects.toThrow(
"marketplace is invalid: 0x7bD733DBc10A1cD04e1e51cC89450941c928.",
);
});

it("Should throw an error given invalid amount", async () => {
Expand Down
25 changes: 14 additions & 11 deletions src/ui/internal/hooks/useNetworkCheck.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,20 @@ export const useNetworkCheck = () => {
}, [isCorrectNetwork]);

const WithNetworkCheck = React.useCallback(
(Body: JSX.Element) =>
!metamaskInstalled ? (
<ModalError
onClick={() => window.open(metamaskUrl)}
type="noMetaMask"
/>
) : isCorrectNetwork ? (
Body
) : (
<ModalError type="wrongNetwork" onClick={onNetworkSwitch} />
),
(Body: JSX.Element) => (
<>
{!metamaskInstalled && (
<ModalError
onClick={() => window.open(metamaskUrl)}
type="noMetaMask"
/>
)}
{isCorrectNetwork === false && (
<ModalError type="wrongNetwork" onClick={onNetworkSwitch} />
)}
{isCorrectNetwork && Body}
</>
),
[isCorrectNetwork, metamaskInstalled],
);

Expand Down