@edgeandnode/graph-auth-kit 6.1.1-gau-add-usepollsafetransaction-1739537269810-173707a9b7a2f0057f7fdefde5326859c440878e → 6.1.1-gau-add-usewaitforsafetransaction-1739825153307-ae65380841053846f20df847aa95081441d5b125
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/{GraphAuthKitInner.context-DkY5ODsb.js → GraphAuthKitInner.context-B8vsvUDy.js} +320 -16
- package/dist/ens/index.js +1 -1
- package/dist/{useGraphAuthKitEnsNames-8d-_Qd5D.js → hooks-ClXeFY-j.js} +12 -241
- package/dist/hooks.d.ts +0 -1
- package/dist/hooks.d.ts.map +1 -1
- package/dist/index.js +26 -23
- package/dist/safe/index.d.ts +1 -0
- package/dist/safe/index.d.ts.map +1 -1
- package/dist/safe/index.js +6 -2
- package/dist/safe/useWaitForSafeTransaction.d.ts +9 -0
- package/dist/safe/useWaitForSafeTransaction.d.ts.map +1 -0
- package/dist/test-harness/index.js +1 -1
- package/dist/useGraphAuthKitEnsNames-BEajLdia.js +211 -0
- package/dist/useWaitForSafeTransaction-D4k3ZLSB.js +44 -0
- package/dist/{utils-C_72bAxT.js → utils-DuHz-YHi.js} +1 -2
- package/package.json +2 -2
- package/dist/utils-DP_AxKkW.js +0 -309
package/dist/utils-DP_AxKkW.js
DELETED
|
@@ -1,309 +0,0 @@
|
|
|
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
|
-
};
|