@graphprotocol/graph-auth-kit 7.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +303 -0
  2. package/dist/Components/ConnectModal.d.ts +2 -0
  3. package/dist/Components/ConnectModal.d.ts.map +1 -0
  4. package/dist/Components/Connected.d.ts +33 -0
  5. package/dist/Components/Connected.d.ts.map +1 -0
  6. package/dist/Components/ConnectorOption.d.ts +7 -0
  7. package/dist/Components/ConnectorOption.d.ts.map +1 -0
  8. package/dist/Components/Disconnected.d.ts +28 -0
  9. package/dist/Components/Disconnected.d.ts.map +1 -0
  10. package/dist/Components/MultisigSignerOptions.d.ts +2 -0
  11. package/dist/Components/MultisigSignerOptions.d.ts.map +1 -0
  12. package/dist/Components/PrimaryConnectOptions.d.ts +2 -0
  13. package/dist/Components/PrimaryConnectOptions.d.ts.map +1 -0
  14. package/dist/Components/SafeInputForm.d.ts +2 -0
  15. package/dist/Components/SafeInputForm.d.ts.map +1 -0
  16. package/dist/Components/SafeSelection.d.ts +2 -0
  17. package/dist/Components/SafeSelection.d.ts.map +1 -0
  18. package/dist/Components/SwitchChain.d.ts +24 -0
  19. package/dist/Components/SwitchChain.d.ts.map +1 -0
  20. package/dist/Components/index.d.ts +4 -0
  21. package/dist/Components/index.d.ts.map +1 -0
  22. package/dist/GraphAuthKit.context.d.ts +130 -0
  23. package/dist/GraphAuthKit.context.d.ts.map +1 -0
  24. package/dist/GraphAuthKitInner.context-B3nCqd7x.js +629 -0
  25. package/dist/client.d.ts +12519 -0
  26. package/dist/client.d.ts.map +1 -0
  27. package/dist/constants.d.ts +366 -0
  28. package/dist/constants.d.ts.map +1 -0
  29. package/dist/ens/hooks/index.d.ts +5 -0
  30. package/dist/ens/hooks/index.d.ts.map +1 -0
  31. package/dist/ens/hooks/useGraphAuthKitAvatar.d.ts +55 -0
  32. package/dist/ens/hooks/useGraphAuthKitAvatar.d.ts.map +1 -0
  33. package/dist/ens/hooks/useGraphAuthKitAvatars.d.ts +29 -0
  34. package/dist/ens/hooks/useGraphAuthKitAvatars.d.ts.map +1 -0
  35. package/dist/ens/hooks/useGraphAuthKitEnsName.d.ts +52 -0
  36. package/dist/ens/hooks/useGraphAuthKitEnsName.d.ts.map +1 -0
  37. package/dist/ens/hooks/useGraphAuthKitEnsNames.d.ts +28 -0
  38. package/dist/ens/hooks/useGraphAuthKitEnsNames.d.ts.map +1 -0
  39. package/dist/ens/index.d.ts +2 -0
  40. package/dist/ens/index.d.ts.map +1 -0
  41. package/dist/ens/index.js +7 -0
  42. package/dist/errors.d.ts +21 -0
  43. package/dist/errors.d.ts.map +1 -0
  44. package/dist/hooks-D5Hw1GuR.js +511 -0
  45. package/dist/hooks.d.ts +125 -0
  46. package/dist/hooks.d.ts.map +1 -0
  47. package/dist/index.d.ts +11 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +141 -0
  50. package/dist/inner/GraphAuthKitInner.context.d.ts +121 -0
  51. package/dist/inner/GraphAuthKitInner.context.d.ts.map +1 -0
  52. package/dist/inner/hooks.d.ts +13 -0
  53. package/dist/inner/hooks.d.ts.map +1 -0
  54. package/dist/inner/index.d.ts +3 -0
  55. package/dist/inner/index.d.ts.map +1 -0
  56. package/dist/safe/SafeEthersSigner.d.ts +39 -0
  57. package/dist/safe/SafeEthersSigner.d.ts.map +1 -0
  58. package/dist/safe/SafeMinimal.abi.d.ts +80 -0
  59. package/dist/safe/SafeMinimal.abi.d.ts.map +1 -0
  60. package/dist/safe/constants.d.ts +27 -0
  61. package/dist/safe/constants.d.ts.map +1 -0
  62. package/dist/safe/index.d.ts +5 -0
  63. package/dist/safe/index.d.ts.map +1 -0
  64. package/dist/safe/index.js +19 -0
  65. package/dist/safe/safeViemActions.d.ts +4 -0
  66. package/dist/safe/safeViemActions.d.ts.map +1 -0
  67. package/dist/safe/useWaitForSafeTransaction.d.ts +10 -0
  68. package/dist/safe/useWaitForSafeTransaction.d.ts.map +1 -0
  69. package/dist/safe/utils.d.ts +51 -0
  70. package/dist/safe/utils.d.ts.map +1 -0
  71. package/dist/test-harness/MockGraphAuthKit.context.d.ts +103 -0
  72. package/dist/test-harness/MockGraphAuthKit.context.d.ts.map +1 -0
  73. package/dist/test-harness/index.d.ts +3 -0
  74. package/dist/test-harness/index.d.ts.map +1 -0
  75. package/dist/test-harness/index.js +6 -0
  76. package/dist/test-harness/utils.d.ts +135 -0
  77. package/dist/test-harness/utils.d.ts.map +1 -0
  78. package/dist/types.d.ts +37 -0
  79. package/dist/types.d.ts.map +1 -0
  80. package/dist/useGraphAuthKitEnsNames-DHMYvwgX.js +211 -0
  81. package/dist/useWaitForSafeTransaction-YeFsJ9A5.js +46 -0
  82. package/dist/utils-Br1fBg8o.js +897 -0
  83. package/dist/utils.d.ts +20 -0
  84. package/dist/utils.d.ts.map +1 -0
  85. package/package.json +98 -0
