@edgeandnode/graph-auth-kit 0.3.2 → 0.4.0
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.
- package/dist/Components/Connected.d.ts +7 -4
- package/dist/Components/Connected.d.ts.map +1 -1
- package/dist/Components/ConnectorOption.d.ts +2 -8
- package/dist/Components/ConnectorOption.d.ts.map +1 -1
- package/dist/Components/MultisigSignerOptions.d.ts.map +1 -1
- package/dist/Components/PrimaryConnectOptions.d.ts.map +1 -1
- package/dist/Components/index.d.ts +1 -1
- package/dist/Components/index.d.ts.map +1 -1
- package/dist/{GraphAuthKit.context-B7OJAuEY.js → GraphAuthKit.context-BHUGruS-.js} +130 -100
- package/dist/hooks.d.ts +1 -1
- package/dist/hooks.d.ts.map +1 -1
- package/dist/index.js +33 -23
- package/dist/{GraphAuthKitInner.context.d.ts → inner/GraphAuthKitInner.context.d.ts} +6 -7
- package/dist/inner/GraphAuthKitInner.context.d.ts.map +1 -0
- package/dist/inner/hooks.d.ts +13 -0
- package/dist/inner/hooks.d.ts.map +1 -0
- package/dist/inner/index.d.ts +3 -0
- package/dist/inner/index.d.ts.map +1 -0
- package/dist/test-harness/MockGraphAuthKit.context.d.ts +1 -1
- package/dist/test-harness/MockGraphAuthKit.context.d.ts.map +1 -1
- package/dist/test-harness/index.d.ts +1 -0
- package/dist/test-harness/index.d.ts.map +1 -1
- package/dist/test-harness/index.js +196 -4
- package/dist/test-harness/utils.d.ts +214 -0
- package/dist/test-harness/utils.d.ts.map +1 -0
- package/dist/types.d.ts +12 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/GraphAuthKitInner.context.d.ts.map +0 -1
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import { type UseGraphAuthKitAccountReturnType } from '../hooks';
|
|
3
|
+
import { type GraphAuthKitConnector } from '../types';
|
|
4
|
+
export type ConnectedAccountReturn = Readonly<{
|
|
5
|
+
address: NonNullable<UseGraphAuthKitAccountReturnType['address']>;
|
|
6
|
+
chain: NonNullable<UseGraphAuthKitAccountReturnType['chain']>;
|
|
7
|
+
connector: GraphAuthKitConnector;
|
|
8
|
+
}>;
|
|
3
9
|
export type ConnectedProps = {
|
|
4
|
-
children(account:
|
|
5
|
-
address: NonNullable<UseGraphAuthKitAccountReturnType['address']>;
|
|
6
|
-
chain: NonNullable<UseGraphAuthKitAccountReturnType['chain']>;
|
|
7
|
-
}): ReactNode;
|
|
10
|
+
children(account: ConnectedAccountReturn): ReactNode;
|
|
8
11
|
};
|
|
9
12
|
/**
|
|
10
13
|
* Utility component that only renders the passed in children if the user is authenticated.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Connected.d.ts","sourceRoot":"","sources":["../../src/Components/Connected.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAA0B,KAAK,gCAAgC,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"Connected.d.ts","sourceRoot":"","sources":["../../src/Components/Connected.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAA0B,KAAK,gCAAgC,EAA4B,MAAM,UAAU,CAAA;AAClH,OAAO,EAAE,KAAK,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;CACjC,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,aAarD"}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
export type ConnectorOptionProps = {
|
|
4
|
-
connector: GraphAuthKitConnector;
|
|
5
|
-
title: ReactNode;
|
|
1
|
+
import { type GraphAuthKitConnectorOpt } from '../types';
|
|
2
|
+
export type ConnectorOptionProps = GraphAuthKitConnectorOpt & {
|
|
6
3
|
selected?: boolean;
|
|
7
4
|
disabled?: boolean;
|
|
8
|
-
description?: ReactNode;
|
|
9
|
-
Image: ElementType;
|
|
10
|
-
onClick(): void;
|
|
11
5
|
};
|
|
12
6
|
export declare function ConnectorOption(props: ConnectorOptionProps): import("react").JSX.Element;
|
|
13
7
|
//# sourceMappingURL=ConnectorOption.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectorOption.d.ts","sourceRoot":"","sources":["../../src/Components/ConnectorOption.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"ConnectorOption.d.ts","sourceRoot":"","sources":["../../src/Components/ConnectorOption.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,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,+BAiB1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultisigSignerOptions.d.ts","sourceRoot":"","sources":["../../src/Components/MultisigSignerOptions.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MultisigSignerOptions.d.ts","sourceRoot":"","sources":["../../src/Components/MultisigSignerOptions.tsx"],"names":[],"mappings":"AAYA,wBAAgB,qBAAqB,gCAuHpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrimaryConnectOptions.d.ts","sourceRoot":"","sources":["../../src/Components/PrimaryConnectOptions.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrimaryConnectOptions.d.ts","sourceRoot":"","sources":["../../src/Components/PrimaryConnectOptions.tsx"],"names":[],"mappings":"AASA,wBAAgB,qBAAqB,gCA6CpC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Connected, type ConnectedProps } from './Connected';
|
|
1
|
+
export { Connected, type ConnectedAccountReturn, type ConnectedProps } from './Connected';
|
|
2
2
|
export { Disconnected, type DisconnectedProps } from './Disconnected';
|
|
3
3
|
export { SwitchChain, type SwitchChainProps } from './SwitchChain';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAA;
|
|
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"}
|
|
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment } from "@theme-ui/core/jsx-runtime";
|
|
|
2
2
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
3
3
|
import { createContext, useContext, useRef, useState, useReducer, useEffect } from "react";
|
|
4
4
|
import { useConfig, useConnect, useDisconnect, useAccountEffect, createConfig, createStorage, cookieStorage, cookieToInitialState, WagmiProvider } from "wagmi";
|
|
5
|
-
import {
|
|
5
|
+
import { injected, coinbaseWallet, walletConnect } from "wagmi/connectors";
|
|
6
6
|
import { Icon, ExperimentalButton, Alert, Divider, Link, ExperimentalSelect, ExperimentalInput, List, ExperimentalModal, ExperimentalLoadingIndicator } from "@edgeandnode/gds";
|
|
7
7
|
import { http, createPublicClient, createClient, isAddress } from "viem";
|
|
8
8
|
import { z } from "zod";
|
|
@@ -24,11 +24,11 @@ const GraphAuthKitProps = RequiredInfuraKey.merge(RequiredWalletConnectProjectId
|
|
|
24
24
|
chains: z.union([z.literal("ALL"), z.literal("MAINNET"), z.literal("TESTNET")]).default("ALL").readonly()
|
|
25
25
|
});
|
|
26
26
|
const GraphAuthKitConnector = z.union([
|
|
27
|
-
z.literal(coinbaseWallet.type),
|
|
28
27
|
z.literal(injected.type),
|
|
29
|
-
z.literal(
|
|
30
|
-
z.literal(walletConnect.type)
|
|
31
|
-
|
|
28
|
+
z.literal(coinbaseWallet.type),
|
|
29
|
+
z.literal(walletConnect.type),
|
|
30
|
+
z.literal("multisig")
|
|
31
|
+
]);
|
|
32
32
|
RequiredInfuraKey.extend({
|
|
33
33
|
chain: SupportedClientChainId.optional().nullable().default(DefChain.id)
|
|
34
34
|
});
|
|
@@ -125,14 +125,13 @@ function useGraphAuthKitInnerContext() {
|
|
|
125
125
|
}
|
|
126
126
|
function GraphAuthKitInnerContextProvider({ infuraKey, children }) {
|
|
127
127
|
const config = useConfig();
|
|
128
|
-
const { connect
|
|
128
|
+
const { connect } = useConnect();
|
|
129
129
|
const { disconnectAsync } = useDisconnect();
|
|
130
130
|
const firstConnectCheckRef = useRef();
|
|
131
131
|
const [_connectModalOpen, setConnectModalOpen] = useState(false);
|
|
132
132
|
const [_modalTitle, setModalTitle] = useState();
|
|
133
133
|
const [_modalSubtitle, setModalSubtitle] = useState();
|
|
134
134
|
const [_authenticating, setAuthenticating] = useState(false);
|
|
135
|
-
const [_connector, setConnector] = useState();
|
|
136
135
|
const [_connectFailureMessage, setConnectFailureMessage] = useState();
|
|
137
136
|
const [_modalState, setModalState] = useState("primary");
|
|
138
137
|
const [_enteredMultisigInfo, setEnteredMultisigInfo] = useState();
|
|
@@ -146,13 +145,9 @@ function GraphAuthKitInnerContextProvider({ infuraKey, children }) {
|
|
|
146
145
|
typeof multisigCookie === "string" ? JSON.parse(multisigCookie) : multisigCookie
|
|
147
146
|
);
|
|
148
147
|
if (parsedMultisigSchema.success && isAddress(parsedMultisigSchema.data.address)) {
|
|
148
|
+
console.log("useAccountEffect.onConnect(). multisig saved in cookie.");
|
|
149
149
|
setEnteredMultisigInfo(parsedMultisigSchema.data);
|
|
150
|
-
setConnector("multisig");
|
|
151
150
|
}
|
|
152
|
-
} else {
|
|
153
|
-
const parsedConnector = GraphAuthKitConnector.safeParse(data.connector.type);
|
|
154
|
-
const connector = parsedConnector.success ? parsedConnector.data : "injected";
|
|
155
|
-
setConnector(connector);
|
|
156
151
|
}
|
|
157
152
|
firstConnectCheckRef.current = true;
|
|
158
153
|
}
|
|
@@ -160,18 +155,15 @@ function GraphAuthKitInnerContextProvider({ infuraKey, children }) {
|
|
|
160
155
|
});
|
|
161
156
|
const _connect = async (connector) => {
|
|
162
157
|
setAuthenticating(true);
|
|
163
|
-
setConnector(void 0);
|
|
164
158
|
setConnectFailureMessage(void 0);
|
|
165
|
-
const conn = connectors.find((c) => c.type === connector) ?? injected();
|
|
166
159
|
connect(
|
|
167
|
-
{ connector
|
|
160
|
+
{ connector },
|
|
168
161
|
{
|
|
169
162
|
onSuccess() {
|
|
170
|
-
|
|
163
|
+
setEnteredMultisigInfo(void 0);
|
|
171
164
|
setConnectModalOpen(false);
|
|
172
165
|
setModalTitle("Connect your wallet");
|
|
173
166
|
setModalSubtitle(void 0);
|
|
174
|
-
setEnteredMultisigInfo(void 0);
|
|
175
167
|
setModalState("primary");
|
|
176
168
|
},
|
|
177
169
|
onError(err) {
|
|
@@ -189,16 +181,14 @@ function GraphAuthKitInnerContextProvider({ infuraKey, children }) {
|
|
|
189
181
|
};
|
|
190
182
|
const _connectMultisig = async (params) => {
|
|
191
183
|
setAuthenticating(true);
|
|
192
|
-
setConnector(void 0);
|
|
193
184
|
setConnectFailureMessage(void 0);
|
|
194
|
-
const conn = connectors.find((c) => c.type === params.connector) ?? injected();
|
|
195
185
|
connect(
|
|
196
|
-
{ connector:
|
|
186
|
+
{ connector: params.connector },
|
|
197
187
|
{
|
|
198
188
|
async onSuccess(data) {
|
|
199
189
|
var _a;
|
|
200
190
|
if (data.chainId !== params.network) {
|
|
201
|
-
await disconnectAsync({ connector:
|
|
191
|
+
await disconnectAsync({ connector: params.connector }).then(() => {
|
|
202
192
|
var _a2;
|
|
203
193
|
void ((_a2 = config.storage) == null ? void 0 : _a2.removeItem(MULTISIG_AUTH_STORAGE_KEY));
|
|
204
194
|
setConnectFailureMessage(MultisigErrorMap["INVALID_NETWORK"]);
|
|
@@ -217,15 +207,15 @@ function GraphAuthKitInnerContextProvider({ infuraKey, children }) {
|
|
|
217
207
|
eoa
|
|
218
208
|
});
|
|
219
209
|
if (!eoaIsSafeOwner) {
|
|
220
|
-
await disconnectAsync({ connector:
|
|
210
|
+
await disconnectAsync({ connector: params.connector }).then(() => {
|
|
221
211
|
var _a2;
|
|
222
212
|
void ((_a2 = config.storage) == null ? void 0 : _a2.removeItem(MULTISIG_AUTH_STORAGE_KEY));
|
|
223
213
|
setConnectFailureMessage(MultisigErrorMap["INVALID_SIGNER"]);
|
|
224
214
|
});
|
|
225
215
|
return;
|
|
226
216
|
}
|
|
227
|
-
setConnector("multisig");
|
|
228
217
|
void ((_a = config.storage) == null ? void 0 : _a.setItem(MULTISIG_AUTH_STORAGE_KEY, _enteredMultisigInfo));
|
|
218
|
+
setEnteredMultisigInfo({ address: params.address, network: params.network, enteredSafeIsValid: true });
|
|
229
219
|
setConnectModalOpen(false);
|
|
230
220
|
setModalTitle("Connect your wallet");
|
|
231
221
|
setModalSubtitle(void 0);
|
|
@@ -262,14 +252,12 @@ function GraphAuthKitInnerContextProvider({ infuraKey, children }) {
|
|
|
262
252
|
_setSafeInfo: setEnteredMultisigInfo,
|
|
263
253
|
_authenticating,
|
|
264
254
|
_setAuthenticating: setAuthenticating,
|
|
265
|
-
_connector,
|
|
266
255
|
_connectFailureMessage,
|
|
267
256
|
_connect,
|
|
268
257
|
_connectMultisig,
|
|
269
258
|
_reset() {
|
|
270
259
|
var _a;
|
|
271
260
|
setAuthenticating(false);
|
|
272
|
-
setConnector(void 0);
|
|
273
261
|
setConnectFailureMessage(void 0);
|
|
274
262
|
setModalTitle("Connect your wallet");
|
|
275
263
|
setModalSubtitle(void 0);
|
|
@@ -312,46 +300,116 @@ async function connectedWalletIsEoA(client, address) {
|
|
|
312
300
|
const code = await client.getCode({ address });
|
|
313
301
|
return code == null || code === "0x";
|
|
314
302
|
}
|
|
303
|
+
function usePrimaryConnectOptions() {
|
|
304
|
+
const { connectors } = useConfig();
|
|
305
|
+
const ctx = useGraphAuthKitInnerContext();
|
|
306
|
+
const configuredConnectors = connectors.filter((c) => c.type === injected.type && c.name !== "Injected" || c.type !== injected.type).reduce((map, curr) => {
|
|
307
|
+
const connector = GraphAuthKitConnector.safeParse(curr.type);
|
|
308
|
+
return {
|
|
309
|
+
...map,
|
|
310
|
+
[curr.name]: {
|
|
311
|
+
id: curr.id,
|
|
312
|
+
title: curr.name,
|
|
313
|
+
connector: connector.success ? connector.data : curr.type,
|
|
314
|
+
installed: curr.type === injected.type,
|
|
315
|
+
Image: correctConnectOptionIcon(curr),
|
|
316
|
+
async onConnect() {
|
|
317
|
+
void ctx._connect(curr);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
}, {});
|
|
322
|
+
return [
|
|
323
|
+
...Object.values(configuredConnectors).sort((a, b) => {
|
|
324
|
+
if (a.installed === b.installed) {
|
|
325
|
+
return 0;
|
|
326
|
+
}
|
|
327
|
+
return a.installed ? -1 : 1;
|
|
328
|
+
}),
|
|
329
|
+
{
|
|
330
|
+
id: "multisig",
|
|
331
|
+
title: "Safe",
|
|
332
|
+
connector: "multisig",
|
|
333
|
+
installed: false,
|
|
334
|
+
Image: /* @__PURE__ */ jsx(Icon.LogoSafeColor, { size: "24px" }),
|
|
335
|
+
onConnect() {
|
|
336
|
+
ctx._setModalState("safe_entry");
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
];
|
|
340
|
+
}
|
|
341
|
+
function useMultisigConnectOptions() {
|
|
342
|
+
const { connectors } = useConfig();
|
|
343
|
+
const ctx = useGraphAuthKitInnerContext();
|
|
344
|
+
const configuredConnectors = connectors.filter((c) => c.type === injected.type && c.name !== "Injected" || c.type !== injected.type).reduce((map, curr) => {
|
|
345
|
+
const connector = GraphAuthKitConnector.safeParse(curr.type);
|
|
346
|
+
return {
|
|
347
|
+
...map,
|
|
348
|
+
[curr.name]: {
|
|
349
|
+
id: curr.id,
|
|
350
|
+
title: curr.name,
|
|
351
|
+
connector: connector.success ? connector.data : curr.type,
|
|
352
|
+
installed: curr.type === injected.type,
|
|
353
|
+
Image: correctConnectOptionIcon(curr),
|
|
354
|
+
async onConnect() {
|
|
355
|
+
var _a, _b;
|
|
356
|
+
void ctx._connectMultisig({
|
|
357
|
+
connector: curr,
|
|
358
|
+
address: ((_a = ctx._enteredMultisigInfo) == null ? void 0 : _a.address) || "0x",
|
|
359
|
+
network: ((_b = ctx._enteredMultisigInfo) == null ? void 0 : _b.network) || L2Chain.id
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
}, {});
|
|
365
|
+
return Object.values(configuredConnectors).sort((a, b) => {
|
|
366
|
+
if (a.installed === b.installed) {
|
|
367
|
+
return 0;
|
|
368
|
+
}
|
|
369
|
+
return a.installed ? -1 : 1;
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
function correctConnectOptionIcon(conn) {
|
|
373
|
+
if (conn.icon != null) {
|
|
374
|
+
return /* @__PURE__ */ jsx("img", { src: conn.icon, alt: conn.name, className: "size-6" });
|
|
375
|
+
}
|
|
376
|
+
switch (conn.type) {
|
|
377
|
+
case coinbaseWallet.type: {
|
|
378
|
+
return /* @__PURE__ */ jsx(Icon.LogoCoinbaseWallet, { size: "24px" });
|
|
379
|
+
}
|
|
380
|
+
case walletConnect.type: {
|
|
381
|
+
return /* @__PURE__ */ jsx(Icon.LogoWalletConnectColor, { size: "24px" });
|
|
382
|
+
}
|
|
383
|
+
default: {
|
|
384
|
+
return /* @__PURE__ */ jsx(Icon.LogoMetaMaskColor, { size: "24px" });
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
315
388
|
function ConnectorOption(props) {
|
|
316
389
|
return /* @__PURE__ */ jsxs(
|
|
317
390
|
"button",
|
|
318
391
|
{
|
|
319
|
-
className: "flex w-full cursor-pointer items-center gap-x-2 rounded-4 border border-white/
|
|
392
|
+
className: "flex w-full cursor-pointer items-center justify-between gap-x-2 rounded-4 border border-white/8 bg-white/4 p-3 text-white/48 hover:bg-white/8 hover:text-white aria-selected:border-purple aria-selected:text-white",
|
|
320
393
|
style: {
|
|
321
394
|
WebkitBackfaceVisibility: "hidden"
|
|
322
395
|
},
|
|
323
|
-
onClick: props.
|
|
396
|
+
onClick: () => void props.onConnect(),
|
|
324
397
|
disabled: props.disabled,
|
|
325
398
|
children: [
|
|
326
|
-
/* @__PURE__ */
|
|
327
|
-
|
|
328
|
-
/* @__PURE__ */ jsx("
|
|
329
|
-
|
|
330
|
-
|
|
399
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2", children: [
|
|
400
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center", children: props.Image }),
|
|
401
|
+
/* @__PURE__ */ jsx("h6", { className: "text-h16 whitespace-nowrap text-inherit", children: props.title })
|
|
402
|
+
] }),
|
|
403
|
+
props.installed ? /* @__PURE__ */ jsx("p", { className: "text-p12 text-white/48", children: "Installed" }) : null
|
|
331
404
|
]
|
|
332
405
|
}
|
|
333
406
|
);
|
|
334
407
|
}
|
|
335
|
-
const multisigConnectOptions = [
|
|
336
|
-
{
|
|
337
|
-
connector: "injected",
|
|
338
|
-
title: "MetaMask",
|
|
339
|
-
Image: Icon.LogoMetaMaskColor
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
connector: "walletConnect",
|
|
343
|
-
title: "WalletConnect",
|
|
344
|
-
Image: Icon.LogoWalletConnectColor
|
|
345
|
-
},
|
|
346
|
-
{
|
|
347
|
-
connector: "coinbaseWallet",
|
|
348
|
-
title: "Coinbase Wallet",
|
|
349
|
-
Image: Icon.LogoCoinbaseWallet
|
|
350
|
-
}
|
|
351
|
-
];
|
|
352
408
|
function MultisigSignerOptions() {
|
|
409
|
+
const config = useConfig();
|
|
353
410
|
const authKit = useGraphAuthKit();
|
|
354
411
|
const ctx = useGraphAuthKitInnerContext();
|
|
412
|
+
const multisigConnectOpts = useMultisigConnectOptions();
|
|
355
413
|
const [selectedConnector, setSelectedConnector] = useState(null);
|
|
356
414
|
if (ctx._enteredMultisigInfo == null || !ctx._enteredMultisigInfo.address) {
|
|
357
415
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col justify-between gap-y-24", children: [
|
|
@@ -398,24 +456,21 @@ function MultisigSignerOptions() {
|
|
|
398
456
|
description: ctx._connectFailureMessage.description
|
|
399
457
|
}
|
|
400
458
|
) : null,
|
|
401
|
-
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-col gap-y-2", children:
|
|
459
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-col gap-y-2", children: multisigConnectOpts.map((opt) => /* @__PURE__ */ jsx(
|
|
402
460
|
ConnectorOption,
|
|
403
461
|
{
|
|
404
462
|
...opt,
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
463
|
+
disabled: ctx._authenticating,
|
|
464
|
+
selected: selectedConnector != null && selectedConnector.id === opt.id,
|
|
465
|
+
onConnect: () => {
|
|
466
|
+
const selected = config.connectors.find((c) => c.id === opt.id);
|
|
467
|
+
if (selected != null) {
|
|
468
|
+
setSelectedConnector(selected);
|
|
469
|
+
void opt.onConnect();
|
|
409
470
|
}
|
|
410
|
-
setSelectedConnector(opt.connector);
|
|
411
|
-
void ctx._connectMultisig({
|
|
412
|
-
connector: opt.connector,
|
|
413
|
-
network: ctx._enteredMultisigInfo.network,
|
|
414
|
-
address: ctx._enteredMultisigInfo.address
|
|
415
|
-
});
|
|
416
471
|
}
|
|
417
472
|
},
|
|
418
|
-
opt.
|
|
473
|
+
opt.id
|
|
419
474
|
)) })
|
|
420
475
|
] }),
|
|
421
476
|
/* @__PURE__ */ jsx(Divider, {}),
|
|
@@ -447,30 +502,9 @@ function MultisigSignerOptions() {
|
|
|
447
502
|
] })
|
|
448
503
|
] });
|
|
449
504
|
}
|
|
450
|
-
const primaryConnectOptions = [
|
|
451
|
-
{
|
|
452
|
-
connector: "injected",
|
|
453
|
-
title: "MetaMask",
|
|
454
|
-
Image: Icon.LogoMetaMaskColor
|
|
455
|
-
},
|
|
456
|
-
{
|
|
457
|
-
connector: "walletConnect",
|
|
458
|
-
title: "WalletConnect",
|
|
459
|
-
Image: Icon.LogoWalletConnectColor
|
|
460
|
-
},
|
|
461
|
-
{
|
|
462
|
-
connector: "coinbaseWallet",
|
|
463
|
-
title: "Coinbase Wallet",
|
|
464
|
-
Image: Icon.LogoCoinbaseWallet
|
|
465
|
-
},
|
|
466
|
-
{
|
|
467
|
-
connector: "multisig",
|
|
468
|
-
title: "Safe",
|
|
469
|
-
Image: Icon.LogoSafeColor
|
|
470
|
-
}
|
|
471
|
-
];
|
|
472
505
|
function PrimaryConnectOptions() {
|
|
473
506
|
const ctx = useGraphAuthKitInnerContext();
|
|
507
|
+
const primaryConnectOpts = usePrimaryConnectOptions();
|
|
474
508
|
const [selectedConnector, setSelectedConnector] = useState(null);
|
|
475
509
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-8", children: [
|
|
476
510
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
@@ -485,22 +519,18 @@ function PrimaryConnectOptions() {
|
|
|
485
519
|
description: ctx._connectFailureMessage.description
|
|
486
520
|
}
|
|
487
521
|
) : null,
|
|
488
|
-
/* @__PURE__ */ jsx("div", { className: "
|
|
522
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-col gap-y-2", children: primaryConnectOpts.map((opt) => /* @__PURE__ */ jsx(
|
|
489
523
|
ConnectorOption,
|
|
490
524
|
{
|
|
491
525
|
...opt,
|
|
492
526
|
disabled: ctx._authenticating,
|
|
493
|
-
selected: selectedConnector != null && selectedConnector === opt.
|
|
494
|
-
|
|
527
|
+
selected: selectedConnector != null && selectedConnector === opt.id,
|
|
528
|
+
onConnect: () => {
|
|
495
529
|
setSelectedConnector(opt.connector);
|
|
496
|
-
|
|
497
|
-
ctx._setModalState("safe_entry");
|
|
498
|
-
} else {
|
|
499
|
-
void ctx._connect(opt.connector);
|
|
500
|
-
}
|
|
530
|
+
void opt.onConnect();
|
|
501
531
|
}
|
|
502
532
|
},
|
|
503
|
-
opt.
|
|
533
|
+
opt.id
|
|
504
534
|
)) }),
|
|
505
535
|
/* @__PURE__ */ jsxs("p", { className: "text-p12 text-white/64", children: [
|
|
506
536
|
"By connecting a wallet, you agree to The Graph's",
|
|
@@ -919,14 +949,14 @@ export {
|
|
|
919
949
|
chainIsSupportedChain as c,
|
|
920
950
|
defInnerState as d,
|
|
921
951
|
clientToProvider as e,
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
952
|
+
GraphAuthKitConnector as f,
|
|
953
|
+
buildInfuraHttpTransport as g,
|
|
954
|
+
buildPublicClient as h,
|
|
955
|
+
BuildClientArgs as i,
|
|
956
|
+
useGraphAuthKit as j,
|
|
957
|
+
GraphAuthKitProvider as k,
|
|
958
|
+
RequiredWalletConnectProjectId as l,
|
|
959
|
+
GraphAuthKitProps as m,
|
|
930
960
|
isChainL2 as n,
|
|
931
961
|
isChainL1 as o,
|
|
932
962
|
isChainMainnet as p,
|
package/dist/hooks.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type providers } from 'ethers';
|
|
|
2
2
|
import { type Address, type Chain } from 'viem';
|
|
3
3
|
import { type Config, type Connector, type ResolvedRegister, type UseAccountReturnType, type UseWalletClientReturnType, type UseWriteContractParameters, type UseWriteContractReturnType } from 'wagmi';
|
|
4
4
|
import { SafeEthersSigner } from './safe/SafeEthersSigner';
|
|
5
|
-
import {
|
|
5
|
+
import { GraphAuthKitConnector } from './types';
|
|
6
6
|
/**
|
|
7
7
|
* Hook to to convert a Viem Client to an ethers.js Signer:
|
|
8
8
|
* - if a multisig wallet is connected return an instance of SafeEthersSigner
|
package/dist/hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAA;AAEvC,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAc,MAAM,MAAM,CAAA;AAC3D,OAAO,EACL,KAAK,MAAM,EACX,KAAK,SAAS,EACd,KAAK,gBAAgB,EAErB,KAAK,oBAAoB,EAKzB,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAChC,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,QAAQ,CAAA;AAEvC,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAc,MAAM,MAAM,CAAA;AAC3D,OAAO,EACL,KAAK,MAAM,EACX,K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AAS,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,EAChH,UAAU,GAAE,0BAA0B,CAAC,MAAM,EAAE,OAAO,CAAM,GAC3D,0BAA0B,CAAC,MAAM,EAAE,OAAO,CAAC,CA8B7C"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { u as useGraphAuthKitInnerContext, e as clientToProvider } from "./GraphAuthKit.context-
|
|
5
|
-
import {
|
|
4
|
+
import { u as useGraphAuthKitInnerContext, e as clientToProvider, f as GraphAuthKitConnector } from "./GraphAuthKit.context-BHUGruS-.js";
|
|
5
|
+
import { i, B, a, m, k, R, l, b, g, h, c, r, o, n, p, q, j } from "./GraphAuthKit.context-BHUGruS-.js";
|
|
6
6
|
import { b as createSafe, c as createApiKit } from "./utils-KuRu9vB-.js";
|
|
7
|
-
import { j as j2, A, D, g as g2, h as h2, L, e, M, a as a2, S, k as k2, l as l2, f
|
|
7
|
+
import { j as j2, A, D, g as g2, h as h2, L, e, M, a as a2, S, k as k2, l as l2, f, d, i as i2 } from "./utils-KuRu9vB-.js";
|
|
8
8
|
import { useMutation } from "@tanstack/react-query";
|
|
9
9
|
import { useMemo } from "react";
|
|
10
10
|
import { encodeFunctionData, getAddress } from "viem";
|
|
@@ -316,7 +316,7 @@ function useClientToEthersSigner() {
|
|
|
316
316
|
return useMemo(() => {
|
|
317
317
|
if (!client) return void 0;
|
|
318
318
|
const provider = clientToProvider(client);
|
|
319
|
-
if (ctx.
|
|
319
|
+
if (ctx._enteredMultisigInfo != null) {
|
|
320
320
|
const safeAddress = getAddress(ctx._enteredMultisigInfo.address);
|
|
321
321
|
const safeEthersSigner = new SafeEthersSigner(
|
|
322
322
|
safeAddress,
|
|
@@ -326,18 +326,26 @@ function useClientToEthersSigner() {
|
|
|
326
326
|
);
|
|
327
327
|
return safeEthersSigner;
|
|
328
328
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}, [chainId, client, ctx._connector, ctx._enteredMultisigInfo]);
|
|
329
|
+
return provider.getSigner();
|
|
330
|
+
}, [chainId, client, ctx._enteredMultisigInfo]);
|
|
332
331
|
}
|
|
333
332
|
function useGraphAuthKitConnector() {
|
|
334
|
-
|
|
335
|
-
|
|
333
|
+
var _a;
|
|
334
|
+
const account = useGraphAuthKitAccount();
|
|
335
|
+
const ctx = useGraphAuthKitInnerContext();
|
|
336
|
+
if (account.connector == null) {
|
|
337
|
+
return null;
|
|
338
|
+
}
|
|
339
|
+
if (((_a = ctx._enteredMultisigInfo) == null ? void 0 : _a.address) != null) {
|
|
340
|
+
return "multisig";
|
|
341
|
+
}
|
|
342
|
+
const parsed = GraphAuthKitConnector.safeParse(account.connector.type);
|
|
343
|
+
return parsed.success ? parsed.data : null;
|
|
336
344
|
}
|
|
337
345
|
function useGraphAuthKitAccount() {
|
|
338
346
|
const data = useAccount();
|
|
339
347
|
const ctx = useGraphAuthKitInnerContext();
|
|
340
|
-
if (data.address == null || !data.isConnected ||
|
|
348
|
+
if (data.address == null || !data.isConnected || data.connector == null) {
|
|
341
349
|
return {
|
|
342
350
|
address: void 0,
|
|
343
351
|
addresses: void 0,
|
|
@@ -352,7 +360,7 @@ function useGraphAuthKitAccount() {
|
|
|
352
360
|
eoa: void 0
|
|
353
361
|
};
|
|
354
362
|
}
|
|
355
|
-
if (ctx.
|
|
363
|
+
if (ctx._enteredMultisigInfo != null) {
|
|
356
364
|
const address = getAddress(ctx._enteredMultisigInfo.address);
|
|
357
365
|
const [, ...rest] = data.addresses ?? [];
|
|
358
366
|
return {
|
|
@@ -385,7 +393,7 @@ function useGraphAuthKitWalletClient() {
|
|
|
385
393
|
if (!walletClient.data) {
|
|
386
394
|
return walletClient;
|
|
387
395
|
}
|
|
388
|
-
if (ctx.
|
|
396
|
+
if (ctx._enteredMultisigInfo != null) {
|
|
389
397
|
const safeAddress = getAddress(ctx._enteredMultisigInfo.address);
|
|
390
398
|
const safeWalletClient = walletClient.data.extend(safeViemActions(safeAddress, ctx._enteredMultisigInfo.network));
|
|
391
399
|
return { ...walletClient, data: safeWalletClient };
|
|
@@ -416,12 +424,14 @@ function useGraphAuthKitWriteContract(parameters = {}) {
|
|
|
416
424
|
}
|
|
417
425
|
function Connected({ children }) {
|
|
418
426
|
const account = useGraphAuthKitAccount();
|
|
419
|
-
|
|
427
|
+
const connector = useGraphAuthKitConnector();
|
|
428
|
+
if (account.address == null || account.chain == null || connector == null) {
|
|
420
429
|
return null;
|
|
421
430
|
}
|
|
422
431
|
return children({
|
|
423
432
|
address: account.address,
|
|
424
|
-
chain: account.chain
|
|
433
|
+
chain: account.chain,
|
|
434
|
+
connector
|
|
425
435
|
});
|
|
426
436
|
}
|
|
427
437
|
function Disconnected({ children }) {
|
|
@@ -467,36 +477,36 @@ function SwitchChain(props) {
|
|
|
467
477
|
export {
|
|
468
478
|
j2 as AUTH_STORAGE_KEY,
|
|
469
479
|
A as ApiKitUrlMap,
|
|
470
|
-
|
|
480
|
+
i as BuildClientArgs,
|
|
471
481
|
B as BuildPublicClientArgs,
|
|
472
482
|
Connected,
|
|
473
483
|
D as DefChain,
|
|
474
484
|
Disconnected,
|
|
475
|
-
|
|
485
|
+
GraphAuthKitConnector,
|
|
476
486
|
a as GraphAuthKitContext,
|
|
477
|
-
|
|
478
|
-
|
|
487
|
+
m as GraphAuthKitProps,
|
|
488
|
+
k as GraphAuthKitProvider,
|
|
479
489
|
g2 as L1Chain,
|
|
480
490
|
h2 as L1ChainTestnet,
|
|
481
491
|
L as L2Chain,
|
|
482
492
|
e as L2ChainTestnet,
|
|
483
493
|
M as MULTISIG_AUTH_STORAGE_KEY,
|
|
484
494
|
R as RequiredInfuraKey,
|
|
485
|
-
|
|
495
|
+
l as RequiredWalletConnectProjectId,
|
|
486
496
|
a2 as SafeSupportedNetworkNames,
|
|
487
497
|
S as SafeSupportedNetworks,
|
|
488
498
|
k2 as SupportedClientChainId,
|
|
489
499
|
l2 as SupportedClientChains,
|
|
490
500
|
SwitchChain,
|
|
491
501
|
b as buildClient,
|
|
492
|
-
|
|
493
|
-
|
|
502
|
+
g as buildInfuraHttpTransport,
|
|
503
|
+
h as buildPublicClient,
|
|
494
504
|
c as chainIsSupportedChain,
|
|
495
505
|
clientToProvider,
|
|
496
506
|
r as connectedWalletIsEoA,
|
|
497
507
|
createApiKit,
|
|
498
508
|
createSafe,
|
|
499
|
-
|
|
509
|
+
f as fetchOwnedSafes,
|
|
500
510
|
o as isChainL1,
|
|
501
511
|
n as isChainL2,
|
|
502
512
|
p as isChainMainnet,
|
|
@@ -505,7 +515,7 @@ export {
|
|
|
505
515
|
i2 as isValidSafe,
|
|
506
516
|
useAuthAccount,
|
|
507
517
|
useClientToEthersSigner,
|
|
508
|
-
|
|
518
|
+
j as useGraphAuthKit,
|
|
509
519
|
useGraphAuthKitAccount,
|
|
510
520
|
useGraphAuthKitConnector,
|
|
511
521
|
useGraphAuthKitWalletClient,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type Dispatch, type ReactNode } from 'react';
|
|
2
2
|
import { type Address } from 'viem';
|
|
3
|
+
import { type Connector } from 'wagmi';
|
|
3
4
|
import { z } from 'zod';
|
|
4
|
-
import { type SignerError } from '
|
|
5
|
-
import { SafeSupportedNetworks } from '
|
|
6
|
-
import {
|
|
5
|
+
import { type SignerError } from '../errors';
|
|
6
|
+
import { SafeSupportedNetworks } from '../safe';
|
|
7
|
+
import { type RequiredInfuraKey } from '../types';
|
|
7
8
|
export declare const GraphAuthKitModalState: readonly ["primary", "safe_entry", "safe_eoa_signer"];
|
|
8
9
|
export type GraphAuthKitModalState = (typeof GraphAuthKitModalState)[number];
|
|
9
10
|
export declare const MultisigSchema: z.ZodObject<{
|
|
@@ -58,18 +59,16 @@ export type GraphAuthKitInnerState = {
|
|
|
58
59
|
*/
|
|
59
60
|
_authenticating: boolean;
|
|
60
61
|
_setAuthenticating: Dispatch<boolean>;
|
|
61
|
-
/** The user-selected Wallet connector. */
|
|
62
|
-
_connector?: GraphAuthKitConnector;
|
|
63
62
|
/** If the connection fails, display the error message */
|
|
64
63
|
_connectFailureMessage?: SignerError;
|
|
65
64
|
/** Takes the wallet connector the user selected in the modal and connects the user to the wagmi context */
|
|
66
|
-
_connect(connector:
|
|
65
|
+
_connect(connector: Connector): void | Promise<void>;
|
|
67
66
|
/**
|
|
68
67
|
* If the user is connecting via a Safe multisig, take their EoA signer, connect it,
|
|
69
68
|
* and connect the Safe instance to the wagmi context.
|
|
70
69
|
*/
|
|
71
70
|
_connectMultisig(params: {
|
|
72
|
-
connector:
|
|
71
|
+
connector: Connector;
|
|
73
72
|
network: SafeSupportedNetworks;
|
|
74
73
|
address: Address;
|
|
75
74
|
}): void | Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphAuthKitInner.context.d.ts","sourceRoot":"","sources":["../../src/inner/GraphAuthKitInner.context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAgC,MAAM,OAAO,CAAA;AAClG,OAAO,EAAE,KAAK,OAAO,EAAa,MAAM,MAAM,CAAA;AAC9C,OAAO,EAAE,KAAK,SAAS,EAA0D,MAAM,OAAO,CAAA;AAC9F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,WAAW,CAAA;AAC9D,OAAO,EAAe,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAC5D,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEjD,eAAO,MAAM,sBAAsB,uDAAwD,CAAA;AAC3F,MAAM,MAAM,s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A;KACjB,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxB,+DAA+D;IAC/D,MAAM,IAAI,IAAI,CAAA;CACf,CAAA;AAED,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;CAeiB,CAAA;AAC3C,eAAO,MAAM,wBAAwB,iDAAuD,CAAA;AAE5F;;;;;;GAMG;AACH,wBAAgB,2BAA2B,2BAE1C;AAED,MAAM,MAAM,qCAAqC,GAAG,QAAQ,CAAC;IAC3D,SAAS,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAA;IACzC,QAAQ,EAAE,SAAS,CAAA;CACpB,CAAC,CAAA;AACF,wBAAgB,gCAAgC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,qCAAqC,+BAuL9G"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type GraphAuthKitConnectorOpt } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Displays a list of the configured connectors for the user to choose to connect with.
|
|
4
|
+
* Includes:
|
|
5
|
+
* - the injected/installed wallets the user browser has (MetaMask, Rabby, Rainbow, etc)
|
|
6
|
+
* - Coinbase Wallet
|
|
7
|
+
* - WalletConnect
|
|
8
|
+
* - Safe -> we add this as it is not a configured connector due to how we handle multisig connections
|
|
9
|
+
* @returns a list of available wallet connections the user can choose from to connect
|
|
10
|
+
*/
|
|
11
|
+
export declare function usePrimaryConnectOptions(): readonly GraphAuthKitConnectorOpt[];
|
|
12
|
+
export declare function useMultisigConnectOptions(): readonly GraphAuthKitConnectorOpt[];
|
|
13
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/inner/hooks.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAyB,KAAK,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAI/E;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,IAAI,SAAS,wBAAwB,EAAE,CA8C9E;AAED,wBAAgB,yBAAyB,IAAI,SAAS,wBAAwB,EAAE,CAsC/E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/inner/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA;AAC3C,cAAc,SAAS,CAAA"}
|
|
@@ -2,7 +2,7 @@ import { type ReactNode } from 'react';
|
|
|
2
2
|
import { type Chain } from 'viem';
|
|
3
3
|
import { type State } from 'wagmi';
|
|
4
4
|
import { type MockParameters } from 'wagmi/connectors';
|
|
5
|
-
import { type GraphAuthKitInnerState } from '../GraphAuthKitInner.context';
|
|
5
|
+
import { type GraphAuthKitInnerState } from '../inner/GraphAuthKitInner.context';
|
|
6
6
|
export type MockGraphAuthKitProviderProps<chains extends readonly [Chain, ...Chain[]] = readonly [Chain, ...Chain[]]> = {
|
|
7
7
|
infuraKey: string;
|
|
8
8
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MockGraphAuthKit.context.d.ts","sourceRoot":"","sources":["../../src/test-harness/MockGraphAuthKit.context.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,MAAM,CAAA;AACjC,OAAO,EAKL,KAAK,KAAK,EAGX,MAAM,OAAO,CAAA;AACd,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAK5D,OAAO,EAGL,KAAK,sBAAsB,EAE5B,MAAM,
|
|
1
|
+
{"version":3,"file":"MockGraphAuthKit.context.d.ts","sourceRoot":"","sources":["../../src/test-harness/MockGraphAuthKit.context.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,MAAM,CAAA;AACjC,OAAO,EAKL,KAAK,KAAK,EAGX,MAAM,OAAO,CAAA;AACd,OAAO,EAAQ,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAK5D,OAAO,EAGL,KAAK,sBAAsB,EAE5B,MAAM,oCAAoC,CAAA;AAG3C,MAAM,MAAM,6BAA6B,CAAC,MAAM,SAAS,SAAS,CAAC,KAAK,EAAE,GAAG,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,GAAG,KAAK,EAAE,CAAC,IAClH;IACE,SAAS,EAAE,MAAM,CAAA;IAEjB;;;;OAIG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;IACrC;;;;;;OAMG;IACH,mBAAmB,EAAE,cAAc,CAAA;IAEnC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,aAAa,CAAC,EAAE,sBAAsB,CAAA;IAEtC,QAAQ,EAAE,SAAS,CAAA;CACpB,CAAA;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,+BAsC5E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-harness/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-harness/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,SAAS,CAAA"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { jsx } from "@theme-ui/core/jsx-runtime";
|
|
2
2
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
3
3
|
import { createConfig, createStorage, cookieStorage, cookieToInitialState, WagmiProvider, useDisconnect } from "wagmi";
|
|
4
|
-
import { mock } from "wagmi/connectors";
|
|
5
|
-
import { c as chainIsSupportedChain, b as buildClient, G as GraphAuthKitInnerContext, d as defInnerState, u as useGraphAuthKitInnerContext, a as GraphAuthKitContext } from "../GraphAuthKit.context-
|
|
6
|
-
import { L as L2Chain, e as L2ChainTestnet, g as L1Chain, h as L1ChainTestnet, D as DefChain, j as AUTH_STORAGE_KEY } from "../utils-KuRu9vB-.js";
|
|
4
|
+
import { mock, injected, coinbaseWallet, walletConnect } from "wagmi/connectors";
|
|
5
|
+
import { c as chainIsSupportedChain, b as buildClient, G as GraphAuthKitInnerContext, d as defInnerState, u as useGraphAuthKitInnerContext, a as GraphAuthKitContext, R as RequiredInfuraKey } from "../GraphAuthKit.context-BHUGruS-.js";
|
|
6
|
+
import { L as L2Chain, e as L2ChainTestnet, g as L1Chain, h as L1ChainTestnet, D as DefChain, j as AUTH_STORAGE_KEY, k as SupportedClientChainId, S as SafeSupportedNetworks } from "../utils-KuRu9vB-.js";
|
|
7
|
+
import { isAddress } from "viem";
|
|
8
|
+
import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
|
|
9
|
+
import { z } from "zod";
|
|
7
10
|
function MockGraphAuthKitProvider(props) {
|
|
8
11
|
const mockConfig = createConfig({
|
|
9
12
|
chains: [L2Chain, L2ChainTestnet, L1Chain, L1ChainTestnet],
|
|
@@ -58,6 +61,195 @@ function MockGraphAuthKitContent({ children }) {
|
|
|
58
61
|
}
|
|
59
62
|
);
|
|
60
63
|
}
|
|
64
|
+
z.union([
|
|
65
|
+
RequiredInfuraKey.extend({ status: z.literal("disconnected") }),
|
|
66
|
+
RequiredInfuraKey.extend({
|
|
67
|
+
status: z.literal("connected"),
|
|
68
|
+
account: z.union([
|
|
69
|
+
z.object({ type: z.literal("generated") }),
|
|
70
|
+
z.object({
|
|
71
|
+
type: z.literal("provided"),
|
|
72
|
+
/** If the specified connection is with a multisig, this is the multisig address */
|
|
73
|
+
address: z.custom((val) => val != null && typeof val === "string" && isAddress(val)),
|
|
74
|
+
chain: SupportedClientChainId.optional().default(L2Chain.id),
|
|
75
|
+
connector: z.union([
|
|
76
|
+
z.object({
|
|
77
|
+
type: z.union([
|
|
78
|
+
z.literal(injected.type),
|
|
79
|
+
z.literal(coinbaseWallet.type),
|
|
80
|
+
z.literal(walletConnect.type)
|
|
81
|
+
])
|
|
82
|
+
}),
|
|
83
|
+
/** If specified as a multsig, provide the EoA and Safe supported chain */
|
|
84
|
+
z.object({
|
|
85
|
+
type: z.literal("multisig"),
|
|
86
|
+
eoa: z.custom((val) => val != null && typeof val === "string" && isAddress(val)),
|
|
87
|
+
network: SafeSupportedNetworks.optional().default(L2Chain.id)
|
|
88
|
+
})
|
|
89
|
+
])
|
|
90
|
+
})
|
|
91
|
+
])
|
|
92
|
+
})
|
|
93
|
+
]);
|
|
94
|
+
function buildMockProviderState(args) {
|
|
95
|
+
if (args.status === "disconnected") {
|
|
96
|
+
return {
|
|
97
|
+
props: {
|
|
98
|
+
infuraKey: args.infuraKey,
|
|
99
|
+
initialState: void 0,
|
|
100
|
+
innerCtxState: {
|
|
101
|
+
...defInnerState,
|
|
102
|
+
_infuraKey: args.infuraKey
|
|
103
|
+
},
|
|
104
|
+
mockConnectorParams: {
|
|
105
|
+
accounts: ["0x"]
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
connectedAddress: null,
|
|
109
|
+
connector: null,
|
|
110
|
+
graphAuthKitConnector: null,
|
|
111
|
+
chain: null
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (args.account.type === "generated") {
|
|
115
|
+
const privKey = generatePrivateKey();
|
|
116
|
+
const account = privateKeyToAccount(privKey);
|
|
117
|
+
const address = account.address;
|
|
118
|
+
const connector2 = selectedTypeToMockConnector("injected");
|
|
119
|
+
return {
|
|
120
|
+
props: {
|
|
121
|
+
infuraKey: args.infuraKey,
|
|
122
|
+
initialState: {
|
|
123
|
+
status: "connected",
|
|
124
|
+
chainId: L2Chain.id,
|
|
125
|
+
connections: /* @__PURE__ */ new Map([
|
|
126
|
+
[
|
|
127
|
+
connector2.uid,
|
|
128
|
+
{
|
|
129
|
+
accounts: [address],
|
|
130
|
+
chainId: L2Chain.id,
|
|
131
|
+
connector: connector2
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
]),
|
|
135
|
+
current: connector2.uid
|
|
136
|
+
},
|
|
137
|
+
innerCtxState: {
|
|
138
|
+
...defInnerState,
|
|
139
|
+
_infuraKey: args.infuraKey
|
|
140
|
+
},
|
|
141
|
+
mockConnectorParams: {
|
|
142
|
+
accounts: [address]
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
connectedAddress: address,
|
|
146
|
+
connector: connector2,
|
|
147
|
+
graphAuthKitConnector: "injected",
|
|
148
|
+
chain: L2Chain.id
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
if (args.account.connector.type === "multisig") {
|
|
152
|
+
const connector2 = selectedTypeToMockConnector("injected");
|
|
153
|
+
return {
|
|
154
|
+
props: {
|
|
155
|
+
infuraKey: args.infuraKey,
|
|
156
|
+
initialState: {
|
|
157
|
+
status: "connected",
|
|
158
|
+
chainId: args.account.connector.network,
|
|
159
|
+
connections: /* @__PURE__ */ new Map([
|
|
160
|
+
[
|
|
161
|
+
connector2.uid,
|
|
162
|
+
{
|
|
163
|
+
accounts: [args.account.connector.eoa],
|
|
164
|
+
chainId: args.account.connector.network,
|
|
165
|
+
connector: connector2
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
]),
|
|
169
|
+
current: connector2.uid
|
|
170
|
+
},
|
|
171
|
+
innerCtxState: {
|
|
172
|
+
...defInnerState,
|
|
173
|
+
_infuraKey: args.infuraKey,
|
|
174
|
+
_enteredMultisigInfo: {
|
|
175
|
+
address: args.account.address,
|
|
176
|
+
network: args.account.connector.network,
|
|
177
|
+
enteredSafeIsValid: true
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
mockConnectorParams: {
|
|
181
|
+
accounts: [args.account.address, args.account.connector.eoa]
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
connectedAddress: args.account.address,
|
|
185
|
+
connector: connector2,
|
|
186
|
+
graphAuthKitConnector: args.account.connector.type,
|
|
187
|
+
chain: args.account.connector.network
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
const connector = selectedTypeToMockConnector(args.account.connector.type);
|
|
191
|
+
return {
|
|
192
|
+
props: {
|
|
193
|
+
infuraKey: args.infuraKey,
|
|
194
|
+
initialState: {
|
|
195
|
+
status: "connected",
|
|
196
|
+
chainId: args.account.chain,
|
|
197
|
+
connections: /* @__PURE__ */ new Map([
|
|
198
|
+
[
|
|
199
|
+
connector.uid,
|
|
200
|
+
{
|
|
201
|
+
accounts: [args.account.address],
|
|
202
|
+
chainId: args.account.chain,
|
|
203
|
+
connector
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
]),
|
|
207
|
+
current: connector.uid
|
|
208
|
+
},
|
|
209
|
+
innerCtxState: {
|
|
210
|
+
...defInnerState,
|
|
211
|
+
_infuraKey: args.infuraKey
|
|
212
|
+
},
|
|
213
|
+
mockConnectorParams: {
|
|
214
|
+
accounts: [args.account.address]
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
connectedAddress: args.account.address,
|
|
218
|
+
connector,
|
|
219
|
+
graphAuthKitConnector: args.account.connector.type,
|
|
220
|
+
chain: args.account.chain
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
const disconnectedMockState = buildMockProviderState({
|
|
224
|
+
infuraKey: "doesnotmatter.notconnected",
|
|
225
|
+
status: "disconnected"
|
|
226
|
+
});
|
|
227
|
+
function selectedTypeToMockConnector(connector) {
|
|
228
|
+
switch (connector) {
|
|
229
|
+
case "coinbaseWallet": {
|
|
230
|
+
return {
|
|
231
|
+
id: "coinbaseWalletSDK",
|
|
232
|
+
name: "Coinbase Wallet",
|
|
233
|
+
uid: "192a483cf83",
|
|
234
|
+
type: "coinbaseWallet"
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
case "walletConnect": {
|
|
238
|
+
return {
|
|
239
|
+
id: "walletConnect",
|
|
240
|
+
name: "WalletConnect",
|
|
241
|
+
uid: "92a483cf83b",
|
|
242
|
+
type: "walletConnect"
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
case "multisig":
|
|
246
|
+
default: {
|
|
247
|
+
return { id: "io.metamask", name: "MetaMask", type: "injected", uid: "27cbd81134e" };
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
61
251
|
export {
|
|
62
|
-
MockGraphAuthKitProvider
|
|
252
|
+
MockGraphAuthKitProvider,
|
|
253
|
+
buildMockProviderState,
|
|
254
|
+
disconnectedMockState
|
|
63
255
|
};
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { type Address } from 'viem';
|
|
2
|
+
import { type Connector } from 'wagmi';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { SupportedClientChainId } from '../constants';
|
|
5
|
+
import { type GraphAuthKitConnector } from '../types';
|
|
6
|
+
import { type MockGraphAuthKitProviderProps } from './MockGraphAuthKit.context';
|
|
7
|
+
declare const BuildMockProviderStateArgs: z.ZodUnion<readonly [z.ZodObject<z.objectUtil.extendShape<{
|
|
8
|
+
infuraKey: z.ZodReadonly<z.ZodString>;
|
|
9
|
+
}, {
|
|
10
|
+
status: z.ZodLiteral<"disconnected">;
|
|
11
|
+
}>, "strip", z.ZodTypeAny, {
|
|
12
|
+
status: "disconnected";
|
|
13
|
+
infuraKey: string;
|
|
14
|
+
}, {
|
|
15
|
+
status: "disconnected";
|
|
16
|
+
infuraKey: string;
|
|
17
|
+
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
18
|
+
infuraKey: z.ZodReadonly<z.ZodString>;
|
|
19
|
+
}, {
|
|
20
|
+
status: z.ZodLiteral<"connected">;
|
|
21
|
+
account: z.ZodUnion<readonly [z.ZodObject<{
|
|
22
|
+
type: z.ZodLiteral<"generated">;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
type: "generated";
|
|
25
|
+
}, {
|
|
26
|
+
type: "generated";
|
|
27
|
+
}>, z.ZodObject<{
|
|
28
|
+
type: z.ZodLiteral<"provided">;
|
|
29
|
+
/** If the specified connection is with a multisig, this is the multisig address */
|
|
30
|
+
address: z.ZodType<string, z.ZodTypeDef, string>;
|
|
31
|
+
chain: z.ZodDefault<z.ZodOptional<z.ZodReadonly<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<11155111>, z.ZodLiteral<42161>, z.ZodLiteral<421614>]>>>>;
|
|
32
|
+
connector: z.ZodUnion<readonly [z.ZodObject<{
|
|
33
|
+
type: z.ZodUnion<readonly [z.ZodLiteral<"injected">, z.ZodLiteral<"coinbaseWallet">, z.ZodLiteral<"walletConnect">]>;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
type: "injected" | "coinbaseWallet" | "walletConnect";
|
|
36
|
+
}, {
|
|
37
|
+
type: "injected" | "coinbaseWallet" | "walletConnect";
|
|
38
|
+
}>, z.ZodObject<{
|
|
39
|
+
type: z.ZodLiteral<"multisig">;
|
|
40
|
+
eoa: z.ZodType<string, z.ZodTypeDef, string>;
|
|
41
|
+
network: z.ZodDefault<z.ZodOptional<z.ZodReadonly<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<11155111>, z.ZodLiteral<42161>]>>>>;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
type: "multisig";
|
|
44
|
+
network: 1 | 11155111 | 42161;
|
|
45
|
+
eoa: string;
|
|
46
|
+
}, {
|
|
47
|
+
type: "multisig";
|
|
48
|
+
eoa: string;
|
|
49
|
+
network?: 1 | 11155111 | 42161 | undefined;
|
|
50
|
+
}>]>;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
type: "provided";
|
|
53
|
+
chain: 1 | 11155111 | 42161 | 421614;
|
|
54
|
+
address: string;
|
|
55
|
+
connector: {
|
|
56
|
+
type: "injected" | "coinbaseWallet" | "walletConnect";
|
|
57
|
+
} | {
|
|
58
|
+
type: "multisig";
|
|
59
|
+
network: 1 | 11155111 | 42161;
|
|
60
|
+
eoa: string;
|
|
61
|
+
};
|
|
62
|
+
}, {
|
|
63
|
+
type: "provided";
|
|
64
|
+
address: string;
|
|
65
|
+
connector: {
|
|
66
|
+
type: "injected" | "coinbaseWallet" | "walletConnect";
|
|
67
|
+
} | {
|
|
68
|
+
type: "multisig";
|
|
69
|
+
eoa: string;
|
|
70
|
+
network?: 1 | 11155111 | 42161 | undefined;
|
|
71
|
+
};
|
|
72
|
+
chain?: 1 | 11155111 | 42161 | 421614 | undefined;
|
|
73
|
+
}>]>;
|
|
74
|
+
}>, "strip", z.ZodTypeAny, {
|
|
75
|
+
status: "connected";
|
|
76
|
+
infuraKey: string;
|
|
77
|
+
account: {
|
|
78
|
+
type: "generated";
|
|
79
|
+
} | {
|
|
80
|
+
type: "provided";
|
|
81
|
+
chain: 1 | 11155111 | 42161 | 421614;
|
|
82
|
+
address: string;
|
|
83
|
+
connector: {
|
|
84
|
+
type: "injected" | "coinbaseWallet" | "walletConnect";
|
|
85
|
+
} | {
|
|
86
|
+
type: "multisig";
|
|
87
|
+
network: 1 | 11155111 | 42161;
|
|
88
|
+
eoa: string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
}, {
|
|
92
|
+
status: "connected";
|
|
93
|
+
infuraKey: string;
|
|
94
|
+
account: {
|
|
95
|
+
type: "generated";
|
|
96
|
+
} | {
|
|
97
|
+
type: "provided";
|
|
98
|
+
address: string;
|
|
99
|
+
connector: {
|
|
100
|
+
type: "injected" | "coinbaseWallet" | "walletConnect";
|
|
101
|
+
} | {
|
|
102
|
+
type: "multisig";
|
|
103
|
+
eoa: string;
|
|
104
|
+
network?: 1 | 11155111 | 42161 | undefined;
|
|
105
|
+
};
|
|
106
|
+
chain?: 1 | 11155111 | 42161 | 421614 | undefined;
|
|
107
|
+
};
|
|
108
|
+
}>]>;
|
|
109
|
+
export type BuildMockProviderStateArgs = z.infer<typeof BuildMockProviderStateArgs>;
|
|
110
|
+
/**
|
|
111
|
+
* Util function to build the correct props and state to setup the `MockGraphAuthKitProvider`
|
|
112
|
+
* instance to be either connected or disconnected to test components/hooks that rely on the
|
|
113
|
+
* apps connected state, wagmi hooks, or graph-auth-kit hooks.
|
|
114
|
+
*
|
|
115
|
+
* @example <caption>Disconnected</caption>
|
|
116
|
+
* ```tsx
|
|
117
|
+
* import { buildMockProviderState, MockGraphAuthKitProvider } from '@edgeandnode/graph-auth-kit/test-harness'
|
|
118
|
+
*
|
|
119
|
+
* const infuraKey = ''
|
|
120
|
+
*
|
|
121
|
+
* const { props } = buildMockProviderState({ status: 'disconnected', infuraKey })
|
|
122
|
+
*
|
|
123
|
+
* return (
|
|
124
|
+
* <MockGraphAuthKitProvider {...props}>
|
|
125
|
+
* <SwitchChain requestedChain={L2Chain} />
|
|
126
|
+
* </MockGraphAuthKitProvider>
|
|
127
|
+
* )
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* @example <caption>Connected | generated address</caption>
|
|
131
|
+
* ```tsx
|
|
132
|
+
* import { buildMockProviderState, MockGraphAuthKitProvider } from '@edgeandnode/graph-auth-kit/test-harness'
|
|
133
|
+
*
|
|
134
|
+
* const infuraKey = ''
|
|
135
|
+
*
|
|
136
|
+
* const { props } = buildMockProviderState({ status: 'connected', infuraKey, account: { type: 'generated' } })
|
|
137
|
+
*
|
|
138
|
+
* return (
|
|
139
|
+
* <MockGraphAuthKitProvider {...props}>
|
|
140
|
+
* <SwitchChain requestedChain={L2Chain} />
|
|
141
|
+
* </MockGraphAuthKitProvider>
|
|
142
|
+
* )
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @example <caption>Connected | provided address | EoA account</caption>
|
|
146
|
+
* ```tsx
|
|
147
|
+
* import { buildMockProviderState, MockGraphAuthKitProvider } from '@edgeandnode/graph-auth-kit/test-harness'
|
|
148
|
+
*
|
|
149
|
+
* const infuraKey = ''
|
|
150
|
+
*
|
|
151
|
+
* const { props } = buildMockProviderState({
|
|
152
|
+
* status: 'connected',
|
|
153
|
+
* infuraKey,
|
|
154
|
+
* account: {
|
|
155
|
+
* type: 'provided',
|
|
156
|
+
* address: '0x8c1b521970fDAB85d71260E08ee1dA5Dd878c60D',
|
|
157
|
+
* chain: 42161,
|
|
158
|
+
* connector: { type: 'injected' }
|
|
159
|
+
* }
|
|
160
|
+
* })
|
|
161
|
+
*
|
|
162
|
+
* return (
|
|
163
|
+
* <MockGraphAuthKitProvider {...props}>
|
|
164
|
+
* <SwitchChain requestedChain={L2Chain} />
|
|
165
|
+
* </MockGraphAuthKitProvider>
|
|
166
|
+
* )
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* @example <caption>Connected | provided address | Multisig account</caption>
|
|
170
|
+
* ```tsx
|
|
171
|
+
* import { buildMockProviderState, MockGraphAuthKitProvider } from '@edgeandnode/graph-auth-kit/test-harness'
|
|
172
|
+
*
|
|
173
|
+
* const infuraKey = ''
|
|
174
|
+
*
|
|
175
|
+
* const { props } = buildMockProviderState({
|
|
176
|
+
* status: 'connected',
|
|
177
|
+
* infuraKey,
|
|
178
|
+
* account: {
|
|
179
|
+
* type: 'provided',
|
|
180
|
+
* address: '0x177A0331E70e137Fd9f678F19093eA08aD1F5685',
|
|
181
|
+
* chain: 42161,
|
|
182
|
+
* connector: {
|
|
183
|
+
* type: 'multisig',
|
|
184
|
+
* eoa: '0x8c1b521970fDAB85d71260E08ee1dA5Dd878c60D',
|
|
185
|
+
* network: 42161
|
|
186
|
+
* }
|
|
187
|
+
* }
|
|
188
|
+
* })
|
|
189
|
+
*
|
|
190
|
+
* return (
|
|
191
|
+
* <MockGraphAuthKitProvider {...props}>
|
|
192
|
+
* <SwitchChain requestedChain={L2Chain} />
|
|
193
|
+
* </MockGraphAuthKitProvider>
|
|
194
|
+
* )
|
|
195
|
+
* ```
|
|
196
|
+
*
|
|
197
|
+
* @returns the built MockGraphAuthKitProvider props and connected/disconnected state values
|
|
198
|
+
*/
|
|
199
|
+
export declare function buildMockProviderState(args: BuildMockProviderStateArgs): {
|
|
200
|
+
props: Pick<MockGraphAuthKitProviderProps, 'initialState' | 'innerCtxState' | 'mockConnectorParams' | 'infuraKey'>;
|
|
201
|
+
connectedAddress: Address | null;
|
|
202
|
+
connector: Connector | null;
|
|
203
|
+
graphAuthKitConnector: GraphAuthKitConnector | null;
|
|
204
|
+
chain: SupportedClientChainId | null;
|
|
205
|
+
};
|
|
206
|
+
export declare const disconnectedMockState: {
|
|
207
|
+
props: Pick<MockGraphAuthKitProviderProps, "initialState" | "innerCtxState" | "mockConnectorParams" | "infuraKey">;
|
|
208
|
+
connectedAddress: Address | null;
|
|
209
|
+
connector: Connector | null;
|
|
210
|
+
graphAuthKitConnector: GraphAuthKitConnector | null;
|
|
211
|
+
chain: SupportedClientChainId | null;
|
|
212
|
+
};
|
|
213
|
+
export {};
|
|
214
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/test-harness/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAa,MAAM,MAAM,CAAA;AAE9C,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAEvD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAW,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAG9D,OAAO,EAAE,KAAK,qBAAqB,EAAqB,MAAM,UAAU,CAAA;AAExE,OAAO,EAAE,KAAK,6BAA6B,EAAE,MAAM,4BAA4B,CAAA;AAE/E,QAAA,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;QAQxB,mFAAmF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAqBhF,CAAA;AACX,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAEnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,0BAA0B,GAAG;IACxE,KAAK,EAAE,IAAI,CAAC,6BAA6B,EAAE,cAAc,GAAG,eAAe,GAAG,qBAAqB,GAAG,WAAW,CAAC,CAAA;IAClH,gBAAgB,EAAE,OAAO,GAAG,IAAI,CAAA;IAChC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAA;IAC3B,qBAAqB,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACnD,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAAA;CACrC,CAuIA;AACD,eAAO,MAAM,qBAAqB;WA7IzB,IAAI,CAAC,6BAA6B,EAAE,cAAc,GAAG,eAAe,GAAG,qBAAqB,GAAG,WAAW,CAAC;sBAChG,OAAO,GAAG,IAAI;eACrB,SAAS,GAAG,IAAI;2BACJ,qBAAqB,GAAG,IAAI;WAC5C,sBAAsB,GAAG,IAAI;CA4IpC,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
export declare const RequiredInfuraKey: z.ZodObject<{
|
|
3
4
|
infuraKey: z.ZodReadonly<z.ZodString>;
|
|
@@ -49,6 +50,16 @@ export declare const GraphAuthKitProps: z.ZodObject<z.objectUtil.extendShape<z.o
|
|
|
49
50
|
chains?: "ALL" | "MAINNET" | "TESTNET" | undefined;
|
|
50
51
|
}>;
|
|
51
52
|
export type GraphAuthKitProps = z.infer<typeof GraphAuthKitProps>;
|
|
52
|
-
export declare const GraphAuthKitConnector: z.
|
|
53
|
+
export declare const GraphAuthKitConnector: z.ZodUnion<readonly [z.ZodLiteral<"injected">, z.ZodLiteral<"coinbaseWallet">, z.ZodLiteral<"walletConnect">, z.ZodLiteral<"multisig">]>;
|
|
53
54
|
export type GraphAuthKitConnector = z.infer<typeof GraphAuthKitConnector>;
|
|
55
|
+
export type GraphAuthKitConnectorOpt = {
|
|
56
|
+
/** The RDNS UUID of the connector from the wagmi connector mipd */
|
|
57
|
+
id: string;
|
|
58
|
+
connector: GraphAuthKitConnector;
|
|
59
|
+
/** The connector option is an injected wallet installed in the users browser */
|
|
60
|
+
installed: boolean;
|
|
61
|
+
title: ReactNode;
|
|
62
|
+
Image: ReactNode;
|
|
63
|
+
onConnect(): void | Promise<void>;
|
|
64
|
+
};
|
|
54
65
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,iBAAiB;;;;;;EAE5B,CAAA;AACF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAEjE,eAAO,MAAM,8BAA8B;;;;;;EAEzC,CAAA;AACF,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAA;AAE3F,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAW5B,CAAA;AACF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAEjE,eAAO,MAAM,qBAAqB,0IAKvB,CAAA;AACX,MAAM,MAAM,qB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