@edgeandnode/graph-auth-kit 6.1.1-gau-add-usewaitforsafetransaction-1739825153307-ae65380841053846f20df847aa95081441d5b125 → 6.2.0-focus-and-nav-1739902127239-6cca9d0cd9cb24eb8b7465832e6023b10c11f90e

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.
@@ -1,97 +1,11 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { buildEnsResolver } from "@edgeandnode/ens";
3
3
  import { createContext, useContext, useRef, useState } from "react";
4
- import { http, createPublicClient, createClient, isAddress } from "viem";
4
+ import { isAddress } from "viem";
5
5
  import { useConnect, useDisconnect, useAccountEffect } from "wagmi";
6
6
  import { z } from "zod";
7
- import { l1Mainnet, l1Testnet, l2Mainnet, l2Testnet } from "@edgeandnode/common";
8
- import { mainnet, sepolia, arbitrum, arbitrumSepolia } from "viem/chains";
9
- import { injected, coinbaseWallet, walletConnect } from "wagmi/connectors";
10
- import "@safe-global/protocol-kit";
7
+ import { q as SupportedClientChainId, D as DefChain, o as L2Chain, p as L2ChainTestnet, n as L1ChainTestnet, L as L1Chain, m as AUTH_STORAGE_KEY, M as MULTISIG_AUTH_STORAGE_KEY, S as SafeSupportedNetworks, j as buildPublicClient, e as isSafeOwner } from "./utils-DP_AxKkW.js";
11
8
  import { providers } from "ethers";
