1
1
import React , { useState , useEffect , useMemo } from "react" ;
2
2
import { usePluginData } from "@docusaurus/useGlobalData" ;
3
+ import BrowserOnly from "@docusaurus/BrowserOnly" ;
3
4
import ldClient from "launchdarkly" ;
5
+ import { MetaMaskProvider } from "@metamask/sdk-react" ;
4
6
import { useLocation } from "@docusaurus/router" ;
5
7
import Layout from "@theme-original/Layout" ;
6
8
import ParserOpenRPC from "@site/src/components/ParserOpenRPC" ;
@@ -15,6 +17,32 @@ const EXEPT_METHODS = [
15
17
"eth_signTypedData_v4" ,
16
18
] ;
17
19
20
+ const MetaMaskWrapper = ( { children } ) => {
21
+ return (
22
+ < BrowserOnly >
23
+ { ( ) => (
24
+ < MetaMaskProvider
25
+ debug = { false }
26
+ sdkOptions = { {
27
+ checkInstallationOnAllCalls : true ,
28
+ extensionOnly : true ,
29
+ preferDesktop : true ,
30
+ logging : {
31
+ sdk : false ,
32
+ } ,
33
+ dappMetadata : {
34
+ name : "Reference pages" ,
35
+ url : window . location . href ,
36
+ } ,
37
+ } }
38
+ >
39
+ { children }
40
+ </ MetaMaskProvider >
41
+ ) }
42
+ </ BrowserOnly >
43
+ ) ;
44
+ } ;
45
+
18
46
export default function LayoutWrapper ( { children } ) {
19
47
const location = useLocation ( ) ;
20
48
const { netData } = usePluginData ( "plugin-json-rpc" ) as {
@@ -58,20 +86,21 @@ export default function LayoutWrapper({ children }) {
58
86
59
87
if ( ! referencePageName ) {
60
88
return (
61
- < Layout > { children } </ Layout >
62
- )
89
+ < MetaMaskWrapper >
90
+ < Layout > { children } </ Layout >
91
+ </ MetaMaskWrapper >
92
+ ) ;
63
93
}
64
94
65
95
return (
66
96
< >
67
- {
68
- ! ldReady ? null : (
69
- < >
70
- {
71
- newReferenceEnabled ? (
72
- < Layout >
73
- < div className = { styles . pageWrapper } >
74
- { children ?. props ?. children [ 0 ] ?. type === "aside" && (
97
+ { ! ldReady ? null : (
98
+ < >
99
+ { newReferenceEnabled ? (
100
+ < MetaMaskWrapper >
101
+ < Layout >
102
+ < div className = { styles . pageWrapper } >
103
+ { children ?. props ?. children [ 0 ] ?. type === "aside" && (
75
104
< > { children . props . children [ 0 ] } </ >
76
105
) }
77
106
< div className = { styles . mainContainer } >
@@ -84,13 +113,12 @@ export default function LayoutWrapper({ children }) {
84
113
</ div >
85
114
</ div >
86
115
</ Layout >
87
- ) : (
88
- < Layout > { children } </ Layout >
89
- )
90
- }
91
- </ >
92
- )
93
- }
116
+ </ MetaMaskWrapper >
117
+ ) : (
118
+ < Layout > { children } </ Layout >
119
+ ) }
120
+ </ >
121
+ ) }
94
122
</ >
95
- )
123
+ ) ;
96
124
}
0 commit comments