package/README.md ADDED
@@ -0,0 +1,303 @@
1
+ # @graphprotocol/graph-auth-kit
2
+
3
+ Authentication Kit for connecting The Graph apps/dapps to a wallet.
4
+
5
+ Relies on/requires [`wagmi`](https://wagmi.sh/) + [`viem`](https://viem.sh/) for allowing users to connect their wallets and interact with the connected auth state context.
6
+
7
+ Exposes a simple `useGraphAuthKit` hook that lets the app open the connect modal, letting users connect to their wallet of choice (one of: injected/MetaMask, coinbase, WalletConnect, Safe). See integration example below.
8
+
9
+ ## Install
10
+
11
+ Currently, `graph-auth-kit` has a lot of peer deps needed to interact with the library. But this may change after testing. At the very least, `wagmi, viem, @tanstack/react-query` will be needed.
12
+
13
+ ```bash
14
+ # with bun
15
+ bun add @graphprotocol/graph-auth-kit \
16
+ @graphprotocol/common \
17
+ @graphprotocol/gds \
18
+ @graphprotocol/go \
19
+ @emotion/react \
20
+ @tanstack/react-query \
21
+ cookies-next \
22
+ ethers@5.7.2 \
23
+ theme-ui \
24
+ viem@2.x \
25
+ wagmi
26
+
27
+ # with pnpm
28
+ pnpm add @graphprotocol/graph-auth-kit \
29
+ @graphprotocol/common \
30
+ @graphprotocol/gds \
31
+ @graphprotocol/go \
32
+ @emotion/react \
33
+ @tanstack/react-query \
34
+ cookies-next \
35
+ ethers@5.7.2 \
36
+ theme-ui \
37
+ viem@2.x \
38
+ wagmi
39
+ ```
40
+
41
+ ## Usage
42
+
43
+ Properties:
44
+
45
+ - `config` -> [REQUIRED]. The instantiated [wagmi config](https://wagmi.sh/react/api/createConfig) instance.
46
+ - `queryClient` -> [OPTIONAL]. The `GraphAuthKitProvider` renders a `QueryClientProvider` instance. Pass in an instantiated `QueryClient` to use, otherwise, `GraphAuthKit` will instantiate its own.
47
+ - `infuraKey` -> [REQUIRED]
48
+ - `gatewayApiKey` -> [OPTIONAL]. A The Graph Gateway API key used to query Subgraphs published on the Graph Network. Used for ENS name resolution
49
+
50
+ ### Example
51
+
52
+ - Setup the `GraphAuthKitProvider`.
53
+ - **Note** you do not need to add the `ConnectModal` component, the `GraphAuthKitProvider` renders it for us
54
+ - **Note** you do not need to add the `QueryClientProvider` as `GraphAuthKitProvider` instantiates and renders it
55
+ - you can pass a `QueryClient` instance to the `GraphAuthKitProvider`, otherwise, it will instantiate its own
56
+
57
+ ```tsx
58
+ // _app.tsx
59
+
60
+ import { QueryClient } from '@tanstack/react-query'
61
+ import { AppProps } from 'next'
62
+ import { useRef } from 'react'
63
+ import { createClient } from 'viem'
64
+ import { cookieStorage, createConfig, createStorage } from 'wagmi'
65
+ import { coinbaseWallet, injected, walletConnect } from 'wagmi/connectors'
66
+
67
+ import { AnalyticsProvider, GDSProvider } from '@graphprotocol/gds'
68
+ import {
69
+ AUTH_STORAGE_KEY,
70
+ buildInfuraHttpTransport,
71
+ chainIsSupportedChain,
72
+ DefChain,
73
+ GraphAuthKitProvider,
74
+ L1Chain,
75
+ L1ChainTestnet,
76
+ L2Chain,
77
+ L2ChainTestnet,
78
+ } from '@graphprotocol/graph-auth-kit'
79
+
80
+ import { FutureNextLink } from '../components/FutureNextLink'
81
+ import { Layout } from '../components/Layout'
82
+
83
+ const infuraKey = process.env.INFURA_KEY!
84
+ const walletConnectProjectID = process.env.WALLETCONNECT_PROJECT_ID!
85
+ const gatewayApiKey = process.env.GATEWAY_API_KEY
86
+
87
+ import '@graphprotocol/gds/style.css'
88
+ import '../app.css'
89
+
90
+ const config = createConfig({
91
+ chains: [L2Chain, L2ChainTestnet, L1Chain, L1ChainTestnet] as const,
92
+ ssr: typeof window !== 'undefined',
93
+ client(params) {
94
+ const chain = chainIsSupportedChain(params.chain) ? params.chain : DefChain
95
+ const transport = buildInfuraHttpTransport({
96
+ chain: chain.id,
97
+ infuraKey,
98
+ })
99
+
100
+ return createClient({
101
+ chain,
102
+ transport,
103
+ })
104
+ },
105
+ connectors: [
106
+ injected(),
107
+ coinbaseWallet({
108
+ appName: 'Boom',
109
+ }),
110
+ walletConnect({
111
+ projectId: env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID,
112
+ qrModalOptions: {
113
+ themeMode: 'dark',
114
+ },
115
+ }),
116
+ ],
117
+ storage: createStorage({
118
+ storage: cookieStorage,
119
+ key: AUTH_STORAGE_KEY,
120
+ }),
121
+ })
122
+
123
+ declare module 'wagmi' {
124
+ interface Register {
125
+ config: typeof config
126
+ }
127
+ }
128
+
129
+ export default function App({ Component, router, pageProps }: AppProps) {
130
+ const queryClient = useRef<QueryClient>()
131
+ if (!queryClient.current) {
132
+ queryClient.current = new QueryClient({
133
+ defaultOptions: {
134
+ queries: {
135
+ // With SSR, we usually want to set some default staleTime
136
+ // above 0 to avoid refetching immediately on the client
137
+ staleTime: 60 * 1000,
138
+ },
139
+ },
140
+ })
141
+ }
142
+
143
+ return (
144
+ <GDSProvider clientRouter={router} clientLink={FutureNextLink} useThemeUI>
145
+ <AnalyticsProvider
146
+ app="EXPLORER"
147
+ clientRouter={router}
148
+ mixpanel={{
149
+ sdk: mixpanel,
150
+ token: process.env.MIXPANEL_TOKEN ?? null,
151
+ }}
152
+ googleAnalytics={{
153
+ sdk: googleAnalytics,
154
+ measurementId: process.env.GOOGLE_ANALYTICS_MEASUREMENT_ID ?? null,
155
+ }}
156
+ >
157
+ <GraphAuthKitProvider
158
+ config={config}
159
+ queryClient={queryClient.current}
160
+ infuraKey={infuraKey}
161
+ gatewayApiKey={gatewayApiKey}
162
+ >
163
+ <Layout>
164
+ <DefaultSeo {...defaultSEO} />
165
+ <Component {...pageProps} />
166
+ </Layout>
167
+ <ReactQueryDevtools initialIsOpen={false} />
168
+ </GraphAuthKitProvider>
169
+ </AnalyticsProvider>
170
+ </GDSProvider>
171
+ )
172
+ }
173
+ ```
174
+
175
+ - Usage in a component
176
+
177
+ ```tsx
178
+ // components/Layout.tsx
179
+
180
+ import { ReactNode } from 'react'
181
+ import { useAccountEffect, useEnsName } from 'wagmi'
182
+
183
+ import { Layout as GDSLayout, UserProfile } from '@graphprotocol/gds'
184
+ import { GlobalFooter, GlobalHeader, NPSForm } from '@graphprotocol/go'
185
+ import { L1Chain, useGraphAuthKitConnector, useGraphAuthKit, useGraphAuthKitAccount } from '@graphprotocol/graph-auth-kit/hooks'
186
+
187
+ import { NavDropDownMenu } from './NavDropDownMenu'
188
+
189
+ export function Layout({ children }: Readonly<{ children: ReactNode }>) {
190
+ const authkit = useGraphAuthKit()
191
+ const { address } = useGraphAuthKitAccount()
192
+ const { data: ens } = useEnsName({ address, blockTag: 'latest', chainId: L1Chain.id })
193
+ const connector = useGraphAuthKitConnector()
194
+
195
+ const walletConnected = Boolean(address)
196
+
197
+ useAccountEffect({
198
+ onConnect(data) {
199
+ console.log('user connected wallet', {data})
200
+ },
201
+ onDisconnect() {
202
+ console.log('user disconnected wallet')
203
+ },
204
+ })
205
+
206
+ return (
207
+ <GDSLayout
208
+ header={
209
+ <GlobalHeader
210
+ activeProduct="EXPLORER"
211
+ basePath="/explorer"
212
+ showSupportButton={walletConnected}
213
+ rigtContent={(defaultContent) => (
214
+ <>
215
+ {!walletConnected ?
216
+ <GlobalHeader.ConnectButton onClick={() => authkit.openConnectModal()} />
217
+ ) : (
218
+ <UserProfile
219
+ ethereumAccount={address}
220
+ graphAccount={...}
221
+ ens={ens}
222
+ profileUrl={`/profile/${address}?view=Overview`}
223
+ profileUrlAs={`/profile/${address}?view=Overview`}
224
+ onConnect={() => authkit.openConnectModal()}
225
+ onDisconnect={() => authkit.disconnect()}
226
+ userDropDownMenu={<NavDropDownMenu />}
227
+ accountTag={connector === 'safe' ? 'multisig' : undefined}
228
+ />
229
+ )}
230
+ </>
231
+ )}
232
+ />
233
+ }
234
+ footer={
235
+ <>
236
+ <NPSForm sx={{ mb: Spacing['64px'] }} />
237
+ <GlobalFooter />
238
+ </>
239
+ }
240
+ >
241
+ {children}
242
+ </GDSLayout>
243
+ )
244
+ }
245
+ ```
246
+
247
+ ## Hooks
248
+
249
+ - `useGraphAuthKitAccount` -> This is an override of the [wagmi useAccount hook](https://wagmi.sh/react/api/hooks/useAccount). The reason is, if the user connects with a multisig, the wagmi context is connected with the user-selected EoA, so all of the wagmi context hooks reference this EoA and not the Safe. This returns the wagmi `UseAccountReturnType` but the `address` and `addresses` values include the entered Safe address. It also adds an `eoa` property that is the connected EoA address.
250
+ - `useGraphAuthKitConnector` -> The user selected wallet/connector option.
251
+ - `useClientToEthersSigner` -> Returns the ethers@5.x.x JsonRpcSigner or SafeEthersSigner if the user is connected via a multisig
252
+ - `useAuthAccount` -> similar to the `useGraphAuthKitAccount` but requires the user to be authenticated and throws an error if not
253
+ - `useGraphAuthKitAccountEffect` -> Override of the [wagmi useAccountEffect hook](https://wagmi.sh/react/api/hooks/useAccountEffect) that listens to account changes and the `_enteredMultisigInfo` on the inner context instance. If the account data changes, emits a `onConnect` or `onDisconnect` event, but in the `onConnect` also checks the `useGraphAuthKitInnerContext()._enteredMultisigInfo` value and if the user has connected via a multisig, returns the mutlsig as the `address` value and the connected EoA as the `eoa` value.
254
+ - `useGraphAuthKitWalletClient` -> Override of the [wagmi useWalletClient hook](https://wagmi.sh/react/api/hooks/useWalletClient) that returns the extended Safe viem actions if the user is connected to a multisig.
255
+ - `useGraphAuthKitWriteContract` -> Override of the [wagmi useWriteContract hook](https://wagmi.sh/react/api/hooks/useWriteContract) that creates the transaction on the Safe if the user is connected via multisig; otherwise, returns the `useWriteContract` mutation hook.
256
+
257
+ ## Components
258
+
259
+ - `Connected` -> renders the passed in `children` _only if_ the user is connected.
260
+
261
+ ```tsx
262
+ import { Connected } from '@graphprotocol/graph-auth-kit'
263
+
264
+ export function ShowMeConnected() {
265
+ return <Connected>{(account) => <div>Connected Wallet: {account.address}</div>}</Connected>
266
+ }
267
+ ```
268
+
269
+ - `Disconnected` -> renders the passed in `children` _only if_ the user id disconnected. Useful for rendering components like a "Connect Wallet" CTA that should only render if the user is _not_ authenticated.
270
+
271
+ ```tsx
272
+ import { ExperimentalButton as Button } from '@graphprotocol/gds'
273
+ import { Disconnected, useGraphAuthKit } from '@graphprotocol/graph-auth-kit'
274
+
275
+ export function ShowMeDisconnected() {
276
+ const authkit = useGraphAuthKit()
277
+
278
+ return (
279
+ <Disconnected>
280
+ <Button variant="primary" onClick={() => authkit.openConnectModal()}>
281
+ Connect Wallet
282
+ </Button>
283
+ </Disconnected>
284
+ )
285
+ }
286
+ ```
287
+
288
+ - `SwitchChain` -> Similar to the `SwitchNetwork` component from GDS, but uses the [wagmi useSwitchChain hook](https://wagmi.sh/react/api/hooks/useSwitchChain).
289
+
290
+ ```tsx
291
+ import { ExperimentalButton as Button } from '@graphprotocol/gds'
292
+ import { L2Chain, SwitchChain } from '@graphprotocol/graph-auth-kit'
293
+
294
+ export function LetMeSwitchChain() {
295
+ return <SwitchChain requestedChain={L2Chain} />
296
+ }
297
+ ```
298
+
299
+ ## References
300
+
301
+ - [`wagmi`](https://wagmi.sh/)
302
+ - [`viem`](https://viem.sh/)
303
+ - [Engineering Plan](https://www.notion.so/edgeandnode/Replace-Wallet-Connection-Library-0e4c5e1e015b428dbb52b1f627b712f0)
@@ -0,0 +1,2 @@
1
+ export declare function ConnectModal(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=ConnectModal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectModal.d.ts","sourceRoot":"","sources":["../../src/Components/ConnectModal.tsx"],"names":[],"mappings":"AASA,wBAAgB,YAAY,4CA4B3B"}
@@ -0,0 +1,33 @@
1
+ import { ReactNode } from 'react';
2
+ import { UseGraphAuthKitAccountReturnType } from '../hooks';
3
+ import { GraphAuthKitConnector } from '../types';
4
+ export type ConnectedAccountReturn = Readonly<{
5
+ address: NonNullable<UseGraphAuthKitAccountReturnType['address']>;
6
+ chain: NonNullable<UseGraphAuthKitAccountReturnType['chain']>;
7
+ connector: GraphAuthKitConnector;
8
+ connectedWithMultisig: UseGraphAuthKitAccountReturnType['connectedWithMultisig'];
9
+ }>;
10
+ export type ConnectedProps = {
11
+ children(account: ConnectedAccountReturn): ReactNode;
12
+ };
13
+ /**
14
+ * Utility component that only renders the passed in children if the user is authenticated.
15
+ * Otherwise, it renders null.
16
+ * Useful for wrapping components where you want to guarantee that they are only rendered,
17
+ * if the user is connected.
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * import { Connected } from '@graphprotocol/graph-auth-kit'
22
+ *
23
+ * export function ShowMeConnected() {
24
+ * return (
25
+ * <Connected>
26
+ * {(account) => <div>Connected Wallet: {account.address}</div>}
27
+ * </Connected>
28
+ * )
29
+ * }
30
+ * ```
31
+ */
32
+ export declare function Connected({ children }: ConnectedProps): ReactNode;
33
+ //# sourceMappingURL=Connected.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Connected.d.ts","sourceRoot":"","sources":["../../src/Components/Connected.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAA0B,KAAK,gCAAgC,EAA4B,MAAM,UAAU,CAAA;AAClH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAErD,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAC5C,OAAO,EAAE,WAAW,CAAC,gCAAgC,CAAC,SAAS,CAAC,CAAC,CAAA;IACjE,KAAK,EAAE,WAAW,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAAC,CAAA;IAC7D,SAAS,EAAE,qBAAqB,CAAA;IAChC,qBAAqB,EAAE,gCAAgC,CAAC,uBAAuB,CAAC,CAAA;CACjF,CAAC,CAAA;AACF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,OAAO,EAAE,sBAAsB,GAAG,SAAS,CAAA;CACrD,CAAA;AACD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CAAC,EAAE,QAAQ,EAAE,EAAE,cAAc,aAcrD"}
@@ -0,0 +1,7 @@
1
+ import { GraphAuthKitConnectorOpt } from '../types';
2
+ export type ConnectorOptionProps = GraphAuthKitConnectorOpt & {
3
+ selected?: boolean;
4
+ disabled?: boolean;
5
+ };
6
+ export declare function ConnectorOption(props: ConnectorOptionProps): import("react/jsx-runtime").JSX.Element;
7
+ //# sourceMappingURL=ConnectorOption.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectorOption.d.ts","sourceRoot":"","sources":["../../src/Components/ConnectorOption.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAExD,MAAM,MAAM,oBAAoB,GAAG,wBAAwB,GAAG;IAC5D,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AACD,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,2CAiB1D"}
@@ -0,0 +1,28 @@
1
+ import { ReactNode } from 'react';
2
+ export type DisconnectedProps = {
3
+ children: ReactNode;
4
+ };
5
+ /**
6
+ * Utility component that only renders the passed in children if the user is NOT connected/authenticated.
7
+ * If the user is connected, this will render null.
8
+ * Useful for wrapping components where you want to guarantee that they are only rendered,
9
+ * if the user is NOT connected.
10
+ * Such as: a connect wallet button, etc
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * import { Disconnected, useGraphAuthKit } from '@graphprotocol/graph-auth-kit'
15
+ *
16
+ * export function ShowMeDisonnected() {
17
+ * const authkit = useGraphAuthKit()
18
+ *
19
+ * return (
20
+ * <Disconnected>
21
+ * <button onClick={() => authkit.openConnectModal()}>Connect</button>
22
+ * </Disconnected>
23
+ * )
24
+ * }
25
+ * ```
26
+ */
27
+ export declare function Disconnected({ children }: DisconnectedProps): ReactNode;
28
+ //# sourceMappingURL=Disconnected.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Disconnected.d.ts","sourceRoot":"","sources":["../../src/Components/Disconnected.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAItC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,SAAS,CAAA;CACpB,CAAA;AACD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE,iBAAiB,aAQ3D"}
@@ -0,0 +1,2 @@
1
+ export declare function MultisigSignerOptions(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=MultisigSignerOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultisigSignerOptions.d.ts","sourceRoot":"","sources":["../../src/Components/MultisigSignerOptions.tsx"],"names":[],"mappings":"AAYA,wBAAgB,qBAAqB,4CAgHpC"}
@@ -0,0 +1,2 @@
1
+ export declare function PrimaryConnectOptions(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=PrimaryConnectOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PrimaryConnectOptions.d.ts","sourceRoot":"","sources":["../../src/Components/PrimaryConnectOptions.tsx"],"names":[],"mappings":"AASA,wBAAgB,qBAAqB,4CAuDpC"}
@@ -0,0 +1,2 @@
1
+ export declare function SafeInputForm(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=SafeInputForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SafeInputForm.d.ts","sourceRoot":"","sources":["../../src/Components/SafeInputForm.tsx"],"names":[],"mappings":"AA0EA,wBAAgB,aAAa,4CAqL5B"}
@@ -0,0 +1,2 @@
1
+ export declare function SafeSelection(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=SafeSelection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SafeSelection.d.ts","sourceRoot":"","sources":["../../src/Components/SafeSelection.tsx"],"names":[],"mappings":"AAiBA,wBAAgB,aAAa,4CA+F5B"}
@@ -0,0 +1,24 @@
1
+ import { Compute, ExactPartial } from '@wagmi/core/internal';
2
+ import { AddEthereumChainParameter } from 'viem';
3
+ import { Config, Connector, ResolvedRegister } from 'wagmi';
4
+ export type SwitchChainProps<config extends Config = ResolvedRegister['config']> = {
5
+ /** The chain to switch to. Must be one of the available chains in the registered config */
6
+ requestedChain: config['chains'][number];
7
+ /**
8
+ * Listens to the switchChain success event and emits.
9
+ * Useful for updating the UI when the chain switches.
10
+ */
11
+ onSuccess?(data: {
12
+ [key in keyof Extract<config['chains'][number], {
13
+ id: Config extends config ? number : config['chains'][number]['id'];
14
+ }>]: Extract<config['chains'][number], {
15
+ id: Config extends config ? number : config['chains'][number]['id'];
16
+ }>[key];
17
+ }, variables: {
18
+ connector?: Connector | undefined;
19
+ chainId: config['chains'][number]['id'];
20
+ addEthereumChainParameter?: Compute<ExactPartial<Omit<AddEthereumChainParameter, 'chainId'>>> | undefined;
21
+ }): Promise<void> | void;
22
+ };
23
+ export declare function SwitchChain<const config extends Config = ResolvedRegister['config']>(props: SwitchChainProps<config>): import("react/jsx-runtime").JSX.Element | null;
24
+ //# sourceMappingURL=SwitchChain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SwitchChain.d.ts","sourceRoot":"","sources":["../../src/Components/Swit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B,CAAA;AACD,wBAAgB,WAAW,CAAC,KAAK,CAAC,MAAM,SAAS,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,gBAAgB,CAAC,MAAM,CAAC,kDAuCpH"}
@@ -0,0 +1,4 @@
1
+ export { Connected, type ConnectedAccountReturn, type ConnectedProps } from './Connected';
2
+ export { Disconnected, type DisconnectedProps } from './Disconnected';
3
+ export { SwitchChain, type SwitchChainProps } from './SwitchChain';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,sBAAsB,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAA;AACzF,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACrE,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAA"}
@@ -0,0 +1,130 @@
1
+ import { QueryClient } from '@tanstack/react-query';
2
+ import { ReactNode } from 'react';
3
+ import { Config, ResolvedRegister } from 'wagmi';
4
+ import { GraphAuthKitProps } from './types';
5
+ export type GraphAuthKitState = {
6
+ /** Opens the GraphAuthKit connect modal to allow user to go through wallet connect flow */
7
+ openConnectModal(props?: {
8
+ title?: ReactNode;
9
+ subtitle?: ReactNode;
10
+ afterConnectUrl?: string;
11
+ }): void;
12
+ /** Closes the GraphAuthKit connect modal */
13
+ closeConnectModal(): void;
14
+ /** Disconnect the GraphAuthKit state. Wraps the disconnect from the useDisconnect() hook */
15
+ disconnect(): void | Promise<void>;
16
+ };
17
+ export declare const GraphAuthKitContext: import('react').Context<GraphAuthKitState>;
18
+ export declare function useGraphAuthKit(): GraphAuthKitState;
19
+ export type GraphAuthKitProviderProps<config extends Config = ResolvedRegister['config']> = GraphAuthKitProps & {
20
+ /**
21
+ * [Required]. The instantiated wagmi config instance.
22
+ */
23
+ config: config;
24
+ /**
25
+ * [Optional]. An instantiated @tanstack/react-query `QueryClient` instance.
26
+ * If null, will instantiate a `QueryClient` and pass to the `QueryClientProvider`.
27
+ */
28
+ queryClient?: QueryClient;
29
+ safeApiKey?: string;
30
+ } & Readonly<{
31
+ children: ReactNode;
32
+ }>;
33
+ /**
34
+ * Builds and renders a wagmi config instance wrapped in a `WagmiProvider` context.
35
+ * This then wraps the `GraphAuthKitContext.Provider` which provides the connect modal state for app users to connect their wallet.
36
+ *
37
+ * @example <caption>Configure and render the GraphAuthKit for explorer</caption>
38
+ * ```tsx
39
+ * // _app.tsx
40
+ *
41
+ * import { QueryClient } from '@tanstack/react-query'
42
+ * import { AppProps } from 'next'
43
+ * import { useRef } from 'react'
44
+ * import { createClient } from 'viem'
45
+ * import { cookieStorage, createConfig, createStorage } from 'wagmi'
46
+ * import { coinbaseWallet, injected, walletConnect } from 'wagmi/connectors'
47
+ *
48
+ * import {
49
+ * AUTH_STORAGE_KEY,
50
+ * buildInfuraHttpTransport,
51
+ * chainIsSupportedChain,
52
+ * DefChain,
53
+ * GraphAuthKitProvider,
54
+ * L1Chain,
55
+ * L2Chain,
56
+ * } from '@graphprotocol/graph-auth-kit'
57
+ *
58
+ * const infuraKey = process.env.INFURA_KEY!
59
+ * const walletConnectProjectID = process.env.WALLETCONNECT_PROJECT_ID!
60
+ * const gatewayApiKey = process.env.GATEWAY_API_KEY
61
+ * const safeApiKey = process.env.SAFE_API_KEY
62
+ *
63
+ * const config = createConfig({
64
+ * chains: [L2Chain, L1Chain] as const,
65
+ * ssr: typeof window !== 'undefined',
66
+ * client(params) {
67
+ * const chain = chainIsSupportedChain(params.chain) ? params.chain : DefChain
68
+ * const transport = buildInfuraHttpTransport({
69
+ * chain: chain.id,
70
+ * infuraKey
71
+ * })
72
+ *
73
+ * return createClient({ chain, transport })
74
+ * },
75
+ * connectors: [
76
+ * injected(),
77
+ * coinbaseWallet({
78
+ * appName: 'The Graph Explorer',
79
+ * appLogoUrl: 'https://storage.googleapis.com/graph-website/seo/graph-explorer.jpg'
80
+ * }),
81
+ * walletConnect({
82
+ * projectId: walletConnectProjectID,
83
+ * metadata: {
84
+ * name: 'The Graph Explorer',
85
+ * description: `See what’s happening on The Graph Network and participate as a Delegator, Curator, Indexer, or Developer.`,
86
+ * url: 'https://thegraph.com/explorer',
87
+ * icons: ['https://storage.googleapis.com/graph-website/seo/graph-explorer.jpg'],
88
+ * },
89
+ * qrModalOptions: {
90
+ * themeMode: 'dark'
91
+ * }
92
+ * })
93
+ * ],
94
+ * storage: createStorage({ storage: cookieStorage, key: AUTH_STORAGE_KEY })
95
+ * })
96
+ *
97
+ * export default function App({ Component, router, pageProps }: AppProps) {
98
+ * const queryClient = useRef<QueryClient>()
99
+ * if (!queryClient.current) {
100
+ * queryClient.current = new QueryClient({
101
+ * defaultOptions: {
102
+ * queries: {
103
+ * staleTime: 60 * 1000
104
+ * }
105
+ * }
106
+ * })
107
+ * }
108
+ *
109
+ * declare module 'wagmi' {
110
+ * interface Register {
111
+ * config: typeof config
112
+ * }
113
+ * }
114
+ *
115
+ * return (
116
+ * <GraphAuthKitProvider
117
+ * config={config}
118
+ * queryClient={queryClient.current}
119
+ * infuraKey={infuraKey}
120
+ * gatewayApiKey={gatewayApiKey}
121
+ * safeApiKey={safeApiKey}
122
+ * >
123
+ * <Component {...pageProps} />
124
+ * </GraphAuthKitProvider>
125
+ * )
126
+ * }
127
+ * ```
128
+ */
129
+ export declare function GraphAuthKitProvider<const config extends Config = ResolvedRegister['config']>(props: GraphAuthKitProviderProps<config>): import("react/jsx-runtime").JSX.Element;
130
+ //# sourceMappingURL=GraphAuthKit.context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphAuthKit.context.d.ts","sourceRoot":"","sources":["../src/GraphAuthKit.context.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAuB,MAAM,uBAAuB,CAAA;AACxE,OAAO,EAAiB,KAAK,S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