12
- const AUTH_STORAGE_KEY = "thegraph__authstate";
13
- const MULTISIG_AUTH_STORAGE_KEY = "multisig";
14
- const L1Chain = { ...mainnet, graphCliName: l1Mainnet.id, caip2Id: l1Mainnet.caip2Id };
15
- const L1ChainTestnet = { ...sepolia, graphCliName: l1Testnet.id, caip2Id: l1Testnet.caip2Id };
16
- const L2Chain = { ...arbitrum, graphCliName: l2Mainnet.id, caip2Id: l2Mainnet.caip2Id };
17
- const L2ChainTestnet = { ...arbitrumSepolia, graphCliName: l2Testnet.id, caip2Id: l2Testnet.caip2Id };
18
- const DefChain = L2Chain;
19
- const SupportedClientChainId = z.union([
20
- z.literal(L1Chain.id),
21
- z.literal(L1ChainTestnet.id),
22
- z.literal(L2Chain.id),
23
- z.literal(L2ChainTestnet.id)
24
- ]).readonly();
25
- const SupportedClientChains = [L2Chain, L2ChainTestnet, L1Chain, L1ChainTestnet];
26
- const SupportedL1ClientChainId = z.union([z.literal(L1Chain.id), z.literal(L1ChainTestnet.id)]).readonly();
27
- const SupportedL2ClientChainId = z.union([z.literal(L2Chain.id), z.literal(L2ChainTestnet.id)]).readonly();
28
- const RequiredInfuraKey = z.object({
29
- infuraKey: z.string({ required_error: "The Infura Key is required" }).min(1).readonly()
30
- });
31
- const RequiredWalletConnectProjectId = z.object({
32
- walletConnectProjectID: z.string({ required_error: "The WalletConnect Project ID is required" }).min(1).readonly()
33
- });
34
- const OptionalGatewayApiKey = z.object({
35
- gatewayApiKey: z.string().min(32).max(32).optional().nullable().describe("The Graph Gateway API Key used to query Subgraphs published on The Graph Network")
36
- });
37
- const GraphAuthKitProps = RequiredInfuraKey.merge(OptionalGatewayApiKey);
38
- const GraphAuthKitConnector = z.union([
39
- z.literal(injected.type),
40
- z.literal(coinbaseWallet.type),
41
- z.literal(walletConnect.type),
42
- z.literal("multisig")
43
- ]);
44
- RequiredInfuraKey.extend({
45
- chain: SupportedClientChainId.optional().nullable().default(DefChain.id)
46
- });
47
- function buildInfuraHttpTransport({
48
- chain = DefChain.id,
49
- infuraKey
50
- }) {
51
- switch (chain) {
52
- case L1Chain.id: {
53
- return http(`https://mainnet.infura.io/v3/${infuraKey}`);
54
- }
55
- case L1ChainTestnet.id: {
56
- return http(`https://sepolia.infura.io/v3/${infuraKey}`);
57
- }
58
- case L2ChainTestnet.id: {
59
- return http(`https://arbitrum-sepolia.infura.io/v3/${infuraKey}`);
60
- }
61
- default: {
62
- return http(`https://arbitrum-mainnet.infura.io/v3/${infuraKey}`);
63
- }
64
- }
65
- }
66
- const BuildPublicClientArgs = RequiredInfuraKey.extend({
67
- chain: z.custom().optional().default(DefChain)
68
- });
69
- function isBuildPublicClientArgs(args) {
70
- return args != null && typeof args === "object" && typeof args.infuraKey === "string";
71
- }
72
- function buildPublicClient({ chain = DefChain, infuraKey }) {
73
- const transport = buildInfuraHttpTransport({
74
- chain: chain.id,
75
- infuraKey
76
- });
77
- return createPublicClient({
78
- chain,
79
- transport
80
- });
81
- }
82
- const BuildClientArgs = RequiredInfuraKey.extend({
83
- chain: z.custom().optional().default(DefChain)
84
- });
85
- function buildClient({ chain = DefChain, infuraKey }) {
86
- const transport = buildInfuraHttpTransport({
87
- chain: chain.id,
88
- infuraKey
89
- });
90
- return createClient({
91
- chain,
92
- transport
93
- });
94
- }
95
9
  const MultisigErrorMap = {
96
10
  INVALID_SIGNER: {
97
11
  title: "Signer Wallet is Invalid",
@@ -102,193 +16,6 @@ const MultisigErrorMap = {
102
16
  description: "The signing wallet must be connected to the same network as the Multisig."
103
17
  }
104
18
  };
105
- const SafeSupportedNetworks = z.union([z.literal(L1Chain.id), z.literal(L1ChainTestnet.id), z.literal(L2Chain.id)]).readonly();
106
- function isSafeSupportedNetwork(network) {
107
- return SafeSupportedNetworks.safeParse(network).success;
108
- }
109
- const SafeSupportedNetworkNames = {
110
- [L2Chain.id]: { shortName: "arb1", name: L2Chain.name, id: L2Chain.id },
111
- [L1Chain.id]: { shortName: "eth", name: L1Chain.name, id: L1Chain.id },
112
- [L1ChainTestnet.id]: { shortName: "sep", name: L1ChainTestnet.name, id: L1ChainTestnet.id }
113
- };
114
- const ApiKitUrlMap = {
115
- [L1Chain.id]: "https://safe-transaction-mainnet.safe.global/api",
116
- [L1ChainTestnet.id]: "https://safe-transaction-sepolia.safe.global/api",
117
- [L2Chain.id]: "https://safe-transaction-arbitrum.safe.global/api"
118
- };
119
- const SafeMinimalAbi = [
120
- {
121
- inputs: [],
122
- payable: false,
123
- stateMutability: "nonpayable",
124
- type: "constructor"
125
- },
126
- {
127
- constant: true,
128
- inputs: [],
129
- name: "getThreshold",
130
- outputs: [
131
- {
132
- internalType: "uint256",
133
- name: "",
134
- type: "uint256"
135
- }
136
- ],
137
- payable: false,
138
- stateMutability: "view",
139
- type: "function"
140
- },
141
- {
142
- constant: true,
143
- inputs: [],
144
- name: "getOwners",
145
- outputs: [
146
- {
147
- internalType: "address[]",
148
- name: "",
149
- type: "address[]"
150
- }
151
- ],
152
- payable: false,
153
- stateMutability: "view",
154
- type: "function"
155
- },
156
- {
157
- constant: false,
158
- inputs: [
159
- {
160
- internalType: "bytes",
161
- name: "_data",
162
- type: "bytes"
163
- },
164
- {
165
- internalType: "bytes",
166
- name: "_signature",
167
- type: "bytes"
168
- }
169
- ],
170
- name: "isValidSignature",
171
- outputs: [
172
- {
173
- internalType: "bytes4",
174
- name: "",
175
- type: "bytes4"
176
- }
177
- ],
178
- payable: false,
179
- stateMutability: "nonpayable",
180
- type: "function"
181
- },
182
- {
183
- constant: true,
184
- inputs: [],
185
- name: "nonce",
186
- outputs: [
187
- {
188
- internalType: "uint256",
189
- name: "",
190
- type: "uint256"
191
- }
192
- ],
193
- payable: false,
194
- stateMutability: "view",
195
- type: "function"
196
- },
197
- {
198
- constant: true,
199
- inputs: [
200
- {
201
- internalType: "address",
202
- name: "owner",
203
- type: "address"
204
- }
205
- ],
206
- name: "isOwner",
207
- outputs: [
208
- {
209
- internalType: "bool",
210
- name: "",
211
- type: "bool"
212
- }
213
- ],
214
- payable: false,
215
- stateMutability: "view",
216
- type: "function"
217
- }
218
- ];
219
- async function createApiKit(chainId) {
220
- const { default: SafeApiKit } = await import("@safe-global/api-kit");
221
- const SafeApiKitClass = typeof SafeApiKit === "function" ? SafeApiKit : SafeApiKit.default;
222
- const apiKit = new SafeApiKitClass({
223
- chainId: BigInt(chainId),
224
- txServiceUrl: ApiKitUrlMap[chainId]
225
- });
226
- return apiKit;
227
- }
228
- async function createSafe(config) {
229
- const { default: Safe2 } = await import("@safe-global/protocol-kit");
230
- const SafeClass = typeof Safe2 === "function" ? Safe2 : Safe2.default;
231
- const protocolKit = await SafeClass.init(config);
232
- return protocolKit;
233
- }
234
- async function isValidSafe(args) {
235
- try {
236
- const client = isBuildPublicClientArgs(args.clientOrBuildClientArgs) ? buildPublicClient(args.clientOrBuildClientArgs) : args.clientOrBuildClientArgs;
237
- await client.readContract({
238
- address: args.safeAddress,
239
- abi: SafeMinimalAbi,
240
- functionName: "getThreshold"
241
- });
242
- return true;
243
- } catch (err) {
244
- console.warn("isValidSafe - failure checking safe", { err: err.message });
245
- return false;
246
- }
247
- }
248
- async function isSafeOwner(args) {
249
- try {
250
- const client = isBuildPublicClientArgs(args.clientOrBuildClientArgs) ? buildPublicClient(args.clientOrBuildClientArgs) : args.clientOrBuildClientArgs;
251
- return await client.readContract({
252
- address: args.safeAddress,
253
- abi: SafeMinimalAbi,
254
- functionName: "isOwner",
255
- args: [args.eoa]
256
- });
257
- } catch (err) {
258
- console.warn("isSafeOwner - failure checking if EoA is Safe owner", { err: err.message });
259
- return false;
260
- }
261
- }
262
- async function fetchOwnedSafes(args) {
263
- let safes = {};
264
- for (const chain of args.chains ?? [L2Chain.id, L1Chain.id, L1ChainTestnet.id]) {
265
- const chainSafes = await fetchSafesByChain(args.signer, chain);
266
- safes = { ...safes, [chain]: chainSafes };
267
- }
268
- return safes;
269
- }
270
- const OwnerResponseSchema = z.object({
271
- safes: z.array(z.custom((val) => val != null && typeof val === "string" && isAddress(val)))
272
- });
273
- async function fetchSafesByChain(signer, chain) {
274
- const txServiceUrl = ApiKitUrlMap[chain];
275
- const response = await fetch(`${txServiceUrl}/v1/owners/${signer}/safes/`, {
276
- method: "get",
277
- headers: {
278
- Accept: "application/json",
279
- "Content-Type": "application/json"
280
- }
281
- });
282
- if (response.status !== 200) {
283
- return [];
284
- }
285
- const json = await response.json();
286
- const parsed = OwnerResponseSchema.safeParse(json);
287
- if (!parsed.success) {
288
- return [];
289
- }
290
- return parsed.data.safes;
291
- }
292
19
  function chainIsSupportedChain(chain) {
293
20
  return SupportedClientChainId.safeParse(chain.id).success;
294
21
  }
@@ -574,49 +301,18 @@ function GraphAuthKitInnerContextProvider({
574
301
  );
575
302
  }
576
303
  export {
577
- ApiKitUrlMap as A,
578
- BuildPublicClientArgs as B,
579
- isChainL1 as C,
580
- DefChain as D,
581
- isChainMainnet as E,
582
- isChainTestnet as F,
583
- GraphAuthKitProps as G,
584
- clientToProvider as H,
585
- connectedWalletIsEoA as I,
586
- useGraphAuthKitInnerContext as J,
587
- MultisigSchema as K,
588
- L1Chain as L,
589
- MULTISIG_AUTH_STORAGE_KEY as M,
590
- GraphAuthKitInnerContextProvider as N,
591
- OptionalGatewayApiKey as O,
592
- GraphAuthKitInnerContext as P,
593
- defInnerState as Q,
594
- RequiredInfuraKey as R,
595
- SafeSupportedNetworks as S,
596
- SafeSupportedNetworkNames as a,
597
- createSafe as b,
598
- createApiKit as c,
599
- isValidSafe as d,
600
- isSafeOwner as e,
601
- fetchOwnedSafes as f,
602
- buildInfuraHttpTransport as g,
603
- isBuildPublicClientArgs as h,
604
- isSafeSupportedNetwork as i,
605
- buildPublicClient as j,
606
- BuildClientArgs as k,
607
- buildClient as l,
608
- AUTH_STORAGE_KEY as m,
609
- L1ChainTestnet as n,
610
- L2Chain as o,
611
- L2ChainTestnet as p,
612
- SupportedClientChainId as q,
613
- SupportedClientChains as r,
614
- SupportedL1ClientChainId as s,
615
- SupportedL2ClientChainId as t,
616
- RequiredWalletConnectProjectId as u,
617
- GraphAuthKitConnector as v,
618
- chainIsSupportedChain as w,
619
- isSupportedChainId as x,
620
- mapChainIdToChain as y,
621
- isChainL2 as z
304
+ GraphAuthKitInnerContextProvider as G,
305
+ MultisigSchema as M,
306
+ isChainL2 as a,
307
+ isChainL1 as b,
308
+ chainIsSupportedChain as c,
309
+ isChainMainnet as d,
310
+ isChainTestnet as e,
311
+ clientToProvider as f,
312
+ connectedWalletIsEoA as g,
313
+ GraphAuthKitInnerContext as h,
314
+ isSupportedChainId as i,
315
+ defInnerState as j,
316
+ mapChainIdToChain as m,
317
+ useGraphAuthKitInnerContext as u
622
318
  };
package/dist/ens/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { u, a, b, c } from "../useGraphAuthKitEnsNames-BEajLdia.js";
1
+ import { u, a, b, c } from "../useGraphAuthKitEnsNames-FYkTkbYz.js";
2
2
  export {
3
3
  u as useGraphAuthKitAvatar,
4
4
  a as useGraphAuthKitAvatars,
package/dist/index.js CHANGED
@@ -1,13 +1,12 @@
1
1
  "use client";
2
- import { m, A, k, B, D, v, G, L, n, o, p, M, O, R, u, a, S, q, r, s, t, l, g, j, w, H, I, c, b, f, h, C, z, E, F, e, i, x, d, y } from "./GraphAuthKitInner.context-B8vsvUDy.js";
3
- import { G as G2, a as a2, M as M2, b as b2, d as d2, u as u2 } from "./utils-DuHz-YHi.js";
4
- import { a as useGraphAuthKitAccount, b as useGraphAuthKitConnector } from "./hooks-ClXeFY-j.js";
5
- import { d as d3, c as c2, e as e2, f as f2, g as g2, u as u3 } from "./hooks-ClXeFY-j.js";
6
- import { g as g3, u as u4, w as w2 } from "./useWaitForSafeTransaction-D4k3ZLSB.js";
2
+ import { m, A, k, B, D, v, G, L, n, o, p, M, O, R, u, a, S, q, r, s, t, l, g, j, c, b, f, h, e, i, d } from "./utils-DP_AxKkW.js";
3
+ import { G as G2, a as a2, M as M2, b as b2, d as d2, u as u2 } from "./utils-C_72bAxT.js";
4
+ import { d as useGraphAuthKitAccount, e as useGraphAuthKitConnector } from "./useGraphAuthKitEnsNames-FYkTkbYz.js";
5
+ import { g as g2, f as f2, i as i2, u as u3, a as a3, b as b3, c as c2, j as j2, k as k2, h as h2 } from "./useGraphAuthKitEnsNames-FYkTkbYz.js";
6
+ import { c as c3, f as f3, g as g3, b as b4, a as a4, d as d3, e as e2, i as i3, m as m2 } from "./GraphAuthKitInner.context-DkY5ODsb.js";
7
7
  import { jsx, jsxs } from "react/jsx-runtime";
8
8
  import { Alert, ExperimentalButton } from "@edgeandnode/gds";
9
9
  import { useConfig, useSwitchChain } from "wagmi";
10
- import { u as u5, a as a3, b as b3, c as c3 } from "./useGraphAuthKitEnsNames-BEajLdia.js";
11
10
  function Connected({ children }) {
12
11
  const account = useGraphAuthKitAccount();
13
12
  const connector = useGraphAuthKitConnector();
@@ -102,37 +101,34 @@ export {
102
101
  g as buildInfuraHttpTransport,
103
102
  b2 as buildMockProviderState,
104
103
  j as buildPublicClient,
105
- w as chainIsSupportedChain,
106
- H as clientToProvider,
107
- I as connectedWalletIsEoA,
104
+ c3 as chainIsSupportedChain,
105
+ f3 as clientToProvider,
106
+ g3 as connectedWalletIsEoA,
108
107
  c as createApiKit,
109
108
  b as createSafe,
110
109
  d2 as disconnectedMockState,
111
110
  f as fetchOwnedSafes,
112
- g3 as getSafeTransaction,
113
111
  h as isBuildPublicClientArgs,
114
- C as isChainL1,
115
- z as isChainL2,
116
- E as isChainMainnet,
117
- F as isChainTestnet,
112
+ b4 as isChainL1,
113
+ a4 as isChainL2,
114
+ d3 as isChainMainnet,
115
+ e2 as isChainTestnet,
118
116
  e as isSafeOwner,
119
117
  i as isSafeSupportedNetwork,
120
- x as isSupportedChainId,
118
+ i3 as isSupportedChainId,
121
119
  d as isValidSafe,
122
- y as mapChainIdToChain,
123
- d3 as useAuthAccount,
124
- c2 as useClientToEthersSigner,
120
+ m2 as mapChainIdToChain,
121
+ g2 as useAuthAccount,
122
+ f2 as useClientToEthersSigner,
125
123
  u2 as useGraphAuthKit,
126
124
  useGraphAuthKitAccount,
127
- e2 as useGraphAuthKitAccountEffect,
128
- u5 as useGraphAuthKitAvatar,
125
+ i2 as useGraphAuthKitAccountEffect,
126
+ u3 as useGraphAuthKitAvatar,
129
127
  a3 as useGraphAuthKitAvatars,
130
128
  useGraphAuthKitConnector,
131
129
  b3 as useGraphAuthKitEnsName,
132
- c3 as useGraphAuthKitEnsNames,
133
- f2 as useGraphAuthKitWalletClient,
134
- g2 as useGraphAuthKitWriteContract,
135
- u3 as useMultisigInfo,
136
- u4 as useWaitForSafeTransaction,
137
- w2 as waitForSafeTransation
130
+ c2 as useGraphAuthKitEnsNames,
131
+ j2 as useGraphAuthKitWalletClient,
132
+ k2 as useGraphAuthKitWriteContract,
133
+ h2 as useMultisigInfo
138
134
  };
@@ -1,4 +1,3 @@
1
1
  export * from './constants';
2
- export * from './useWaitForSafeTransaction';
3
2
  export * from './utils';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/safe/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/safe/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA"}
@@ -1,5 +1,4 @@
1
- import { A, a, S, c, b, f, e, i, d } from "../GraphAuthKitInner.context-B8vsvUDy.js";
2
- import { g, u, w } from "../useWaitForSafeTransaction-D4k3ZLSB.js";
1
+ import { A, a, S, c, b, f, e, i, d } from "../utils-DP_AxKkW.js";
3
2
  export {
4
3
  A as ApiKitUrlMap,
5
4
  a as SafeSupportedNetworkNames,
@@ -7,10 +6,7 @@ export {
7
6
  c as createApiKit,
8
7
  b as createSafe,
9
8
  f as fetchOwnedSafes,
10
- g as getSafeTransaction,
11
9
  e as isSafeOwner,
12
10
  i as isSafeSupportedNetwork,
13
- d as isValidSafe,
14
- u as useWaitForSafeTransaction,
15
- w as waitForSafeTransation
11
+ d as isValidSafe
16
12
  };
@@ -1,4 +1,4 @@
1
- import { M, b, d } from "../utils-DuHz-YHi.js";
1
+ import { M, b, d } from "../utils-C_72bAxT.js";
2
2
  export {
3
3
  M as MockGraphAuthKitProvider,
4
4
  b as buildMockProviderState,
@@ -1,13 +1,17 @@
1
+ "use client";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ import { createIdenticon } from "@edgeandnode/gds";
6
+ import { getEnsAvatarQueryKey, getEnsNameQueryKey } from "@wagmi/core/query";
7
+ import { writeContractMutationOptions, useQuery } from "wagmi/query";
8
+ import { b as createSafe, c as createApiKit, v as GraphAuthKitConnector, M as MULTISIG_AUTH_STORAGE_KEY, o as L2Chain, n as L1ChainTestnet, p as L2ChainTestnet, L as L1Chain } from "./utils-DP_AxKkW.js";
9
+ import { f as clientToProvider, u as useGraphAuthKitInnerContext, M as MultisigSchema, i as isSupportedChainId } from "./GraphAuthKitInner.context-DkY5ODsb.js";
10
+ import { useChainId, useConnectorClient, useAccount, useConfig, useAccountEffect, useWalletClient } from "wagmi";
4
11
  import { useMutation } from "@tanstack/react-query";
5
12
  import { watchAccount } from "@wagmi/core";
6
13
  import { useMemo, useState, useEffect } from "react";
7
14
  import { encodeFunctionData, getAddress, isAddress } from "viem";
8
- import { useChainId, useConnectorClient, useAccount, useConfig, useAccountEffect, useWalletClient } from "wagmi";
9
- import { writeContractMutationOptions } from "wagmi/query";
10
- import { b as createSafe, c as createApiKit, H as clientToProvider, J as useGraphAuthKitInnerContext, v as GraphAuthKitConnector, M as MULTISIG_AUTH_STORAGE_KEY, K as MultisigSchema } from "./GraphAuthKitInner.context-B8vsvUDy.js";
11
15
  import { VoidSigner } from "@ethersproject/abstract-signer";
12
16
  import "@safe-global/protocol-kit";
13
17
  import { OperationType } from "@safe-global/types-kit";
@@ -473,13 +477,215 @@ function useGraphAuthKitWriteContract(parameters = {}) {
473
477
  writeContractAsync: mutateAsync
474
478
  };
475
479
  }
480
+ function useGraphAuthKitAvatar(args = {}) {
481
+ const innerCtx = useGraphAuthKitInnerContext();
482
+ const account = useGraphAuthKitAccount();
483
+ const address = args.address || account.address || void 0;
484
+ const chain = args.chain != null ? args.chain : account.chainId != null && isSupportedChainId(account.chainId) ? account.chainId : L2Chain.id;
485
+ return useQuery({
486
+ queryKey: getEnsAvatarQueryKey({
487
+ chainId: chain,
488
+ blockTag: "latest",
489
+ name: address
490
+ }),
491
+ async queryFn() {
492
+ if (address == null) {
493
+ return createIdenticon("0x0000000000000000000000000000000000000000");
494
+ }
495
+ const avatar = await innerCtx._ensResolver.resolveAvatar({
496
+ ...args,
497
+ address,
498
+ chain
499
+ });
500
+ return avatar || createIdenticon(address);
501
+ }
502
+ });
503
+ }
504
+ function useGraphAuthKitAvatars(args) {
505
+ const innerCtx = useGraphAuthKitInnerContext();
506
+ const account = useGraphAuthKitAccount();
507
+ const chain = args.chain != null ? args.chain : account.chainId != null && isSupportedChainId(account.chainId) ? account.chainId : L2Chain.id;
508
+ return useQuery({
509
+ queryKey: getAvatarsBatchQueryKey({
510
+ chainId: chain,
511
+ blockTag: "latest",
512
+ addresses: args.addresses
513
+ }),
514
+ async queryFn() {
515
+ if (args.addresses.length === 0) {
516
+ return {};
517
+ }
518
+ const map = await innerCtx._ensResolver.resolveAvatarsBatch({
519
+ ...args,
520
+ addresses: args.addresses,
521
+ chain
522
+ });
523
+ return Object.entries(map).reduce((accum, [addr, avatar]) => {
524
+ accum[addr] = avatar || createIdenticon(addr);
525
+ return accum;
526
+ }, map);
527
+ }
528
+ });
529
+ }
530
+ function filterQueryOptions$1(options) {
531
+ const {
532
+ // import('@tanstack/query-core').QueryOptions
533
+ _defaulted,
534
+ behavior,
535
+ gcTime,
536
+ initialData,
537
+ initialDataUpdatedAt,
538
+ maxPages,
539
+ meta,
540
+ networkMode,
541
+ queryFn,
542
+ queryHash,
543
+ queryKey,
544
+ queryKeyHashFn,
545
+ retry,
546
+ retryDelay,
547
+ structuralSharing,
548
+ // import('@tanstack/query-core').InfiniteQueryObserverOptions
549
+ getPreviousPageParam,
550
+ getNextPageParam,
551
+ initialPageParam,
552
+ // import('@tanstack/react-query').UseQueryOptions
553
+ _optimisticResults,
554
+ enabled,
555
+ notifyOnChangeProps,
556
+ placeholderData,
557
+ refetchInterval,
558
+ refetchIntervalInBackground,
559
+ refetchOnMount,
560
+ refetchOnReconnect,
561
+ refetchOnWindowFocus,
562
+ retryOnMount,
563
+ select,
564
+ staleTime,
565
+ suspense,
566
+ throwOnError,
567
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
568
+ // wagmi
569
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
570
+ config,
571
+ connector,
572
+ query,
573
+ ...rest
574
+ } = options;
575
+ return rest;
576
+ }
577
+ function getAvatarsBatchQueryKey(options = { addresses: [] }) {
578
+ return ["ensAvatars", filterQueryOptions$1(options)];
579
+ }
580
+ function useGraphAuthKitEnsName(args = {}) {
581
+ const innerCtx = useGraphAuthKitInnerContext();
582
+ const chainId = useChainId();
583
+ const account = useGraphAuthKitAccount();
584
+ const address = args.address || account.address || void 0;
585
+ const testnet = args.testnet ?? (chainId === L1ChainTestnet.id || chainId === L2ChainTestnet.id);
586
+ return useQuery({
587
+ queryKey: getEnsNameQueryKey({
588
+ chainId: testnet ? L1ChainTestnet.id : L1Chain.id,
589
+ blockTag: "latest",
590
+ address
591
+ }),
592
+ async queryFn() {
593
+ if (address == null) {
594
+ return null;
595
+ }
596
+ return await innerCtx._ensResolver.resolveEnsName({
597
+ ...args,
598
+ address,
599
+ testnet
600
+ });
601
+ },
602
+ enabled: args.address != null
603
+ });
604
+ }
605
+ function useGraphAuthKitEnsNames(args) {
606
+ const innerCtx = useGraphAuthKitInnerContext();
607
+ const chainId = useChainId();
608
+ const testnet = args.testnet ?? (chainId === L1ChainTestnet.id || chainId === L2ChainTestnet.id);
609
+ return useQuery({
610
+ queryKey: getEnsNamesBatchQueryKey({
611
+ chainId: testnet ? L1ChainTestnet.id : L1Chain.id,
612
+ blockTag: "latest",
613
+ addresses: args.addresses
614
+ }),
615
+ async queryFn() {
616
+ if (args.addresses.length === 0) {
617
+ return {};
618
+ }
619
+ return await innerCtx._ensResolver.resolveEnsNamesBatch({
620
+ ...args,
621
+ addresses: args.addresses,
622
+ testnet
623
+ });
624
+ },
625
+ enabled: args.addresses.length > 0
626
+ });
627
+ }
628
+ function filterQueryOptions(options) {
629
+ const {
630
+ // import('@tanstack/query-core').QueryOptions
631
+ _defaulted,
632
+ behavior,
633
+ gcTime,
634
+ initialData,
635
+ initialDataUpdatedAt,
636
+ maxPages,
637
+ meta,
638
+ networkMode,
639
+ queryFn,
640
+ queryHash,
641
+ queryKey,
642
+ queryKeyHashFn,
643
+ retry,
644
+ retryDelay,
645
+ structuralSharing,
646
+ // import('@tanstack/query-core').InfiniteQueryObserverOptions
647
+ getPreviousPageParam,
648
+ getNextPageParam,
649
+ initialPageParam,
650
+ // import('@tanstack/react-query').UseQueryOptions
651
+ _optimisticResults,
652
+ enabled,
653
+ notifyOnChangeProps,
654
+ placeholderData,
655
+ refetchInterval,
656
+ refetchIntervalInBackground,
657
+ refetchOnMount,
658
+ refetchOnReconnect,
659
+ refetchOnWindowFocus,
660
+ retryOnMount,
661
+ select,
662
+ staleTime,
663
+ suspense,
664
+ throwOnError,
665
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
666
+ // wagmi
667
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
668
+ config,
669
+ connector,
670
+ query,
671
+ ...rest
672
+ } = options;
673
+ return rest;
674
+ }
675
+ function getEnsNamesBatchQueryKey(options = { addresses: [] }) {
676
+ return ["ensName", filterQueryOptions(options)];
677
+ }
476
678
  export {
477
- useGraphAuthKitAccount as a,
478
- useGraphAuthKitConnector as b,
479
- useClientToEthersSigner as c,
480
- useAuthAccount as d,
481
- useGraphAuthKitAccountEffect as e,
482
- useGraphAuthKitWalletClient as f,
483
- useGraphAuthKitWriteContract as g,
484
- useMultisigInfo as u
679
+ useGraphAuthKitAvatars as a,
680
+ useGraphAuthKitEnsName as b,
681
+ useGraphAuthKitEnsNames as c,
682
+ useGraphAuthKitAccount as d,
683
+ useGraphAuthKitConnector as e,
684
+ useClientToEthersSigner as f,
685
+ useAuthAccount as g,
686
+ useMultisigInfo as h,
687
+ useGraphAuthKitAccountEffect as i,
688
+ useGraphAuthKitWalletClient as j,
689
+ useGraphAuthKitWriteContract as k,
690
+ useGraphAuthKitAvatar as u
485
691
  };
@@ -3,9 +3,10 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
3
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
4
4
  import { useConfig, WagmiProvider, useDisconnect, createConfig, createStorage, cookieStorage, cookieToInitialState } from "wagmi";
5
5
  import { injected, walletConnect, coinbaseWallet, mock } from "wagmi/connectors";
6
- import { J as useGraphAuthKitInnerContext, v as GraphAuthKitConnector, o as L2Chain, a as SafeSupportedNetworkNames, j as buildPublicClient, L as L1Chain, n as L1ChainTestnet, d as isValidSafe, S as SafeSupportedNetworks, N as GraphAuthKitInnerContextProvider, p as L2ChainTestnet, m as AUTH_STORAGE_KEY, w as chainIsSupportedChain, D as DefChain, l as buildClient, P as GraphAuthKitInnerContext, Q as defInnerState, R as RequiredInfuraKey, O as OptionalGatewayApiKey, q as SupportedClientChainId } from "./GraphAuthKitInner.context-B8vsvUDy.js";
6
+ import { v as GraphAuthKitConnector, o as L2Chain, a as SafeSupportedNetworkNames, j as buildPublicClient, L as L1Chain, n as L1ChainTestnet, d as isValidSafe, S as SafeSupportedNetworks, p as L2ChainTestnet, m as AUTH_STORAGE_KEY, D as DefChain, l as buildClient, R as RequiredInfuraKey, O as OptionalGatewayApiKey, q as SupportedClientChainId } from "./utils-DP_AxKkW.js";
7
7
  import { useState, useReducer, useId, useEffect, createContext, useContext } from "react";
8
8
  import { Icon, ExperimentalModal, ExperimentalButton, Alert, Link, ExperimentalLoadingIndicator, ExperimentalSelect, ExperimentalInput, Divider, List } from "@edgeandnode/gds";
9
+ import { u as useGraphAuthKitInnerContext, G as GraphAuthKitInnerContextProvider, c as chainIsSupportedChain, h as GraphAuthKitInnerContext, j as defInnerState } from "./GraphAuthKitInner.context-DkY5ODsb.js";
9
10
  import { addrShortener } from "@edgeandnode/common";
10
11
  import { isAddress } from "viem";
11
12
  import { NetworkIcon } from "@edgeandnode/go";
@@ -0,0 +1,309 @@
1
+ import "@safe-global/protocol-kit";
2
+ import { http, createPublicClient, createClient, isAddress } from "viem";
3
+ import { z } from "zod";
4
+ import { l1Mainnet, l1Testnet, l2Mainnet, l2Testnet } from "@edgeandnode/common";
5
+ import { mainnet, sepolia, arbitrum, arbitrumSepolia } from "viem/chains";
6
+ import { injected, coinbaseWallet, walletConnect } from "wagmi/connectors";
7
+ const AUTH_STORAGE_KEY = "thegraph__authstate";
8
+ const MULTISIG_AUTH_STORAGE_KEY = "multisig";
9
+ const L1Chain = { ...mainnet, graphCliName: l1Mainnet.id, caip2Id: l1Mainnet.caip2Id };
10
+ const L1ChainTestnet = { ...sepolia, graphCliName: l1Testnet.id, caip2Id: l1Testnet.caip2Id };
11
+ const L2Chain = { ...arbitrum, graphCliName: l2Mainnet.id, caip2Id: l2Mainnet.caip2Id };
12
+ const L2ChainTestnet = { ...arbitrumSepolia, graphCliName: l2Testnet.id, caip2Id: l2Testnet.caip2Id };
13
+ const DefChain = L2Chain;
14
+ const SupportedClientChainId = z.union([
15
+ z.literal(L1Chain.id),
16
+ z.literal(L1ChainTestnet.id),
17
+ z.literal(L2Chain.id),
18
+ z.literal(L2ChainTestnet.id)
19
+ ]).readonly();
20
+ const SupportedClientChains = [L2Chain, L2ChainTestnet, L1Chain, L1ChainTestnet];
21
+ const SupportedL1ClientChainId = z.union([z.literal(L1Chain.id), z.literal(L1ChainTestnet.id)]).readonly();
22
+ const SupportedL2ClientChainId = z.union([z.literal(L2Chain.id), z.literal(L2ChainTestnet.id)]).readonly();
23
+ const RequiredInfuraKey = z.object({
24
+ infuraKey: z.string({ required_error: "The Infura Key is required" }).min(1).readonly()
25
+ });
26
+ const RequiredWalletConnectProjectId = z.object({
27
+ walletConnectProjectID: z.string({ required_error: "The WalletConnect Project ID is required" }).min(1).readonly()
28
+ });
29
+ const OptionalGatewayApiKey = z.object({
30
+ gatewayApiKey: z.string().min(32).max(32).optional().nullable().describe("The Graph Gateway API Key used to query Subgraphs published on The Graph Network")
31
+ });
32
+ const GraphAuthKitProps = RequiredInfuraKey.merge(OptionalGatewayApiKey);
33
+ const GraphAuthKitConnector = z.union([
34
+ z.literal(injected.type),
35
+ z.literal(coinbaseWallet.type),
36
+ z.literal(walletConnect.type),
37
+ z.literal("multisig")
38
+ ]);
39
+ RequiredInfuraKey.extend({
40
+ chain: SupportedClientChainId.optional().nullable().default(DefChain.id)
41
+ });
42
+ function buildInfuraHttpTransport({
43
+ chain = DefChain.id,
44
+ infuraKey
45
+ }) {
46
+ switch (chain) {
47
+ case L1Chain.id: {
48
+ return http(`https://mainnet.infura.io/v3/${infuraKey}`);
49
+ }
50
+ case L1ChainTestnet.id: {
51
+ return http(`https://sepolia.infura.io/v3/${infuraKey}`);
52
+ }
53
+ case L2ChainTestnet.id: {
54
+ return http(`https://arbitrum-sepolia.infura.io/v3/${infuraKey}`);
55
+ }
56
+ default: {
57
+ return http(`https://arbitrum-mainnet.infura.io/v3/${infuraKey}`);
58
+ }
59
+ }
60
+ }
61
+ const BuildPublicClientArgs = RequiredInfuraKey.extend({
62
+ chain: z.custom().optional().default(DefChain)
63
+ });
64
+ function isBuildPublicClientArgs(args) {
65
+ return args != null && typeof args === "object" && typeof args.infuraKey === "string";
66
+ }
67
+ function buildPublicClient({ chain = DefChain, infuraKey }) {
68
+ const transport = buildInfuraHttpTransport({
69
+ chain: chain.id,
70
+ infuraKey
71
+ });
72
+ return createPublicClient({
73
+ chain,
74
+ transport
75
+ });
76
+ }
77
+ const BuildClientArgs = RequiredInfuraKey.extend({
78
+ chain: z.custom().optional().default(DefChain)
79
+ });
80
+ function buildClient({ chain = DefChain, infuraKey }) {
81
+ const transport = buildInfuraHttpTransport({
82
+ chain: chain.id,
83
+ infuraKey
84
+ });
85
+ return createClient({
86
+ chain,
87
+ transport
88
+ });
89
+ }
90
+ const SafeSupportedNetworks = z.union([z.literal(L1Chain.id), z.literal(L1ChainTestnet.id), z.literal(L2Chain.id)]).readonly();
91
+ function isSafeSupportedNetwork(network) {
92
+ return SafeSupportedNetworks.safeParse(network).success;
93
+ }
94
+ const SafeSupportedNetworkNames = {
95
+ [L2Chain.id]: { shortName: "arb1", name: L2Chain.name, id: L2Chain.id },
96
+ [L1Chain.id]: { shortName: "eth", name: L1Chain.name, id: L1Chain.id },
97
+ [L1ChainTestnet.id]: { shortName: "sep", name: L1ChainTestnet.name, id: L1ChainTestnet.id }
98
+ };
99
+ const ApiKitUrlMap = {
100
+ [L1Chain.id]: "https://safe-transaction-mainnet.safe.global/api",
101
+ [L1ChainTestnet.id]: "https://safe-transaction-sepolia.safe.global/api",
102
+ [L2Chain.id]: "https://safe-transaction-arbitrum.safe.global/api"
103
+ };
104
+ const SafeMinimalAbi = [
105
+ {
106
+ inputs: [],
107
+ payable: false,
108
+ stateMutability: "nonpayable",
109
+ type: "constructor"
110
+ },
111
+ {
112
+ constant: true,
113
+ inputs: [],
114
+ name: "getThreshold",
115
+ outputs: [
116
+ {
117
+ internalType: "uint256",
118
+ name: "",
119
+ type: "uint256"
120
+ }
121
+ ],
122
+ payable: false,
123
+ stateMutability: "view",
124
+ type: "function"
125
+ },
126
+ {
127
+ constant: true,
128
+ inputs: [],
129
+ name: "getOwners",
130
+ outputs: [
131
+ {
132
+ internalType: "address[]",
133
+ name: "",
134
+ type: "address[]"
135
+ }
136
+ ],
137
+ payable: false,
138
+ stateMutability: "view",
139
+ type: "function"
140
+ },
141
+ {
142
+ constant: false,
143
+ inputs: [
144
+ {
145
+ internalType: "bytes",
146
+ name: "_data",
147
+ type: "bytes"
148
+ },
149
+ {
150
+ internalType: "bytes",
151
+ name: "_signature",
152
+ type: "bytes"
153
+ }
154
+ ],
155
+ name: "isValidSignature",
156
+ outputs: [
157
+ {
158
+ internalType: "bytes4",
159
+ name: "",
160
+ type: "bytes4"
161
+ }
162
+ ],
163
+ payable: false,
164
+ stateMutability: "nonpayable",
165
+ type: "function"
166
+ },
167
+ {
168
+ constant: true,
169
+ inputs: [],
170
+ name: "nonce",
171
+ outputs: [
172
+ {
173
+ internalType: "uint256",
174
+ name: "",
175
+ type: "uint256"
176
+ }
177
+ ],
178
+ payable: false,
179
+ stateMutability: "view",
180
+ type: "function"
181
+ },
182
+ {
183
+ constant: true,
184
+ inputs: [
185
+ {
186
+ internalType: "address",
187
+ name: "owner",
188
+ type: "address"
189
+ }
190
+ ],
191
+ name: "isOwner",
192
+ outputs: [
193
+ {
194
+ internalType: "bool",
195
+ name: "",
196
+ type: "bool"
197
+ }
198
+ ],
199
+ payable: false,
200
+ stateMutability: "view",
201
+ type: "function"
202
+ }
203
+ ];
204
+ async function createApiKit(chainId) {
205
+ const { default: SafeApiKit } = await import("@safe-global/api-kit");
206
+ const SafeApiKitClass = typeof SafeApiKit === "function" ? SafeApiKit : SafeApiKit.default;
207
+ const apiKit = new SafeApiKitClass({
208
+ chainId: BigInt(chainId),
209
+ txServiceUrl: ApiKitUrlMap[chainId]
210
+ });
211
+ return apiKit;
212
+ }
213
+ async function createSafe(config) {
214
+ const { default: Safe2 } = await import("@safe-global/protocol-kit");
215
+ const SafeClass = typeof Safe2 === "function" ? Safe2 : Safe2.default;
216
+ const protocolKit = await SafeClass.init(config);
217
+ return protocolKit;
218
+ }
219
+ async function isValidSafe(args) {
220
+ try {
221
+ const client = isBuildPublicClientArgs(args.clientOrBuildClientArgs) ? buildPublicClient(args.clientOrBuildClientArgs) : args.clientOrBuildClientArgs;
222
+ await client.readContract({
223
+ address: args.safeAddress,
224
+ abi: SafeMinimalAbi,
225
+ functionName: "getThreshold"
226
+ });
227
+ return true;
228
+ } catch (err) {
229
+ console.warn("isValidSafe - failure checking safe", { err: err.message });
230
+ return false;
231
+ }
232
+ }
233
+ async function isSafeOwner(args) {
234
+ try {
235
+ const client = isBuildPublicClientArgs(args.clientOrBuildClientArgs) ? buildPublicClient(args.clientOrBuildClientArgs) : args.clientOrBuildClientArgs;
236
+ return await client.readContract({
237
+ address: args.safeAddress,
238
+ abi: SafeMinimalAbi,
239
+ functionName: "isOwner",
240
+ args: [args.eoa]
241
+ });
242
+ } catch (err) {
243
+ console.warn("isSafeOwner - failure checking if EoA is Safe owner", { err: err.message });
244
+ return false;
245
+ }
246
+ }
247
+ async function fetchOwnedSafes(args) {
248
+ let safes = {};
249
+ for (const chain of args.chains ?? [L2Chain.id, L1Chain.id, L1ChainTestnet.id]) {
250
+ const chainSafes = await fetchSafesByChain(args.signer, chain);
251
+ safes = { ...safes, [chain]: chainSafes };
252
+ }
253
+ return safes;
254
+ }
255
+ const OwnerResponseSchema = z.object({
256
+ safes: z.array(z.custom((val) => val != null && typeof val === "string" && isAddress(val)))
257
+ });
258
+ async function fetchSafesByChain(signer, chain) {
259
+ const txServiceUrl = ApiKitUrlMap[chain];
260
+ const response = await fetch(`${txServiceUrl}/v1/owners/${signer}/safes/`, {
261
+ method: "get",
262
+ headers: {
263
+ Accept: "application/json",
264
+ "Content-Type": "application/json"
265
+ }
266
+ });
267
+ if (response.status !== 200) {
268
+ return [];
269
+ }
270
+ const json = await response.json();
271
+ const parsed = OwnerResponseSchema.safeParse(json);
272
+ if (!parsed.success) {
273
+ return [];
274
+ }
275
+ return parsed.data.safes;
276
+ }
277
+ export {
278
+ ApiKitUrlMap as A,
279
+ BuildPublicClientArgs as B,
280
+ DefChain as D,
281
+ GraphAuthKitProps as G,
282
+ L1Chain as L,
283
+ MULTISIG_AUTH_STORAGE_KEY as M,
284
+ OptionalGatewayApiKey as O,
285
+ RequiredInfuraKey as R,
286
+ SafeSupportedNetworks as S,
287
+ SafeSupportedNetworkNames as a,
288
+ createSafe as b,
289
+ createApiKit as c,
290
+ isValidSafe as d,
291
+ isSafeOwner as e,
292
+ fetchOwnedSafes as f,
293
+ buildInfuraHttpTransport as g,
294
+ isBuildPublicClientArgs as h,
295
+ isSafeSupportedNetwork as i,
296
+ buildPublicClient as j,
297
+ BuildClientArgs as k,
298
+ buildClient as l,
299
+ AUTH_STORAGE_KEY as m,
300
+ L1ChainTestnet as n,
301
+ L2Chain as o,
302
+ L2ChainTestnet as p,
303
+ SupportedClientChainId as q,
304
+ SupportedClientChains as r,
305
+ SupportedL1ClientChainId as s,
306
+ SupportedL2ClientChainId as t,
307
+ RequiredWalletConnectProjectId as u,
308
+ GraphAuthKitConnector as v
309
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@edgeandnode/graph-auth-kit",
3
3
  "private": false,
4
- "version": "6.1.1-gau-add-usewaitforsafetransaction-1739825153307-ae65380841053846f20df847aa95081441d5b125",
4
+ "version": "6.2.0-focus-and-nav-1739902127239-6cca9d0cd9cb24eb8b7465832e6023b10c11f90e",
5
5
  "description": "Wallet authentication connect kit in The Graph suite of applications",
6
6
  "author": "Edge & Node",
7
7
  "license": "UNLICENSED",
@@ -55,15 +55,15 @@
55
55
  "viem": "^2.21",
56
56
  "wagmi": "^2.12",
57
57
  "@edgeandnode/common": "^7.0.1",
58
- "@edgeandnode/gds": "^6.3.0",
58
+ "@edgeandnode/gds": "^6.4.0-focus-and-nav-1739902127239-6cca9d0cd9cb24eb8b7465832e6023b10c11f90e",
59
59
  "@edgeandnode/ens": "^2.1.0",
60
- "@edgeandnode/go": "^9.1.0"
60
+ "@edgeandnode/go": "^9.2.0-focus-and-nav-1739902127239-6cca9d0cd9cb24eb8b7465832e6023b10c11f90e"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@emotion/react": "^11.14",
64
64
  "@ethersproject/abstract-provider": "^5.7.0",
65
65
  "@ethersproject/properties": "^5.7.0",
66
- "@tanstack/react-query": "^5.66.0",
66
+ "@tanstack/react-query": "^5.66.7",
67
67
  "@types/react": "^18.3.18",
68
68
  "@types/react-dom": "^18.3.5",
69
69
  "dotenv": "^16.4.7",
@@ -76,8 +76,8 @@
76
76
  "wagmi": "^2.14.11",
77
77
  "@edgeandnode/common": "^7.0.1",
78
78
  "@edgeandnode/ens": "^2.1.0",
79
- "@edgeandnode/gds": "^6.3.0",
80
- "@edgeandnode/go": "^9.1.0",
79
+ "@edgeandnode/gds": "^6.4.0-focus-and-nav-1739902127239-6cca9d0cd9cb24eb8b7465832e6023b10c11f90e",
80
+ "@edgeandnode/go": "^9.2.0-focus-and-nav-1739902127239-6cca9d0cd9cb24eb8b7465832e6023b10c11f90e",
81
81
  "@edgeandnode/jsx": "^1.1.0",
82
82
  "@edgeandnode/test-utils": "^2.1.0"
83
83
  },
@@ -1,9 +0,0 @@
1
- import { SafeMultisigTransactionResponse } from '@safe-global/types-kit';
2
- import { Config, ResolvedRegister } from 'wagmi';
3
- import { SafeSupportedNetworks } from './constants';
4
- export declare function getSafeTransaction(safeTxHash: string, network: SafeSupportedNetworks): Promise<SafeMultisigTransactionResponse>;
5
- export declare function waitForSafeTransation(safeTxHash: string, network: SafeSupportedNetworks, pollingInterval?: number): Promise<SafeMultisigTransactionResponse>;
6
- export declare function useWaitForSafeTransaction<const config extends Config = ResolvedRegister['config']>({ safeTxHash, }: {
7
- safeTxHash: string | undefined;
8
- }): import('@tanstack/react-query').UseQueryResult<SafeMultisigTransactionResponse | undefined, Error>;
9
- //# sourceMappingURL=useWaitForSafeTransaction.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useWaitForSafeTransaction.d.ts","sourceRoot":"","sources":["../../src/safe/useWaitForSafeTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,wBAAwB,CAAA;AAE7E,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,gBAAgB,EAAa,MAAM,OAAO,CAAA;AAIrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAGnD,wBAAsB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,4CAI1F;AAED,wBAAsB,qBAAqB,CACzC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,qBAAqB,EAC9B,eAAe,GAAE,MAAc,4CAWhC;AAED,wBAAgB,yBAAyB,CAAC,KAAK,CAAC,MAAM,SAAS,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,EAAE,EAClG,UAAU,GACX,EAAE;IACD,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;CAC/B,sGAiBA"}
@@ -1,211 +0,0 @@
1
- "use client";
2
- import { createIdenticon } from "@edgeandnode/gds";
3
- import { getEnsAvatarQueryKey, getEnsNameQueryKey } from "@wagmi/core/query";
4
- import { useQuery } from "wagmi/query";
5
- import { J as useGraphAuthKitInnerContext, x as isSupportedChainId, o as L2Chain, n as L1ChainTestnet, p as L2ChainTestnet, L as L1Chain } from "./GraphAuthKitInner.context-B8vsvUDy.js";
6
- import { a as useGraphAuthKitAccount } from "./hooks-ClXeFY-j.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
- };
@@ -1,44 +0,0 @@
1
- import { useQuery } from "@tanstack/react-query";
2
- import { useConfig } from "wagmi";
3
- import { u as useMultisigInfo } from "./hooks-ClXeFY-j.js";
4
- import { c as createApiKit } from "./GraphAuthKitInner.context-B8vsvUDy.js";
5
- async function getSafeTransaction(safeTxHash, network) {
6
- const apiKit = await createApiKit(network);
7
- const txDetails = await apiKit.getTransaction(safeTxHash);
8
- return txDetails;
9
- }
10
- async function waitForSafeTransation(safeTxHash, network, pollingInterval = 4e3) {
11
- return new Promise((resolve) => {
12
- const poll = async () => {
13
- const txDetails = await getSafeTransaction(safeTxHash, network);
14
- if (txDetails.transactionHash) {
15
- resolve(txDetails);
16
- } else setTimeout(poll, pollingInterval);
17
- };
18
- void poll();
19
- });
20
- }
21
- function useWaitForSafeTransaction({
22
- safeTxHash
23
- }) {
24
- const config = useConfig();
25
- const _enteredMultisigInfo = useMultisigInfo();
26
- return useQuery({
27
- queryKey: ["SafeMultisigTransactionResponse", safeTxHash],
28
- queryFn: async () => {
29
- if (!_enteredMultisigInfo || !safeTxHash) return;
30
- const txDetails = await waitForSafeTransation(
31
- safeTxHash,
32
- _enteredMultisigInfo.network,
33
- config.getClient().pollingInterval
34
- );
35
- return txDetails;
36
- },
37
- enabled: _enteredMultisigInfo != null && safeTxHash != null
38
- });
39
- }
40
- export {
41
- getSafeTransaction as g,
42
- useWaitForSafeTransaction as u,
43
- waitForSafeTransation as w
44
- };