@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
@@ -0,0 +1,103 @@
1
+ import { ReactNode } from 'react';
2
+ import { Chain } from 'viem';
3
+ import { State } from 'wagmi';
4
+ import { MockParameters } from 'wagmi/connectors';
5
+ import { GraphAuthKitInnerState } from '../inner/GraphAuthKitInner.context';
6
+ export type MockGraphAuthKitProviderProps<chains extends readonly [Chain, ...Chain[]] = readonly [Chain, ...Chain[]]> = {
7
+ infuraKey: string;
8
+ gatewayApiKey?: string | null;
9
+ /**
10
+ * Provide an initial state to pass to the `WagmiConfig` that establishes if we have a connected (authenticated) user
11
+ * If a string, use the `cookieToInitialState` util to derive
12
+ * @see https://wagmi.sh/core/api/createConfig#state-1
13
+ */
14
+ initialState?: State<chains> | string;
15
+ /**
16
+ * Parameters that are passed to the `mock` connector constructor for building the mock connector.
17
+ * Includes:
18
+ * - accounts -> addresses to establish as connected for the user
19
+ *
20
+ * @see https://wagmi.sh/react/api/connectors/mock#parameters
21
+ */
22
+ mockConnectorParams: MockParameters;
23
+ /**
24
+ * Provide the default value for the inner context.
25
+ * Allows the mock to set the conntected state up with a safe, etc.
26
+ *
27
+ * @default {
28
+ * _infuraKey: '',
29
+ * _connectModalOpen: false,
30
+ * _setConnectModalOpen() {},
31
+ * _modalTitle: 'Connect your wallet',
32
+ * _setModalTitle() {},
33
+ * _setModalSubtitle() {},
34
+ * _modalState: 'primary',
35
+ * _setModalState() {},
36
+ * _setSafeInfo() {},
37
+ * _authenticating: false,
38
+ * _setAuthenticating() {},
39
+ * _connect() {},
40
+ * _connectMultisig() {},
41
+ * _reset() {},
42
+ * }
43
+ */
44
+ innerCtxState?: GraphAuthKitInnerState;
45
+ children: ReactNode;
46
+ };
47
+ /**
48
+ * Exposed mock `<GraphAuthKitProvider>` instance for testing components and hooks exposed
49
+ * by this library and wagmi.
50
+ *
51
+ * Allows for passing in addresses and information to establish an authenticated/connected `WagmiProvider` instance.
52
+ *
53
+ * @example <caption>User is not authenticated</caption>
54
+ * ```tsx
55
+ * import { MockGraphAuthKitProvider } from '@graphprotocol/graph-auth-kit/test-harness'
56
+ *
57
+ * <MockGraphAuthKitProvider infuraKey="abc123" mockConnectorParams={{ accounts: ['0x'] }}>
58
+ * <RendersAccount />
59
+ * </MockGraphAuthKitProvider>
60
+ * ```
61
+ *
62
+ * @example <caption>User is authenticated</caption>
63
+ * ```tsx
64
+ * import { MockGraphAuthKitProvider } from '@graphprotocol/graph-auth-kit/test-harness'
65
+ *
66
+ * <MockGraphAuthKitProvider
67
+ * infuraKey="abc123"
68
+ * mockConnectorParams={{ accounts: ['0x8c1b521970fDAB85d71260E08ee1dA5Dd878c60D'] }}
69
+ * initialState={{
70
+ * chainId: 42161,
71
+ * status: 'connected',
72
+ * current: null,
73
+ * connections: new Map<string, Connection>()
74
+ * }}
75
+ * innerCtxState={{...default, _connector: 'injected'}}
76
+ * >
77
+ * <RendersAccount />
78
+ * </MockGraphAuthKitProvider>
79
+ * ```
80
+ *
81
+ * @example <caption>User is authenticated with a Safe</caption>
82
+ * ```tsx
83
+ * import { MockGraphAuthKitProvider } from '@graphprotocol/graph-auth-kit/test-harness'
84
+ *
85
+ * <MockGraphAuthKitProvider
86
+ * infuraKey="abc123"
87
+ * mockConnectorParams={{ accounts: ['0x8c1b521970fDAB85d71260E08ee1dA5Dd878c60D'] }}
88
+ * initialState={{
89
+ * chainId: 42161,
90
+ * status: 'connected',
91
+ * current: null,
92
+ * connections: new Map<string, Connection>()
93
+ * }}
94
+ * innerCtxState={{...default, _connector: 'multisig', _enteredMultisigInfo: {address: '0x8c1b521970fDAB85d71260E08ee1dA5Dd878c60D',network:42161} }}
95
+ * >
96
+ * <RendersAccount />
97
+ * </MockGraphAuthKitProvider>
98
+ * ```
99
+ *
100
+ * @param props used to initialize the wagmi and inner context state
101
+ */
102
+ export declare function MockGraphAuthKitProvider(props: MockGraphAuthKitProviderProps): import("react/jsx-runtime").JSX.Element;
103
+ //# sourceMappingURL=MockGraphAuthKit.context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MockGraphAuthKit.context.d.ts","sourceRoot":"","sources":["../../src/test-harness/MockGraphAuthKit.context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,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;IACjB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAE7B;;;;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,2CAsC5E"}
@@ -0,0 +1,3 @@
1
+ export * from './MockGraphAuthKit.context';
2
+ export * from './utils';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test-harness/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,SAAS,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { M, b, d } from "../utils-Br1fBg8o.js";
2
+ export {
3
+ M as MockGraphAuthKitProvider,
4
+ b as buildMockProviderState,
5
+ d as disconnectedMockState
6
+ };
@@ -0,0 +1,135 @@
1
+ import { Address } from 'viem';
2
+ import { Connector } from 'wagmi';
3
+ import { z } from 'zod';
4
+ import { SupportedClientChainId } from '../constants';
5
+ import { GraphAuthKitConnector } from '../types';
6
+ import { MockGraphAuthKitProviderProps } from './MockGraphAuthKit.context';
7
+ declare const BuildMockProviderStateArgs: z.ZodUnion<readonly [z.ZodObject<{
8
+ infuraKey: z.ZodReadonly<z.ZodString>;
9
+ gatewayApiKey: z.ZodNullable<z.ZodOptional<z.ZodString>>;
10
+ status: z.ZodLiteral<"disconnected">;
11
+ }, z.core.$strip>, z.ZodObject<{
12
+ infuraKey: z.ZodReadonly<z.ZodString>;
13
+ gatewayApiKey: z.ZodNullable<z.ZodOptional<z.ZodString>>;
14
+ status: z.ZodLiteral<"connected">;
15
+ account: z.ZodUnion<readonly [z.ZodObject<{
16
+ type: z.ZodLiteral<"generated">;
17
+ }, z.core.$strip>, z.ZodObject<{
18
+ type: z.ZodLiteral<"provided">;
19
+ address: z.ZodCustom<string, string>;
20
+ chain: z.ZodDefault<z.ZodOptional<z.ZodReadonly<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<11155111>, z.ZodLiteral<42161>, z.ZodLiteral<421614>]>>>>;
21
+ connector: z.ZodUnion<readonly [z.ZodObject<{
22
+ type: z.ZodUnion<readonly [z.ZodLiteral<"injected">, z.ZodLiteral<"coinbaseWallet">, z.ZodLiteral<"walletConnect">]>;
23
+ }, z.core.$strip>, z.ZodObject<{
24
+ type: z.ZodLiteral<"multisig">;
25
+ eoa: z.ZodCustom<string, string>;
26
+ network: z.ZodDefault<z.ZodOptional<z.ZodReadonly<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<11155111>, z.ZodLiteral<42161>]>>>>;
27
+ }, z.core.$strip>]>;
28
+ }, z.core.$strip>]>;
29
+ }, z.core.$strip>]>;
30
+ export type BuildMockProviderStateArgs = z.infer<typeof BuildMockProviderStateArgs>;
31
+ /**
32
+ * Util function to build the correct props and state to setup the `MockGraphAuthKitProvider`
33
+ * instance to be either connected or disconnected to test components/hooks that rely on the
34
+ * apps connected state, wagmi hooks, or graph-auth-kit hooks.
35
+ *
36
+ * @example <caption>Disconnected</caption>
37
+ * ```tsx
38
+ * import { buildMockProviderState, MockGraphAuthKitProvider } from '@graphprotocol/graph-auth-kit/test-harness'
39
+ *
40
+ * const infuraKey = ''
41
+ *
42
+ * const { props } = buildMockProviderState({ status: 'disconnected', infuraKey })
43
+ *
44
+ * return (
45
+ * <MockGraphAuthKitProvider {...props}>
46
+ * <SwitchChain requestedChain={L2Chain} />
47
+ * </MockGraphAuthKitProvider>
48
+ * )
49
+ * ```
50
+ *
51
+ * @example <caption>Connected | generated address</caption>
52
+ * ```tsx
53
+ * import { buildMockProviderState, MockGraphAuthKitProvider } from '@graphprotocol/graph-auth-kit/test-harness'
54
+ *
55
+ * const infuraKey = ''
56
+ *
57
+ * const { props } = buildMockProviderState({ status: 'connected', infuraKey, account: { type: 'generated' } })
58
+ *
59
+ * return (
60
+ * <MockGraphAuthKitProvider {...props}>
61
+ * <SwitchChain requestedChain={L2Chain} />
62
+ * </MockGraphAuthKitProvider>
63
+ * )
64
+ * ```
65
+ *
66
+ * @example <caption>Connected | provided address | EoA account</caption>
67
+ * ```tsx
68
+ * import { buildMockProviderState, MockGraphAuthKitProvider } from '@graphprotocol/graph-auth-kit/test-harness'
69
+ *
70
+ * const infuraKey = ''
71
+ *
72
+ * const { props } = buildMockProviderState({
73
+ * status: 'connected',
74
+ * infuraKey,
75
+ * account: {
76
+ * type: 'provided',
77
+ * address: '0x8c1b521970fDAB85d71260E08ee1dA5Dd878c60D',
78
+ * chain: 42161,
79
+ * connector: { type: 'injected' }
80
+ * }
81
+ * })
82
+ *
83
+ * return (
84
+ * <MockGraphAuthKitProvider {...props}>
85
+ * <SwitchChain requestedChain={L2Chain} />
86
+ * </MockGraphAuthKitProvider>
87
+ * )
88
+ * ```
89
+ *
90
+ * @example <caption>Connected | provided address | Multisig account</caption>
91
+ * ```tsx
92
+ * import { buildMockProviderState, MockGraphAuthKitProvider } from '@graphprotocol/graph-auth-kit/test-harness'
93
+ *
94
+ * const infuraKey = ''
95
+ *
96
+ * const { props } = buildMockProviderState({
97
+ * status: 'connected',
98
+ * infuraKey,
99
+ * account: {
100
+ * type: 'provided',
101
+ * address: '0x177A0331E70e137Fd9f678F19093eA08aD1F5685',
102
+ * chain: 42161,
103
+ * connector: {
104
+ * type: 'multisig',
105
+ * eoa: '0x8c1b521970fDAB85d71260E08ee1dA5Dd878c60D',
106
+ * network: 42161
107
+ * }
108
+ * }
109
+ * })
110
+ *
111
+ * return (
112
+ * <MockGraphAuthKitProvider {...props}>
113
+ * <SwitchChain requestedChain={L2Chain} />
114
+ * </MockGraphAuthKitProvider>
115
+ * )
116
+ * ```
117
+ *
118
+ * @returns the built MockGraphAuthKitProvider props and connected/disconnected state values
119
+ */
120
+ export declare function buildMockProviderState(args: BuildMockProviderStateArgs): {
121
+ props: Pick<MockGraphAuthKitProviderProps, 'initialState' | 'innerCtxState' | 'mockConnectorParams' | 'infuraKey' | 'gatewayApiKey'>;
122
+ connectedAddress: Address | null;
123
+ connector: Connector | null;
124
+ graphAuthKitConnector: GraphAuthKitConnector | null;
125
+ chain: SupportedClientChainId | null;
126
+ };
127
+ export declare const disconnectedMockState: {
128
+ props: Pick<MockGraphAuthKitProviderProps, "initialState" | "innerCtxState" | "mockConnectorParams" | "infuraKey" | "gatewayApiKey">;
129
+ connectedAddress: Address | null;
130
+ connector: Connector | null;
131
+ graphAuthKitConnector: GraphAuthKitConnector | null;
132
+ chain: SupportedClientChainId | null;
133
+ };
134
+ export {};
135
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/test-harness/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAa,MAAM,MAAM,CAAA;AAE9C,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,OAAO,CAAA;AAElD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAW,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAG9D,OAAO,EAAE,KAAK,qBAAqB,EAA4C,MAAM,UAAU,CAAA;AAE/F,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAA;AAE/E,QAAA,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;mBA6BrB,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,CACT,6BAA6B,EAC7B,cAAc,GAAG,eAAe,GAAG,qBAAqB,GAAG,WAAW,GAAG,eAAe,CACzF,CAAA;IACD,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,CA8KA;AACD,eAAO,MAAM,qBAAqB;WAvLzB,IAAI,CACT,6BAA6B,EAC7B,cAAc,GAAG,eAAe,GAAG,qBAAqB,GAAG,WAAW,GAAG,eAAe,CACzF;sBACiB,OAAO,GAAG,IAAI;eACrB,SAAS,GAAG,IAAI;2BACJ,qBAAqB,GAAG,IAAI;WAC5C,sBAAsB,GAAG,IAAI;CAmLpC,CAAA"}
@@ -0,0 +1,37 @@
1
+ import { ReactNode } from 'react';
2
+ import { z } from 'zod';
3
+ export declare const RequiredInfuraKey: z.ZodObject<{
4
+ infuraKey: z.ZodReadonly<z.ZodString>;
5
+ }, z.core.$strip>;
6
+ export type RequiredInfuraKey = z.infer<typeof RequiredInfuraKey>;
7
+ export declare const RequiredWalletConnectProjectId: z.ZodObject<{
8
+ walletConnectProjectID: z.ZodReadonly<z.ZodString>;
9
+ }, z.core.$strip>;
10
+ export type RequiredWalletConnectProjectId = z.infer<typeof RequiredWalletConnectProjectId>;
11
+ export declare const OptionalGatewayApiKey: z.ZodObject<{
12
+ gatewayApiKey: z.ZodNullable<z.ZodOptional<z.ZodString>>;
13
+ }, z.core.$strip>;
14
+ export type OptionalGatewayApiKey = z.infer<typeof OptionalGatewayApiKey>;
15
+ export declare const OptionalSafeApiKey: z.ZodObject<{
16
+ safeApiKey: z.ZodOptional<z.ZodString>;
17
+ }, z.core.$strip>;
18
+ export type OptionalSafeApiKey = z.infer<typeof OptionalSafeApiKey>;
19
+ export declare const GraphAuthKitProps: z.ZodObject<{
20
+ infuraKey: z.ZodReadonly<z.ZodString>;
21
+ gatewayApiKey: z.ZodNullable<z.ZodOptional<z.ZodString>>;
22
+ safeApiKey: z.ZodOptional<z.ZodString>;
23
+ }, z.core.$strip>;
24
+ export type GraphAuthKitProps = z.infer<typeof GraphAuthKitProps>;
25
+ export declare const GraphAuthKitConnector: z.ZodUnion<readonly [z.ZodLiteral<"injected">, z.ZodLiteral<"coinbaseWallet">, z.ZodLiteral<"walletConnect">, z.ZodLiteral<"multisig">]>;
26
+ export type GraphAuthKitConnector = z.infer<typeof GraphAuthKitConnector>;
27
+ export type GraphAuthKitConnectorOpt = {
28
+ /** The RDNS UUID of the connector from the wagmi connector mipd */
29
+ id: string;
30
+ connector: GraphAuthKitConnector;
31
+ /** The connector option is an injected wallet installed in the users browser */
32
+ installed: boolean;
33
+ title: ReactNode;
34
+ Image: ReactNode;
35
+ onConnect(): void | Promise<void>;
36
+ };
37
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,iBAAiB;;iBAE5B,CAAA;AACF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAEjE,eAAO,MAAM,8BAA8B;;iBAEzC,CAAA;AACF,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAA;AAE3F,eAAO,MAAM,qBAAqB;;iBAQhC,CAAA;AACF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAEzE,eAAO,MAAM,kBAAkB;;iBAE7B,CAAA;AACF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAEnE,eAAO,MAAM,iBAAiB;;;;iBAA2E,CAAA;AACzG,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAEjE,eAAO,MAAM,qBAAqB,0IAKvB,CAAA;AACX,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAEzE,MAAM,MAAM,wBAAwB,GAAG;IACrC,mEAAmE;IACnE,EAAE,EAAE,MAAM,CAAA;IAEV,SAAS,EAAE,qBAAqB,CAAA;IAEhC,gFAAgF;IAChF,SAAS,EAAE,OAAO,CAAA;IAElB,KAAK,EAAE,SAAS,CAAA;IAChB,KAAK,EAAE,SAAS,CAAA;IAEhB,SAAS,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAClC,CAAA"}
@@ -0,0 +1,211 @@
1
+ "use client";
2
+ import { createIdenticon } from "@graphprotocol/gds";
3
+ import { getEnsAvatarQueryKey, getEnsNameQueryKey } from "@wagmi/core/query";
4
+ import { useQuery } from "wagmi/query";
5
+ import { K as useGraphAuthKitInnerContext, y as isSupportedChainId, o as L2Chain, n as L1ChainTestnet, p as L2ChainTestnet, L as L1Chain } from "./GraphAuthKitInner.context-B3nCqd7x.js";
6
+ import { a as useGraphAuthKitAccount } from "./hooks-D5Hw1GuR.js";
7
+ import { useChainId } from "wagmi";
8
+ function useGraphAuthKitAvatar(args = {}) {
9
+ const innerCtx = useGraphAuthKitInnerContext();
10
+ const account = useGraphAuthKitAccount();
11
+ const address = args.address || account.address || void 0;
12
+ const chain = args.chain != null ? args.chain : account.chainId != null && isSupportedChainId(account.chainId) ? account.chainId : L2Chain.id;
13
+ return useQuery({
14
+ queryKey: getEnsAvatarQueryKey({
15
+ chainId: chain,
16
+ blockTag: "latest",
17
+ name: address
18
+ }),
19
+ async queryFn() {
20
+ if (address == null) {
21
+ return createIdenticon("0x0000000000000000000000000000000000000000");
22
+ }
23
+ const avatar = await innerCtx._ensResolver.resolveAvatar({
24
+ ...args,
25
+ address,
26
+ chain
27
+ });
28
+ return avatar || createIdenticon(address);
29
+ }
30
+ });
31
+ }
32
+ function useGraphAuthKitAvatars(args) {
33
+ const innerCtx = useGraphAuthKitInnerContext();
34
+ const account = useGraphAuthKitAccount();
35
+ const chain = args.chain != null ? args.chain : account.chainId != null && isSupportedChainId(account.chainId) ? account.chainId : L2Chain.id;
36
+ return useQuery({
37
+ queryKey: getAvatarsBatchQueryKey({
38
+ chainId: chain,
39
+ blockTag: "latest",
40
+ addresses: args.addresses
41
+ }),
42
+ async queryFn() {
43
+ if (args.addresses.length === 0) {
44
+ return {};
45
+ }
46
+ const map = await innerCtx._ensResolver.resolveAvatarsBatch({
47
+ ...args,
48
+ addresses: args.addresses,
49
+ chain
50
+ });
51
+ return Object.entries(map).reduce((accum, [addr, avatar]) => {
52
+ accum[addr] = avatar || createIdenticon(addr);
53
+ return accum;
54
+ }, map);
55
+ }
56
+ });
57
+ }
58
+ function filterQueryOptions$1(options) {
59
+ const {
60
+ // import('@tanstack/query-core').QueryOptions
61
+ _defaulted,
62
+ behavior,
63
+ gcTime,
64
+ initialData,
65
+ initialDataUpdatedAt,
66
+ maxPages,
67
+ meta,
68
+ networkMode,
69
+ queryFn,
70
+ queryHash,
71
+ queryKey,
72
+ queryKeyHashFn,
73
+ retry,
74
+ retryDelay,
75
+ structuralSharing,
76
+ // import('@tanstack/query-core').InfiniteQueryObserverOptions
77
+ getPreviousPageParam,
78
+ getNextPageParam,
79
+ initialPageParam,
80
+ // import('@tanstack/react-query').UseQueryOptions
81
+ _optimisticResults,
82
+ enabled,
83
+ notifyOnChangeProps,
84
+ placeholderData,
85
+ refetchInterval,
86
+ refetchIntervalInBackground,
87
+ refetchOnMount,
88
+ refetchOnReconnect,
89
+ refetchOnWindowFocus,
90
+ retryOnMount,
91
+ select,
92
+ staleTime,
93
+ suspense,
94
+ throwOnError,
95
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
96
+ // wagmi
97
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
98
+ config,
99
+ connector,
100
+ query,
101
+ ...rest
102
+ } = options;
103
+ return rest;
104
+ }
105
+ function getAvatarsBatchQueryKey(options = { addresses: [] }) {
106
+ return ["ensAvatars", filterQueryOptions$1(options)];
107
+ }
108
+ function useGraphAuthKitEnsName(args = {}) {
109
+ const innerCtx = useGraphAuthKitInnerContext();
110
+ const chainId = useChainId();
111
+ const account = useGraphAuthKitAccount();
112
+ const address = args.address || account.address || void 0;
113
+ const testnet = args.testnet ?? (chainId === L1ChainTestnet.id || chainId === L2ChainTestnet.id);
114
+ return useQuery({
115
+ queryKey: getEnsNameQueryKey({
116
+ chainId: testnet ? L1ChainTestnet.id : L1Chain.id,
117
+ blockTag: "latest",
118
+ address
119
+ }),
120
+ async queryFn() {
121
+ if (address == null) {
122
+ return null;
123
+ }
124
+ return await innerCtx._ensResolver.resolveEnsName({
125
+ ...args,
126
+ address,
127
+ testnet
128
+ });
129
+ },
130
+ enabled: args.address != null
131
+ });
132
+ }
133
+ function useGraphAuthKitEnsNames(args) {
134
+ const innerCtx = useGraphAuthKitInnerContext();
135
+ const chainId = useChainId();
136
+ const testnet = args.testnet ?? (chainId === L1ChainTestnet.id || chainId === L2ChainTestnet.id);
137
+ return useQuery({
138
+ queryKey: getEnsNamesBatchQueryKey({
139
+ chainId: testnet ? L1ChainTestnet.id : L1Chain.id,
140
+ blockTag: "latest",
141
+ addresses: args.addresses
142
+ }),
143
+ async queryFn() {
144
+ if (args.addresses.length === 0) {
145
+ return {};
146
+ }
147
+ return await innerCtx._ensResolver.resolveEnsNamesBatch({
148
+ ...args,
149
+ addresses: args.addresses,
150
+ testnet
151
+ });
152
+ },
153
+ enabled: args.addresses.length > 0
154
+ });
155
+ }
156
+ function filterQueryOptions(options) {
157
+ const {
158
+ // import('@tanstack/query-core').QueryOptions
159
+ _defaulted,
160
+ behavior,
161
+ gcTime,
162
+ initialData,
163
+ initialDataUpdatedAt,
164
+ maxPages,
165
+ meta,
166
+ networkMode,
167
+ queryFn,
168
+ queryHash,
169
+ queryKey,
170
+ queryKeyHashFn,
171
+ retry,
172
+ retryDelay,
173
+ structuralSharing,
174
+ // import('@tanstack/query-core').InfiniteQueryObserverOptions
175
+ getPreviousPageParam,
176
+ getNextPageParam,
177
+ initialPageParam,
178
+ // import('@tanstack/react-query').UseQueryOptions
179
+ _optimisticResults,
180
+ enabled,
181
+ notifyOnChangeProps,
182
+ placeholderData,
183
+ refetchInterval,
184
+ refetchIntervalInBackground,
185
+ refetchOnMount,
186
+ refetchOnReconnect,
187
+ refetchOnWindowFocus,
188
+ retryOnMount,
189
+ select,
190
+ staleTime,
191
+ suspense,
192
+ throwOnError,
193
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
194
+ // wagmi
195
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
196
+ config,
197
+ connector,
198
+ query,
199
+ ...rest
200
+ } = options;
201
+ return rest;
202
+ }
203
+ function getEnsNamesBatchQueryKey(options = { addresses: [] }) {
204
+ return ["ensName", filterQueryOptions(options)];
205
+ }
206
+ export {
207
+ useGraphAuthKitAvatars as a,
208
+ useGraphAuthKitEnsName as b,
209
+ useGraphAuthKitEnsNames as c,
210
+ useGraphAuthKitAvatar as u
211
+ };
@@ -0,0 +1,46 @@
1
+ import { useQuery } from "@tanstack/react-query";
2
+ import { useConfig } from "wagmi";
3
+ import { u as useMultisigInfo } from "./hooks-D5Hw1GuR.js";
4
+ import { c as createApiKit } from "./GraphAuthKitInner.context-B3nCqd7x.js";
5
+ async function getSafeTransaction(safeTxHash, network, safeApiKey) {
6
+ const apiKit = await createApiKit(network, safeApiKey);
7
+ const txDetails = await apiKit.getTransaction(safeTxHash);
8
+ return txDetails;
9
+ }
10
+ async function waitForSafeTransation(safeTxHash, network, pollingInterval = 4e3, safeApiKey) {
11
+ return new Promise((resolve) => {
12
+ const poll = async () => {
13
+ const txDetails = await getSafeTransaction(safeTxHash, network, safeApiKey);
14
+ if (txDetails.transactionHash) {
15
+ resolve(txDetails);
16
+ } else setTimeout(poll, pollingInterval);
17
+ };
18
+ void poll();
19
+ });
20
+ }
21
+ function useWaitForSafeTransaction({
22
+ safeTxHash,
23
+ safeApiKey
24
+ }) {
25
+ const config = useConfig();
26
+ const _enteredMultisigInfo = useMultisigInfo();
27
+ return useQuery({
28
+ queryKey: ["SafeMultisigTransactionResponse", safeTxHash],
29
+ queryFn: async () => {
30
+ if (!_enteredMultisigInfo || !safeTxHash || !safeApiKey) return;
31
+ const txDetails = await waitForSafeTransation(
32
+ safeTxHash,
33
+ _enteredMultisigInfo.network,
34
+ config.getClient().pollingInterval,
35
+ safeApiKey
36
+ );
37
+ return txDetails;
38
+ },
39
+ enabled: _enteredMultisigInfo != null && safeTxHash != null && safeApiKey != null
40
+ });
41
+ }
42
+ export {
43
+ getSafeTransaction as g,
44
+ useWaitForSafeTransaction as u,
45
+ waitForSafeTransation as w
46
+ };