@edgeandnode/graph-auth-kit 0.2.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.
Files changed (57) hide show
  1. package/README.md +238 -0
  2. package/dist/Components/ConnectModal.d.ts +2 -0
  3. package/dist/Components/ConnectModal.d.ts.map +1 -0
  4. package/dist/Components/ConnectorOption.d.ts +13 -0
  5. package/dist/Components/ConnectorOption.d.ts.map +1 -0
  6. package/dist/Components/MultisigSignerOptions.d.ts +2 -0
  7. package/dist/Components/MultisigSignerOptions.d.ts.map +1 -0
  8. package/dist/Components/PrimaryConnectOptions.d.ts +2 -0
  9. package/dist/Components/PrimaryConnectOptions.d.ts.map +1 -0
  10. package/dist/Components/SafeInputForm.d.ts +2 -0
  11. package/dist/Components/SafeInputForm.d.ts.map +1 -0
  12. package/dist/Components/SafeSelection.d.ts +2 -0
  13. package/dist/Components/SafeSelection.d.ts.map +1 -0
  14. package/dist/GraphAuthKit.context-DBwb2jco.js +936 -0
  15. package/dist/GraphAuthKit.context.d.ts +80 -0
  16. package/dist/GraphAuthKit.context.d.ts.map +1 -0
  17. package/dist/GraphAuthKitInner.context.d.ts +109 -0
  18. package/dist/GraphAuthKitInner.context.d.ts.map +1 -0
  19. package/dist/client.d.ts +8612 -0
  20. package/dist/client.d.ts.map +1 -0
  21. package/dist/constants.d.ts +329 -0
  22. package/dist/constants.d.ts.map +1 -0
  23. package/dist/errors.d.ts +21 -0
  24. package/dist/errors.d.ts.map +1 -0
  25. package/dist/hooks.d.ts +74 -0
  26. package/dist/hooks.d.ts.map +1 -0
  27. package/dist/index.d.ts +8 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +442 -0
  30. package/dist/safe/SafeEthersSigner.d.ts +37 -0
  31. package/dist/safe/SafeEthersSigner.d.ts.map +1 -0
  32. package/dist/safe/SafeMinimal.abi.d.ts +80 -0
  33. package/dist/safe/SafeMinimal.abi.d.ts.map +1 -0
  34. package/dist/safe/constants.d.ts +26 -0
  35. package/dist/safe/constants.d.ts.map +1 -0
  36. package/dist/safe/index.d.ts +3 -0
  37. package/dist/safe/index.d.ts.map +1 -0
  38. package/dist/safe/index.js +11 -0
  39. package/dist/safe/safeViemActions.d.ts +4 -0
  40. package/dist/safe/safeViemActions.d.ts.map +1 -0
  41. package/dist/safe/utils.d.ts +38 -0
  42. package/dist/safe/utils.d.ts.map +1 -0
  43. package/dist/safe/utils.test.d.ts +2 -0
  44. package/dist/safe/utils.test.d.ts.map +1 -0
  45. package/dist/test-harness/MockGraphAuthKit.context.d.ts +102 -0
  46. package/dist/test-harness/MockGraphAuthKit.context.d.ts.map +1 -0
  47. package/dist/test-harness/index.d.ts +2 -0
  48. package/dist/test-harness/index.d.ts.map +1 -0
  49. package/dist/test-harness/index.js +63 -0
  50. package/dist/types.d.ts +54 -0
  51. package/dist/types.d.ts.map +1 -0
  52. package/dist/utils-KuRu9vB-.js +218 -0
  53. package/dist/utils.d.ts +18 -0
  54. package/dist/utils.d.ts.map +1 -0
  55. package/dist/utils.test.d.ts +2 -0
  56. package/dist/utils.test.d.ts.map +1 -0
  57. package/package.json +93 -0
