Skip to content

Commit

Permalink
fix: hide browser native wallet when window.ethereum is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Oct 30, 2024
1 parent 374517c commit 3e4a212
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/context/Web3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,6 @@ const Web3SignerProvider = (props: {
const [providers, setProviders] = createSignal<
Record<string, EIP6963ProviderDetail>
>({
[browserRdns]: {
provider: window.ethereum,
info: {
name: "Browser native",
uuid: browserRdns,
rdns: browserRdns,
disabled: window.ethereum === undefined,
},
},
[HardwareRdns.Ledger]: {
provider: new LedgerSigner(t),
info: {
Expand Down Expand Up @@ -120,6 +111,21 @@ const Web3SignerProvider = (props: {
EIP1193Provider | undefined
>(undefined);

if (window.ethereum !== undefined) {
setProviders({
...providers(),
[browserRdns]: {
provider: window.ethereum,
info: {
name: "Browser native",
uuid: browserRdns,
rdns: browserRdns,
disabled: window.ethereum === undefined,
},
},
});
}

window.addEventListener(
"eip6963:announceProvider",
(event: EIP6963AnnounceProviderEvent) => {
Expand Down

0 comments on commit 3e4a212

Please sign in to comment.