-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,239 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,18 @@ | ||
import React from "react"; | ||
import Link from "@docusaurus/Link"; | ||
import styles from "./styles.module.css"; | ||
import global from "../global.module.css"; | ||
import { EIP6963ProviderDetail } from "@site/src/hooks/store.ts"; | ||
|
||
interface AuthBoxProps { | ||
metamaskProviders: any; | ||
handleConnect: (i) => void; | ||
selectedProvider?: number; | ||
handleConnect: () => void; | ||
} | ||
|
||
const MetamaskInstallMessage = () => ( | ||
<div className={styles.msgWrapper}> | ||
<strong className={styles.msgHeading}>Install MetaMask</strong> | ||
<p className={styles.msgText}> | ||
Install MetaMask for your browser to enable interactive features | ||
</p> | ||
<Link className={global.primaryBtn} href="https://metamask.io/download/"> | ||
Install MetaMask | ||
</Link> | ||
</div> | ||
); | ||
|
||
export const AuthBox = ({ | ||
metamaskProviders = [], | ||
selectedProvider, | ||
handleConnect, | ||
}: AuthBoxProps) => { | ||
if (metamaskProviders.length === 0) { | ||
return <MetamaskInstallMessage />; | ||
} | ||
|
||
if (metamaskProviders.length > 0) { | ||
return null; | ||
} | ||
|
||
export const AuthBox = ({ handleConnect }: AuthBoxProps) => { | ||
return ( | ||
<div className={styles.msgWrapper}> | ||
<p>Select a MetaMask provider to use interactive features:</p> | ||
<div className={styles.mmBtnRow}> | ||
{metamaskProviders.map((provider: EIP6963ProviderDetail, i) => ( | ||
<div key={provider.info.uuid} className={styles.mmBtnCol}> | ||
<button className={styles.mmBtn} onClick={() => handleConnect(i)}> | ||
<img | ||
src={provider.info.icon} | ||
alt={provider.info.name} | ||
width="30" | ||
/> | ||
<div className="padding-left--md">{provider.info.name}</div> | ||
{selectedProvider === i && ( | ||
<span className={styles.mmBtnCheck}>✓</span> | ||
)} | ||
</button> | ||
</div> | ||
))} | ||
</div> | ||
<p className={styles.msgText}>Connect MetaMask to test requests using your wallet</p> | ||
<button className={global.primaryBtn} onClick={() => handleConnect()}> | ||
Connect MetaMask | ||
</button> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React, { ReactChild } from "react"; | ||
import { MetaMaskProvider } from '@metamask/sdk-react'; | ||
import BrowserOnly from '@docusaurus/BrowserOnly'; | ||
|
||
export default function Root({ children }: { children: ReactChild}) { | ||
return ( | ||
<BrowserOnly fallback={<div>Loading...</div>}> | ||
{ | ||
() => { | ||
return ( | ||
<MetaMaskProvider debug={false} sdkOptions={{ | ||
logging:{ | ||
developerMode: false, | ||
}, | ||
checkInstallationImmediately: false, | ||
dappMetadata: { | ||
name: "New mm app", | ||
url: "https://docs.metamask.io/", | ||
}, | ||
preferDesktop: true | ||
}}> | ||
{children} | ||
</MetaMaskProvider> | ||
) | ||
} | ||
} | ||
</BrowserOnly> | ||
); | ||
} |
Oops, something went wrong.