package/dist/index.js ADDED
@@ -0,0 +1,442 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
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-DBwb2jco.js";
5
+ import { h, B, m, a, l, j, R, k, b, f, g, c, r, o, n, p, q, i } from "./GraphAuthKit.context-DBwb2jco.js";
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 as f2, d, i as i2 } from "./utils-KuRu9vB-.js";
8
+ import { useMutation } from "@tanstack/react-query";
9
+ import { useMemo } from "react";
10
+ import { encodeFunctionData, getAddress } from "viem";
11
+ import { useChainId, useConnectorClient, useAccount, useWalletClient, useConfig } from "wagmi";
12
+ import { writeContractMutationOptions } from "wagmi/query";
13
+ import { VoidSigner } from "@ethersproject/abstract-signer";
14
+ import { OperationType } from "@safe-global/safe-core-sdk-types";
15
+ import { utils, BigNumber } from "ethers";
16
+ const createLibAddress = "0x7cbB62EaA69F79e6873cD1ecB2392971036cFAa4";
17
+ const createLibInterface = new utils.Interface([
18
+ {
19
+ anonymous: false,
20
+ inputs: [
21
+ {
22
+ indexed: false,
23
+ internalType: "address",
24
+ name: "newContract",
25
+ type: "address"
26
+ }
27
+ ],
28
+ name: "ContractCreation",
29
+ type: "event"
30
+ },
31
+ {
32
+ inputs: [
33
+ {
34
+ internalType: "uint256",
35
+ name: "value",
36
+ type: "uint256"
37
+ },
38
+ {
39
+ internalType: "bytes",
40
+ name: "deploymentData",
41
+ type: "bytes"
42
+ }
43
+ ],
44
+ name: "performCreate",
45
+ outputs: [
46
+ {
47
+ internalType: "address",
48
+ name: "newContract",
49
+ type: "address"
50
+ }
51
+ ],
52
+ stateMutability: "nonpayable",
53
+ type: "function"
54
+ },
55
+ {
56
+ inputs: [
57
+ {
58
+ internalType: "uint256",
59
+ name: "value",
60
+ type: "uint256"
61
+ },
62
+ {
63
+ internalType: "bytes",
64
+ name: "deploymentData",
65
+ type: "bytes"
66
+ },
67
+ {
68
+ internalType: "bytes32",
69
+ name: "salt",
70
+ type: "bytes32"
71
+ }
72
+ ],
73
+ name: "performCreate2",
74
+ outputs: [
75
+ {
76
+ internalType: "address",
77
+ name: "newContract",
78
+ type: "address"
79
+ }
80
+ ],
81
+ stateMutability: "nonpayable",
82
+ type: "function"
83
+ }
84
+ ]);
85
+ const mapStatus = (receipt) => {
86
+ const success = receipt.logs.find(
87
+ (log) => log.topics[0] === "0x442e715f626346e8c54381002da614f62bee8d27386535b2521ec8540898556e"
88
+ );
89
+ return !!success ? 1 : 0;
90
+ };
91
+ const mapContractAddress = (receipt, safeTx) => {
92
+ if (safeTx.to.toLowerCase() === createLibAddress.toLowerCase()) {
93
+ const creationLog = receipt.logs.find(
94
+ (log) => log.topics[0] === "0x4db17dd5e4732fb6da34a148104a592783ca119a1e7bb8829eba6cbadef0b511"
95
+ );
96
+ if (creationLog) return utils.getAddress("0x" + creationLog.data.slice(creationLog.data.length - 40));
97
+ }
98
+ return receipt.contractAddress;
99
+ };
100
+ const mapReceipt = (receipt, safeTx) => {
101
+ receipt.status = mapStatus(receipt);
102
+ receipt.contractAddress = mapContractAddress(receipt, safeTx);
103
+ return receipt;
104
+ };
105
+ const sleep = (duration) => new Promise((resolve) => setTimeout(resolve, duration));
106
+ class SafeEthersSigner extends VoidSigner {
107
+ constructor(safeAddress, provider, signerAddress, chainId, options) {
108
+ super(safeAddress, provider);
109
+ __publicField(this, "safeAddress");
110
+ __publicField(this, "signerAddress");
111
+ __publicField(this, "chainId");
112
+ __publicField(this, "options");
113
+ __publicField(this, "safe");
114
+ __publicField(this, "apiKit");
115
+ this.signerAddress = signerAddress;
116
+ this.safeAddress = safeAddress;
117
+ this.chainId = chainId;
118
+ this.options = options;
119
+ }
120
+ createSafeInstance() {
121
+ const eip1193Provider = {
122
+ request: async (args) => {
123
+ var _a;
124
+ return (_a = this.provider) == null ? void 0 : _a.send(args.method, args.params);
125
+ }
126
+ };
127
+ return createSafe({
128
+ provider: eip1193Provider,
129
+ signer: this.signerAddress,
130
+ safeAddress: this.safeAddress
131
+ });
132
+ }
133
+ async getSafeInstance() {
134
+ if (!this.safe) {
135
+ this.safe = await this.createSafeInstance();
136
+ }
137
+ return this.safe;
138
+ }
139
+ createApiKitInstance() {
140
+ return createApiKit(this.chainId);
141
+ }
142
+ async getApiKitInstance() {
143
+ if (!this.apiKit) {
144
+ this.apiKit = await this.createApiKitInstance();
145
+ }
146
+ return this.apiKit;
147
+ }
148
+ async buildTransactionResponse(safeTxHash, safeTx) {
149
+ const connectedSafe = await this.getSafeInstance();
150
+ const connectedService = await this.getApiKitInstance();
151
+ const chainIdBigInt = await connectedSafe.getChainId();
152
+ return {
153
+ to: safeTx.to,
154
+ value: BigNumber.from(safeTx.value),
155
+ data: safeTx.data,
156
+ operation: safeTx.operation,
157
+ gasLimit: BigNumber.from(safeTx.safeTxGas),
158
+ gasPrice: BigNumber.from(0),
159
+ nonce: safeTx.nonce,
160
+ chainId: parseInt(chainIdBigInt.toString()),
161
+ hash: safeTxHash,
162
+ from: this.address,
163
+ confirmations: 0,
164
+ wait: async (confirmations) => {
165
+ var _a, _b;
166
+ while (true) {
167
+ try {
168
+ const txDetails = await connectedService.getTransaction(safeTxHash);
169
+ if (txDetails.transactionHash) {
170
+ this._checkProvider("sendTransaction");
171
+ const receipt = await ((_a = this.provider) == null ? void 0 : _a.waitForTransaction(
172
+ txDetails.transactionHash,
173
+ confirmations
174
+ ));
175
+ return mapReceipt(receipt, safeTx);
176
+ }
177
+ } catch (e2) {
178
+ }
179
+ await sleep(((_b = this.options) == null ? void 0 : _b.pollingDelay) ?? 5e3);
180
+ }
181
+ }
182
+ };
183
+ }
184
+ /**
185
+ * Populates all fields in a transaction, signs it and sends it to the Safe transaction service
186
+ *
187
+ * @param transaction - The transaction what should be send
188
+ * @returns A promise that resolves to a SafeTransactionReponse, that contains all the information of the transaction.
189
+ */
190
+ async sendTransaction(transaction) {
191
+ var _a;
192
+ const tx = await transaction;
193
+ let operation = OperationType.Call;
194
+ let to = await tx.to;
195
+ let data = ((_a = await tx.data) == null ? void 0 : _a.toString()) ?? "0x";
196
+ let value = BigNumber.from(await tx.value ?? 0);
197
+ if (!to) {
198
+ to = createLibAddress;
199
+ data = createLibInterface.encodeFunctionData("performCreate", [value, data]);
200
+ value = BigNumber.from(0);
201
+ operation = OperationType.DelegateCall;
202
+ }
203
+ const baseTx = {
204
+ to,
205
+ data,
206
+ value: value.toString(),
207
+ operation
208
+ };
209
+ const apiKit = await this.getApiKitInstance();
210
+ const nonce = await apiKit.getNextNonce(this.address);
211
+ const safeTransactionData = {
212
+ ...baseTx,
213
+ nonce
214
+ // baseGas,
215
+ // gasPrice,
216
+ // gasToken,
217
+ // refundReceiver,
218
+ };
219
+ const estimateTx = await apiKit.estimateSafeTransaction(this.safeAddress, safeTransactionData);
220
+ safeTransactionData.safeTxGas = estimateTx.safeTxGas;
221
+ const connectedSafe = await this.getSafeInstance();
222
+ const safeTransaction = await connectedSafe.createTransaction({ transactions: [safeTransactionData] });
223
+ const safeTxHash = await connectedSafe.getTransactionHash(safeTransaction);
224
+ const senderSignature = await connectedSafe.signHash(safeTxHash);
225
+ await apiKit.proposeTransaction({
226
+ safeAddress: this.safeAddress,
227
+ safeTransactionData: safeTransaction.data,
228
+ safeTxHash,
229
+ senderAddress: this.signerAddress,
230
+ senderSignature: senderSignature.data
231
+ });
232
+ return this.buildTransactionResponse(safeTxHash, safeTransaction.data);
233
+ }
234
+ }
235
+ function safeViemActions(safeAddress, chainId) {
236
+ return (client) => {
237
+ return {
238
+ async writeContract(parameters) {
239
+ const eip1193Provider = {
240
+ async request({ method, params }) {
241
+ if (method === "eth_requestAccounts") {
242
+ return client.requestAddresses();
243
+ }
244
+ if (method === "eth_accounts") {
245
+ return client.getAddresses();
246
+ }
247
+ if (method === "eth_signTypedData_v4") {
248
+ const arg = params && Array.isArray(params) ? params[1] : void 0;
249
+ const json = JSON.parse(arg);
250
+ return client.signTypedData(json);
251
+ }
252
+ if (method === "eth_sendTransaction") {
253
+ const tx = params && Array.isArray(params) ? params[0] : void 0;
254
+ return client.sendTransaction({
255
+ account: client.account,
256
+ chain: client.chain,
257
+ to: (tx == null ? void 0 : tx.to) || "0x",
258
+ value: tx == null ? void 0 : tx.value,
259
+ data: tx == null ? void 0 : tx.data,
260
+ nonce: tx == null ? void 0 : tx.nonce
261
+ });
262
+ }
263
+ return client.request({ method, params });
264
+ }
265
+ };
266
+ const apiKit = await createApiKit(chainId);
267
+ const signerAddresses = await client.getAddresses();
268
+ const signerAddress = signerAddresses[0];
269
+ const protocolKit = await createSafe({ provider: eip1193Provider, signer: signerAddress, safeAddress });
270
+ const { abi, address, args, dataSuffix, functionName, value, ...request } = parameters;
271
+ const data = encodeFunctionData({
272
+ abi,
273
+ args,
274
+ functionName
275
+ });
276
+ const dataWithSuffix = `${data}${dataSuffix ? dataSuffix.replace("0x", "") : ""}`;
277
+ const operation = OperationType.Call;
278
+ const baseTx = {
279
+ to: address,
280
+ data: dataWithSuffix,
281
+ value: value ? value.toString() : "0",
282
+ operation
283
+ };
284
+ const nonce = await apiKit.getNextNonce(safeAddress);
285
+ const safeTransactionData = {
286
+ ...baseTx,
287
+ nonce
288
+ // baseGas,
289
+ // gasPrice,
290
+ // gasToken,
291
+ // refundReceiver,
292
+ };
293
+ const estimateTx = await apiKit.estimateSafeTransaction(safeAddress, safeTransactionData);
294
+ safeTransactionData.safeTxGas = estimateTx.safeTxGas;
295
+ const safeTransaction = await protocolKit.createTransaction({ transactions: [safeTransactionData] });
296
+ const safeTxHash = await protocolKit.getTransactionHash(safeTransaction);
297
+ const senderSignature = await protocolKit.signHash(safeTxHash);
298
+ await apiKit.proposeTransaction({
299
+ safeAddress,
300
+ safeTransactionData: safeTransaction.data,
301
+ safeTxHash,
302
+ senderAddress: signerAddress,
303
+ senderSignature: senderSignature.data
304
+ });
305
+ return safeTxHash;
306
+ }
307
+ };
308
+ };
309
+ }
310
+ function useClientToEthersSigner() {
311
+ const chainId = useChainId();
312
+ const { data: client } = useConnectorClient({ chainId });
313
+ const ctx = useGraphAuthKitInnerContext();
314
+ return useMemo(() => {
315
+ if (!client) return void 0;
316
+ const provider = clientToProvider(client);
317
+ if (ctx._connector === "multisig" && ctx._enteredMultisigInfo != null) {
318
+ const safeAddress = getAddress(ctx._enteredMultisigInfo.address);
319
+ const safeEthersSigner = new SafeEthersSigner(
320
+ safeAddress,
321
+ provider,
322
+ client.account.address,
323
+ chainId
324
+ );
325
+ return safeEthersSigner;
326
+ }
327
+ const signer = provider.getSigner();
328
+ return signer;
329
+ }, [chainId, client, ctx._connector, ctx._enteredMultisigInfo]);
330
+ }
331
+ function useGraphAuthKitConnector() {
332
+ const { _connector } = useGraphAuthKitInnerContext();
333
+ return _connector || null;
334
+ }
335
+ function useGraphAuthKitAccount() {
336
+ const data = useAccount();
337
+ const ctx = useGraphAuthKitInnerContext();
338
+ if (data.address == null || !data.isConnected || ctx._connector == null) {
339
+ return {
340
+ address: void 0,
341
+ addresses: void 0,
342
+ chain: void 0,
343
+ chainId: void 0,
344
+ connector: void 0,
345
+ isConnected: false,
346
+ isReconnecting: false,
347
+ isConnecting: false,
348
+ isDisconnected: true,
349
+ status: "disconnected",
350
+ eoa: void 0
351
+ };
352
+ }
353
+ if (ctx._connector === "multisig" && ctx._enteredMultisigInfo != null) {
354
+ const address = getAddress(ctx._enteredMultisigInfo.address);
355
+ const [, ...rest] = data.addresses ?? [];
356
+ return {
357
+ ...data,
358
+ address,
359
+ addresses: [address, data.address, ...rest],
360
+ eoa: data.address
361
+ };
362
+ }
363
+ return { ...data, eoa: void 0 };
364
+ }
365
+ function useGraphAuthKitWalletClient() {
366
+ const ctx = useGraphAuthKitInnerContext();
367
+ const walletClient = useWalletClient();
368
+ if (!walletClient.data) {
369
+ return walletClient;
370
+ }
371
+ if (ctx._connector === "multisig" && ctx._enteredMultisigInfo != null) {
372
+ const safeAddress = getAddress(ctx._enteredMultisigInfo.address);
373
+ const safeWalletClient = walletClient.data.extend(safeViemActions(safeAddress, ctx._enteredMultisigInfo.network));
374
+ return { ...walletClient, data: safeWalletClient };
375
+ }
376
+ return walletClient;
377
+ }
378
+ function useGraphAuthKitWriteContract(parameters = {}) {
379
+ const { data: walletClient } = useGraphAuthKitWalletClient();
380
+ const { mutation } = parameters;
381
+ const config = useConfig(parameters);
382
+ const mutationOptions = writeContractMutationOptions(config);
383
+ const customMutationFn = (variables) => {
384
+ if (!walletClient) {
385
+ throw new Error("WalletClient is not available");
386
+ }
387
+ return walletClient.writeContract(variables);
388
+ };
389
+ const { mutate, mutateAsync, ...result } = useMutation({
390
+ ...mutation,
391
+ ...mutationOptions,
392
+ mutationFn: customMutationFn
393
+ });
394
+ return {
395
+ ...result,
396
+ writeContract: mutate,
397
+ writeContractAsync: mutateAsync
398
+ };
399
+ }
400
+ export {
401
+ j2 as AUTH_STORAGE_KEY,
402
+ A as ApiKitUrlMap,
403
+ h as BuildClientArgs,
404
+ B as BuildPublicClientArgs,
405
+ D as DefChain,
406
+ m as GraphAuthKitConnector,
407
+ a as GraphAuthKitContext,
408
+ l as GraphAuthKitProps,
409
+ j as GraphAuthKitProvider,
410
+ g2 as L1Chain,
411
+ h2 as L1ChainTestnet,
412
+ L as L2Chain,
413
+ e as L2ChainTestnet,
414
+ M as MULTISIG_AUTH_STORAGE_KEY,
415
+ R as RequiredInfuraKey,
416
+ k as RequiredWalletConnectProjectId,
417
+ a2 as SafeSupportedNetworkNames,
418
+ S as SafeSupportedNetworks,
419
+ k2 as SupportedClientChainId,
420
+ l2 as SupportedClientChains,
421
+ b as buildClient,
422
+ f as buildInfuraHttpTransport,
423
+ g as buildPublicClient,
424
+ c as chainIsSupportedChain,
425
+ clientToProvider,
426
+ r as connectedWalletIsEoA,
427
+ createApiKit,
428
+ createSafe,
429
+ f2 as fetchOwnedSafes,
430
+ o as isChainL1,
431
+ n as isChainL2,
432
+ p as isChainMainnet,
433
+ q as isChainTestnet,
434
+ d as isSafeOwner,
435
+ i2 as isValidSafe,
436
+ useClientToEthersSigner,
437
+ i as useGraphAuthKit,
438
+ useGraphAuthKitAccount,
439
+ useGraphAuthKitConnector,
440
+ useGraphAuthKitWalletClient,
441
+ useGraphAuthKitWriteContract
442
+ };
@@ -0,0 +1,37 @@
1
+ import { type TransactionReceipt, type TransactionRequest, type TransactionResponse } from '@ethersproject/abstract-provider';
2
+ import { VoidSigner } from '@ethersproject/abstract-signer';
3
+ import { type Deferrable } from '@ethersproject/properties';
4
+ import type SafeApiKit from '@safe-global/api-kit';
5
+ import type Safe from '@safe-global/protocol-kit';
6
+ import { OperationType, type SafeTransactionData } from '@safe-global/safe-core-sdk-types';
7
+ import { type providers } from 'ethers';
8
+ import { type SafeSupportedNetworks } from './constants';
9
+ export declare const mapReceipt: (receipt: providers.TransactionReceipt, safeTx: SafeTransactionData) => TransactionReceipt;
10
+ export interface SafeTransactionResponse extends TransactionResponse {
11
+ operation: OperationType;
12
+ }
13
+ export interface SafeEthersSignerOptions {
14
+ pollingDelay?: number;
15
+ }
16
+ export declare class SafeEthersSigner extends VoidSigner {
17
+ readonly safeAddress: string;
18
+ readonly signerAddress: string;
19
+ readonly chainId: SafeSupportedNetworks;
20
+ readonly options?: SafeEthersSignerOptions;
21
+ safe?: Safe;
22
+ apiKit?: SafeApiKit;
23
+ constructor(safeAddress: string, provider: providers.Web3Provider, signerAddress: string, chainId: SafeSupportedNetworks, options?: SafeEthersSignerOptions);
24
+ createSafeInstance(): Promise<Safe>;
25
+ getSafeInstance(): Promise<Safe>;
26
+ createApiKitInstance(): Promise<SafeApiKit>;
27
+ getApiKitInstance(): Promise<SafeApiKit>;
28
+ buildTransactionResponse(safeTxHash: string, safeTx: SafeTransactionData): Promise<SafeTransactionResponse>;
29
+ /**
30
+ * Populates all fields in a transaction, signs it and sends it to the Safe transaction service
31
+ *
32
+ * @param transaction - The transaction what should be send
33
+ * @returns A promise that resolves to a SafeTransactionReponse, that contains all the information of the transaction.
34
+ */
35
+ sendTransaction(transaction: Deferrable<TransactionRequest>): Promise<SafeTransactionResponse>;
36
+ }
37
+ //# sourceMappingURL=SafeEthersSigner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SafeEthersSigner.d.ts","sourceRoot":"","sources":["../../src/safe/SafeEthersSigner.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACzB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAC3D,OAAO,EAAE,KA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uB,CAAC;CAyDrG"}
@@ -0,0 +1,80 @@
1
+ declare const _default: readonly [{
2
+ readonly inputs: readonly [];
3
+ readonly payable: false;
4
+ readonly stateMutability: "nonpayable";
5
+ readonly type: "constructor";
6
+ }, {
7
+ readonly constant: true;
8
+ readonly inputs: readonly [];
9
+ readonly name: "getThreshold";
10
+ readonly outputs: readonly [{
11
+ readonly internalType: "uint256";
12
+ readonly name: "";
13
+ readonly type: "uint256";
14
+ }];
15
+ readonly payable: false;
16
+ readonly stateMutability: "view";
17
+ readonly type: "function";
18
+ }, {
19
+ readonly constant: true;
20
+ readonly inputs: readonly [];
21
+ readonly name: "getOwners";
22
+ readonly outputs: readonly [{
23
+ readonly internalType: "address[]";
24
+ readonly name: "";
25
+ readonly type: "address[]";
26
+ }];
27
+ readonly payable: false;
28
+ readonly stateMutability: "view";
29
+ readonly type: "function";
30
+ }, {
31
+ readonly constant: false;
32
+ readonly inputs: readonly [{
33
+ readonly internalType: "bytes";
34
+ readonly name: "_data";
35
+ readonly type: "bytes";
36
+ }, {
37
+ readonly internalType: "bytes";
38
+ readonly name: "_signature";
39
+ readonly type: "bytes";
40
+ }];
41
+ readonly name: "isValidSignature";
42
+ readonly outputs: readonly [{
43
+ readonly internalType: "bytes4";
44
+ readonly name: "";
45
+ readonly type: "bytes4";
46
+ }];
47
+ readonly payable: false;
48
+ readonly stateMutability: "nonpayable";
49
+ readonly type: "function";
50
+ }, {
51
+ readonly constant: true;
52
+ readonly inputs: readonly [];
53
+ readonly name: "nonce";
54
+ readonly outputs: readonly [{
55
+ readonly internalType: "uint256";
56
+ readonly name: "";
57
+ readonly type: "uint256";
58
+ }];
59
+ readonly payable: false;
60
+ readonly stateMutability: "view";
61
+ readonly type: "function";
62
+ }, {
63
+ readonly constant: true;
64
+ readonly inputs: readonly [{
65
+ readonly internalType: "address";
66
+ readonly name: "owner";
67
+ readonly type: "address";
68
+ }];
69
+ readonly name: "isOwner";
70
+ readonly outputs: readonly [{
71
+ readonly internalType: "bool";
72
+ readonly name: "";
73
+ readonly type: "bool";
74
+ }];
75
+ readonly payable: false;
76
+ readonly stateMutability: "view";
77
+ readonly type: "function";
78
+ }];
79
+ export default _default;
80
+ //# sourceMappingURL=SafeMinimal.abi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SafeMinimal.abi.d.ts","sourceRoot":"","sources":["../../src/safe/SafeMinimal.abi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,wBAoGU"}
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ export declare const SafeSupportedNetworks: z.ZodReadonly<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<11155111>, z.ZodLiteral<42161>]>>;
3
+ export type SafeSupportedNetworks = z.infer<typeof SafeSupportedNetworks>;
4
+ export declare const SafeSupportedNetworkNames: {
5
+ readonly 42161: {
6
+ readonly shortName: "arb1";
7
+ readonly name: "Arbitrum One";
8
+ readonly id: 42161;
9
+ };
10
+ readonly 1: {
11
+ readonly shortName: "eth";
12
+ readonly name: "Ethereum";
13
+ readonly id: 1;
14
+ };
15
+ readonly 11155111: {
16
+ readonly shortName: "sep";
17
+ readonly name: "Sepolia";
18
+ readonly id: 11155111;
19
+ };
20
+ };
21
+ export declare const ApiKitUrlMap: {
22
+ readonly 1: "https://safe-transaction-mainnet.safe.global/api";
23
+ readonly 11155111: "https://safe-transaction-sepolia.safe.global/api";
24
+ readonly 42161: "https://safe-transaction-arbitrum.safe.global/api";
25
+ };
26
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/safe/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAIvB,eAAO,MAAM,qBAAqB,oGAErB,CAAA;AACb,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAEzE,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;CAWrC,CAAA;AAED,eAAO,MAAM,YAAY;;;;CAIiC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './constants';
2
+ export * from './utils';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/safe/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { A, a, S, c, b, f, d, i } from "../utils-KuRu9vB-.js";
2
+ export {
3
+ A as ApiKitUrlMap,
4
+ a as SafeSupportedNetworkNames,
5
+ S as SafeSupportedNetworks,
6
+ c as createApiKit,
7
+ b as createSafe,
8
+ f as fetchOwnedSafes,
9
+ d as isSafeOwner,
10
+ i as isValidSafe
11
+ };
@@ -0,0 +1,4 @@
1
+ import { type Account, type Chain, type Transport, type WalletActions, type WalletClient } from 'viem';
2
+ import { type SafeSupportedNetworks } from './constants';
3
+ export declare function safeViemActions(safeAddress: string, chainId: SafeSupportedNetworks): <transport extends Transport, chain extends Chain | undefined = Chain | undefined, account extends Account | undefined = Account | undefined>(client: WalletClient<transport, chain, account>) => Pick<WalletActions<chain, account>, "writeContract">;
4
+ //# sourceMappingURL=safeViemActions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safeViemActions.d.ts","sourceRoot":"","sources":["../../src/safe/safeViemActions.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAEV,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,MAAM,CAAA;AAGb,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAGxD,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,qBAAqB,IAE/E,SAAS,SAAS,SAAS,EAC3B,KAAK,SAAS,KAAK,GAAG,SAAS,sBAC/B,OAAO,SAAS,OAAO,GAAG,SAAS,gCAE3B,YAAY,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,KAC9C,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,eAAe,CAAC,CAgGxD"}
@@ -0,0 +1,38 @@
1
+ import type SafeApiKit from '@safe-global/api-kit';
2
+ import type Safe from '@safe-global/protocol-kit';
3
+ import { type SafeConfig } from '@safe-global/protocol-kit';
4
+ import { type Address } from 'viem';
5
+ import { type PublicClient } from '../client';
6
+ import { type SafeSupportedNetworks } from './constants';
7
+ export declare function createApiKit(chainId: SafeSupportedNetworks): Promise<SafeApiKit>;
8
+ export declare function createSafe(config: SafeConfig): Promise<Safe>;
9
+ export type IsValidSafeArgs = {
10
+ client: PublicClient;
11
+ chain: SafeSupportedNetworks;
12
+ safeAddress: Address;
13
+ };
14
+ export declare function isValidSafe(args: IsValidSafeArgs): Promise<boolean>;
15
+ export type IsSafeOwnerArgs = {
16
+ client: PublicClient;
17
+ chain: SafeSupportedNetworks;
18
+ safeAddress: Address;
19
+ eoa: Address;
20
+ };
21
+ export declare function isSafeOwner(args: IsSafeOwnerArgs): Promise<boolean>;
22
+ export type FetchOwnedSafesArgs<chains extends readonly [SafeSupportedNetworks, ...SafeSupportedNetworks[]]> = {
23
+ /** The EoA Safe signer to fetch owned Safes for */
24
+ signer: Address;
25
+ /**
26
+ * Which chains to retrieve the EoA owned Safes on.
27
+ * @default all
28
+ */
29
+ chains?: chains;
30
+ };
31
+ export declare function fetchOwnedSafes<const chains extends readonly [SafeSupportedNetworks, ...SafeSupportedNetworks[]]>(args: FetchOwnedSafesArgs<chains>): Promise<{
32
+ [K in chains[number]]: readonly Address[];
33
+ }>;
34
+ export type SafesByChain = {
35
+ address: Address;
36
+ chain: SafeSupportedNetworks;
37
+ };
38
+ //# s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AK,CAAC,MAAM,SAAS,SAAS,CAAC,qBAAqB,EAAE,GAAG,qBAAqB,EAAE,CAAC,EACjF,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC;KAAG,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,SAAS,OAAO,EAAE;CAAE,CAAC,CAQ3F;AAMD,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,qBAAqB,CAAA;CAC7B,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=utils.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../src/safe/utils.test.ts"],"names":[],"mappings":""}