Skip to content

Commit

Permalink
feat: show when no browser wallet found
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Nov 15, 2024
1 parent 8f6e924 commit 207b3ca
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 3 deletions.
19 changes: 18 additions & 1 deletion src/components/ConnectWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import {
import type { EIP6963ProviderInfo } from "../consts/Types";
import { useCreateContext } from "../context/Create";
import { useGlobalContext } from "../context/Global";
import { useWeb3Signer } from "../context/Web3";
import { customDerivationPathRdns, useWeb3Signer } from "../context/Web3";
import "../style/web3.scss";
import { formatError } from "../utils/errors";
import { cropString, isMobile } from "../utils/helper";
import HardwareDerivationPaths, { connect } from "./HardwareDerivationPaths";
import Warning from "./Warning";

const Modal = (props: {
derivationPath: string;
Expand All @@ -32,6 +33,13 @@ const Modal = (props: {
const [hardwareProvider, setHardwareProvider] =
createSignal<EIP6963ProviderInfo>(undefined);

const hasBrowserWallet = createMemo(() => {
return Object.values(providers()).some(
(provider) =>
!customDerivationPathRdns.includes(provider.info.rdns),
);
});

const Provider = (providerProps: { provider: EIP6963ProviderInfo }) => {
return (
<div
Expand Down Expand Up @@ -90,6 +98,15 @@ const Modal = (props: {
<IoClose />
</span>
<hr class="spacer" />
<Show when={!hasBrowserWallet()}>
<hr />

<div class="no-browser-wallet">
<Warning />
<h3>{t("no_browser_wallet")}</h3>
</div>
<hr class="spacer" />
</Show>
<For
each={Object.values(providers()).sort((a, b) =>
a.info.name
Expand Down
5 changes: 5 additions & 0 deletions src/components/Warning.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const Warning = () => {
return <p style={{ "font-size": "46px", margin: "0" }}>⚠️</p>;
};

export default Warning;
1 change: 1 addition & 0 deletions src/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ const dict = {
wallet_connect_failed: "Wallet connection failed: {{ error }}",
ledger_open_app_prompt: "Open Ethereum or RSK app",
copy_preimage: "Copy preimage",
no_browser_wallet: "No browser wallet detected",
},
de: {
language: "Deutsch",
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Error.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import Warning from "../components/Warning";
import { useGlobalContext } from "../context/Global";

const Error = (props: { error?: string; subline?: string }) => {
const { t } = useGlobalContext();
return (
<div class="frame">
<p style={{ "font-size": "46px", margin: "0" }}>⚠️</p>
<Warning />
<hr />
<h2>{props.error || t("error")}</h2>
<p>{props.subline || t("error_subline")}</p>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/RefundStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import log from "loglevel";
import { For, createResource } from "solid-js";

import DownloadRefund from "../components/DownloadRefund";
import Warning from "../components/Warning";
import { useGlobalContext } from "../context/Global";
import { usePayContext } from "../context/Pay";
import type { DictKey } from "../i18n/i18n";
Expand Down Expand Up @@ -39,7 +40,7 @@ const RefundStep = () => {
</For>
</ul>
<hr />
<p style={{ "font-size": "46px", margin: "0" }}>⚠️</p>
<Warning />
<h3>{t("backup_refund_skip")}</h3>
<hr />
<div class="btns btns-space-between">
Expand Down
8 changes: 8 additions & 0 deletions src/style/web3.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@
height: 4rem;
min-width: 5rem;
}

.no-browser-wallet {
display: flex;
justify-content: center;
align-items: center;

gap: 1rem;
}

0 comments on commit 207b3ca

Please sign in to comment.