@seedprotocol/publish 0.4.18 → 0.4.20

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 (44) hide show
  1. package/README.md +6 -0
  2. package/dist/config.d.ts +24 -1
  3. package/dist/config.d.ts.map +1 -1
  4. package/dist/helpers/arweave.d.ts +3 -2
  5. package/dist/helpers/arweave.d.ts.map +1 -1
  6. package/dist/helpers/arweave.test.d.ts +2 -0
  7. package/dist/helpers/arweave.test.d.ts.map +1 -0
  8. package/dist/helpers/ensureManagedAccountReady.test.d.ts +2 -0
  9. package/dist/helpers/ensureManagedAccountReady.test.d.ts.map +1 -0
  10. package/dist/hooks/useArweaveL1Finalize.d.ts +23 -0
  11. package/dist/hooks/useArweaveL1Finalize.d.ts.map +1 -0
  12. package/dist/hooks/useItemPublishStatus.d.ts +8 -0
  13. package/dist/hooks/useItemPublishStatus.d.ts.map +1 -1
  14. package/dist/index-BfABV7U1.js +4840 -0
  15. package/dist/index-BfABV7U1.js.map +1 -0
  16. package/dist/index-DhVUuOO3.js +4824 -0
  17. package/dist/index-DhVUuOO3.js.map +1 -0
  18. package/dist/index-P7oBN4Yu.js +4785 -0
  19. package/dist/index-P7oBN4Yu.js.map +1 -0
  20. package/dist/index.d.ts +4 -2
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +110 -4734
  23. package/dist/index.js.map +1 -1
  24. package/dist/services/PublishManager/actions/createPublish.d.ts.map +1 -1
  25. package/dist/services/arweaveL1Finalize/enqueue.d.ts +7 -0
  26. package/dist/services/arweaveL1Finalize/enqueue.d.ts.map +1 -0
  27. package/dist/services/arweaveL1Finalize/worker.d.ts +3 -0
  28. package/dist/services/arweaveL1Finalize/worker.d.ts.map +1 -0
  29. package/dist/services/publish/actors/createArweaveDataItems.d.ts.map +1 -1
  30. package/dist/services/publish/actors/createArweaveTransactions.d.ts.map +1 -1
  31. package/dist/services/publish/actors/createAttestations.d.ts.map +1 -1
  32. package/dist/services/publish/actors/createAttestationsDirectToEas.d.ts.map +1 -1
  33. package/dist/services/publish/helpers/getPublishUploadData.d.ts +8 -2
  34. package/dist/services/publish/helpers/getPublishUploadData.d.ts.map +1 -1
  35. package/dist/services/upload/uploadMachine.d.ts +1 -1
  36. package/dist/types.d.ts +10 -2
  37. package/dist/types.d.ts.map +1 -1
  38. package/dist/worker-BxY09Tmw.js +73 -0
  39. package/dist/worker-BxY09Tmw.js.map +1 -0
  40. package/dist/worker-Ce8qDQKc.js +73 -0
  41. package/dist/worker-Ce8qDQKc.js.map +1 -0
  42. package/dist/worker-F-UKvyIU.js +73 -0
  43. package/dist/worker-F-UKvyIU.js.map +1 -0
  44. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1,4737 +1,113 @@
1
- import { getGetAdditionalSyncAddresses as mn, getAttesterForSeed as fn, getVersionsForSeedUid as hn, getMetadataAttestationUidsForSeedUid as yn, VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA as gn, updateSeedRevokedAt as wn, setGetPublisherForNewSeeds as bn, setRevokeExecutor as An, setAdditionalSyncAddresses as vn, client as ut, getSegmentedItemProperties as nt, setSchemaUidForModel as ke, setSchemaUidForSchemaDefinition as oe, INTERNAL_DATA_TYPES as Sn, getEasSchemaForItemProperty as En, getRelatedItemsForPublish as In, BaseArweaveClient as Pn, Item as ae, getCorrectId as Lt, BaseFileManager as G, getUploadPipelineTransactionStatus as Un, resolvePublishPayloadValues as pt, getItemPropertiesFromEas as Tn, updateVersionUid as Dn, itemHasPublishUploadCandidates as xn, isItemOwned as Mt, validateItemForPublish as Cn, BaseDb as k, publishProcesses as P, uploadProcesses as Rn } from "@seedprotocol/sdk";
2
- import { prepareContractCall as x, readContract as _, createThirdwebClient as _n, getContract as V, sendTransaction as F, waitForReceipt as N, parseEventLogs as at, prepareEvent as Y } from "thirdweb";
3
- import { createWallet as De, inAppWallet as Ot } from "thirdweb/wallets";
4
- import { useActiveAccount as Ln, ThirdwebProvider as Mn, ConnectButton as On, darkTheme as Bn } from "thirdweb/react";
5
- import { isContractDeployed as Fn } from "thirdweb/utils";
6
- import { useState as be, useRef as Bt, useEffect as te, createContext as Nn, useContext as kn, useMemo as $n } from "react";
7
- import { optimismSepolia as v } from "thirdweb/chains";
8
- import Z from "debug";
9
- import { encodeAbiParameters as Ft, decodeAbiParameters as Hn } from "viem";
10
- import { jsx as me, jsxs as Vn } from "react/jsx-runtime";
11
- import { SeedProvider as Wn, useLiveQuery as Re } from "@seedprotocol/react";
12
- import { SeedProvider as qo } from "@seedprotocol/react";
13
- import { getInstalledModules as qn, installModule as jn } from "thirdweb/modules";
14
- import { SchemaEncoder as Gn, ZERO_BYTES32 as Yn, NO_EXPIRATION as Jn, SchemaRegistry as $e, ZERO_ADDRESS as Ke } from "@ethereum-attestation-service/eas-sdk";
15
- import { fromPromise as fe, fromCallback as he, setup as Nt, assign as T, enqueueActions as _e, createActor as Xe } from "xstate";
16
- import zn from "arweave";
17
- import { ethers as $ } from "ethers";
18
- import { readFile as Zn } from "node:fs/promises";
19
- import { and as Kn, eq as X, desc as Ae, notInArray as Xn, inArray as Qn } from "drizzle-orm";
20
- import { useSelector as ea } from "@xstate/react";
21
- async function ta(e) {
22
- return _({
23
- contract: e.contract,
24
- method: [
25
- "0x8878ed33",
26
- [
27
- {
28
- type: "address",
29
- name: "_adminSigner"
30
- },
31
- {
32
- type: "bytes",
33
- name: "_data"
34
- }
35
- ],
36
- [
37
- {
38
- type: "address"
39
- }
40
- ]
41
- ],
42
- params: [e.adminSigner, e.data]
43
- });
44
- }
45
- function na(e) {
46
- return x({
47
- contract: e.contract,
48
- method: [
49
- "0xd8fd8f44",
50
- [
51
- {
52
- type: "address",
53
- name: "_admin"
54
- },
55
- {
56
- type: "bytes",
57
- name: "_data"
58
- }
59
- ],
60
- [
61
- {
62
- type: "address"
63
- }
64
- ]
65
- ],
66
- params: [e.admin, e.data]
67
- });
68
- }
69
- const kt = "0x4200000000000000000000000000000000000020", aa = "0x44d562ac1d7cd77e232978687fea027ace48f719cf1d58c7888e509663bb87fc", $t = "0x76f47d88bfaf670f5208911181fcdc0e160cb16d", Ht = "0x4200000000000000000000000000000000000021", mt = "0xcd8c945872df8e664e55cf8885c85ea3ea8f2148", L = {
70
- SUCCESS: "success",
71
- FAILURE: "failure"
72
- }, ra = [
73
- "pollingForConfirmation",
74
- "uploadingData",
75
- "uploadingViaBundler"
76
- ], sa = 3e4, oa = Z("permaPress:helpers:thirdweb");
77
- let He = null;
78
- function R() {
79
- if (!He) {
80
- const { thirdwebClientId: e } = C();
81
- He = _n({ clientId: e });
82
- }
83
- return He;
84
- }
85
- const Is = [
86
- // embeddedWallet(),
87
- De("io.metamask")
88
- // createWallet("com.coinbase.wallet"),
89
- // createWallet("me.rainbow"),
90
- ], Ps = () => {
91
- const [e, t] = be(null);
92
- return De("io.metamask"), Bt(!1), te(() => {
93
- (async () => {
94
- })();
95
- }, []), e;
96
- }, Us = () => {
97
- const e = Ln(), [t, n] = be(null);
98
- return te(() => {
99
- !e || !e.address || n(V({
100
- client: R(),
101
- chain: v,
102
- address: e.address
103
- }));
104
- }, [e]), t;
105
- }, Vt = () => {
106
- const { thirdwebAccountFactoryAddress: e } = C();
107
- return V({
108
- client: R(),
109
- chain: v,
110
- address: e
111
- });
112
- };
113
- async function Wt(e, t = "0x") {
114
- const n = Vt();
115
- return ta({
116
- contract: n,
117
- adminSigner: e,
118
- data: t
119
- });
120
- }
121
- async function xe(e) {
122
- const t = V({
123
- client: R(),
124
- chain: v,
125
- address: e
126
- });
127
- return Fn(t);
128
- }
129
- async function ft(e) {
130
- if (!e)
131
- return { needsDeploy: !0 };
132
- if (await xe(e.address))
133
- return { address: e.address, account: e };
134
- const n = await Wt(e.address);
135
- return await xe(n) ? { address: n, account: e } : { needsDeploy: !0 };
136
- }
137
- const Ts = [
138
- De("io.metamask"),
139
- De("me.rainbow")
140
- ], ia = async (e) => {
141
- const t = Vt(), n = na({
142
- contract: t,
143
- admin: e.address,
144
- data: "0x"
145
- }), a = await F({
146
- account: e,
147
- transaction: n
148
- });
149
- oa("createAccountTx result:", a);
150
- const r = await N({
151
- client: R(),
152
- transactionHash: a.transactionHash,
153
- chain: v
154
- });
155
- if (!r)
156
- throw new Error("Failed to deploy smart wallet");
157
- return r;
158
- }, Ds = {
159
- name: "Seed Protocol",
160
- description: "Seed Protocol",
161
- url: "https://seedprotocol.io"
162
- };
163
- async function rt(e = v) {
164
- const t = Le();
165
- await t.autoConnect({ client: R(), chain: e });
166
- const n = t.getAccount();
167
- if (!n)
168
- throw new Error("Failed to get managed account");
169
- return n.address;
170
- }
171
- async function ca() {
172
- try {
173
- const e = st();
174
- return await e.autoConnect({ client: R(), chain: v }), e.getAccount() ?? null;
175
- } catch {
176
- return null;
177
- }
178
- }
179
- const Le = () => Ot({
180
- auth: {
181
- options: [
182
- "farcaster",
183
- "email",
184
- "passkey",
185
- "phone"
186
- ]
187
- },
188
- executionMode: {
189
- mode: "EIP4337",
190
- smartAccount: {
191
- chain: v,
192
- factoryAddress: $t,
193
- gasless: !0
194
- }
195
- }
196
- // executionMode: {
197
- // mode: 'EIP4337',
198
- // smartAccount: {
199
- // chain: optimismSepolia,
200
- // factoryAddress: thirdwebAccountFactoryAddress,
201
- // gasless: true,
202
- // overrides: {
203
- // // Custom paymaster that passes through but lets you modify the UserOp
204
- // paymaster: async (userOp) => {
205
- // const hexifyBigInts: any = (obj: any) => {
206
- // if (typeof obj === "bigint") return `0x${obj.toString(16)}`;
207
- // if (Array.isArray(obj)) return obj.map(hexifyBigInts);
208
- // if (obj && typeof obj === "object") {
209
- // return Object.fromEntries(
210
- // Object.entries(obj).map(([k, v]) => [k, hexifyBigInts(v)])
211
- // );
212
- // }
213
- // return obj;
214
- // };
215
- // const chainIdHex = `0x${optimismSepolia.id.toString(16)}`;
216
- // // Increase callGasLimit before sending to paymaster
217
- // const modifiedUserOp = hexifyBigInts({
218
- // ...userOp,
219
- // callGasLimit: BigInt(8000000), // Double it, or set a fixed value
220
- // });
221
- // console.log("[SmartWallet Paymaster]", getPublishConfig().thirdwebClientId);
222
- // // Call thirdweb's default paymaster endpoint
223
- // const response = await fetch(
224
- // `https://${optimismSepolia.id}.bundler.thirdweb.com/v2`,
225
- // {
226
- // method: "POST",
227
- // headers: {
228
- // "Content-Type": "application/json",
229
- // "X-Client-Id": getPublishConfig().thirdwebClientId,
230
- // },
231
- // body: JSON.stringify({
232
- // id: 1,
233
- // jsonrpc: "2.0",
234
- // method: "pm_sponsorUserOperation",
235
- // params: [modifiedUserOp, '0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789', chainIdHex],
236
- // }),
237
- // }
238
- // );
239
- // const data = await response.json();
240
- // console.log("[SmartWallet Paymaster Response]", data);
241
- // return {
242
- // paymasterAndData: data.result.paymasterAndData,
243
- // preVerificationGas: data.result.preVerificationGas,
244
- // verificationGasLimit: data.result.verificationGasLimit,
245
- // callGasLimit: data.result.callGasLimit,
246
- // };
247
- // },
248
- // execute: (accountContract, transaction) => {
249
- // // Log the gas that was set on the transaction
250
- // console.log("[SmartWallet Execute]", {
251
- // gas: transaction.gas,
252
- // to: transaction.to,
253
- // dataLength: transaction.data?.length,
254
- // });
255
- // // Return the default execute call — don't change behavior,
256
- // // just observe what's being passed through
257
- // return prepareContractCall({
258
- // contract: accountContract,
259
- // method: "function execute(address, uint256, bytes)",
260
- // params: [
261
- // transaction.to ?? "",
262
- // transaction.value ?? 0n,
263
- // transaction.data ?? "0x",
264
- // ],
265
- // gas: transaction.gas, // Pass through whatever was set
266
- // });
267
- // },
268
- // },
269
- // }
270
- // }
271
- }), st = () => Ot({
272
- auth: {
273
- options: [
274
- "farcaster",
275
- "email",
276
- "passkey",
277
- "phone"
278
- ]
279
- },
280
- executionMode: {
281
- mode: "EIP7702",
282
- sponsorGas: !0
283
- }
284
- }), da = () => [
285
- st()
286
- ], la = [
287
- { type: "error", name: "AccessDenied", inputs: [] },
288
- { type: "error", name: "AlreadyRevoked", inputs: [] },
289
- { type: "error", name: "InvalidRevocation", inputs: [] },
290
- { type: "error", name: "InvalidRevocations", inputs: [] },
291
- { type: "error", name: "InvalidSchema", inputs: [] },
292
- { type: "error", name: "Irrevocable", inputs: [] },
293
- { type: "error", name: "NotFound", inputs: [] },
294
- { type: "error", name: "NotPayable", inputs: [] },
295
- { type: "error", name: "InsufficientValue", inputs: [] },
296
- { type: "error", name: "InvalidLength", inputs: [] }
297
- ], ua = () => Y({
298
- signature: "event Attested(address indexed recipient, address indexed attester, bytes32 uid, bytes32 indexed schemaUID)"
299
- }), pa = "0x0000000000000000000000000000000000000000", q = "0x" + "0".repeat(64);
300
- function ht(e, t, n) {
301
- const { easContractAddress: a } = C(), r = V({
302
- client: e,
303
- chain: t,
304
- address: a
305
- });
306
- return x({
307
- contract: r,
308
- method: "function attest((bytes32 schema,(address recipient,uint64 expirationTime,bool revocable,bytes32 refUID,bytes data,uint256 value) data) request) payable returns (bytes32)",
309
- params: [
310
- {
311
- schema: n.schema,
312
- data: {
313
- recipient: n.data.recipient ?? pa,
314
- expirationTime: n.data.expirationTime ?? 0n,
315
- revocable: n.data.revocable ?? !0,
316
- refUID: n.data.refUID,
317
- data: n.data.data,
318
- value: n.data.value ?? 0n
319
- }
320
- }
321
- ]
322
- });
323
- }
324
- function ma(e, t, n) {
325
- const { easContractAddress: a } = C(), r = V({
326
- client: e,
327
- chain: t,
328
- address: a
329
- });
330
- return x({
331
- contract: r,
332
- method: "function multiAttest((bytes32 schema,(address recipient,uint64 expirationTime,bool revocable,bytes32 refUID,bytes data,uint256 value)[] data)[] requests) payable returns (bytes32[])",
333
- params: [n]
334
- });
335
- }
336
- function Ve(e) {
337
- return Ft([{ type: "bytes32" }], [e]);
338
- }
339
- function yt(e, t) {
340
- if (!e.logs?.length) return;
341
- const n = t.toLowerCase(), a = e.logs.filter((r) => r.address && r.address.toLowerCase() === n);
342
- if (a.length)
343
- try {
344
- const o = at({
345
- logs: a,
346
- events: [ua()],
347
- strict: !1
348
- })[0]?.args?.uid;
349
- if (o && o !== q) return o;
350
- } catch {
351
- }
352
- }
353
- function fa(e, t, n) {
354
- const { easContractAddress: a } = C(), r = V({
355
- client: e,
356
- chain: t,
357
- address: a,
358
- abi: [...la]
359
- });
360
- return x({
361
- contract: r,
362
- method: "function multiRevoke((bytes32 schema,(bytes32 uid,uint256 value)[] data)[] multiRequests) payable",
363
- params: [
364
- n.map((s) => ({
365
- schema: s.schema,
366
- data: s.data.map((o) => ({
367
- uid: o.uid,
368
- value: o.value ?? 0n
369
- }))
370
- }))
371
- ]
372
- });
373
- }
374
- async function ha(e) {
375
- const { account: t, attester: n } = e;
376
- if (!n || t.address.toLowerCase() === n.toLowerCase())
377
- return t;
378
- const a = mn();
379
- if (a) {
380
- const r = await a(), s = n.toLowerCase();
381
- if (r?.some((o) => o?.toLowerCase() === s))
382
- throw new Error(
383
- "Revocation not supported for items published via the modular executor."
384
- );
385
- }
386
- try {
387
- const r = await Wt(t.address), s = n.toLowerCase(), o = r.toLowerCase();
388
- if (s === o && await xe(r)) {
389
- const i = Le();
390
- await i.autoConnect({
391
- client: R(),
392
- chain: v
393
- });
394
- const u = i.getAccount();
395
- if (u)
396
- return u;
397
- }
398
- } catch {
399
- }
400
- return t;
401
- }
402
- async function ya(e) {
403
- const { seedLocalId: t, seedUid: n, seedSchemaUid: a } = e, r = await ca();
404
- if (!r)
405
- throw new Error("No wallet connected. Connect a wallet to revoke attestations.");
406
- const s = await fn({ seedLocalId: t, seedUid: n }), o = await ha({ account: r, attester: s }), c = R(), [i, u] = await Promise.all([
407
- hn(n),
408
- yn(n)
409
- ]), d = i.map((h) => h.uid), p = /* @__PURE__ */ new Map();
410
- for (const { uid: h, schemaUid: y } of u) {
411
- const f = p.get(y) ?? [];
412
- f.push(h), p.set(y, f);
413
- }
414
- const l = [];
415
- for (const [h, y] of p)
416
- y.length > 0 && l.push({
417
- schema: h,
418
- data: y.map((f) => ({ uid: f }))
419
- });
420
- d.length > 0 && l.push({
421
- schema: gn,
422
- data: d.map((h) => ({ uid: h }))
423
- }), l.push({
424
- schema: a,
425
- data: [{ uid: n }]
426
- });
427
- for (const h of l) {
428
- if (h.data.length === 0) continue;
429
- const y = fa(c, v, [h]);
430
- try {
431
- const f = await F({ account: o, transaction: y });
432
- await N({
433
- client: c,
434
- chain: v,
435
- transactionHash: f.transactionHash
436
- });
437
- } catch (f) {
438
- const A = f instanceof Error ? f.message : String(f);
439
- if (A.includes("AccessDenied") || A.includes("0x4ca88867"))
440
- throw new Error(
441
- "Only the original attester can revoke attestations. Connect the wallet that published this item."
442
- );
443
- if (A.includes("AlreadyRevoked"))
444
- continue;
445
- throw f;
446
- }
447
- }
448
- const m = Math.floor(Date.now() / 1e3);
449
- await wn({ seedLocalId: t, revokedAt: m });
450
- }
451
- let ot = null;
452
- function ga(e) {
453
- ot = e;
454
- }
455
- function wa() {
456
- return ot;
457
- }
458
- function qt(e) {
459
- ga(e), bn(async () => {
460
- try {
461
- return await rt(v);
462
- } catch {
463
- return;
464
- }
465
- }), An(ya), vn(async () => e.useModularExecutor && e.modularAccountModuleContract ? [e.modularAccountModuleContract] : []);
466
- }
467
- const xs = qt;
468
- function C() {
469
- const e = ot;
470
- if (!e)
471
- throw new Error(
472
- "@seedprotocol/publish: Call initPublish() or ensure PublishProvider is mounted with config before using the publish package"
473
- );
474
- const t = e.useArweaveBundler ?? !1, n = e.arweaveUploadVerificationBaseUrl ?? e.uploadApiBaseUrl;
475
- return {
476
- ...e,
477
- thirdwebAccountFactoryAddress: $t,
478
- easContractAddress: Ht,
479
- useIntegerLocalIds: e.useIntegerLocalIds ?? !1,
480
- useDirectEas: e.useDirectEas ?? !1,
481
- modularAccountModuleData: e.modularAccountModuleData ?? "0x",
482
- useModularExecutor: e.useModularExecutor ?? !1,
483
- useArweaveBundler: t,
484
- arweaveUploadVerificationBaseUrl: n,
485
- autoDeployManagedAccount: e.autoDeployManagedAccount ?? !1
486
- };
487
- }
488
- class jt extends Error {
489
- constructor(t, n, a, r, s = "METADATA_PROPERTIES_MISSING") {
490
- super(t), this.seedLocalId = n, this.expectedSchemas = a, this.foundSchemas = r, this.code = s, this.name = "AttestationVerificationError";
491
- }
492
- }
493
- class K extends Error {
494
- constructor(t, n, a, r) {
495
- super(t), this.code = n, this.managedAddress = a, this.name = "ManagedAccountPublishError", this.underlyingCause = r;
496
- }
497
- /** Original error when connection or deployment failed (avoids shadowing `Error.cause`). */
498
- underlyingCause;
499
- }
500
- function gt(e) {
501
- if (e instanceof K) return !0;
502
- if (typeof e != "object" || e === null) return !1;
503
- const t = e;
504
- return t.name === "ManagedAccountPublishError" && typeof t.code == "string";
505
- }
506
- function ba(e, t = 700) {
507
- if (e == null) return "";
508
- if (e instanceof Error) {
509
- const n = e.cause instanceof Error ? ` | cause: ${e.cause.message}` : "";
510
- return (e.message + n).slice(0, t);
511
- }
512
- if (typeof e == "object") {
513
- const n = e, a = [];
514
- if (typeof n.message == "string" && a.push(n.message), typeof n.shortMessage == "string" && a.push(n.shortMessage), typeof n.details == "string" && a.push(n.details), typeof n.reason == "string" && a.push(n.reason), a.length) return a.join(" | ").slice(0, t);
515
- try {
516
- return JSON.stringify(e).slice(0, t);
517
- } catch {
518
- return String(e).slice(0, t);
519
- }
520
- }
521
- return String(e).slice(0, t);
522
- }
523
- function Aa(e) {
524
- return /Router:\s*function does not exist/i.test(ba(e));
525
- }
526
- const Gt = Nn(null);
527
- function va() {
528
- const e = kn(Gt);
529
- if (!e)
530
- throw new Error("usePublishConfig must be used within PublishProvider");
531
- return e;
532
- }
533
- const Cs = ({
534
- children: e,
535
- config: t,
536
- queryClient: n,
537
- queryClientRef: a
538
- }) => (te(() => {
539
- t && qt(t);
540
- }, [t]), /* @__PURE__ */ me(Gt.Provider, { value: t ?? wa(), children: /* @__PURE__ */ me(Mn, { children: /* @__PURE__ */ me(Wn, { queryClient: n, queryClientRef: a, children: e }) }) })), Sa = "The executor module could not be installed on your publishing account on Optimism Sepolia. Reconnect and try again, or contact support if this persists.";
541
- async function Qe(e, t, n) {
542
- const { modularAccountModuleContract: a } = n;
543
- if (!a) return;
544
- const r = V({
545
- client: R(),
546
- chain: v,
547
- address: e
548
- });
549
- try {
550
- const s = await qn({ contract: r }), o = a.toLowerCase();
551
- if (s.some(
552
- (d) => d.implementation?.toLowerCase() === o
553
- )) return;
554
- const i = jn({
555
- contract: r,
556
- moduleContract: a,
557
- data: Ft([{ type: "address" }], [Ht])
558
- }), u = await F({ transaction: i, account: t });
559
- await N({
560
- client: R(),
561
- transactionHash: u.transactionHash,
562
- chain: v
563
- });
564
- } catch (s) {
565
- if (Aa(s))
566
- return;
567
- throw new K(
568
- Sa,
569
- "EXECUTOR_MODULE_NOT_INSTALLED",
570
- e,
571
- s
572
- );
573
- }
574
- }
575
- function ve(e) {
576
- console.error("[ConnectButton] Wallet setup / module install failed:", e), C().onWalletSetupWarning?.(e);
577
- }
578
- async function Ea(e, t, n) {
579
- if (n.modularAccountModuleContract) {
580
- if (n.useModularExecutor) {
581
- if (!t) {
582
- ve(
583
- new Error(
584
- "Executor module: managed account address not available yet (managed wallet may still be syncing)."
585
- )
586
- );
587
- return;
588
- }
589
- try {
590
- const a = Le();
591
- await a.autoConnect({ client: R(), chain: v });
592
- const r = a.getAccount();
593
- if (!r) {
594
- ve(new Error("Executor module: managed wallet has no account"));
595
- return;
596
- }
597
- await Qe(t, r, n);
598
- } catch (a) {
599
- ve(a);
600
- }
601
- return;
602
- }
603
- try {
604
- await Qe(e.address, e, n);
605
- } catch (a) {
606
- ve(a);
607
- }
608
- }
609
- }
610
- const Rs = () => {
611
- const e = va(), t = async () => {
612
- console.log("[ConnectButton] Disconnected");
613
- try {
614
- await ut.setAddresses([]);
615
- } catch (a) {
616
- console.warn("[ConnectButton] Failed to clear seed client addresses:", a);
617
- }
618
- }, n = async (a, r) => {
619
- const s = a.getAccount();
620
- if (!s) return;
621
- console.log("[ConnectButton] Connected", s.address);
622
- const o = /* @__PURE__ */ new Set([s.address.toLowerCase()]);
623
- let c;
624
- if (e.useModularExecutor)
625
- try {
626
- c = await rt(v), o.add(c.toLowerCase());
627
- } catch {
628
- }
629
- try {
630
- await ut.setAddresses({ owned: [...o] });
631
- } catch (i) {
632
- console.warn("[ConnectButton] Failed to set seed client addresses:", i);
633
- }
634
- await Ea(s, c, e);
635
- };
636
- return /* @__PURE__ */ me(
637
- On,
638
- {
639
- client: R(),
640
- wallets: da(),
641
- autoConnect: !0,
642
- chain: v,
643
- chains: [v],
644
- onConnect: n,
645
- onDisconnect: t,
646
- theme: Bn({
647
- colors: {
648
- primaryButtonBg: "#1D2939",
649
- primaryButtonText: "#FFFFFF",
650
- secondaryButtonHoverBg: "#1D2939",
651
- connectedButtonBg: "#101828",
652
- connectedButtonBgHover: "#1D2939",
653
- borderColor: "#344054"
654
- }
655
- })
656
- }
657
- );
658
- }, _s = ({
659
- value: e,
660
- onChange: t,
661
- disabled: n = !1,
662
- "aria-label": a = "Publish mode"
663
- }) => {
664
- const r = {
665
- display: "inline-flex",
666
- gap: 8,
667
- flexWrap: "wrap"
668
- }, s = (o) => ({
669
- padding: "8px 14px",
670
- fontSize: 13,
671
- borderRadius: 8,
672
- border: `1px solid ${o ? "#344054" : "#D0D5DD"}`,
673
- background: o ? "#101828" : "#fff",
674
- color: o ? "#fff" : "#344054",
675
- cursor: n ? "not-allowed" : "pointer",
676
- opacity: n ? 0.6 : 1
677
- });
678
- return /* @__PURE__ */ Vn("div", { role: "group", "aria-label": a, style: r, children: [
679
- /* @__PURE__ */ me(
680
- "button",
681
- {
682
- type: "button",
683
- disabled: n,
684
- style: s(e === "patch"),
685
- onClick: () => t("patch"),
686
- children: "Publish updates"
687
- }
688
- ),
689
- /* @__PURE__ */ me(
690
- "button",
691
- {
692
- type: "button",
693
- disabled: n,
694
- style: s(e === "new_version"),
695
- onClick: () => t("new_version"),
696
- children: "New version"
697
- }
698
- )
699
- ] });
700
- }, Ia = [
701
- {
702
- inputs: [{ internalType: "bytes32", name: "uid", type: "bytes32" }],
703
- name: "getSchema",
704
- outputs: [
705
- {
706
- components: [
707
- { internalType: "bytes32", name: "uid", type: "bytes32" },
708
- { internalType: "contract ISchemaResolver", name: "resolver", type: "address" },
709
- { internalType: "bool", name: "revocable", type: "bool" },
710
- { internalType: "string", name: "schema", type: "string" }
711
- ],
712
- internalType: "struct SchemaRecord",
713
- name: "",
714
- type: "tuple"
715
- }
716
- ],
717
- stateMutability: "view",
718
- type: "function"
719
- },
720
- {
721
- inputs: [
722
- { internalType: "string", name: "schema", type: "string" },
723
- { internalType: "contract ISchemaResolver", name: "resolver", type: "address" },
724
- { internalType: "bool", name: "revocable", type: "bool" }
725
- ],
726
- name: "register",
727
- outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
728
- stateMutability: "nonpayable",
729
- type: "function"
730
- }
731
- ], Pa = "0x" + "0".repeat(64);
732
- function Ua(e, t) {
733
- return V({
734
- client: e,
735
- chain: t,
736
- address: kt,
737
- abi: Ia
738
- });
739
- }
740
- const Ta = "function getSchema(bytes32 uid) view returns ((bytes32 uid, address resolver, bool revocable, string schema))";
741
- async function Se(e, t, n) {
742
- const a = V({
743
- client: e,
744
- chain: t,
745
- address: kt
746
- // No ABI - use string method so thirdweb parses the exact signature and produces correct selector
747
- }), r = await _({
748
- contract: a,
749
- method: Ta,
750
- params: [n]
751
- });
752
- return !r || r.uid === Pa ? null : r;
753
- }
754
- function We(e, t, n) {
755
- const a = Ua(e, t);
756
- return x({
757
- contract: a,
758
- method: "register",
759
- params: [n.schema, n.resolverAddress, n.revocable]
760
- });
761
- }
762
- const Da = "0x0000000000000000000000000000000000000000";
763
- function qe(e, t, n) {
764
- const r = new Gn("bytes32 schemaId,string name").encodeData([
765
- { name: "schemaId", value: n.schemaUid, type: "bytes32" },
766
- { name: "name", value: n.schemaName, type: "string" }
767
- ]), { easContractAddress: s } = C(), o = V({
768
- client: e,
769
- chain: t,
770
- address: s
771
- // No ABI - use string method so thirdweb parses the exact signature
772
- });
773
- return x({
774
- contract: o,
775
- method: "function attest((bytes32 schema,(address recipient,uint64 expirationTime,bool revocable,bytes32 refUID,bytes data,uint256 value) data) request) payable returns (bytes32)",
776
- params: [
777
- {
778
- schema: aa,
779
- data: {
780
- recipient: Da,
781
- expirationTime: BigInt(Jn),
782
- revocable: !0,
783
- refUID: Yn,
784
- data: r,
785
- value: 0n
786
- }
787
- }
788
- ]
789
- });
790
- }
791
- const ie = "0x0000000000000000000000000000000000000000", ce = !0;
792
- function je(e) {
793
- return e.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
794
- }
795
- async function xa(e) {
796
- const { itemRelationProperties: t, itemImageProperties: n, itemListProperties: a } = await nt(e), r = /* @__PURE__ */ new Set();
797
- e.modelName && r.add(e.modelName);
798
- for (const s of t) {
799
- const o = s.propertyDef?.ref;
800
- o && r.add(o);
801
- }
802
- for (const s of n) {
803
- const o = s.propertyDef?.dataType;
804
- o === "File" ? r.add("File") : o === "Html" ? r.add("Html") : r.add("Image");
805
- }
806
- for (const s of a) {
807
- const o = s.propertyDef?.ref;
808
- o && r.add(o);
809
- }
810
- return r;
811
- }
812
- async function Me(e, t, n, a) {
813
- const { itemBasicProperties: r, itemRelationProperties: s, itemImageProperties: o, itemListProperties: c } = await nt(e), i = [
814
- ...r,
815
- ...s,
816
- ...o,
817
- ...c
818
- ], u = /* @__PURE__ */ new Set(), d = await xa(e), p = /* @__PURE__ */ new Set();
819
- for (const f of d) {
820
- const A = `bytes32 ${je(f)}`, g = $e.getSchemaUID(
821
- A,
822
- ie,
823
- ce
824
- );
825
- if (await Se(n, a, g)) {
826
- ke({ modelName: f, schemaUid: g });
827
- continue;
828
- }
829
- if (p.has(g)) {
830
- ke({ modelName: f, schemaUid: g });
831
- continue;
832
- }
833
- try {
834
- const S = We(n, a, {
835
- schema: A,
836
- resolverAddress: ie,
837
- revocable: ce
838
- }), E = await F({
839
- account: t,
840
- transaction: S
841
- });
842
- await N({
843
- client: n,
844
- chain: a,
845
- transactionHash: E.transactionHash
846
- });
847
- } catch (S) {
848
- throw new Error(
849
- `Failed to register EAS schema for model ${f}: ${S instanceof Error ? S.message : String(S)}`
850
- );
851
- }
852
- try {
853
- const S = qe(n, a, {
854
- schemaUid: g,
855
- schemaName: je(f)
856
- }), E = await F({
857
- account: t,
858
- transaction: S
859
- });
860
- await N({
861
- client: n,
862
- chain: a,
863
- transactionHash: E.transactionHash
864
- });
865
- } catch (S) {
866
- throw new Error(
867
- `Failed to name EAS schema for model ${f}: ${S instanceof Error ? S.message : String(S)}`
868
- );
869
- }
870
- p.add(g), ke({ modelName: f, schemaUid: g });
871
- }
872
- const l = "string storage_transaction_id", m = $e.getSchemaUID(
873
- l,
874
- ie,
875
- ce
876
- );
877
- if (await Se(n, a, m))
878
- oe({ text: l, schemaUid: m });
879
- else if (!u.has(m) && (d.has("Image") || d.has("File") || d.has("Html"))) {
880
- try {
881
- const f = We(n, a, {
882
- schema: l,
883
- resolverAddress: ie,
884
- revocable: ce
885
- }), A = await F({ account: t, transaction: f });
886
- await N({ client: n, chain: a, transactionHash: A.transactionHash });
887
- const g = qe(n, a, {
888
- schemaUid: m,
889
- schemaName: "storage_transaction_id"
890
- }), I = await F({ account: t, transaction: g });
891
- await N({ client: n, chain: a, transactionHash: I.transactionHash });
892
- } catch (f) {
893
- throw new Error(
894
- `Failed to register EAS schema for storageTransactionId: ${f instanceof Error ? f.message : String(f)}`
895
- );
896
- }
897
- u.add(m), oe({ text: l, schemaUid: m });
898
- }
899
- for (const f of i) {
900
- if (!f.propertyDef) continue;
901
- const A = Sn[f.propertyDef.dataType]?.eas ?? "string", g = f, I = g.storagePropertyName && g.storagePropertyName.length > 0 ? g.storagePropertyName : f.propertyName, S = je(I), E = `${A} ${S}`, D = [
902
- "string",
903
- "address",
904
- "bool",
905
- "bytes",
906
- "bytes32",
907
- "uint8",
908
- "uint16",
909
- "uint32",
910
- "uint64",
911
- "uint128",
912
- "uint256"
913
- ].includes(A) ? A : void 0;
914
- let w = await En({
915
- schemaUid: f.schemaUid,
916
- propertyName: I,
917
- easDataType: D
918
- });
919
- if (w) {
920
- const b = await Se(n, a, w.id);
921
- if (b && b.schema === E) {
922
- oe({ text: E, schemaUid: w.id });
923
- continue;
924
- }
925
- }
926
- const U = $e.getSchemaUID(E, ie, ce);
927
- if (await Se(n, a, U)) {
928
- oe({ text: E, schemaUid: U });
929
- continue;
930
- }
931
- if (u.has(U)) {
932
- oe({ text: E, schemaUid: U });
933
- continue;
934
- }
935
- try {
936
- const b = We(n, a, {
937
- schema: E,
938
- resolverAddress: ie,
939
- revocable: ce
940
- }), M = await F({
941
- account: t,
942
- transaction: b
943
- });
944
- await N({
945
- client: n,
946
- chain: a,
947
- transactionHash: M.transactionHash
948
- });
949
- } catch (b) {
950
- throw new Error(
951
- `Failed to register EAS schema for property ${f.propertyName}: ${b instanceof Error ? b.message : String(b)}`
952
- );
953
- }
954
- try {
955
- const b = qe(n, a, {
956
- schemaUid: U,
957
- schemaName: S
958
- }), M = await F({
959
- account: t,
960
- transaction: b
961
- });
962
- await N({
963
- client: n,
964
- chain: a,
965
- transactionHash: M.transactionHash
966
- });
967
- } catch (b) {
968
- throw new Error(
969
- `Failed to name EAS schema for property ${f.propertyName}: ${b instanceof Error ? b.message : String(b)}`
970
- );
971
- }
972
- u.add(U), oe({ text: E, schemaUid: U });
973
- }
974
- const y = await In(e);
975
- for (const f of y)
976
- await Me(f, t, n, a);
977
- }
978
- function Ls(e = {}) {
979
- return Y({
980
- signature: "event AdminUpdated(address indexed signer, bool isAdmin)",
981
- filters: e
982
- });
983
- }
984
- function Ms() {
985
- return Y({
986
- signature: "event Initialized(uint8 version)"
987
- });
988
- }
989
- function Os(e = {}) {
990
- return Y({
991
- signature: "event SignerPermissionsUpdated(address indexed authorizingSigner, address indexed targetSigner, (address signer, uint8 isAdmin, address[] approvedTargets, uint256 nativeTokenLimitPerTransaction, uint128 permissionStartTimestamp, uint128 permissionEndTimestamp, uint128 reqValidityStartTimestamp, uint128 reqValidityEndTimestamp, bytes32 uid) permissions)",
992
- filters: e
993
- });
994
- }
995
- function Bs() {
996
- return Y({
997
- signature: "event ContractURIUpdated(string prevURI, string newURI)"
998
- });
999
- }
1000
- function Ca() {
1001
- return Y({
1002
- signature: "event CreatedAttestation((bytes32 schemaUid, bytes32 attestationUid) result)"
1003
- });
1004
- }
1005
- function Fs() {
1006
- return Y({
1007
- signature: "event EIP712DomainChanged()"
1008
- });
1009
- }
1010
- function Ns() {
1011
- return Y({
1012
- signature: "event Log(string message)"
1013
- });
1014
- }
1015
- function ks(e = {}) {
1016
- return Y({
1017
- signature: "event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)",
1018
- filters: e
1019
- });
1020
- }
1021
- function Ra() {
1022
- return Y({
1023
- signature: "event SeedPublished(bytes returnedDataFromEAS)"
1024
- });
1025
- }
1026
- async function $s(e) {
1027
- return _({
1028
- contract: e.contract,
1029
- method: [
1030
- "0xb0d691fe",
1031
- [],
1032
- [
1033
- {
1034
- type: "address"
1035
- }
1036
- ]
1037
- ],
1038
- params: []
1039
- });
1040
- }
1041
- async function Hs(e) {
1042
- return _({
1043
- contract: e.contract,
1044
- method: [
1045
- "0xc45a0155",
1046
- [],
1047
- [
1048
- {
1049
- type: "address"
1050
- }
1051
- ]
1052
- ],
1053
- params: []
1054
- });
1055
- }
1056
- async function Vs(e) {
1057
- return _({
1058
- contract: e.contract,
1059
- method: [
1060
- "0x8b52d723",
1061
- [],
1062
- [
1063
- {
1064
- type: "tuple[]",
1065
- name: "signers",
1066
- components: [
1067
- {
1068
- type: "address",
1069
- name: "signer"
1070
- },
1071
- {
1072
- type: "address[]",
1073
- name: "approvedTargets"
1074
- },
1075
- {
1076
- type: "uint256",
1077
- name: "nativeTokenLimitPerTransaction"
1078
- },
1079
- {
1080
- type: "uint128",
1081
- name: "startTimestamp"
1082
- },
1083
- {
1084
- type: "uint128",
1085
- name: "endTimestamp"
1086
- }
1087
- ]
1088
- }
1089
- ]
1090
- ],
1091
- params: []
1092
- });
1093
- }
1094
- async function Ws(e) {
1095
- return _({
1096
- contract: e.contract,
1097
- method: [
1098
- "0xe9523c97",
1099
- [],
1100
- [
1101
- {
1102
- type: "address[]"
1103
- }
1104
- ]
1105
- ],
1106
- params: []
1107
- });
1108
- }
1109
- async function qs(e) {
1110
- return _({
1111
- contract: e.contract,
1112
- method: [
1113
- "0x4a00cc48",
1114
- [],
1115
- [
1116
- {
1117
- type: "tuple[]",
1118
- components: [
1119
- {
1120
- type: "tuple",
1121
- name: "metadata",
1122
- components: [
1123
- {
1124
- type: "string",
1125
- name: "name"
1126
- },
1127
- {
1128
- type: "string",
1129
- name: "metadataURI"
1130
- },
1131
- {
1132
- type: "address",
1133
- name: "implementation"
1134
- }
1135
- ]
1136
- },
1137
- {
1138
- type: "tuple[]",
1139
- name: "functions",
1140
- components: [
1141
- {
1142
- type: "bytes4",
1143
- name: "functionSelector"
1144
- },
1145
- {
1146
- type: "string",
1147
- name: "functionSignature"
1148
- }
1149
- ]
1150
- }
1151
- ]
1152
- }
1153
- ]
1154
- ],
1155
- params: []
1156
- });
1157
- }
1158
- async function js(e) {
1159
- return _({
1160
- contract: e.contract,
1161
- method: [
1162
- "0xd42f2f35",
1163
- [],
1164
- [
1165
- {
1166
- type: "tuple[]",
1167
- name: "signers",
1168
- components: [
1169
- {
1170
- type: "address",
1171
- name: "signer"
1172
- },
1173
- {
1174
- type: "address[]",
1175
- name: "approvedTargets"
1176
- },
1177
- {
1178
- type: "uint256",
1179
- name: "nativeTokenLimitPerTransaction"
1180
- },
1181
- {
1182
- type: "uint128",
1183
- name: "startTimestamp"
1184
- },
1185
- {
1186
- type: "uint128",
1187
- name: "endTimestamp"
1188
- }
1189
- ]
1190
- }
1191
- ]
1192
- ],
1193
- params: []
1194
- });
1195
- }
1196
- async function Gs(e) {
1197
- return _({
1198
- contract: e.contract,
1199
- method: [
1200
- "0xce0b6013",
1201
- [
1202
- {
1203
- type: "bytes4",
1204
- name: "_functionSelector"
1205
- }
1206
- ],
1207
- [
1208
- {
1209
- type: "address"
1210
- }
1211
- ]
1212
- ],
1213
- params: [e.functionSelector]
1214
- });
1215
- }
1216
- async function Ys(e) {
1217
- return _({
1218
- contract: e.contract,
1219
- method: [
1220
- "0xd087d288",
1221
- [],
1222
- [
1223
- {
1224
- type: "uint256"
1225
- }
1226
- ]
1227
- ],
1228
- params: []
1229
- });
1230
- }
1231
- async function Js(e) {
1232
- return _({
1233
- contract: e.contract,
1234
- method: [
1235
- "0xf15d424e",
1236
- [
1237
- {
1238
- type: "address",
1239
- name: "signer"
1240
- }
1241
- ],
1242
- [
1243
- {
1244
- type: "tuple",
1245
- components: [
1246
- {
1247
- type: "address",
1248
- name: "signer"
1249
- },
1250
- {
1251
- type: "address[]",
1252
- name: "approvedTargets"
1253
- },
1254
- {
1255
- type: "uint256",
1256
- name: "nativeTokenLimitPerTransaction"
1257
- },
1258
- {
1259
- type: "uint128",
1260
- name: "startTimestamp"
1261
- },
1262
- {
1263
- type: "uint128",
1264
- name: "endTimestamp"
1265
- }
1266
- ]
1267
- }
1268
- ]
1269
- ],
1270
- params: [e.signer]
1271
- });
1272
- }
1273
- async function zs(e) {
1274
- return _({
1275
- contract: e.contract,
1276
- method: [
1277
- "0x7dff5a79",
1278
- [
1279
- {
1280
- type: "address",
1281
- name: "signer"
1282
- }
1283
- ],
1284
- [
1285
- {
1286
- type: "bool"
1287
- }
1288
- ]
1289
- ],
1290
- params: [e.signer]
1291
- });
1292
- }
1293
- async function Zs(e) {
1294
- return _({
1295
- contract: e.contract,
1296
- method: [
1297
- "0x24d7806c",
1298
- [
1299
- {
1300
- type: "address",
1301
- name: "_account"
1302
- }
1303
- ],
1304
- [
1305
- {
1306
- type: "bool"
1307
- }
1308
- ]
1309
- ],
1310
- params: [e.account]
1311
- });
1312
- }
1313
- async function Ks(e) {
1314
- return _({
1315
- contract: e.contract,
1316
- method: [
1317
- "0x1dd756c5",
1318
- [
1319
- {
1320
- type: "address",
1321
- name: "_signer"
1322
- },
1323
- {
1324
- type: "tuple",
1325
- name: "_userOp",
1326
- components: [
1327
- {
1328
- type: "address",
1329
- name: "sender"
1330
- },
1331
- {
1332
- type: "uint256",
1333
- name: "nonce"
1334
- },
1335
- {
1336
- type: "bytes",
1337
- name: "initCode"
1338
- },
1339
- {
1340
- type: "bytes",
1341
- name: "callData"
1342
- },
1343
- {
1344
- type: "uint256",
1345
- name: "callGasLimit"
1346
- },
1347
- {
1348
- type: "uint256",
1349
- name: "verificationGasLimit"
1350
- },
1351
- {
1352
- type: "uint256",
1353
- name: "preVerificationGas"
1354
- },
1355
- {
1356
- type: "uint256",
1357
- name: "maxFeePerGas"
1358
- },
1359
- {
1360
- type: "uint256",
1361
- name: "maxPriorityFeePerGas"
1362
- },
1363
- {
1364
- type: "bytes",
1365
- name: "paymasterAndData"
1366
- },
1367
- {
1368
- type: "bytes",
1369
- name: "signature"
1370
- }
1371
- ]
1372
- }
1373
- ],
1374
- [
1375
- {
1376
- type: "bool"
1377
- }
1378
- ]
1379
- ],
1380
- params: [e.signer, e.userOp]
1381
- });
1382
- }
1383
- async function Xs(e) {
1384
- return _({
1385
- contract: e.contract,
1386
- method: [
1387
- "0xa9082d84",
1388
- [
1389
- {
1390
- type: "tuple",
1391
- name: "req",
1392
- components: [
1393
- {
1394
- type: "address",
1395
- name: "signer"
1396
- },
1397
- {
1398
- type: "uint8",
1399
- name: "isAdmin"
1400
- },
1401
- {
1402
- type: "address[]",
1403
- name: "approvedTargets"
1404
- },
1405
- {
1406
- type: "uint256",
1407
- name: "nativeTokenLimitPerTransaction"
1408
- },
1409
- {
1410
- type: "uint128",
1411
- name: "permissionStartTimestamp"
1412
- },
1413
- {
1414
- type: "uint128",
1415
- name: "permissionEndTimestamp"
1416
- },
1417
- {
1418
- type: "uint128",
1419
- name: "reqValidityStartTimestamp"
1420
- },
1421
- {
1422
- type: "uint128",
1423
- name: "reqValidityEndTimestamp"
1424
- },
1425
- {
1426
- type: "bytes32",
1427
- name: "uid"
1428
- }
1429
- ]
1430
- },
1431
- {
1432
- type: "bytes",
1433
- name: "signature"
1434
- }
1435
- ],
1436
- [
1437
- {
1438
- type: "bool",
1439
- name: "success"
1440
- },
1441
- {
1442
- type: "address",
1443
- name: "signer"
1444
- }
1445
- ]
1446
- ],
1447
- params: [e.req, e.signature]
1448
- });
1449
- }
1450
- async function Qs(e) {
1451
- return _({
1452
- contract: e.contract,
1453
- method: [
1454
- "0xe8a3d485",
1455
- [],
1456
- [
1457
- {
1458
- type: "string"
1459
- }
1460
- ]
1461
- ],
1462
- params: []
1463
- });
1464
- }
1465
- async function eo(e) {
1466
- return _({
1467
- contract: e.contract,
1468
- method: [
1469
- "0x399b77da",
1470
- [
1471
- {
1472
- type: "bytes32",
1473
- name: "_hash"
1474
- }
1475
- ],
1476
- [
1477
- {
1478
- type: "bytes32"
1479
- }
1480
- ]
1481
- ],
1482
- params: [e.hash]
1483
- });
1484
- }
1485
- async function to(e) {
1486
- return _({
1487
- contract: e.contract,
1488
- method: [
1489
- "0x1626ba7e",
1490
- [
1491
- {
1492
- type: "bytes32",
1493
- name: "_hash"
1494
- },
1495
- {
1496
- type: "bytes",
1497
- name: "_signature"
1498
- }
1499
- ],
1500
- [
1501
- {
1502
- type: "bytes4",
1503
- name: "magicValue"
1504
- }
1505
- ]
1506
- ],
1507
- params: [e.hash, e.signature]
1508
- });
1509
- }
1510
- async function no(e) {
1511
- return _({
1512
- contract: e.contract,
1513
- method: [
1514
- "0x01ffc9a7",
1515
- [
1516
- {
1517
- type: "bytes4",
1518
- name: "interfaceId"
1519
- }
1520
- ],
1521
- [
1522
- {
1523
- type: "bool"
1524
- }
1525
- ]
1526
- ],
1527
- params: [e.interfaceId]
1528
- });
1529
- }
1530
- async function ao(e) {
1531
- return _({
1532
- contract: e.contract,
1533
- method: [
1534
- "0x84b0196e",
1535
- [],
1536
- [
1537
- {
1538
- type: "bytes1",
1539
- name: "fields"
1540
- },
1541
- {
1542
- type: "string",
1543
- name: "name"
1544
- },
1545
- {
1546
- type: "string",
1547
- name: "version"
1548
- },
1549
- {
1550
- type: "uint256",
1551
- name: "chainId"
1552
- },
1553
- {
1554
- type: "address",
1555
- name: "verifyingContract"
1556
- },
1557
- {
1558
- type: "bytes32",
1559
- name: "salt"
1560
- },
1561
- {
1562
- type: "uint256[]",
1563
- name: "extensions"
1564
- }
1565
- ]
1566
- ],
1567
- params: []
1568
- });
1569
- }
1570
- async function ro(e) {
1571
- return _({
1572
- contract: e.contract,
1573
- method: [
1574
- "0xd5f5127d",
1575
- [],
1576
- [
1577
- {
1578
- type: "address"
1579
- }
1580
- ]
1581
- ],
1582
- params: []
1583
- });
1584
- }
1585
- async function so(e) {
1586
- return _({
1587
- contract: e.contract,
1588
- method: [
1589
- "0x8da5cb5b",
1590
- [],
1591
- [
1592
- {
1593
- type: "address"
1594
- }
1595
- ]
1596
- ],
1597
- params: []
1598
- });
1599
- }
1600
- function oo(e) {
1601
- return x({
1602
- contract: e.contract,
1603
- method: [
1604
- "0xd1f57894",
1605
- [
1606
- {
1607
- type: "address",
1608
- name: "_defaultAdmin"
1609
- },
1610
- {
1611
- type: "bytes",
1612
- name: "_data"
1613
- }
1614
- ],
1615
- []
1616
- ],
1617
- params: [e.defaultAdmin, e.data]
1618
- });
1619
- }
1620
- function io(e) {
1621
- return x({
1622
- contract: e.contract,
1623
- method: [
1624
- "0xac9650d8",
1625
- [
1626
- {
1627
- type: "bytes[]",
1628
- name: "data"
1629
- }
1630
- ],
1631
- [
1632
- {
1633
- type: "bytes[]",
1634
- name: "results"
1635
- }
1636
- ]
1637
- ],
1638
- params: [e.data]
1639
- });
1640
- }
1641
- function co(e) {
1642
- return x({
1643
- contract: e.contract,
1644
- method: [
1645
- "0xb76464d5",
1646
- [
1647
- {
1648
- type: "address",
1649
- name: "_entrypointOverride"
1650
- }
1651
- ],
1652
- []
1653
- ],
1654
- params: [e.entrypointOverride]
1655
- });
1656
- }
1657
- function lo(e) {
1658
- return x({
1659
- contract: e.contract,
1660
- method: [
1661
- "0x5892e236",
1662
- [
1663
- {
1664
- type: "tuple",
1665
- name: "_req",
1666
- components: [
1667
- {
1668
- type: "address",
1669
- name: "signer"
1670
- },
1671
- {
1672
- type: "uint8",
1673
- name: "isAdmin"
1674
- },
1675
- {
1676
- type: "address[]",
1677
- name: "approvedTargets"
1678
- },
1679
- {
1680
- type: "uint256",
1681
- name: "nativeTokenLimitPerTransaction"
1682
- },
1683
- {
1684
- type: "uint128",
1685
- name: "permissionStartTimestamp"
1686
- },
1687
- {
1688
- type: "uint128",
1689
- name: "permissionEndTimestamp"
1690
- },
1691
- {
1692
- type: "uint128",
1693
- name: "reqValidityStartTimestamp"
1694
- },
1695
- {
1696
- type: "uint128",
1697
- name: "reqValidityEndTimestamp"
1698
- },
1699
- {
1700
- type: "bytes32",
1701
- name: "uid"
1702
- }
1703
- ]
1704
- },
1705
- {
1706
- type: "bytes",
1707
- name: "_signature"
1708
- }
1709
- ],
1710
- []
1711
- ],
1712
- params: [e.req, e.signature]
1713
- });
1714
- }
1715
- function uo(e) {
1716
- return x({
1717
- contract: e.contract,
1718
- method: [
1719
- "0x3a871cdd",
1720
- [
1721
- {
1722
- type: "tuple",
1723
- name: "userOp",
1724
- components: [
1725
- {
1726
- type: "address",
1727
- name: "sender"
1728
- },
1729
- {
1730
- type: "uint256",
1731
- name: "nonce"
1732
- },
1733
- {
1734
- type: "bytes",
1735
- name: "initCode"
1736
- },
1737
- {
1738
- type: "bytes",
1739
- name: "callData"
1740
- },
1741
- {
1742
- type: "uint256",
1743
- name: "callGasLimit"
1744
- },
1745
- {
1746
- type: "uint256",
1747
- name: "verificationGasLimit"
1748
- },
1749
- {
1750
- type: "uint256",
1751
- name: "preVerificationGas"
1752
- },
1753
- {
1754
- type: "uint256",
1755
- name: "maxFeePerGas"
1756
- },
1757
- {
1758
- type: "uint256",
1759
- name: "maxPriorityFeePerGas"
1760
- },
1761
- {
1762
- type: "bytes",
1763
- name: "paymasterAndData"
1764
- },
1765
- {
1766
- type: "bytes",
1767
- name: "signature"
1768
- }
1769
- ]
1770
- },
1771
- {
1772
- type: "bytes32",
1773
- name: "userOpHash"
1774
- },
1775
- {
1776
- type: "uint256",
1777
- name: "missingAccountFunds"
1778
- }
1779
- ],
1780
- [
1781
- {
1782
- type: "uint256",
1783
- name: "validationData"
1784
- }
1785
- ]
1786
- ],
1787
- params: [e.userOp, e.userOpHash, e.missingAccountFunds]
1788
- });
1789
- }
1790
- function po(e) {
1791
- return x({
1792
- contract: e.contract,
1793
- method: [
1794
- "0x4a58db19",
1795
- [],
1796
- []
1797
- ],
1798
- params: []
1799
- });
1800
- }
1801
- function mo(e) {
1802
- return x({
1803
- contract: e.contract,
1804
- method: [
1805
- "0xb61d27f6",
1806
- [
1807
- {
1808
- type: "address",
1809
- name: "_target"
1810
- },
1811
- {
1812
- type: "uint256",
1813
- name: "_value"
1814
- },
1815
- {
1816
- type: "bytes",
1817
- name: "_calldata"
1818
- }
1819
- ],
1820
- []
1821
- ],
1822
- params: [e.target, e.value, e.calldata]
1823
- });
1824
- }
1825
- function fo(e) {
1826
- return x({
1827
- contract: e.contract,
1828
- method: [
1829
- "0x47e1da2a",
1830
- [
1831
- {
1832
- type: "address[]",
1833
- name: "_target"
1834
- },
1835
- {
1836
- type: "uint256[]",
1837
- name: "_value"
1838
- },
1839
- {
1840
- type: "bytes[]",
1841
- name: "_calldata"
1842
- }
1843
- ],
1844
- []
1845
- ],
1846
- params: [e.target, e.value, e.calldata]
1847
- });
1848
- }
1849
- function ho(e) {
1850
- return x({
1851
- contract: e.contract,
1852
- method: [
1853
- "0xbc197c81",
1854
- [
1855
- {
1856
- type: "address"
1857
- },
1858
- {
1859
- type: "address"
1860
- },
1861
- {
1862
- type: "uint256[]"
1863
- },
1864
- {
1865
- type: "uint256[]"
1866
- },
1867
- {
1868
- type: "bytes"
1869
- }
1870
- ],
1871
- [
1872
- {
1873
- type: "bytes4"
1874
- }
1875
- ]
1876
- ],
1877
- params: [e.arg_0, e.arg_1, e.arg_2, e.arg_3, e.arg_4]
1878
- });
1879
- }
1880
- function yo(e) {
1881
- return x({
1882
- contract: e.contract,
1883
- method: [
1884
- "0xf23a6e61",
1885
- [
1886
- {
1887
- type: "address"
1888
- },
1889
- {
1890
- type: "address"
1891
- },
1892
- {
1893
- type: "uint256"
1894
- },
1895
- {
1896
- type: "uint256"
1897
- },
1898
- {
1899
- type: "bytes"
1900
- }
1901
- ],
1902
- [
1903
- {
1904
- type: "bytes4"
1905
- }
1906
- ]
1907
- ],
1908
- params: [e.arg_0, e.arg_1, e.arg_2, e.arg_3, e.arg_4]
1909
- });
1910
- }
1911
- function go(e) {
1912
- return x({
1913
- contract: e.contract,
1914
- method: [
1915
- "0x150b7a02",
1916
- [
1917
- {
1918
- type: "address"
1919
- },
1920
- {
1921
- type: "address"
1922
- },
1923
- {
1924
- type: "uint256"
1925
- },
1926
- {
1927
- type: "bytes"
1928
- }
1929
- ],
1930
- [
1931
- {
1932
- type: "bytes4"
1933
- }
1934
- ]
1935
- ],
1936
- params: [e.arg_0, e.arg_1, e.arg_2, e.arg_3]
1937
- });
1938
- }
1939
- function wo(e) {
1940
- return x({
1941
- contract: e.contract,
1942
- method: [
1943
- "0x938e3d7b",
1944
- [
1945
- {
1946
- type: "string",
1947
- name: "_uri"
1948
- }
1949
- ],
1950
- []
1951
- ],
1952
- params: [e.uri]
1953
- });
1954
- }
1955
- function bo(e) {
1956
- return x({
1957
- contract: e.contract,
1958
- method: [
1959
- "0x4d44560d",
1960
- [
1961
- {
1962
- type: "address",
1963
- name: "withdrawAddress"
1964
- },
1965
- {
1966
- type: "uint256",
1967
- name: "amount"
1968
- }
1969
- ],
1970
- []
1971
- ],
1972
- params: [e.withdrawAddress, e.amount]
1973
- });
1974
- }
1975
- function Ao(e) {
1976
- return x({
1977
- contract: e.contract,
1978
- method: [
1979
- "0x6240d6d9",
1980
- [
1981
- {
1982
- type: "bytes32",
1983
- name: "schemaUid"
1984
- },
1985
- {
1986
- type: "bool",
1987
- name: "revocable"
1988
- }
1989
- ],
1990
- [
1991
- {
1992
- type: "bytes32"
1993
- }
1994
- ]
1995
- ],
1996
- params: [e.schemaUid, e.revocable]
1997
- });
1998
- }
1999
- function vo(e) {
2000
- return x({
2001
- contract: e.contract,
2002
- method: [
2003
- "0x13e0c263",
2004
- [
2005
- {
2006
- type: "bytes32",
2007
- name: "seedUid"
2008
- },
2009
- {
2010
- type: "bytes32",
2011
- name: "versionSchemaUid"
2012
- }
2013
- ],
2014
- [
2015
- {
2016
- type: "bytes32"
2017
- }
2018
- ]
2019
- ],
2020
- params: [e.seedUid, e.versionSchemaUid]
2021
- });
2022
- }
2023
- function wt(e) {
2024
- return x({
2025
- contract: e.contract,
2026
- method: [
2027
- "0x31e19cb8",
2028
- [
2029
- {
2030
- type: "tuple[]",
2031
- name: "requests",
2032
- components: [
2033
- {
2034
- type: "string",
2035
- name: "localId"
2036
- },
2037
- {
2038
- type: "bytes32",
2039
- name: "seedUid"
2040
- },
2041
- {
2042
- type: "bytes32",
2043
- name: "seedSchemaUid"
2044
- },
2045
- {
2046
- type: "bytes32",
2047
- name: "versionUid"
2048
- },
2049
- {
2050
- type: "bytes32",
2051
- name: "versionSchemaUid"
2052
- },
2053
- {
2054
- type: "bool",
2055
- name: "seedIsRevocable"
2056
- },
2057
- {
2058
- type: "tuple[]",
2059
- name: "listOfAttestations",
2060
- components: [
2061
- {
2062
- type: "bytes32",
2063
- name: "schema"
2064
- },
2065
- {
2066
- type: "tuple[]",
2067
- name: "data",
2068
- components: [
2069
- {
2070
- type: "address",
2071
- name: "recipient"
2072
- },
2073
- {
2074
- type: "uint64",
2075
- name: "expirationTime"
2076
- },
2077
- {
2078
- type: "bool",
2079
- name: "revocable"
2080
- },
2081
- {
2082
- type: "bytes32",
2083
- name: "refUID"
2084
- },
2085
- {
2086
- type: "bytes",
2087
- name: "data"
2088
- },
2089
- {
2090
- type: "uint256",
2091
- name: "value"
2092
- }
2093
- ]
2094
- }
2095
- ]
2096
- },
2097
- {
2098
- type: "tuple[]",
2099
- name: "propertiesToUpdate",
2100
- components: [
2101
- {
2102
- type: "string",
2103
- name: "publishLocalId"
2104
- },
2105
- {
2106
- type: "bytes32",
2107
- name: "propertySchemaUid"
2108
- }
2109
- ]
2110
- }
2111
- ]
2112
- }
2113
- ],
2114
- [
2115
- {
2116
- type: "bytes32[]"
2117
- }
2118
- ]
2119
- ],
2120
- params: [e.requests]
2121
- });
2122
- }
2123
- function So(e) {
2124
- return x({
2125
- contract: e.contract,
2126
- method: [
2127
- "0xd688e801",
2128
- [
2129
- {
2130
- type: "tuple[]",
2131
- name: "requests",
2132
- components: [
2133
- { type: "uint256", name: "localIdIndex" },
2134
- { type: "bytes32", name: "seedUid" },
2135
- { type: "bytes32", name: "seedSchemaUid" },
2136
- { type: "bytes32", name: "versionUid" },
2137
- { type: "bytes32", name: "versionSchemaUid" },
2138
- { type: "bool", name: "seedIsRevocable" },
2139
- {
2140
- type: "tuple[]",
2141
- name: "listOfAttestations",
2142
- components: [
2143
- { type: "bytes32", name: "schema" },
2144
- {
2145
- type: "tuple[]",
2146
- name: "data",
2147
- components: [
2148
- { type: "address", name: "recipient" },
2149
- { type: "uint64", name: "expirationTime" },
2150
- { type: "bool", name: "revocable" },
2151
- { type: "bytes32", name: "refUID" },
2152
- { type: "bytes", name: "data" },
2153
- { type: "uint256", name: "value" }
2154
- ]
2155
- }
2156
- ]
2157
- },
2158
- {
2159
- type: "tuple[]",
2160
- name: "propertiesToUpdate",
2161
- components: [
2162
- { type: "uint256", name: "publishLocalIdIndex" },
2163
- { type: "bytes32", name: "propertySchemaUid" }
2164
- ]
2165
- }
2166
- ]
2167
- }
2168
- ],
2169
- [{ type: "bytes32[]" }]
2170
- ],
2171
- params: [e.requests]
2172
- });
2173
- }
2174
- function Eo(e) {
2175
- return x({
2176
- contract: e.contract,
2177
- method: [
2178
- "0xb71308c5",
2179
- [
2180
- {
2181
- type: "tuple",
2182
- name: "request",
2183
- components: [
2184
- {
2185
- type: "string",
2186
- name: "localId"
2187
- },
2188
- {
2189
- type: "bytes32",
2190
- name: "seedUid"
2191
- },
2192
- {
2193
- type: "bytes32",
2194
- name: "seedSchemaUid"
2195
- },
2196
- {
2197
- type: "bytes32",
2198
- name: "versionUid"
2199
- },
2200
- {
2201
- type: "bytes32",
2202
- name: "versionSchemaUid"
2203
- },
2204
- {
2205
- type: "bool",
2206
- name: "seedIsRevocable"
2207
- },
2208
- {
2209
- type: "tuple[]",
2210
- name: "listOfAttestations",
2211
- components: [
2212
- {
2213
- type: "bytes32",
2214
- name: "schema"
2215
- },
2216
- {
2217
- type: "tuple[]",
2218
- name: "data",
2219
- components: [
2220
- {
2221
- type: "address",
2222
- name: "recipient"
2223
- },
2224
- {
2225
- type: "uint64",
2226
- name: "expirationTime"
2227
- },
2228
- {
2229
- type: "bool",
2230
- name: "revocable"
2231
- },
2232
- {
2233
- type: "bytes32",
2234
- name: "refUID"
2235
- },
2236
- {
2237
- type: "bytes",
2238
- name: "data"
2239
- },
2240
- {
2241
- type: "uint256",
2242
- name: "value"
2243
- }
2244
- ]
2245
- }
2246
- ]
2247
- },
2248
- {
2249
- type: "tuple[]",
2250
- name: "propertiesToUpdate",
2251
- components: [
2252
- {
2253
- type: "string",
2254
- name: "publishLocalId"
2255
- },
2256
- {
2257
- type: "bytes32",
2258
- name: "propertySchemaUid"
2259
- }
2260
- ]
2261
- }
2262
- ]
2263
- }
2264
- ],
2265
- [
2266
- {
2267
- type: "bytes32"
2268
- },
2269
- {
2270
- type: "bytes32"
2271
- }
2272
- ]
2273
- ],
2274
- params: [e.request]
2275
- });
2276
- }
2277
- function Io(e) {
2278
- return x({
2279
- contract: e.contract,
2280
- method: [
2281
- "0x715018a6",
2282
- [],
2283
- []
2284
- ],
2285
- params: []
2286
- });
2287
- }
2288
- function Po(e) {
2289
- return x({
2290
- contract: e.contract,
2291
- method: [
2292
- "0xb90b6e0d",
2293
- [
2294
- {
2295
- type: "address",
2296
- name: "_eas"
2297
- }
2298
- ],
2299
- [
2300
- {
2301
- type: "string"
2302
- }
2303
- ]
2304
- ],
2305
- params: [e.eas]
2306
- });
2307
- }
2308
- function Uo(e) {
2309
- return x({
2310
- contract: e.contract,
2311
- method: [
2312
- "0xf2fde38b",
2313
- [
2314
- {
2315
- type: "address",
2316
- name: "newOwner"
2317
- }
2318
- ],
2319
- []
2320
- ],
2321
- params: [e.newOwner]
2322
- });
2323
- }
2324
- const Ce = () => {
2325
- const e = Pn.getHost(), t = zn;
2326
- return Object.keys(t).includes("default") && t.default ? t.default.init({
2327
- host: e,
2328
- protocol: "https"
2329
- }) : t.init({
2330
- host: e,
2331
- protocol: "https"
2332
- });
2333
- }, H = "0x" + "0".repeat(64), it = async (e) => {
2334
- let t;
2335
- try {
2336
- t = await ae.find({ seedLocalId: e });
2337
- } catch {
2338
- }
2339
- return t || new Promise((n) => {
2340
- const a = setInterval(() => {
2341
- try {
2342
- ae.find({ seedLocalId: e }).then((r) => {
2343
- r && (clearInterval(a), n(r));
2344
- });
2345
- } catch {
2346
- }
2347
- }, 200);
2348
- });
2349
- };
2350
- function _a(e) {
2351
- if (!e || typeof e != "object") return;
2352
- const t = e;
2353
- if (Array.isArray(t.data_root))
2354
- return {
2355
- data_root: new Uint8Array(t.data_root),
2356
- chunks: (t.chunks ?? []).map((n) => ({ ...n, dataHash: new Uint8Array(n.dataHash ?? []) })),
2357
- proofs: (t.proofs ?? []).map((n) => ({ ...n, proof: new Uint8Array(n.proof ?? []) }))
2358
- };
2359
- }
2360
- function La(e) {
2361
- return {
2362
- data_root: Array.from(e.data_root),
2363
- chunks: e.chunks.map((t) => ({ ...t, dataHash: Array.from(t.dataHash) })),
2364
- proofs: e.proofs.map((t) => ({ ...t, proof: Array.from(t.proof) }))
2365
- };
2366
- }
2367
- const Ma = fe(
2368
- async ({ input: { context: e } }) => {
2369
- let { item: t } = e;
2370
- t.getPublishUploads || (t = await it(t.seedLocalId));
2371
- const n = await t.getPublishUploads(), a = C(), r = e.signArweaveTransactions ?? a.signArweaveTransactions, s = e.arweaveJwk ?? a.arweaveJwk, o = n.map((d) => ({
2372
- versionLocalId: d.versionLocalId,
2373
- itemPropertyName: d.itemPropertyName,
2374
- transactionJson: d.transactionToSign.toJSON()
2375
- }));
2376
- let c;
2377
- if (r)
2378
- c = await r(o);
2379
- else if (s) {
2380
- const d = Ce(), p = s;
2381
- c = [];
2382
- for (const l of o) {
2383
- const m = d.transactions.fromRaw(l.transactionJson);
2384
- m.data && m.data.byteLength > 0 && !m.chunks && await m.prepareChunks(m.data), await d.transactions.sign(m, p);
2385
- const h = m.toJSON();
2386
- c.push({
2387
- transaction: {
2388
- ...h,
2389
- chunks: m.chunks ? La(m.chunks) : void 0
2390
- },
2391
- versionId: l.versionLocalId,
2392
- modelName: l.itemPropertyName
2393
- });
2394
- }
2395
- } else
2396
- throw new Error(
2397
- "Arweave signing not configured. Provide signArweaveTransactions or arweaveJwk at createPublish or in PublishProvider config."
2398
- );
2399
- const i = Ce();
2400
- return {
2401
- arweaveTransactions: c.map((d) => {
2402
- const { chunks: p, ...l } = d.transaction, m = { ...l }, h = _a(p);
2403
- return h && (m.chunks = h), {
2404
- transaction: i.transactions.fromRaw(m),
2405
- versionId: d.versionId,
2406
- modelName: d.modelName
2407
- };
2408
- }),
2409
- publishUploads: n
2410
- };
2411
- }
2412
- ), Yt = async (e) => {
2413
- const t = e instanceof Uint8Array ? new Uint8Array(e) : new Uint8Array(e), n = await crypto.subtle.digest("SHA-256", t);
2414
- return Array.from(new Uint8Array(n)).map((a) => a.toString(16).padStart(2, "0")).join("");
2415
- }, Oa = {
2416
- png: "image/png",
2417
- jpg: "image/jpeg",
2418
- jpeg: "image/jpeg",
2419
- gif: "image/gif",
2420
- webp: "image/webp",
2421
- svg: "image/svg+xml",
2422
- html: "text/html",
2423
- htm: "text/html",
2424
- json: "application/json",
2425
- txt: "text/plain"
2426
- }, Jt = (e) => {
2427
- const t = e.split(".").pop()?.toLowerCase();
2428
- return t ? Oa[t] : void 0;
2429
- }, et = async (e) => typeof Blob < "u" && e instanceof Blob ? new Uint8Array(await e.arrayBuffer()) : new Uint8Array(e), Ba = (e) => {
2430
- switch (e) {
2431
- case "Image":
2432
- return G.getFilesPath("images");
2433
- case "File":
2434
- return G.getFilesPath("files");
2435
- case "Html":
2436
- return G.getFilesPath("html");
2437
- case "Json":
2438
- return G.getFilesPath("json");
2439
- default:
2440
- return G.getFilesPath("images");
2441
- }
2442
- }, Fa = async (e, t, n) => {
2443
- const a = e.itemProperty, r = [];
2444
- for (const p of e.childProperties) {
2445
- const l = p.localStoragePath;
2446
- !l || l.endsWith("undefined") || !await G.pathExists(l) || r.push({
2447
- propertyName: p.propertyName,
2448
- localStoragePath: l
2449
- });
2450
- }
2451
- let s;
2452
- if ((!r || r.length === 0) && n?.localStoragePath) {
2453
- const p = n.localStoragePath;
2454
- if (p && !p.endsWith("undefined") && await G.pathExists(p))
2455
- try {
2456
- const m = await G.readFileAsBuffer(p);
2457
- s = await et(m);
2458
- } catch {
2459
- const m = await G.getFs();
2460
- s = await et(m.readFileSync(p));
2461
- }
2462
- }
2463
- if (r.length > 0) {
2464
- const p = "===FILE_SEPARATOR===";
2465
- let l = "";
2466
- const m = await G.getFs();
2467
- for (const h of r) {
2468
- let y;
2469
- try {
2470
- y = await m.promises.readFile(h.localStoragePath);
2471
- } catch {
2472
- y = m.readFileSync(h.localStoragePath);
2473
- }
2474
- l += `${p}${h.propertyName}${p}${y}`;
2475
- }
2476
- s = typeof document < "u" ? new TextEncoder().encode(l) : new Uint8Array(Buffer.from(l));
2477
- }
2478
- if (!s) return t;
2479
- const o = new Uint8Array(s), c = await Yt(o);
2480
- let i;
2481
- r.length === 0 && n?.localStoragePath ? i = Jt(n.localStoragePath) : r.length > 0 && (i = "application/octet-stream");
2482
- const u = n ? n.localId : a.localId, d = n ? n.propertyName : a.propertyName;
2483
- return t.push({
2484
- data: o,
2485
- contentHash: c,
2486
- contentType: i,
2487
- itemPropertyName: d,
2488
- itemPropertyLocalId: u,
2489
- seedLocalId: a.seedLocalId,
2490
- versionLocalId: a.versionLocalId
2491
- }), t;
2492
- }, Na = async (e) => {
2493
- const t = [];
2494
- for (const n of e) {
2495
- const a = n.getService().getSnapshot(), r = "context" in a ? a.context : null;
2496
- if (!r) continue;
2497
- const s = r.propertyValue, o = r.refResolvedValue;
2498
- if (!o) continue;
2499
- const { localId: c } = Lt(s ?? "");
2500
- if (!c) continue;
2501
- const i = n.propertyDef?.refValueType ?? n.propertyDef?.dataType ?? "Image", d = `${Ba(i)}/${o}`;
2502
- if (!await G.pathExists(d)) continue;
2503
- const l = await G.readFileAsBuffer(d), m = await et(l), h = await Yt(m), y = Jt(o);
2504
- t.push({
2505
- data: m,
2506
- contentHash: h,
2507
- contentType: y,
2508
- itemPropertyName: n.propertyName,
2509
- itemPropertyLocalId: n.localId,
2510
- seedLocalId: c,
2511
- versionLocalId: n.versionLocalId
2512
- });
2513
- }
2514
- return t;
2515
- }, zt = async (e, t = [], n) => {
2516
- const { itemUploadProperties: a, itemRelationProperties: r, itemImageProperties: s } = await nt(e);
2517
- for (const c of a)
2518
- t = await Fa(c, t, n);
2519
- const o = await Na(s);
2520
- t.push(...o);
2521
- for (const c of r) {
2522
- const i = c.getService().getSnapshot(), u = "context" in i ? i.context : null;
2523
- if (!u) continue;
2524
- const d = u.propertyValue;
2525
- if (!d || c.uid) continue;
2526
- const { localId: p, uid: l } = Lt(d), m = await ae.find({ seedLocalId: p, seedUid: l });
2527
- if (!m)
2528
- throw new Error(`No relatedItem found for ${c.propertyName}`);
2529
- t = await zt(m, t, c);
2530
- }
2531
- return t;
2532
- }, ct = 3, pe = 65, bt = new TextEncoder().encode("seed-recovery");
2533
- function ka(e) {
2534
- return e != null && typeof e == "object" && "privateKey" in e && typeof e.privateKey == "string";
2535
- }
2536
- function $a(e, t, n) {
2537
- let r = e >= 0 ? e << 1 : ~e << 1 | 1, s = n;
2538
- do {
2539
- const o = r & 127;
2540
- r >>>= 7, t[s++] = r ? o | 128 : o;
2541
- } while (r);
2542
- return s - n;
2543
- }
2544
- const dt = (e) => {
2545
- if (!e?.length) return new Uint8Array(0);
2546
- const t = new TextEncoder(), n = new Uint8Array(16), a = [], r = (i) => {
2547
- const u = $a(i, n, 0);
2548
- a.push(n.slice(0, u));
2549
- };
2550
- r(e.length);
2551
- for (const i of e) {
2552
- const u = t.encode(i.name), d = t.encode(i.value);
2553
- r(u.length), a.push(u), r(d.length), a.push(d);
2554
- }
2555
- r(0);
2556
- const s = a.reduce((i, u) => i + u.length, 0), o = new Uint8Array(s);
2557
- let c = 0;
2558
- for (const i of a)
2559
- o.set(i, c), c += i.length;
2560
- return o;
2561
- }, At = (e) => {
2562
- const t = new Uint8Array(8), n = new DataView(t.buffer);
2563
- return n.setUint32(0, e & 4294967295, !0), n.setUint32(4, Math.floor(e / 4294967296), !0), t;
2564
- };
2565
- async function ge(e) {
2566
- return new Uint8Array(
2567
- await crypto.subtle.digest("SHA-384", e)
2568
- );
2569
- }
2570
- function Ee(e, t) {
2571
- const n = new Uint8Array(e.length + t.length);
2572
- return n.set(e, 0), n.set(t, e.length), n;
2573
- }
2574
- async function Zt(e) {
2575
- const t = new TextEncoder();
2576
- if (Array.isArray(e)) {
2577
- const s = Ee(t.encode("list"), t.encode(e.length.toString()));
2578
- let o = await ge(s);
2579
- for (const c of e) {
2580
- const i = await Zt(c);
2581
- o = await ge(Ee(o, i));
2582
- }
2583
- return o;
2584
- }
2585
- const n = Ee(t.encode("blob"), t.encode(e.byteLength.toString())), a = await ge(n), r = await ge(e);
2586
- return ge(Ee(a, r));
2587
- }
2588
- async function lt(e, t, n, a, r) {
2589
- const s = new TextEncoder();
2590
- return Zt([
2591
- s.encode("dataitem"),
2592
- s.encode("1"),
2593
- s.encode(ct.toString()),
2594
- e,
2595
- t,
2596
- n,
2597
- a,
2598
- r
2599
- ]);
2600
- }
2601
- function Kt(e, t, n) {
2602
- const a = dt(t), r = At(t.length), s = At(a.length), o = new Uint8Array([0]), c = new Uint8Array([0]), i = [
2603
- e,
2604
- o,
2605
- c,
2606
- r,
2607
- s,
2608
- a,
2609
- n
2610
- ], u = i.reduce((l, m) => l + m.length, 0), d = new Uint8Array(u);
2611
- let p = 0;
2612
- for (const l of i)
2613
- d.set(l, p), p += l.length;
2614
- return d;
2615
- }
2616
- async function Xt(e, t) {
2617
- const n = new Uint8Array(2);
2618
- new DataView(n.buffer).setUint16(0, ct, !0);
2619
- const a = 2 + pe + t.length, r = new Uint8Array(a);
2620
- r.set(n, 0), r.set(e, 2), r.set(t, 2 + pe);
2621
- const s = await crypto.subtle.digest("SHA-256", new Uint8Array(e));
2622
- return { id: qa(new Uint8Array(s)), raw: r };
2623
- }
2624
- const Ha = async (e, t, n) => {
2625
- const a = $.SigningKey.computePublicKey(t.privateKey, !1), r = $.getBytes(a), s = dt(n), o = new Uint8Array(0), c = new Uint8Array(0), i = await lt(
2626
- r,
2627
- o,
2628
- c,
2629
- s,
2630
- e
2631
- ), u = $.getBytes(await t.signMessage(i)), d = Kt(r, n, e);
2632
- return Xt(u, d);
2633
- }, Va = async (e, t, n) => {
2634
- const a = $.hexlify(bt), r = await t.signMessage({
2635
- message: { raw: a }
2636
- }), s = $.hashMessage(bt), o = $.SigningKey.recoverPublicKey(s, r), c = $.getBytes(o), i = dt(n), u = new Uint8Array(0), d = new Uint8Array(0), p = await lt(
2637
- c,
2638
- u,
2639
- d,
2640
- i,
2641
- e
2642
- ), l = $.hexlify(p), m = await t.signMessage({
2643
- message: { raw: l }
2644
- }), h = $.getBytes(m), y = Kt(c, n, e);
2645
- return Xt(h, y);
2646
- };
2647
- async function Wa(e) {
2648
- const t = 2 + pe + 65 + 1 + 1, n = t + 16;
2649
- if (e.length < n) return !1;
2650
- const a = new DataView(e.buffer, e.byteOffset, e.byteLength);
2651
- if (a.getUint16(0, !0) !== ct) return !1;
2652
- const s = e.slice(2, 2 + pe), o = e.slice(2 + pe, 2 + pe + 65), c = new Uint8Array(0), i = new Uint8Array(0), u = Number(
2653
- a.getUint32(t + 8, !0) + a.getUint32(t + 12, !0) * 4294967296
2654
- ), d = t + 16 + u;
2655
- if (e.length < d) return !1;
2656
- const p = e.slice(t + 16, d), l = e.slice(d);
2657
- try {
2658
- const m = await lt(
2659
- o,
2660
- c,
2661
- i,
2662
- p,
2663
- l
2664
- ), h = $.hashMessage(m), y = $.hexlify(s), f = $.SigningKey.recoverPublicKey(h, y), A = $.getBytes(f);
2665
- return A.length === o.length && A.every((g, I) => g === o[I]);
2666
- } catch {
2667
- return !1;
2668
- }
2669
- }
2670
- const qa = (e) => {
2671
- let t = "";
2672
- for (const n of e)
2673
- t += String.fromCharCode(n);
2674
- return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
2675
- }, ja = Z("seedProtocol:createArweaveDataItems"), Ga = fe(
2676
- async ({ input: { context: e } }) => {
2677
- let { item: t } = e;
2678
- t.getPublishUploads || (t = await it(t.seedLocalId));
2679
- const n = await zt(t), a = C(), r = e.signDataItems ?? a.signDataItems, s = e.dataItemSigner ?? a.dataItemSigner;
2680
- let o, c;
2681
- if (r)
2682
- o = (await r(n)).map((d) => ({
2683
- transaction: { id: d.transaction.id },
2684
- versionId: d.versionId,
2685
- modelName: d.modelName
2686
- }));
2687
- else if (s) {
2688
- const u = s, d = [];
2689
- for (const p of n) {
2690
- const l = [];
2691
- p.contentHash && l.push({ name: "Content-SHA-256", value: p.contentHash }), p.contentType && l.push({ name: "Content-Type", value: p.contentType });
2692
- const m = ka(u) ? await Ha(p.data, u, l) : await Va(p.data, u, l);
2693
- if (!await Wa(m.raw))
2694
- throw ja("DataItem verification failed: id=%s modelName=%s", m.id, p.itemPropertyName), new Error(
2695
- `DataItem signature verification failed for ${p.itemPropertyName}. The signing key may not match the owner, or the payload may have been modified.`
2696
- );
2697
- d.push(m);
2698
- }
2699
- c = d, o = d.map((p, l) => ({
2700
- transaction: { id: p.id },
2701
- versionId: n[l]?.versionLocalId,
2702
- modelName: n[l]?.itemPropertyName
2703
- }));
2704
- } else
2705
- throw new Error(
2706
- "@seedprotocol/publish: useArweaveBundler requires signDataItems or dataItemSigner (pass at createPublish or in PublishProvider config)"
2707
- );
2708
- const i = n.map((u) => ({
2709
- itemPropertyName: u.itemPropertyName,
2710
- itemPropertyLocalId: u.itemPropertyLocalId,
2711
- seedLocalId: u.seedLocalId,
2712
- versionLocalId: u.versionLocalId,
2713
- transactionToSign: null
2714
- }));
2715
- return {
2716
- arweaveTransactions: o,
2717
- publishUploads: i,
2718
- arweaveUploadData: n,
2719
- signedDataItems: c
2720
- };
2721
- }
2722
- ), vt = 8192;
2723
- function Ya(e) {
2724
- const t = new Uint8Array(e);
2725
- let n = "";
2726
- for (let a = 0; a < t.length; a += vt) {
2727
- const r = t.subarray(a, Math.min(a + vt, t.length));
2728
- n += String.fromCharCode.apply(null, r);
2729
- }
2730
- return btoa(n);
2731
- }
2732
- async function Ja(e) {
2733
- const t = [];
2734
- for (const [n, a] of e.entries()) {
2735
- const r = a;
2736
- if (typeof r == "object" && r !== null && "arrayBuffer" in r) {
2737
- const s = await r.arrayBuffer(), o = Ya(s), c = r;
2738
- t.push({
2739
- name: n,
2740
- value: o,
2741
- encoding: "base64",
2742
- filename: c.name || void 0
2743
- });
2744
- } else
2745
- t.push({ name: n, value: String(a) });
2746
- }
2747
- return t;
2748
- }
2749
- function za(e, t, n) {
2750
- const a = ["Upload server returned ", String(e)], r = t && typeof t == "object" && "message" in t ? String(t.message) : t && typeof t == "object" && "error" in t ? String(t.error) : null;
2751
- return r ? a.push(`: ${r}`) : n && a.push(` (${n})`), a.join("");
2752
- }
2753
- function Za(e) {
2754
- if (!e)
2755
- return "Upload server unavailable. Please try again or check your connection.";
2756
- const t = e.toLowerCase();
2757
- return /other side closed|econnreset|socket hang up|connection closed/i.test(t) ? "Upload server closed the connection. It may be busy or the request may be too large—try again." : /etimedout|timeout/i.test(t) ? "Upload request timed out. Please try again." : /enotfound|getaddrinfo|dns/i.test(t) ? "Upload server could not be reached. Check the upload URL and your network." : "Upload failed. Please try again or check the upload server.";
2758
- }
2759
- async function Ka(e, t, n) {
2760
- const a = typeof window < "u" ? window.Main : void 0;
2761
- if (a?.uploadArweaveStart) {
2762
- const o = await Ja(t);
2763
- return a.uploadArweaveStart(e, o);
2764
- }
2765
- const r = await fetch(e, {
2766
- method: "POST",
2767
- body: t
2768
- }), s = await r.json().catch(() => ({}));
2769
- return { status: r.status, body: s };
2770
- }
2771
- const Xa = fe(
2772
- async ({ input: { context: e, event: t } }) => {
2773
- const { arweaveTransactions: n = [], transactionKeys: a, reimbursementTransactionId: r } = e;
2774
- if (r)
2775
- return {
2776
- transactionId: r
2777
- };
2778
- const s = n.map(({ transaction: l }) => l), o = new FormData();
2779
- for (const l of s) {
2780
- let { data: m, chunks: h, ...y } = l;
2781
- const f = m instanceof Blob ? m : new Blob([m]);
2782
- o.append(`${l.id}-data`, f, `${l.id}-data`);
2783
- const A = new Blob([JSON.stringify(h)], { type: "application/json" });
2784
- o.append(`${l.id}-chunks`, A, `${l.id}-chunks`);
2785
- const g = new Blob([JSON.stringify(y)], { type: "application/json" });
2786
- o.append(`${l.id}-json`, g, `${l.id}-json`);
2787
- }
2788
- const { uploadApiBaseUrl: c } = C(), i = `${c}/api/upload/arweave/start`, { status: u, body: d, message: p } = await Ka(
2789
- i,
2790
- o
2791
- );
2792
- if (u >= 300 || u < 200) {
2793
- const l = u === 0 ? p : null;
2794
- l && console.error("[upload]", l);
2795
- const m = u === 0 ? Za(l) : za(u, d, a);
2796
- throw new Error(m);
2797
- }
2798
- return d;
2799
- }
2800
- ), Qa = fe(async ({ input: { context: e, event: t } }) => {
2801
- const { requestResponse: n, reimbursementTransactionId: a } = e;
2802
- if (!n)
2803
- throw new Error("No request response");
2804
- if (!a)
2805
- throw new Error("No reimbursement transaction id");
2806
- const r = Ce();
2807
- await new Promise((o, c) => {
2808
- const i = setInterval(async () => {
2809
- let u;
2810
- try {
2811
- u = await r.transactions.getStatus(a);
2812
- } catch {
2813
- return;
2814
- }
2815
- u && u.confirmed && (clearInterval(i), o());
2816
- }, 5e3);
2817
- });
2818
- }), ne = Z("seedProtocol:services:publish:actors");
2819
- function er(e) {
2820
- if (e instanceof Uint8Array) return e;
2821
- if (e instanceof ArrayBuffer) return new Uint8Array(e);
2822
- throw new Error("Transaction data must be Uint8Array or ArrayBuffer for upload resume");
2823
- }
2824
- const tr = he(
2825
- ({ sendBack: e, input: t }) => {
2826
- const n = t.context, r = (n.arweaveTransactions ?? []).map(({ transaction: u }) => u), s = Ce(), o = n.uploaderState && typeof n.currentTransactionIndex == "number", c = o ? n.currentTransactionIndex : 0;
2827
- (async () => {
2828
- const u = r.length;
2829
- for (let d = c; d < u; d++) {
2830
- const p = r[d];
2831
- if (!p) continue;
2832
- const l = s.transactions.fromRaw(p);
2833
- if (!await s.transactions.verify(l))
2834
- throw new Error("Transaction verification failed");
2835
- let h;
2836
- const y = n.uploaderState;
2837
- if (o && d === c && y) {
2838
- const f = l.data, A = f instanceof Uint8Array ? f : er(f);
2839
- h = await s.transactions.getUploader(y, A);
2840
- } else
2841
- h = await s.transactions.getUploader(l, l.data);
2842
- for (; !h.isComplete; ) {
2843
- ne("uploading chunk"), ne(`uploader.pctComplete: ${h.pctComplete}`), ne(`uploader.uploadedChunks: ${h.uploadedChunks}`), ne(`uploader.totalChunks: ${h.totalChunks}`), ne(h.lastResponseError), ne(h.lastResponseStatus);
2844
- try {
2845
- await h.uploadChunk();
2846
- const f = Math.trunc((d + h.pctComplete / 100) / u * 100);
2847
- e({
2848
- type: "updatePercentage",
2849
- completionPercentage: f,
2850
- uploaderState: h.toJSON(),
2851
- currentTransactionIndex: d
2852
- }), ne(`${h.pctComplete}% complete, ${h.uploadedChunks}/${h.totalChunks}`);
2853
- } catch (f) {
2854
- ne(f);
2855
- }
2856
- }
2857
- }
2858
- return "done";
2859
- })().then((u) => {
2860
- e({ type: "uploadComplete", result: u });
2861
- }).catch((u) => {
2862
- e({ type: "uploadError", error: u });
2863
- });
2864
- }
2865
- ), nr = he(
2866
- ({ sendBack: e, input: { context: t } }) => {
2867
- const { signedDataItems: n } = t, { uploadApiBaseUrl: a, useArweaveBundler: r } = C();
2868
- if (!r || !a) {
2869
- e({
2870
- type: "uploadError",
2871
- error: new Error(
2872
- "Arweave bundler not configured. Set useArweaveBundler and uploadApiBaseUrl."
2873
- )
2874
- });
2875
- return;
2876
- }
2877
- const s = `${a.replace(/\/$/, "")}/api/upload/arweave/batch`;
2878
- if (!n || n.length === 0) {
2879
- e({ type: "uploadComplete", result: "done" });
2880
- return;
2881
- }
2882
- (async () => {
2883
- const c = async (f) => {
2884
- const A = f;
2885
- if (A.raw != null && (A.raw instanceof Uint8Array || Buffer.isBuffer(A.raw)))
2886
- return Buffer.from(A.raw);
2887
- if (typeof A.getRaw == "function") {
2888
- const g = A.getRaw();
2889
- return g instanceof Promise ? g : Buffer.from(g);
2890
- }
2891
- if (A.filename != null)
2892
- return Zn(A.filename);
2893
- throw new Error("Cannot get raw bytes from DataItem");
2894
- }, i = await Promise.all(
2895
- n.map((f) => c(f))
2896
- ), u = i.length;
2897
- let d = 4;
2898
- for (const f of i)
2899
- d += 4 + f.length;
2900
- const p = Buffer.alloc(d);
2901
- let l = 0;
2902
- p.writeUInt32BE(u, l), l += 4;
2903
- for (const f of i)
2904
- p.writeUInt32BE(f.length, l), l += 4, f.copy(p, l), l += f.length;
2905
- const m = await fetch(s, {
2906
- method: "POST",
2907
- headers: { "Content-Type": "application/octet-stream" },
2908
- body: p
2909
- });
2910
- if (!m.ok)
2911
- throw new Error(`Batch upload failed: ${m.status}`);
2912
- const h = await m.json().catch(() => ({})), y = typeof h.failed == "number" ? h.failed : 0;
2913
- if (y > 0) {
2914
- const f = h.total ?? "?", A = h.succeeded ?? 0;
2915
- throw new Error(
2916
- `Arweave batch upload failed: ${y} of ${f} item(s) failed (${A} succeeded)`
2917
- );
2918
- }
2919
- })().then(() => e({ type: "uploadComplete", result: "done" })).catch((c) => e({ type: "uploadError", error: c }));
2920
- }
2921
- ), Qt = "Could not connect the managed publishing account on Optimism Sepolia. Reconnect with the same sign-in method and try again.", ar = "Your publishing smart account is not deployed on Optimism Sepolia yet. Complete wallet setup, enable autoDeployManagedAccount in config if appropriate, then try again.", rr = "The managed account could not be confirmed on Optimism Sepolia after deployment. Wait a moment and retry, or check your network connection.", en = "Automatic deployment of the managed publishing account failed on Optimism Sepolia. Retry or deploy the account through your wallet provider.";
2922
- async function St() {
2923
- const { useModularExecutor: e } = C();
2924
- if (!e)
2925
- return { kind: "skip" };
2926
- let t;
2927
- try {
2928
- t = await rt(v);
2929
- } catch (a) {
2930
- return { kind: "unavailable", cause: a };
2931
- }
2932
- return await xe(t) ? { kind: "ready", managedAddress: t } : { kind: "not_deployed", managedAddress: t };
2933
- }
2934
- async function tn() {
2935
- const e = Le();
2936
- await e.autoConnect({ client: R(), chain: v });
2937
- const t = e.getAccount();
2938
- if (!t)
2939
- throw new K(Qt, "MANAGED_ACCOUNT_UNAVAILABLE");
2940
- return t;
2941
- }
2942
- async function sr() {
2943
- const e = await tn();
2944
- try {
2945
- await ia(e);
2946
- } catch (t) {
2947
- throw new K(en, "MANAGED_ACCOUNT_NOT_DEPLOYED", e.address, t);
2948
- }
2949
- }
2950
- async function nn() {
2951
- const e = C();
2952
- if (!e.useModularExecutor)
2953
- throw new Error("runModularExecutorPublishPrep: useModularExecutor is false");
2954
- let t = await St();
2955
- if (t.kind === "unavailable")
2956
- return {
2957
- ok: !1,
2958
- error: new K(Qt, "MANAGED_ACCOUNT_UNAVAILABLE", void 0, t.cause)
2959
- };
2960
- if (t.kind === "not_deployed")
2961
- if (e.autoDeployManagedAccount) {
2962
- try {
2963
- await sr();
2964
- } catch (n) {
2965
- return { ok: !1, error: gt(n) ? n : new K(en, "MANAGED_ACCOUNT_NOT_DEPLOYED", t.managedAddress, n) };
2966
- }
2967
- if (t = await St(), t.kind !== "ready")
2968
- return {
2969
- ok: !1,
2970
- error: new K(
2971
- rr,
2972
- "MANAGED_ACCOUNT_NOT_DEPLOYED",
2973
- t.kind === "not_deployed" ? t.managedAddress : void 0
2974
- )
2975
- };
2976
- } else
2977
- return {
2978
- ok: !1,
2979
- error: new K(ar, "MANAGED_ACCOUNT_NOT_DEPLOYED", t.managedAddress)
2980
- };
2981
- if (t.kind === "ready") {
2982
- if (e.modularAccountModuleContract)
2983
- try {
2984
- const n = await tn();
2985
- await Qe(t.managedAddress, n, e);
2986
- } catch (n) {
2987
- return gt(n) ? { ok: !1, error: n } : {
2988
- ok: !1,
2989
- error: new K(
2990
- "Executor module setup failed on Optimism Sepolia.",
2991
- "EXECUTOR_MODULE_NOT_INSTALLED",
2992
- t.managedAddress,
2993
- n
2994
- )
2995
- };
2996
- }
2997
- return { ok: !0, managedAddress: t.managedAddress };
2998
- }
2999
- throw new Error("runModularExecutorPublishPrep: unexpected readiness state");
3000
- }
3001
- const or = Z("seedProtocol:services:publish:actors:persistSeedUid"), Et = "0x" + "0".repeat(64), ir = 15e3;
3002
- function an(e, t) {
3003
- const n = e.seedLocalId, a = n ? t.find((s) => s?.localId === n) : void 0, r = a?.seedUid && a.seedUid !== Et ? a.seedUid : t[0]?.seedUid;
3004
- r && r !== Et && (e.seedUid = r);
3005
- }
3006
- async function rn(e, t) {
3007
- const n = e.persistSeedUid;
3008
- if (typeof n != "function") return;
3009
- const a = new Promise(
3010
- (r, s) => setTimeout(() => s(new Error("persistSeedUid timed out")), ir)
3011
- );
3012
- try {
3013
- await Promise.race([n.call(e, t), a]);
3014
- } catch (r) {
3015
- or("persistSeedUid failed (attestations already on-chain):", r);
3016
- }
3017
- }
3018
- async function sn(e) {
3019
- if (e.length === 0) return;
3020
- const { arweaveUploadVerificationBaseUrl: t } = C(), n = await Promise.all(
3021
- e.map(
3022
- (a) => Un(t, a)
3023
- )
3024
- );
3025
- for (let a = 0; a < e.length; a++) {
3026
- const r = e[a], s = n[a];
3027
- if (s) {
3028
- if (s.status === 404)
3029
- throw new Error(
3030
- `Arweave transaction ${r} not found. Upload may have failed. Delete this publish record and try again.`
3031
- );
3032
- if (s.status !== 200)
3033
- throw new Error(
3034
- `Arweave transaction ${r} is not yet available from the upload service (status: ${s.status}). Wait and retry.`
3035
- );
3036
- }
3037
- }
3038
- }
3039
- function cr() {
3040
- return Y({
3041
- signature: "event CreatedAttestation((bytes32 schemaUid, bytes32 attestationUid) result)"
3042
- });
3043
- }
3044
- function dr() {
3045
- return Y({
3046
- signature: "event SeedPublished(bytes32 seedUid, bytes32 versionUid)"
3047
- });
3048
- }
3049
- function Te(e) {
3050
- return e == null || e === "" ? H : ("0x" + (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0").padStart(64, "0").slice(-64)).toLowerCase();
3051
- }
3052
- function It(e, t, n) {
3053
- if (!t || !e.logs?.length) return;
3054
- const a = Te(t);
3055
- if (a === H) return;
3056
- const r = n ? cr : Ca;
3057
- try {
3058
- const s = at({
3059
- logs: e.logs,
3060
- events: [r()],
3061
- strict: !1
3062
- });
3063
- for (const o of s) {
3064
- const c = o?.args?.result;
3065
- if (c?.attestationUid && Te(c.schemaUid) === a) {
3066
- const i = c.attestationUid;
3067
- return i && Te(i) !== H ? i : void 0;
3068
- }
3069
- }
3070
- } catch {
3071
- }
3072
- }
3073
- function Pt(e, t, n, a) {
3074
- const r = t.toLowerCase(), s = e.logs?.filter((o) => o.address && o.address.toLowerCase() === r);
3075
- if (s?.length)
3076
- try {
3077
- const i = at({
3078
- logs: s,
3079
- events: [(a ? dr : Ra)()],
3080
- strict: !1
3081
- })[0];
3082
- if (!i) return;
3083
- if (a) {
3084
- const f = i.args?.seedUid;
3085
- return f && Te(f) !== H ? f : void 0;
3086
- }
3087
- const d = i.args?.returnedDataFromEAS;
3088
- if (!d || d === "0x") return;
3089
- const l = Hn([{ type: "bytes32[]" }], d)[0];
3090
- if (!l?.length) return;
3091
- const h = l[n];
3092
- return h && h !== H ? h : l.length === 1 && l[0] && l[0] !== H ? l[0] : void 0;
3093
- } catch {
3094
- return;
3095
- }
3096
- }
3097
- const de = 64, j = (e) => {
3098
- if (e == null) return "0x" + "0".repeat(de);
3099
- if (typeof e == "string")
3100
- return "0x" + (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0").padStart(de, "0").slice(-de);
3101
- if (e instanceof Uint8Array || typeof ArrayBuffer < "u" && e instanceof ArrayBuffer) {
3102
- const t = e instanceof Uint8Array ? e : new Uint8Array(e);
3103
- return "0x" + Array.from(t).map((a) => a.toString(16).padStart(2, "0")).join("").padStart(de, "0").slice(-de);
3104
- }
3105
- return "0x" + "0".repeat(de);
3106
- }, lr = (e) => {
3107
- if (e == null || typeof e == "string" && (e === "" || e === "0x")) return "0x";
3108
- if (typeof e == "string") {
3109
- const n = (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0");
3110
- return "0x" + (n.length % 2 === 1 ? "0" + n : n);
3111
- }
3112
- if (e instanceof Uint8Array || typeof ArrayBuffer < "u" && e instanceof ArrayBuffer) {
3113
- const t = e instanceof Uint8Array ? e : new Uint8Array(e);
3114
- return "0x" + Array.from(t).map((n) => n.toString(16).padStart(2, "0")).join("");
3115
- }
3116
- return "0x";
3117
- };
3118
- function ur(e) {
3119
- const t = new Set(
3120
- e.map((n) => n?.localId).filter((n) => !!n)
3121
- );
3122
- return e.some(
3123
- (n) => (n?.listOfAttestations ?? []).some((a) => {
3124
- const r = a;
3125
- return r._unresolvedValue && t.has(r._unresolvedValue) ? !0 : Array.isArray(r._rawListIdsForResolve) ? r._rawListIdsForResolve.some((s) => s && t.has(String(s).trim())) : !1;
3126
- })
3127
- );
3128
- }
3129
- function pr(e, t) {
3130
- return (e ?? []).filter(
3131
- (n) => n.publishLocalId && t.has(n.publishLocalId)
3132
- );
3133
- }
3134
- const mr = {
3135
- recipient: Ke,
3136
- expirationTime: BigInt(0),
3137
- revocable: !0,
3138
- refUID: H,
3139
- data: H,
3140
- value: BigInt(0)
3141
- };
3142
- function Ge(e) {
3143
- const t = (e?.listOfAttestations ?? []).map((a) => {
3144
- const r = Array.isArray(a?.data) ? a.data : [];
3145
- return {
3146
- schema: j(a?.schema),
3147
- data: r.map((s) => ({
3148
- ...s,
3149
- refUID: j(s?.refUID),
3150
- data: lr(s?.data),
3151
- expirationTime: s?.expirationTime != null ? BigInt(s.expirationTime) : BigInt(0),
3152
- value: s?.value != null ? BigInt(s.value) : BigInt(0)
3153
- }))
3154
- };
3155
- }), n = (e?.propertiesToUpdate ?? []).map((a) => ({
3156
- ...a,
3157
- propertySchemaUid: j(a?.propertySchemaUid)
3158
- }));
3159
- return {
3160
- ...e,
3161
- seedUid: j(e?.seedUid),
3162
- seedSchemaUid: j(e?.seedSchemaUid),
3163
- versionUid: j(e?.versionUid),
3164
- versionSchemaUid: j(e?.versionSchemaUid),
3165
- listOfAttestations: t,
3166
- propertiesToUpdate: n
3167
- };
3168
- }
3169
- function Ut(e, t) {
3170
- for (const n of e)
3171
- for (const a of n?.propertiesToUpdate ?? []) {
3172
- const r = a?.publishLocalId, s = j(a?.propertySchemaUid);
3173
- if (!r || !s) continue;
3174
- const o = t.get(r);
3175
- if (!o?.listOfAttestations) continue;
3176
- const c = o.listOfAttestations.find(
3177
- (i) => j(i?.schema)?.toLowerCase() === s?.toLowerCase()
3178
- );
3179
- c && (!Array.isArray(c.data) || c.data.length === 0) && (c.data = [{ ...mr, refUID: H }]);
3180
- }
3181
- }
3182
- const fr = Z("seedProtocol:services:publish:actors"), hr = fe(
3183
- async ({ input: { context: e, event: t } }) => {
3184
- const { address: n, account: a } = e, r = e.arweaveTransactions ?? [], s = e.publishUploads ?? [];
3185
- let { item: o } = e;
3186
- const { modularAccountModuleContract: c, useModularExecutor: i } = C();
3187
- if (!n || typeof n != "string" || !n.trim())
3188
- throw new Error("No wallet address for publish. Connect a wallet and try again.");
3189
- if (!a)
3190
- throw new Error("Wallet session is missing. Reconnect your wallet and retry the publish.");
3191
- if (!o?.seedLocalId)
3192
- throw new Error(
3193
- "Attestation recovery failed: Item data is missing. Delete this publish record and try a full publish from the beginning."
3194
- );
3195
- typeof o.getPublishUploads != "function" && (o = await it(o.seedLocalId));
3196
- const d = r.length, p = s.length;
3197
- if (d !== p)
3198
- throw new Error(
3199
- "Attestation recovery failed: Arweave transaction data is missing or incomplete. Delete this publish record and try a full publish from the beginning."
3200
- );
3201
- const l = V({
3202
- client: R(),
3203
- chain: v,
3204
- address: n
3205
- });
3206
- let m = i && c ? V({
3207
- client: R(),
3208
- chain: v,
3209
- address: c
3210
- }) : l;
3211
- await Me(o, a, R(), v);
3212
- const h = r.map(
3213
- (w, U) => {
3214
- const b = w.transaction?.id;
3215
- if (!b || typeof b != "string")
3216
- throw new Error(
3217
- "Attestation recovery failed: Arweave transaction data did not survive restore. Delete this publish record and try a full publish from the beginning."
3218
- );
3219
- const M = s[U];
3220
- if (!M) throw new Error("Publish upload index mismatch");
3221
- return { ...M, txId: b };
3222
- }
3223
- );
3224
- await sn(h.map((w) => w.txId));
3225
- let y;
3226
- try {
3227
- y = await o.getPublishPayload(h, { publishMode: e.publishMode ?? "patch" });
3228
- } catch (w) {
3229
- throw w;
3230
- }
3231
- const f = Array.isArray(y) ? y : [y];
3232
- let A = a;
3233
- if (i) {
3234
- const w = await nn();
3235
- if (!w.ok)
3236
- throw w.error;
3237
- m = V({
3238
- client: R(),
3239
- chain: v,
3240
- address: mt
3241
- });
3242
- const U = st();
3243
- await U.autoConnect({ client: R(), chain: v });
3244
- const B = U.getAccount();
3245
- if (!B)
3246
- throw new Error("Failed to get modular account");
3247
- A = B;
3248
- }
3249
- const g = i ? mt : n, I = f.length > 1 && ur(f);
3250
- let S;
3251
- if (I) {
3252
- let w = structuredClone(f);
3253
- const U = {};
3254
- for (let b = 0; b < w.length; b++) {
3255
- w = await pt(w, U);
3256
- const M = w[b], Q = /* @__PURE__ */ new Set([M.localId]), ye = {
3257
- ...M,
3258
- propertiesToUpdate: pr(M.propertiesToUpdate, Q)
3259
- }, J = Ge(ye), Oe = /* @__PURE__ */ new Map([[J.localId, J]]);
3260
- Ut([J], Oe);
3261
- const Be = {
3262
- ...wt({
3263
- contract: m,
3264
- requests: [J]
3265
- }),
3266
- gas: 5000000n
3267
- }, Fe = await F({
3268
- account: A,
3269
- transaction: await Promise.resolve(Be)
3270
- }), re = await N({
3271
- client: R(),
3272
- chain: v,
3273
- transactionHash: Fe.transactionHash
3274
- });
3275
- if (!re)
3276
- throw new Error("Failed to send transaction");
3277
- const se = !J.seedUid || j(J.seedUid) === H, un = J?.listOfAttestations?.length ?? 0, pn = J?.seedSchemaUid;
3278
- if (se) {
3279
- const Ne = It(re, pn, i) ?? Pt(
3280
- re,
3281
- g,
3282
- un,
3283
- i
3284
- );
3285
- Ne && (U[M.localId] = Ne, w[b] = { ...w[b], seedUid: Ne });
3286
- }
3287
- }
3288
- for (const b of w) {
3289
- const M = b?.localId, Q = b?.seedUid;
3290
- M && Q && j(Q) !== H && (U[M] = j(Q));
3291
- }
3292
- S = (await pt(structuredClone(f), U)).map(
3293
- (b) => Ge({
3294
- ...b,
3295
- seedUid: U[b.localId] ?? b.seedUid
3296
- })
3297
- );
3298
- } else {
3299
- const w = f.map((se) => Ge(se)), U = new Map(w.map((se) => [se?.localId, se]));
3300
- Ut(w, U);
3301
- const B = Array.isArray(y) ? w : [w[0]], b = {
3302
- ...wt({
3303
- contract: m,
3304
- requests: B
3305
- }),
3306
- gas: 5000000n
3307
- }, M = await F({
3308
- account: A,
3309
- transaction: await Promise.resolve(b)
3310
- }), Q = await N({
3311
- client: R(),
3312
- chain: v,
3313
- transactionHash: M.transactionHash
3314
- });
3315
- if (!Q)
3316
- throw new Error("Failed to send transaction");
3317
- const ye = w[0], J = ye?.seedUid, Oe = J === H || !J, Be = ye?.listOfAttestations?.length ?? 0, Fe = ye?.seedSchemaUid, re = Oe ? It(Q, Fe, i) ?? Pt(
3318
- Q,
3319
- g,
3320
- Be,
3321
- i
3322
- ) : void 0;
3323
- S = re && w.length > 0 ? [{ ...w[0], seedUid: re }, ...w.slice(1)] : w;
3324
- }
3325
- an(o, S);
3326
- const E = o, D = S.find((w) => w?.localId === o.seedLocalId)?.seedUid;
3327
- return D && D !== H && await rn(E, n), fr("requestData", y), { easPayload: y };
3328
- }
3329
- ), Tt = Z("seedProtocol:services:publish:verifyAttestations"), yr = "0x" + "0".repeat(64), Ie = 64, Dt = (e) => e == null ? "0x" + "0".repeat(Ie) : typeof e == "string" ? "0x" + (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0").padStart(Ie, "0").slice(-Ie) : "0x" + "0".repeat(Ie), gr = 5e3, Ye = 6;
3330
- async function wr({
3331
- normalizedRequests: e,
3332
- item: t
3333
- }) {
3334
- const n = t.seedLocalId;
3335
- for (const a of e) {
3336
- if (a.listOfAttestations.length === 0 || a.versionUid === yr) continue;
3337
- const r = a.listOfAttestations.map(
3338
- (d) => Dt(d.schema).toLowerCase()
3339
- );
3340
- let s = [], o;
3341
- for (let d = 1; d <= Ye; d++)
3342
- try {
3343
- d > 1 && await new Promise((p) => setTimeout(p, gr)), s = await Tn({
3344
- versionUids: [a.versionUid]
3345
- });
3346
- break;
3347
- } catch (p) {
3348
- if (o = p, Tt("verifyAttestations attempt %d failed:", d, p), d === Ye)
3349
- throw Tt("verifyAttestations: giving up after %d attempts", Ye), o;
3350
- }
3351
- const c = s.map((d) => d.schemaId ? Dt(d.schemaId).toLowerCase() : "").filter(Boolean), i = new Set(c);
3352
- if (r.filter((d) => !i.has(d)).length > 0)
3353
- throw new jt(
3354
- `Publish verification failed: Seed and Version attestations were created, but property/metadata attestations are missing or incomplete. Expected ${r.length} property attestations for schema(s) ${r.join(", ")}; found ${c.length}. Use PublishManager.retryAttestations('${n}') to retry.`,
3355
- n,
3356
- r,
3357
- c,
3358
- "METADATA_PROPERTIES_MISSING"
3359
- );
3360
- }
3361
- }
3362
- const we = Z("seedProtocol:services:publish:createAttestationsDirectToEas"), le = 64, z = (e) => {
3363
- if (e == null) return "0x" + "0".repeat(le);
3364
- if (typeof e == "string")
3365
- return "0x" + (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0").padStart(le, "0").slice(-le);
3366
- if (e instanceof Uint8Array || typeof ArrayBuffer < "u" && e instanceof ArrayBuffer) {
3367
- const t = e instanceof Uint8Array ? e : new Uint8Array(e);
3368
- return "0x" + Array.from(t).map((a) => a.toString(16).padStart(2, "0")).join("").padStart(le, "0").slice(-le);
3369
- }
3370
- return "0x" + "0".repeat(le);
3371
- }, br = (e) => {
3372
- if (e == null || typeof e == "string" && (e === "" || e === "0x")) return "0x";
3373
- if (typeof e == "string") {
3374
- const n = (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0");
3375
- return "0x" + (n.length % 2 === 1 ? "0" + n : n);
3376
- }
3377
- if (e instanceof Uint8Array || typeof ArrayBuffer < "u" && e instanceof ArrayBuffer) {
3378
- const t = e instanceof Uint8Array ? e : new Uint8Array(e);
3379
- return "0x" + Array.from(t).map((n) => n.toString(16).padStart(2, "0")).join("");
3380
- }
3381
- return "0x";
3382
- }, Ar = async (e) => {
3383
- let t;
3384
- try {
3385
- t = await ae.find({ seedLocalId: e });
3386
- } catch {
3387
- }
3388
- return t || new Promise((n) => {
3389
- const a = setInterval(() => {
3390
- try {
3391
- ae.find({ seedLocalId: e }).then((r) => {
3392
- r && (clearInterval(a), n(r));
3393
- });
3394
- } catch {
3395
- }
3396
- }, 200);
3397
- });
3398
- }, vr = fe(
3399
- async ({ input: { context: e, event: t } }) => {
3400
- const { address: n, account: a } = e, r = e.arweaveTransactions ?? [], s = e.publishUploads ?? [];
3401
- let { item: o } = e;
3402
- if (!n || typeof n != "string" || !n.trim())
3403
- throw new Error("No wallet address for publish. Connect a wallet and try again.");
3404
- if (!a)
3405
- throw new Error("Wallet session is missing. Reconnect your wallet and retry the publish.");
3406
- if (!o?.seedLocalId)
3407
- throw new Error(
3408
- "Attestation recovery failed: Item data is missing. Delete this publish record and try a full publish from the beginning."
3409
- );
3410
- typeof o.getPublishUploads != "function" && (o = await Ar(o.seedLocalId));
3411
- const i = r.length, u = s.length;
3412
- if (i !== u)
3413
- throw new Error(
3414
- "Attestation recovery failed: Arweave transaction data is missing or incomplete. Delete this publish record and try a full publish from the beginning."
3415
- );
3416
- await Me(o, a, R(), v);
3417
- const d = r.map(
3418
- (g, I) => {
3419
- const E = g.transaction?.id;
3420
- if (!E || typeof E != "string")
3421
- throw new Error(
3422
- "Attestation recovery failed: Arweave transaction data did not survive restore. Delete this publish record and try a full publish from the beginning."
3423
- );
3424
- const W = s[I];
3425
- if (!W) throw new Error("Publish upload index mismatch");
3426
- return { ...W, txId: E };
3427
- }
3428
- );
3429
- await sn(d.map((g) => g.txId));
3430
- const p = await o.getPublishPayload(d, { publishMode: e.publishMode ?? "patch" }), m = (Array.isArray(p) ? p : [p]).map((g) => {
3431
- const I = (g?.listOfAttestations ?? []).map((E) => {
3432
- const W = Array.isArray(E?.data) ? E.data : [];
3433
- return {
3434
- schema: z(E?.schema),
3435
- data: W.map((D) => ({
3436
- ...D,
3437
- refUID: z(D?.refUID),
3438
- data: br(D?.data)
3439
- }))
3440
- };
3441
- }), S = (g?.propertiesToUpdate ?? []).map((E) => ({
3442
- ...E,
3443
- propertySchemaUid: z(E?.propertySchemaUid)
3444
- }));
3445
- return {
3446
- ...g,
3447
- seedUid: z(g?.seedUid),
3448
- seedSchemaUid: z(g?.seedSchemaUid),
3449
- versionUid: z(g?.versionUid),
3450
- versionSchemaUid: z(g?.versionSchemaUid),
3451
- listOfAttestations: I,
3452
- propertiesToUpdate: S
3453
- };
3454
- }), h = new Map(m.map((g) => [g.localId, g])), y = {
3455
- recipient: Ke,
3456
- expirationTime: BigInt(0),
3457
- revocable: !0,
3458
- refUID: q,
3459
- data: q,
3460
- value: BigInt(0)
3461
- };
3462
- for (const g of m)
3463
- for (const I of g.propertiesToUpdate ?? []) {
3464
- const S = I.publishLocalId, E = z(I.propertySchemaUid);
3465
- if (!S || !E) continue;
3466
- const W = h.get(S);
3467
- if (!W?.listOfAttestations) continue;
3468
- const D = W.listOfAttestations.find(
3469
- (w) => z(w?.schema)?.toLowerCase() === E?.toLowerCase()
3470
- );
3471
- D && (!Array.isArray(D.data) || D.data.length === 0) && (D.data = [{ ...y, refUID: q }]);
3472
- }
3473
- const f = R();
3474
- for (let g = 0; g < m.length; g++) {
3475
- const I = m[g];
3476
- let S = I.seedUid, E = I.versionUid;
3477
- if (S === q) {
3478
- const D = ht(f, v, {
3479
- schema: I.seedSchemaUid,
3480
- data: {
3481
- refUID: q,
3482
- data: Ve(I.seedSchemaUid),
3483
- revocable: I.seedIsRevocable
3484
- }
3485
- }), w = await F({ account: a, transaction: D }), U = await N({
3486
- client: f,
3487
- chain: v,
3488
- transactionHash: w.transactionHash
3489
- });
3490
- if (!U) throw new Error("Failed to create Seed attestation");
3491
- const { easContractAddress: B } = C(), b = yt(U, B);
3492
- if (!b || b === q)
3493
- throw new Error("Failed to get Seed UID from attestation receipt");
3494
- S = b, I.seedUid = b, we("created Seed attestation", S);
3495
- }
3496
- if (S !== q && E === q) {
3497
- const D = ht(f, v, {
3498
- schema: I.versionSchemaUid,
3499
- data: {
3500
- refUID: S,
3501
- data: Ve(I.versionSchemaUid),
3502
- revocable: !0
3503
- }
3504
- }), w = await F({ account: a, transaction: D }), U = await N({
3505
- client: f,
3506
- chain: v,
3507
- transactionHash: w.transactionHash
3508
- });
3509
- if (!U) throw new Error("Failed to create Version attestation");
3510
- const { easContractAddress: B } = C(), b = yt(U, B);
3511
- if (!b || b === q)
3512
- throw new Error("Failed to get Version UID from attestation receipt");
3513
- E = b, I.versionUid = b, await Dn({
3514
- seedLocalId: I.localId,
3515
- versionUid: b,
3516
- publisher: n
3517
- }), we("created Version attestation", E);
3518
- }
3519
- for (const D of I.listOfAttestations)
3520
- for (const w of D.data)
3521
- w.refUID = E;
3522
- for (const D of I.propertiesToUpdate ?? []) {
3523
- const w = h.get(D.publishLocalId);
3524
- if (!w?.listOfAttestations) continue;
3525
- const U = z(D.propertySchemaUid), B = w.listOfAttestations.find(
3526
- (b) => z(b?.schema)?.toLowerCase() === U?.toLowerCase()
3527
- );
3528
- B?.data?.[0] && (B.data[0].data = Ve(S));
3529
- }
3530
- const W = I.listOfAttestations.map((D) => ({
3531
- schema: D.schema,
3532
- data: D.data.map((w) => ({
3533
- recipient: w.recipient ?? Ke,
3534
- expirationTime: w.expirationTime ?? 0n,
3535
- revocable: w.revocable ?? !0,
3536
- refUID: w.refUID ?? q,
3537
- data: w.data ?? "0x",
3538
- value: w.value ?? 0n
3539
- }))
3540
- }));
3541
- if (W.length > 0) {
3542
- const D = ma(f, v, W), w = await F({ account: a, transaction: D });
3543
- if (!await N({
3544
- client: f,
3545
- chain: v,
3546
- transactionHash: w.transactionHash
3547
- })) throw new Error("Failed to create property attestations");
3548
- we("created property attestations for request", g);
3549
- }
3550
- }
3551
- an(o, m);
3552
- const A = o;
3553
- m[0]?.seedUid && m[0].seedUid !== q && await rn(A, n);
3554
- try {
3555
- await wr({ normalizedRequests: m, item: o });
3556
- } catch (g) {
3557
- throw g instanceof jt || we("verifyAttestations failed (non-verification error):", g), g;
3558
- }
3559
- return we("direct EAS publish complete"), { easPayload: p };
3560
- }
3561
- ), Sr = async (e) => {
3562
- let t;
3563
- try {
3564
- t = await ae.find({ seedLocalId: e });
3565
- } catch {
3566
- }
3567
- return t || new Promise((n) => {
3568
- const a = setInterval(() => {
3569
- ae.find({ seedLocalId: e }).then((r) => {
3570
- r && (clearInterval(a), n(r));
3571
- }).catch(() => {
3572
- });
3573
- }, 200);
3574
- });
3575
- };
3576
- async function Er(e) {
3577
- const n = typeof e.getPublishUploads == "function" ? e : await Sr(e.seedLocalId);
3578
- return await xn(n);
3579
- }
3580
- const ue = /* @__PURE__ */ new Set(), Ir = he(({ sendBack: e, input: { context: t } }) => {
3581
- const { item: n, account: a, publishMode: r } = t;
3582
- return (async () => {
3583
- if (!await Mt(n)) {
3584
- e({ type: "notOwner" });
3585
- return;
3586
- }
3587
- if (ue.has(n.seedLocalId)) {
3588
- e({
3589
- type: "redundantPublishProcess"
3590
- });
3591
- return;
3592
- }
3593
- ue.add(n.seedLocalId);
3594
- try {
3595
- a && await Me(n, a, R(), v);
3596
- const c = await Cn(n, [], {
3597
- publishMode: r ?? "patch"
3598
- });
3599
- if (!c.isValid) {
3600
- ue.delete(n.seedLocalId), e({ type: "validationFailed", errors: c.errors });
3601
- return;
3602
- }
3603
- if (await Er(n)) {
3604
- const u = C().useArweaveBundler;
3605
- e({ type: u ? "validPublishProcessBundler" : "validPublishProcess" });
3606
- } else
3607
- e({ type: "skipArweave" });
3608
- } catch (c) {
3609
- ue.delete(n.seedLocalId), console.error("[checking] itemNeedsArweaveUpload failed", c), e({ type: "skipArweave" });
3610
- }
3611
- })().catch(() => {
3612
- ue.delete(n.seedLocalId), e({ type: "validPublishProcess" });
3613
- }), () => {
3614
- ue.delete(n.seedLocalId);
3615
- };
3616
- }), {
3617
- SUCCESS: Je,
3618
- FAILURE: ze
3619
- } = L;
3620
- function ee(e) {
3621
- const t = e;
3622
- return t.error ?? t.data;
3623
- }
3624
- const on = Nt({
3625
- types: {
3626
- context: {},
3627
- input: {}
3628
- },
3629
- actors: {
3630
- createArweaveTransactions: Ma,
3631
- createArweaveDataItems: Ga,
3632
- sendReimbursementRequest: Xa,
3633
- pollForConfirmation: Qa,
3634
- uploadData: tr,
3635
- uploadViaBundler: nr,
3636
- createAttestations: hr,
3637
- createAttestationsDirectToEas: vr,
3638
- checking: Ir
3639
- },
3640
- actions: {
3641
- /** Log error; error/errorStep are assigned per transition. Supports both event.error (custom events) and event.data (XState fromPromise invoke errors). */
3642
- handleError: ({ event: e }) => {
3643
- const t = ee(e);
3644
- t != null ? console.error(t) : console.error("Unknown error (full event):", e);
3645
- },
3646
- assignErrorCreatingArweaveTransactions: T({
3647
- error: ({ event: e }) => ee(e),
3648
- errorStep: () => "creatingArweaveTransactions"
3649
- }),
3650
- assignErrorCreatingArweaveDataItems: T({
3651
- error: ({ event: e }) => ee(e),
3652
- errorStep: () => "creatingArweaveDataItems"
3653
- }),
3654
- assignErrorSendingReimbursementRequest: T({
3655
- error: ({ event: e }) => ee(e),
3656
- errorStep: () => "sendingReimbursementRequest"
3657
- }),
3658
- assignErrorPollingForConfirmation: T({
3659
- error: ({ event: e }) => ee(e),
3660
- errorStep: () => "pollingForConfirmation"
3661
- }),
3662
- assignErrorUploadingData: T({
3663
- error: ({ event: e }) => ee(e),
3664
- errorStep: () => "uploadingData"
3665
- }),
3666
- assignErrorUploadingViaBundler: T({
3667
- error: ({ event: e }) => ee(e),
3668
- errorStep: () => "uploadingViaBundler"
3669
- }),
3670
- assignErrorCreatingAttestations: T({
3671
- error: ({ event: e }) => ee(e),
3672
- errorStep: () => "creatingAttestations"
3673
- }),
3674
- assignErrorCreatingAttestationsDirectToEas: T({
3675
- error: ({ event: e }) => ee(e),
3676
- errorStep: () => "creatingAttestationsDirectToEas"
3677
- }),
3678
- assignAccountFromRetry: T({
3679
- account: ({ event: e }) => e.account
3680
- }),
3681
- assignErrorNotOwner: T({
3682
- error: () => new Error("Item is read-only: you do not own this item. Only the publisher can publish."),
3683
- errorStep: () => "checking"
3684
- }),
3685
- assignErrorValidationFailed: T({
3686
- error: ({ event: e }) => {
3687
- const n = e.errors ?? [], a = n.length > 0 ? `Validation failed (${n.length} error${n.length === 1 ? "" : "s"}):
3688
- ${n.map((s) => s.message).join(`
3689
- `)}` : "Validation failed", r = new Error(a);
3690
- return r.validationErrors = n, r;
3691
- },
3692
- errorStep: () => "checking"
3693
- })
3694
- }
3695
- }).createMachine({
3696
- id: "publish",
3697
- initial: "checking",
3698
- context: ({ input: e }) => e,
3699
- states: {
3700
- checking: {
3701
- on: {
3702
- notOwner: {
3703
- target: ze,
3704
- actions: ["assignErrorNotOwner", "handleError"]
3705
- },
3706
- validationFailed: {
3707
- target: ze,
3708
- actions: ["assignErrorValidationFailed", "handleError"]
3709
- },
3710
- redundantPublishProcess: {
3711
- target: "stopping"
3712
- },
3713
- validPublishProcess: {
3714
- target: "creatingArweaveTransactions"
3715
- },
3716
- validPublishProcessBundler: {
3717
- target: "creatingArweaveDataItems"
3718
- },
3719
- skipArweave: [
3720
- {
3721
- guard: () => C().useDirectEas,
3722
- target: "creatingAttestationsDirectToEas",
3723
- actions: T({
3724
- arweaveTransactions: () => [],
3725
- publishUploads: () => []
3726
- })
3727
- },
3728
- {
3729
- guard: () => !C().useDirectEas,
3730
- target: "creatingAttestations",
3731
- actions: T({
3732
- arweaveTransactions: () => [],
3733
- publishUploads: () => []
3734
- })
3735
- }
3736
- ]
3737
- },
3738
- invoke: {
3739
- src: "checking",
3740
- input: ({ context: e }) => ({ context: e })
3741
- }
3742
- },
3743
- creatingArweaveTransactions: {
3744
- invoke: {
3745
- src: "createArweaveTransactions",
3746
- input: ({ context: e, event: t }) => ({ context: e, event: t }),
3747
- onDone: {
3748
- target: "sendingReimbursementRequest",
3749
- actions: T({
3750
- arweaveTransactions: ({ event: e }) => e.output.arweaveTransactions,
3751
- publishUploads: ({ event: e }) => e.output.publishUploads
3752
- })
3753
- },
3754
- onError: {
3755
- target: "failure",
3756
- actions: ["assignErrorCreatingArweaveTransactions", "handleError"]
3757
- }
3758
- }
3759
- },
3760
- creatingArweaveDataItems: {
3761
- invoke: {
3762
- src: "createArweaveDataItems",
3763
- input: ({ context: e, event: t }) => ({ context: e, event: t }),
3764
- onDone: {
3765
- target: "uploadingViaBundler",
3766
- actions: T({
3767
- arweaveTransactions: ({ event: e }) => e.output.arweaveTransactions,
3768
- publishUploads: ({ event: e }) => e.output.publishUploads,
3769
- arweaveUploadData: ({ event: e }) => e.output.arweaveUploadData,
3770
- signedDataItems: ({ event: e }) => e.output.signedDataItems
3771
- })
3772
- },
3773
- onError: {
3774
- target: "failure",
3775
- actions: ["assignErrorCreatingArweaveDataItems", "handleError"]
3776
- }
3777
- }
3778
- },
3779
- sendingReimbursementRequest: {
3780
- invoke: {
3781
- src: "sendReimbursementRequest",
3782
- input: ({ context: e, event: t }) => ({ context: e, event: t }),
3783
- onDone: {
3784
- target: "pollingForConfirmation",
3785
- actions: T({
3786
- requestResponse: ({ event: e }) => e.output,
3787
- reimbursementTransactionId: ({ event: e }) => e.output.transactionId
3788
- })
3789
- },
3790
- onError: {
3791
- target: "failure",
3792
- actions: ["assignErrorSendingReimbursementRequest", "handleError"]
3793
- }
3794
- }
3795
- },
3796
- pollingForConfirmation: {
3797
- invoke: {
3798
- src: "pollForConfirmation",
3799
- input: ({ context: e, event: t }) => ({ context: e, event: t }),
3800
- onDone: {
3801
- target: "uploadingData",
3802
- actions: T({
3803
- reimbursementConfirmed: !0
3804
- })
3805
- },
3806
- onError: {
3807
- target: "failure",
3808
- actions: ["assignErrorPollingForConfirmation", "handleError"]
3809
- }
3810
- }
3811
- },
3812
- uploadingViaBundler: {
3813
- on: {
3814
- uploadComplete: [
3815
- {
3816
- guard: () => C().useDirectEas,
3817
- target: "creatingAttestationsDirectToEas",
3818
- actions: T({
3819
- completionPercentage: 100
3820
- })
3821
- },
3822
- {
3823
- guard: () => !C().useDirectEas,
3824
- target: "creatingAttestations",
3825
- actions: T({
3826
- completionPercentage: 100
3827
- })
3828
- }
3829
- ],
3830
- uploadError: {
3831
- target: "failure",
3832
- actions: ["assignErrorUploadingViaBundler", "handleError"]
3833
- }
3834
- },
3835
- invoke: {
3836
- src: "uploadViaBundler",
3837
- input: ({ context: e }) => ({ context: e })
3838
- }
3839
- },
3840
- uploadingData: {
3841
- on: {
3842
- updatePercentage: {
3843
- actions: T({
3844
- completionPercentage: ({ event: e }) => e.completionPercentage,
3845
- uploaderState: ({ event: e }) => e.uploaderState,
3846
- currentTransactionIndex: ({ event: e }) => e.currentTransactionIndex
3847
- })
3848
- },
3849
- uploadComplete: [
3850
- {
3851
- guard: () => C().useDirectEas,
3852
- target: "creatingAttestationsDirectToEas",
3853
- actions: T({
3854
- completionPercentage: 100
3855
- })
3856
- },
3857
- {
3858
- guard: () => !C().useDirectEas,
3859
- target: "creatingAttestations",
3860
- actions: T({
3861
- completionPercentage: 100
3862
- })
3863
- }
3864
- ],
3865
- uploadError: {
3866
- target: "failure",
3867
- actions: ["assignErrorUploadingData", "handleError"]
3868
- }
3869
- },
3870
- invoke: {
3871
- src: "uploadData",
3872
- input: ({ context: e }) => ({ context: e })
3873
- }
3874
- },
3875
- creatingAttestations: {
3876
- invoke: {
3877
- src: "createAttestations",
3878
- input: ({ context: e, event: t }) => ({ context: e, event: t }),
3879
- onDone: {
3880
- target: Je,
3881
- actions: T({
3882
- easPayload: ({ event: e }) => e.output?.easPayload
3883
- })
3884
- },
3885
- onError: {
3886
- target: "attestationFailureRecoverable",
3887
- actions: ["assignErrorCreatingAttestations", "handleError"]
3888
- }
3889
- }
3890
- },
3891
- attestationFailureRecoverable: {
3892
- on: {
3893
- retry: {
3894
- target: "creatingAttestations",
3895
- actions: ["assignAccountFromRetry"]
3896
- }
3897
- }
3898
- },
3899
- creatingAttestationsDirectToEas: {
3900
- invoke: {
3901
- src: "createAttestationsDirectToEas",
3902
- input: ({ context: e, event: t }) => ({ context: e, event: t }),
3903
- onDone: {
3904
- target: Je,
3905
- actions: T({
3906
- easPayload: ({ event: e }) => e.output?.easPayload
3907
- })
3908
- },
3909
- onError: {
3910
- target: "attestationFailureRecoverableDirectToEas",
3911
- actions: ["assignErrorCreatingAttestationsDirectToEas", "handleError"]
3912
- }
3913
- }
3914
- },
3915
- attestationFailureRecoverableDirectToEas: {
3916
- on: {
3917
- retry: {
3918
- target: "creatingAttestationsDirectToEas",
3919
- actions: ["assignAccountFromRetry"]
3920
- }
3921
- }
3922
- },
3923
- stopping: {
3924
- entry: ({ context: e }) => {
3925
- console.log(`Actor for ${e.item?.seedLocalId} stopped`);
3926
- },
3927
- type: "final"
3928
- },
3929
- [Je]: {
3930
- type: "final"
3931
- },
3932
- [ze]: {
3933
- type: "final"
3934
- }
3935
- }
3936
- }), Pr = T(({ context: e, event: t }) => {
3937
- const n = t, a = n.publishProcesses ?? /* @__PURE__ */ new Map(), r = n.subscriptions ?? /* @__PURE__ */ new Map();
3938
- return {
3939
- publishProcesses: new Map(a),
3940
- subscriptions: new Map(
3941
- r
3942
- )
3943
- };
3944
- });
3945
- let cn = null;
3946
- function Ur(e) {
3947
- cn = e;
3948
- }
3949
- function Tr() {
3950
- return cn;
3951
- }
3952
- const xt = Z("seedProtocol:services:PublishManager:actors:subscribe");
3953
- function Ct(e) {
3954
- const t = e.value;
3955
- return typeof t == "string" ? t : t && typeof t == "object" ? Object.keys(t)[0] ?? "" : "";
3956
- }
3957
- function Ze(e) {
3958
- return ra.includes(e);
3959
- }
3960
- const dn = he(
3961
- ({ receive: e, input: { publishProcess: t, seedLocalId: n } }) => {
3962
- const a = Tr();
3963
- let r = null;
3964
- const s = () => {
3965
- r != null && (clearInterval(r), r = null);
3966
- }, o = (i) => {
3967
- const u = Ct(i);
3968
- Ze(u) && r == null && a ? r = setInterval(() => {
3969
- try {
3970
- const d = t.getSnapshot();
3971
- if (d.status === "done") {
3972
- s();
3973
- return;
3974
- }
3975
- const p = Ct(d);
3976
- if (!Ze(p)) {
3977
- s();
3978
- return;
3979
- }
3980
- } catch {
3981
- return;
3982
- }
3983
- a?.savePublish(n, t);
3984
- }, sa) : Ze(u) || s();
3985
- }, c = t.subscribe(async (i) => {
3986
- xt("Publish state:", i.value), a && (i.status === "done" ? (s(), a.savePublish(n, t, { triggerPublishDone: !0 })) : (a.savePublish(n, t), o(i)));
3987
- });
3988
- e(({ type: i }) => {
3989
- i === "UNSUBSCRIBE" && (xt("Received UNSUBSCRIBE event"), s(), c.unsubscribe(), a?.removeSubscription(n));
3990
- });
3991
- }
3992
- ), Dr = _e(({ event: e, enqueue: t }) => {
3993
- const n = e, { item: a, address: r, account: s, options: o } = n;
3994
- if (!(r != null && typeof r == "string" && r.trim().length > 0)) {
3995
- console.warn("[createPublish] No valid wallet address; skipping spawn.");
3996
- return;
3997
- }
3998
- t.assign(({ context: i, spawn: u }) => {
3999
- const { publishProcesses: d } = i;
4000
- if (d && d.has(a.seedLocalId))
4001
- return console.warn(`Publish process with seedLocalId "${a.seedLocalId}" already exists.`), i;
4002
- const p = typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `run_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`, l = u(on, {
4003
- input: {
4004
- item: a,
4005
- address: r,
4006
- account: s,
4007
- modelName: a.modelName,
4008
- schemaId: a.schemaUid,
4009
- signDataItems: o?.signDataItems,
4010
- dataItemSigner: o?.dataItemSigner,
4011
- signArweaveTransactions: o?.signArweaveTransactions,
4012
- arweaveJwk: o?.arweaveJwk,
4013
- publishMode: o?.publishMode ?? "patch",
4014
- publishRunId: p
4015
- }
4016
- });
4017
- return d.set(a.seedLocalId, l), {
4018
- publishProcesses: new Map(d)
4019
- };
4020
- }), t.assign(({ context: i, spawn: u }) => {
4021
- const { subscriptions: d, publishProcesses: p } = i, l = p.get(a.seedLocalId);
4022
- if (!l)
4023
- return console.warn(`Publish process with seedLocalId "${a.seedLocalId}" does not exist.`), i;
4024
- if (d && d.has(a.seedLocalId))
4025
- return console.warn(`Subscription with seedLocalId "${a.seedLocalId}" already exists.`), i;
4026
- const m = u(dn, {
4027
- input: { publishProcess: l, seedLocalId: a.seedLocalId }
4028
- });
4029
- return d.set(a.seedLocalId, m), {
4030
- subscriptions: new Map(d)
4031
- };
4032
- });
4033
- }), xr = ({
4034
- context: e,
4035
- event: t
4036
- }) => {
4037
- const n = t, { seedLocalId: a, account: r } = n, s = e.publishProcesses.get(a);
4038
- if (!s) {
4039
- console.warn(`Publish process with seedLocalId "${a}" does not exist.`);
4040
- return;
4041
- }
4042
- s.send({ type: "retry", account: r });
4043
- }, Cr = _e(({ context: e, event: t, enqueue: n }) => {
4044
- const { publishProcesses: a, subscriptions: r } = e, { seedLocalId: s } = t, o = a.get(s);
4045
- if (!o) {
4046
- console.warn(`Publish process with seedLocalId "${s}" does not exist.`);
4047
- return;
4048
- }
4049
- n.stopChild(o);
4050
- const c = r.get(s);
4051
- c && n.stopChild(c);
4052
- const i = new Map(a);
4053
- i.delete(s);
4054
- const u = new Map(r);
4055
- u.delete(s), n.assign({
4056
- publishProcesses: i,
4057
- subscriptions: u
4058
- });
4059
- }), Rr = Z("seedProtocol:PublishManager:index"), _r = _e(({ context: e, enqueue: t }) => {
4060
- Rr("Stopping all actors..."), e.publishProcesses.forEach((n) => {
4061
- t.stopChild(n);
4062
- }), e.subscriptions.forEach((n) => {
4063
- t.stopChild(n);
4064
- }), t.assign({
4065
- publishProcesses: /* @__PURE__ */ new Map(),
4066
- subscriptions: /* @__PURE__ */ new Map()
4067
- });
4068
- }), Lr = _e(({ context: e, event: t, enqueue: n }) => {
4069
- const { seedLocalId: a } = t, r = e.publishProcesses.get(a);
4070
- if (!r) {
4071
- console.warn(`Publish process with seedLocalId "${a}" does not exist.`);
4072
- return;
4073
- }
4074
- n.stopChild(r);
4075
- const s = e.subscriptions.get(a);
4076
- s && n.stopChild(s);
4077
- const o = new Map(e.publishProcesses);
4078
- o.delete(a);
4079
- const c = new Map(e.subscriptions);
4080
- c.delete(a), n.assign({
4081
- publishProcesses: o,
4082
- subscriptions: c
4083
- });
4084
- }), Mr = T(({ context: e, event: t }) => {
4085
- const { subscriptions: n } = e, { seedLocalId: a, newSubscription: r } = t;
4086
- return r && n.set(a, r), {
4087
- subscriptions: new Map(n)
4088
- };
4089
- }), Pe = Z("seedProtocol:services:PublishManager:actors:savePublish"), Rt = /* @__PURE__ */ new Map();
4090
- function Or(e, t) {
4091
- const a = (Rt.get(e) ?? Promise.resolve()).then(t);
4092
- return Rt.set(e, a.catch(() => {
4093
- })), a;
4094
- }
4095
- function Br(e) {
4096
- return e.status === "done" ? e.value === "success" ? "completed" : e.value === "failure" ? "failed" : "completed" : "in_progress";
4097
- }
4098
- const Fr = 500, Ue = 2e3;
4099
- function Nr(e) {
4100
- return JSON.stringify(e, (t, n) => typeof n == "bigint" ? n.toString() : n);
4101
- }
4102
- function _t(e) {
4103
- if (e == null || typeof e != "object") return;
4104
- const t = e, n = t.snapshot, r = (t.context ?? n?.context)?.publishRunId;
4105
- return typeof r == "string" && r.length > 0 ? r : void 0;
4106
- }
4107
- function kr(e, t) {
4108
- if (!e?.error) return {};
4109
- if (t !== "failed" && t !== "in_progress") return {};
4110
- const n = e.error, a = n != null ? (n instanceof Error ? n.message : String(n)).slice(0, Fr) : void 0, r = e.errorStep;
4111
- let s;
4112
- if (n instanceof Error && n.stack)
4113
- s = n.stack.slice(0, Ue);
4114
- else if (n != null && typeof n == "object")
4115
- try {
4116
- s = JSON.stringify(n).slice(0, Ue);
4117
- } catch {
4118
- s = String(n).slice(0, Ue);
4119
- }
4120
- else n != null && (s = String(n).slice(0, Ue));
4121
- return { errorMessage: a ?? void 0, errorStep: r, errorDetails: s };
4122
- }
4123
- const $r = he(({ sendBack: e, input: { persistedSnapshot: t, seedLocalId: n, triggerPublishDone: a } }) => {
4124
- Pe("savePublish seedLocalId", n);
4125
- const r = t;
4126
- Or(n, async () => {
4127
- const o = k.getAppDb();
4128
- if (!o) {
4129
- Pe("savePublish: DB not ready, skipping"), e({ type: "SAVE_PUBLISH_DONE", seedLocalId: n, triggerPublishDone: a });
4130
- return;
4131
- }
4132
- const c = await o.select().from(P).where(Kn(X(P.seedLocalId, n), X(P.status, "in_progress"))).orderBy(Ae(P.updatedAt)).limit(1), i = typeof t == "string" ? t : Nr(t), u = Br(r), d = Date.now(), p = kr(r.context, u);
4133
- if (c.length > 0) {
4134
- const l = c[0];
4135
- await o.update(P).set({
4136
- persistedSnapshot: i,
4137
- status: u,
4138
- updatedAt: d,
4139
- ...r.status === "done" && u !== "in_progress" ? { completedAt: d } : {},
4140
- ...p
4141
- }).where(X(P.id, l.id));
4142
- } else {
4143
- const l = _t(r);
4144
- if (l != null && u === "in_progress" && r.status !== "done") {
4145
- const A = (await o.select().from(P).where(X(P.seedLocalId, n)).orderBy(Ae(P.startedAt)).limit(1))[0];
4146
- if (A && (A.status === "completed" || A.status === "failed"))
4147
- try {
4148
- const g = JSON.parse(A.persistedSnapshot);
4149
- if (_t(g) === l) {
4150
- Pe(
4151
- "savePublish: skip stale insert — same publishRunId as latest terminal row",
4152
- n,
4153
- l
4154
- );
4155
- return;
4156
- }
4157
- } catch {
4158
- }
4159
- }
4160
- const m = r.context?.item, h = r.context?.modelName ?? m?.modelName ?? "", y = r.context?.schemaId ?? m?.schemaId;
4161
- await o.insert(P).values({
4162
- seedLocalId: n,
4163
- modelName: h,
4164
- schemaId: y ?? null,
4165
- status: u,
4166
- startedAt: d,
4167
- persistedSnapshot: i,
4168
- createdAt: d,
4169
- updatedAt: d,
4170
- ...p
4171
- });
4172
- }
4173
- }).then(() => {
4174
- e({ type: "SAVE_PUBLISH_DONE", seedLocalId: n, triggerPublishDone: a });
4175
- }).catch((o) => {
4176
- Pe("savePublish error", o), e({ type: "SAVE_PUBLISH_DONE", seedLocalId: n, triggerPublishDone: a });
4177
- });
4178
- });
4179
- function Hr(e) {
4180
- try {
4181
- return e.getPersistedSnapshot?.() ?? e.getSnapshot();
4182
- } catch {
4183
- const t = e.getSnapshot(), n = t.context;
4184
- if (!n?.item) return t;
4185
- const a = n.item;
4186
- return {
4187
- ...t,
4188
- context: {
4189
- ...n,
4190
- item: {
4191
- seedLocalId: a.seedLocalId,
4192
- modelName: a.modelName,
4193
- schemaId: a.schemaId
4194
- }
4195
- }
4196
- };
4197
- }
4198
- }
4199
- const Vr = T(({ context: e, event: t, spawn: n }) => {
4200
- const { publishProcesses: a } = e, { seedLocalId: r, publishProcess: s, triggerPublishDone: o } = t;
4201
- if (!s)
4202
- return e;
4203
- const c = new Map(a);
4204
- c.set(r, s);
4205
- const i = Hr(s);
4206
- return n($r, {
4207
- id: `savePublish_${r}_${Date.now()}`,
4208
- input: { persistedSnapshot: i, seedLocalId: r, triggerPublishDone: o }
4209
- }), { publishProcesses: c };
4210
- }), Wr = T(({ context: e, event: t }) => {
4211
- const { publishProcesses: n, subscriptions: a } = e, r = t.seedLocalId, s = a.get(r);
4212
- s && s.send({ type: "UNSUBSCRIBE" });
4213
- const o = new Map(n);
4214
- o.delete(r);
4215
- const c = new Map(a);
4216
- return c.delete(r), {
4217
- publishProcesses: o,
4218
- subscriptions: c
4219
- };
4220
- }), qr = T(({ context: e, event: t }) => {
4221
- const { subscriptions: n } = e, a = t.seedLocalId, r = new Map(n);
4222
- return r.delete(a), {
4223
- subscriptions: r
4224
- };
4225
- }), jr = 6e4, Gr = 2e3;
4226
- async function Yr(e) {
4227
- const t = Date.now() + e;
4228
- for (; Date.now() < t; ) {
4229
- if (k.PlatformClass && k.getAppDb()) return !0;
4230
- await new Promise((n) => setTimeout(n, Gr));
4231
- }
4232
- return !1;
4233
- }
4234
- function Jr(e) {
4235
- const t = e.value;
4236
- return typeof t == "string" ? t : t && typeof t == "object" ? Object.keys(t)[0] ?? "" : "";
4237
- }
4238
- function zr(e) {
4239
- const t = Jr(e);
4240
- if (t === "pollingForConfirmation" && (!e.context?.reimbursementTransactionId || !e.context?.requestResponse))
4241
- return !1;
4242
- if (t === "uploadingData") {
4243
- const n = e.context?.arweaveTransactions, a = e.context?.publishUploads;
4244
- if (!Array.isArray(n) || n.length === 0 || !Array.isArray(a)) return !1;
4245
- }
4246
- return !0;
4247
- }
4248
- const Zr = he(
4249
- ({ sendBack: e, input: { context: t } }) => {
4250
- (async () => {
4251
- const a = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
4252
- if (!await Yr(jr))
4253
- return e({ type: "RESTORE_FROM_DB_DONE", publishProcesses: a, subscriptions: r }), { newPublishProcesses: a, newSubscriptions: r };
4254
- const o = k.getAppDb();
4255
- if (!o)
4256
- return e({ type: "RESTORE_FROM_DB_DONE", publishProcesses: a, subscriptions: r }), { newPublishProcesses: a, newSubscriptions: r };
4257
- const c = await o.select().from(P).where(X(P.status, "in_progress")), i = /* @__PURE__ */ new Map(), u = [...c].sort(
4258
- (p, l) => (l.updatedAt ?? l.createdAt ?? 0) - (p.updatedAt ?? p.createdAt ?? 0)
4259
- );
4260
- for (const p of u)
4261
- i.has(p.seedLocalId) || i.set(p.seedLocalId, p);
4262
- const d = Array.from(i.values());
4263
- for (const p of d) {
4264
- let l;
4265
- try {
4266
- l = JSON.parse(p.persistedSnapshot);
4267
- } catch {
4268
- continue;
4269
- }
4270
- if (l.status === "done") continue;
4271
- const m = l.context?.item?.seedLocalId ?? p.seedLocalId;
4272
- if (!m || !zr(l)) continue;
4273
- l.context = l.context ?? {}, l.context.item = {
4274
- ...l.context.item,
4275
- seedLocalId: m,
4276
- modelName: l.context.item?.modelName ?? l.context.modelName ?? p.modelName ?? "",
4277
- schemaId: l.context.item?.schemaId ?? l.context.schemaId ?? p.schemaId ?? void 0
4278
- };
4279
- const h = Xe(on, {
4280
- snapshot: l,
4281
- input: void 0
4282
- }), y = Xe(dn, {
4283
- input: {
4284
- publishProcess: h,
4285
- seedLocalId: m
4286
- }
4287
- });
4288
- a.set(m, h), r.set(m, y), h.start(), y.start();
4289
- }
4290
- return { newPublishProcesses: a, newSubscriptions: r };
4291
- })().then((a) => {
4292
- if (!a) return;
4293
- const { newPublishProcesses: r, newSubscriptions: s } = a;
4294
- e({
4295
- type: "RESTORE_FROM_DB_DONE",
4296
- publishProcesses: r,
4297
- subscriptions: s
4298
- });
4299
- });
4300
- }
4301
- ), ln = Z("seedProtocol:PublishManager:index"), Kr = Nt({
4302
- types: {
4303
- context: {},
4304
- input: {},
4305
- events: {}
4306
- },
4307
- actors: {
4308
- restoreFromDb: Zr
4309
- },
4310
- actions: {
4311
- assignRestoreFromDb: Pr,
4312
- createPublish: Dr,
4313
- addSubscription: Mr,
4314
- requestSavePublish: Vr,
4315
- publishDone: Wr,
4316
- removeSubscription: qr,
4317
- retryAttestations: xr,
4318
- stopPublish: Cr,
4319
- stopAll: _r,
4320
- query: Lr
4321
- }
4322
- }).createMachine({
4323
- id: "publishManager",
4324
- initial: "restoreFromDb",
4325
- context: {
4326
- publishProcesses: /* @__PURE__ */ new Map(),
4327
- subscriptions: /* @__PURE__ */ new Map()
4328
- },
4329
- states: {
4330
- restoreFromDb: {
4331
- on: {
4332
- RESTORE_FROM_DB_DONE: {
4333
- target: "active",
4334
- actions: ["assignRestoreFromDb"]
4335
- }
4336
- },
4337
- invoke: {
4338
- src: "restoreFromDb",
4339
- input: ({ context: e }) => ({ context: e })
4340
- }
4341
- },
4342
- active: {
4343
- on: {
4344
- CREATE_PUBLISH: {
4345
- actions: ["createPublish"]
4346
- },
4347
- ADD_SUBSCRIPTION: {
4348
- actions: ["addSubscription"]
4349
- },
4350
- REQUEST_SAVE_PUBLISH: {
4351
- actions: ["requestSavePublish"]
4352
- },
4353
- SAVE_PUBLISH_DONE: [
4354
- {
4355
- guard: ({ event: e }) => e.triggerPublishDone === !0,
4356
- actions: ["publishDone"]
4357
- }
4358
- ],
4359
- PUBLISH_DONE: {
4360
- actions: ["publishDone"]
4361
- },
4362
- REMOVE_SUBSCRIPTION: {
4363
- actions: ["removeSubscription"]
4364
- },
4365
- RETRY_ATTESTATIONS: {
4366
- actions: ["retryAttestations"]
4367
- },
4368
- STOP_PUBLISH: {
4369
- actions: ["stopPublish"]
4370
- },
4371
- QUERY: {
4372
- actions: ["query"]
4373
- },
4374
- STOP_ALL: {
4375
- actions: ["stopAll"]
4376
- }
4377
- }
4378
- }
4379
- }
4380
- }), O = Xe(Kr, {
4381
- input: {
4382
- publishProcesses: /* @__PURE__ */ new Map(),
4383
- subscriptions: /* @__PURE__ */ new Map()
4384
- }
4385
- });
4386
- Ur({
4387
- savePublish: (e, t, n) => {
4388
- O.send({
4389
- type: "REQUEST_SAVE_PUBLISH",
4390
- seedLocalId: e,
4391
- publishProcess: t,
4392
- triggerPublishDone: n?.triggerPublishDone
4393
- });
4394
- },
4395
- onPublishDone: (e) => {
4396
- O.send({ type: "PUBLISH_DONE", seedLocalId: e });
4397
- },
4398
- removeSubscription: (e) => {
4399
- O.send({ type: "REMOVE_SUBSCRIPTION", seedLocalId: e });
4400
- }
4401
- });
4402
- const Xr = O.subscribe((e) => {
4403
- ln("PublishManager snapshot:", e);
4404
- });
4405
- typeof document < "u" && (O.start(), window.addEventListener("load", () => {
4406
- ln("PublishManager started");
4407
- }), window.addEventListener("beforeunload", () => {
4408
- Xr.unsubscribe(), O.stop();
4409
- }));
4410
- const tt = {
4411
- getService: () => O,
4412
- createPublish: (e, t, n, a) => O.send({ type: "CREATE_PUBLISH", item: e, address: t, account: n, options: a }),
4413
- retryAttestations: (e, t) => O.send({ type: "RETRY_ATTESTATIONS", seedLocalId: e, account: t }),
4414
- stopPublish: (e) => O.send({ type: "STOP_PUBLISH", seedLocalId: e }),
4415
- query: (e) => O.send({ type: "QUERY", seedLocalId: e }),
4416
- stopAll: () => O.send({ type: "STOP_ALL" }),
4417
- getPublish: (e) => O.getSnapshot().context.publishProcesses.get(e),
4418
- savePublish: (e, t) => O.send({ type: "REQUEST_SAVE_PUBLISH", seedLocalId: e, publishProcess: t }),
4419
- addSubscription: (e, t) => O.send({ type: "ADD_SUBSCRIPTION", seedLocalId: e, newSubscription: t }),
4420
- removeSubscription: (e) => O.send({ type: "REMOVE_SUBSCRIPTION", seedLocalId: e })
4421
- };
4422
- function To(e) {
4423
- return e === "creatingAttestationsDirectToEas" ? "creatingAttestations" : e;
4424
- }
4425
- function Qr(e, t, n) {
4426
- return e != null ? n : t?.status === "completed" ? L.SUCCESS : t?.status === "failed" ? L.FAILURE : n;
4427
- }
4428
- function es(e) {
4429
- if (e) {
4430
- if (e.status === "failed") return L.FAILURE;
4431
- if (e.status === "completed") return L.SUCCESS;
4432
- if (e.completedAt != null) {
4433
- try {
4434
- const t = JSON.parse(e.persistedSnapshot);
4435
- if (t.status === "done" && t.value === L.FAILURE)
4436
- return L.FAILURE;
4437
- } catch {
4438
- }
4439
- return L.SUCCESS;
4440
- }
4441
- try {
4442
- const t = JSON.parse(e.persistedSnapshot);
4443
- if (t.status === "done") {
4444
- if (t.value === L.SUCCESS) return L.SUCCESS;
4445
- if (t.value === L.FAILURE) return L.FAILURE;
4446
- }
4447
- if (typeof t.value == "string") return t.value;
4448
- } catch {
4449
- return;
4450
- }
4451
- }
4452
- }
4453
- function ts(e) {
4454
- return !e || e.status !== "done" ? !1 : e.value === L.SUCCESS || e.value === L.FAILURE;
4455
- }
4456
- function ns(e) {
4457
- const t = tt.getService(), n = ea(t, (m) => m?.context?.publishProcesses?.get(e) ?? null), a = Bt(null);
4458
- te(() => {
4459
- a.current = null;
4460
- }, [e]);
4461
- const [r, s] = be(void 0), [o, c] = be(null), i = k.getAppDb(), d = Re(
4462
- e && i ? i.select().from(P).where(X(P.seedLocalId, e)).orderBy(Ae(P.startedAt)).limit(1) : null
4463
- )?.[0], p = d?.status, l = $n(() => {
4464
- if (n != null)
4465
- return r;
4466
- if (o === "success" || o === "failure")
4467
- return o;
4468
- const m = es(d);
4469
- return m === L.SUCCESS || m === L.FAILURE ? m : Qr(
4470
- n,
4471
- p != null ? { status: p } : void 0,
4472
- r
4473
- );
4474
- }, [n, p, r, o, d]);
4475
- return te(() => {
4476
- c(null);
4477
- }, [e]), te(() => {
4478
- n == null && (p === "completed" ? c("success") : p === "failed" && c("failure"));
4479
- }, [p, n]), te(() => {
4480
- n != null && c(null);
4481
- }, [n]), te(() => {
4482
- if (!n) {
4483
- const y = a.current;
4484
- ts(y) ? (s(y.value), y.value === L.SUCCESS ? c("success") : y.value === L.FAILURE && c("failure")) : s(void 0);
4485
- return;
4486
- }
4487
- const m = n.getSnapshot();
4488
- a.current = { value: m?.value, status: m.status }, s(m?.value);
4489
- const h = n.subscribe((y) => {
4490
- a.current = { value: y?.value, status: y?.status }, s(y?.value);
4491
- });
4492
- return () => {
4493
- h.unsubscribe();
4494
- };
4495
- }, [n, e]), {
4496
- publishProcess: n ?? null,
4497
- value: l
4498
- };
4499
- }
4500
- function Do(e) {
4501
- const [t, n] = be(!0);
4502
- return te(() => {
4503
- if (!e) {
4504
- n(!1);
4505
- return;
4506
- }
4507
- Mt(e).then(n).catch(() => n(!1));
4508
- }, [e?.seedLocalId]), t;
4509
- }
4510
- function xo(e) {
4511
- const { publishProcess: t, value: n } = ns(e ?? ""), a = k.getAppDb(), s = Re(
4512
- e && a ? a.select().from(P).where(X(P.seedLocalId, e)).orderBy(Ae(P.startedAt)).limit(1) : null
4513
- )?.[0], o = !!t || s?.status === "in_progress";
4514
- return {
4515
- latestRecord: s,
4516
- publishProcess: t,
4517
- isActive: o,
4518
- publishValue: n
4519
- };
4520
- }
4521
- function as() {
4522
- const e = k.getAppDb();
4523
- return Re(
4524
- e ? e.select().from(P).orderBy(Ae(P.startedAt)) : null
4525
- );
4526
- }
4527
- function Co() {
4528
- const e = as();
4529
- if (e !== void 0)
4530
- return e.filter((t) => t.status !== "in_progress").length;
4531
- }
4532
- function Ro(e) {
4533
- const t = k.getAppDb(), n = Re(
4534
- e != null && t ? t.select().from(P).where(X(P.id, e)).limit(1) : null
4535
- ), a = n === void 0;
4536
- return { record: n && n.length > 0 ? n[0] : null, isLoading: a };
4537
- }
4538
- async function _o() {
4539
- const e = k.getAppDb();
4540
- e && await e.delete(P).where(Xn(P.status, ["in_progress"]));
4541
- }
4542
- async function Lo() {
4543
- const e = k.getAppDb();
4544
- e && await e.delete(P);
4545
- }
4546
- async function Mo() {
4547
- const e = k.getAppDb();
4548
- e && await e.delete(Rn);
4549
- }
4550
- async function Oo(e) {
4551
- const t = k.getAppDb();
4552
- t && await t.delete(P).where(X(P.seedLocalId, e));
4553
- }
4554
- async function Bo(e) {
4555
- const t = k.getAppDb();
4556
- t && await t.delete(P).where(X(P.id, e));
4557
- }
4558
- async function Fo(e) {
4559
- if (e.length === 0) return;
4560
- const t = k.getAppDb();
4561
- t && await t.delete(P).where(Qn(P.id, e));
4562
- }
4563
- function No(e) {
4564
- try {
4565
- return (JSON.parse(e.persistedSnapshot).context?.arweaveTransactions ?? []).map((a) => a.transaction?.id).filter((a) => typeof a == "string");
4566
- } catch {
4567
- return [];
4568
- }
4569
- }
4570
- function ko(e) {
4571
- try {
4572
- return JSON.parse(e.persistedSnapshot).context?.easPayload ?? void 0;
4573
- } catch {
4574
- return;
4575
- }
4576
- }
4577
- function $o(e) {
4578
- const t = /* @__PURE__ */ new Map();
4579
- for (let n = 0; n < e.length; n++) {
4580
- const a = e[n]?.localId;
4581
- a != null && t.set(a, BigInt(n));
4582
- }
4583
- return e.map((n, a) => {
4584
- const r = (n.propertiesToUpdate ?? []).map((c) => {
4585
- const i = c.publishLocalId, u = i != null ? t.get(i) : void 0;
4586
- if (i != null && i !== "" && u === void 0)
4587
- throw new Error(
4588
- `publishLocalId "${i}" not found in payload (valid localIds: ${Array.from(t.keys()).join(", ")})`
4589
- );
4590
- const { publishLocalId: d, ...p } = c;
4591
- return {
4592
- ...p,
4593
- publishLocalIdIndex: u ?? BigInt(0)
4594
- };
4595
- }), { localId: s, ...o } = n;
4596
- return {
4597
- ...o,
4598
- localIdIndex: BigInt(a),
4599
- propertiesToUpdate: r
4600
- };
4601
- });
4602
- }
4603
- const rs = "A connected wallet is required for publishing with the modular executor. Connect your wallet and try again.";
4604
- async function Ho(e, t, n, a) {
4605
- const r = C(), s = await n();
4606
- if (!s || !s.trim())
4607
- return { outcome: "no_address" };
4608
- if (r.useModularExecutor) {
4609
- if (!t)
4610
- return {
4611
- outcome: "managed_not_ready",
4612
- error: new K(rs, "MANAGED_ACCOUNT_UNAVAILABLE")
4613
- };
4614
- const c = await nn();
4615
- if (!c.ok)
4616
- return { outcome: "managed_not_ready", error: c.error };
4617
- const i = c.managedAddress, u = await ft(t ?? null);
4618
- return "needsDeploy" in u ? { outcome: "needs_deploy" } : (tt.createPublish(e, i, u.account, {
4619
- dataItemSigner: u.account,
4620
- ...a
4621
- }), { outcome: "started" });
4622
- }
4623
- const o = await ft(t ?? null);
4624
- return "address" in o ? (tt.createPublish(e, o.address, o.account, {
4625
- dataItemSigner: o.account,
4626
- ...a
4627
- }), { outcome: "started" }) : { outcome: "needs_deploy" };
4628
- }
1
+ import { A as e, C as t, Y as r, M as i, f as n, P as o, d as l, aC as u, a4 as c, _ as d, D as P, q as g, r as h, o as A, c as b, aq as m, a7 as p, aK as v, aL as E, a8 as y, v as I, w as C, t as S, Z as M, a9 as f, au as F, e as R, K as W, L as w, J as D, ad as B, aD as U, aE as x, ae as V, af as O, ag as T, ah as z, ai as N, B as L, x as q, Q as H, a0 as j, $ as k, F as G, av as J, y as K, aj as Q, U as X, a1 as Y, ar as Z, a2 as _, ak as $, al as aa, G as sa, V as ea, a3 as ta, i as ra, ax as ia, a5 as na, am as oa, an as la, a as ua, b as ca, W as da, as as Pa, ao as ga, aa as ha, aM as Aa, aN as ba, ay as ma, aF as pa, aG as va, aH as Ea, aw as ya, ab as Ia, aO as Ca, p as Sa, aP as Ma, H as fa, X as Fa, O as Ra, ac as Wa, aI as wa, aQ as Da, az as Ba, aA as Ua, a6 as xa, s as Va, at as Oa, aR as Ta, I as za, N as Na, T as La, z as qa, j as Ha, k as ja, S as ka, u as Ga, h as Ja, n as Ka, l as Qa, m as Xa, aB as Ya, E as Za, ap as _a, R as $a, aJ as as } from "./index-BfABV7U1.js";
2
+ import { SeedProvider as es } from "@seedprotocol/react";
4629
3
  export {
4630
- jt as AttestationVerificationError,
4631
- Rs as ConnectButton,
4632
- Ts as ExternalWalletsForDeploy,
4633
- K as ManagedAccountPublishError,
4634
- tt as PublishManager,
4635
- _s as PublishModeButtons,
4636
- Cs as PublishProvider,
4637
- qo as SeedProvider,
4638
- po as addDeposit,
4639
- Ls as adminUpdatedEvent,
4640
- Ds as appMetadata,
4641
- Lo as clearAllPublishProcesses,
4642
- Mo as clearAllUploadProcesses,
4643
- _o as clearCompletedPublishProcesses,
4644
- xs as configurePublish,
4645
- Qs as contractURI,
4646
- Bs as contractURIUpdatedEvent,
4647
- Ao as createSeed,
4648
- vo as createVersion,
4649
- Ca as createdAttestationEvent,
4650
- Bo as deletePublishProcessById,
4651
- Fo as deletePublishProcessesByIds,
4652
- Oo as deletePublishProcessesForSeed,
4653
- ia as deploySmartWalletContract,
4654
- Fs as eIP712DomainChangedEvent,
4655
- ao as eip712Domain,
4656
- Me as ensureEasSchemasForItem,
4657
- Qe as ensureExecutorModuleInstalled,
4658
- St as ensureManagedAccountReady,
4659
- Ho as ensureSmartWalletThenPublish,
4660
- $s as entryPoint,
4661
- mo as execute,
4662
- fo as executeBatch,
4663
- Hs as factory,
4664
- Vs as getAllActiveSigners,
4665
- Ws as getAllAdmins,
4666
- qs as getAllExtensions,
4667
- js as getAllSigners,
4668
- Ce as getArweave,
4669
- No as getArweaveTransactionIds,
4670
- R as getClient,
4671
- ca as getConnectedAccount,
4672
- rt as getConnectedManagedAccountAddress,
4673
- To as getDisplayStepId,
4674
- ro as getEas,
4675
- ko as getEasPayload,
4676
- Gs as getImplementationForFunction,
4677
- Vt as getManagedAccountFactoryContract,
4678
- Le as getManagedAccountWallet,
4679
- eo as getMessageHash,
4680
- st as getModularAccountWallet,
4681
- Ys as getNonce,
4682
- Js as getPermissionsForSigner,
4683
- es as getPublishMachineValueForUi,
4684
- Wt as getSmartWalletAddressForAdmin,
4685
- da as getWalletsForConnectButton,
4686
- qt as initPublish,
4687
- oo as initialize,
4688
- Ms as initializedEvent,
4689
- zs as isActiveSigner,
4690
- Zs as isAdmin,
4691
- gt as isManagedAccountPublishError,
4692
- Aa as isRouterNonModularCoreAccountError,
4693
- xe as isSmartWalletDeployed,
4694
- to as isValidSignature,
4695
- Ks as isValidSigner,
4696
- Ns as logEvent,
4697
- wt as multiPublish,
4698
- So as multiPublishWithIntegerIds,
4699
- io as multicall,
4700
- ho as onERC1155BatchReceived,
4701
- yo as onERC1155Received,
4702
- go as onERC721Received,
4703
- so as owner,
4704
- ks as ownershipTransferredEvent,
4705
- Eo as publish,
4706
- on as publishMachine,
4707
- Io as renounceOwnership,
4708
- Qr as resolvePublishDisplayValue,
4709
- ft as resolveSmartWalletForPublish,
4710
- nn as runModularExecutorPublishPrep,
4711
- Ra as seedPublishedEvent,
4712
- wo as setContractURI,
4713
- Po as setEas,
4714
- co as setEntrypointOverride,
4715
- lo as setPermissionsForSigner,
4716
- Os as signerPermissionsUpdatedEvent,
4717
- ba as stringifyUnderlyingCause,
4718
- no as supportsInterface,
4719
- Uo as transferOwnership,
4720
- $o as transformPayloadToIntegerIds,
4721
- sr as tryDeployManagedAccount,
4722
- Us as useActiveSmartWalletContract,
4723
- Do as useCanPublishItem,
4724
- xo as useItemPublishStatus,
4725
- Ps as useLocalWalletAccount,
4726
- va as usePublishConfig,
4727
- ns as usePublishProcess,
4728
- Ro as usePublishProcessById,
4729
- as as usePublishProcesses,
4730
- Co as usePublishProcessesNonActiveCount,
4731
- uo as validateUserOp,
4732
- Wa as verifyDataItem,
4733
- Xs as verifySignerPermissionRequest,
4734
- Is as wallets,
4735
- bo as withdrawDepositTo
4
+ e as AttestationVerificationError,
5
+ t as ConnectButton,
6
+ r as ExternalWalletsForDeploy,
7
+ i as ManagedAccountPublishError,
8
+ n as PublishManager,
9
+ o as PublishModeButtons,
10
+ l as PublishProvider,
11
+ es as SeedProvider,
12
+ u as addDeposit,
13
+ c as adminUpdatedEvent,
14
+ d as appMetadata,
15
+ P as buildPublishAnchorBytes,
16
+ g as clearAllPublishProcesses,
17
+ h as clearAllUploadProcesses,
18
+ A as clearCompletedPublishProcesses,
19
+ b as configurePublish,
20
+ m as contractURI,
21
+ p as contractURIUpdatedEvent,
22
+ v as createSeed,
23
+ E as createVersion,
24
+ y as createdAttestationEvent,
25
+ I as deletePublishProcessById,
26
+ C as deletePublishProcessesByIds,
27
+ S as deletePublishProcessesForSeed,
28
+ M as deploySmartWalletContract,
29
+ f as eIP712DomainChangedEvent,
30
+ F as eip712Domain,
31
+ R as ensureEasSchemasForItem,
32
+ W as ensureExecutorModuleInstalled,
33
+ w as ensureManagedAccountReady,
34
+ D as ensureSmartWalletThenPublish,
35
+ B as entryPoint,
36
+ U as execute,
37
+ x as executeBatch,
38
+ V as factory,
39
+ O as getAllActiveSigners,
40
+ T as getAllAdmins,
41
+ z as getAllExtensions,
42
+ N as getAllSigners,
43
+ L as getArweave,
44
+ q as getArweaveTransactionIds,
45
+ H as getClient,
46
+ j as getConnectedAccount,
47
+ k as getConnectedManagedAccountAddress,
48
+ G as getDisplayStepId,
49
+ J as getEas,
50
+ K as getEasPayload,
51
+ Q as getImplementationForFunction,
52
+ X as getManagedAccountFactoryContract,
53
+ Y as getManagedAccountWallet,
54
+ Z as getMessageHash,
55
+ _ as getModularAccountWallet,
56
+ $ as getNonce,
57
+ aa as getPermissionsForSigner,
58
+ sa as getPublishMachineValueForUi,
59
+ ea as getSmartWalletAddressForAdmin,
60
+ ta as getWalletsForConnectButton,
61
+ ra as initPublish,
62
+ ia as initialize,
63
+ na as initializedEvent,
64
+ oa as isActiveSigner,
65
+ la as isAdmin,
66
+ ua as isManagedAccountPublishError,
67
+ ca as isRouterNonModularCoreAccountError,
68
+ da as isSmartWalletDeployed,
69
+ Pa as isValidSignature,
70
+ ga as isValidSigner,
71
+ ha as logEvent,
72
+ Aa as multiPublish,
73
+ ba as multiPublishWithIntegerIds,
74
+ ma as multicall,
75
+ pa as onERC1155BatchReceived,
76
+ va as onERC1155Received,
77
+ Ea as onERC721Received,
78
+ ya as owner,
79
+ Ia as ownershipTransferredEvent,
80
+ Ca as publish,
81
+ Sa as publishMachine,
82
+ Ma as renounceOwnership,
83
+ fa as resolvePublishDisplayValue,
84
+ Fa as resolveSmartWalletForPublish,
85
+ Ra as runModularExecutorPublishPrep,
86
+ Wa as seedPublishedEvent,
87
+ wa as setContractURI,
88
+ Da as setEas,
89
+ Ba as setEntrypointOverride,
90
+ Ua as setPermissionsForSigner,
91
+ xa as signerPermissionsUpdatedEvent,
92
+ Va as stringifyUnderlyingCause,
93
+ Oa as supportsInterface,
94
+ Ta as transferOwnership,
95
+ za as transformPayloadToIntegerIds,
96
+ Na as tryDeployManagedAccount,
97
+ La as useActiveSmartWalletContract,
98
+ qa as useArweaveL1Finalize,
99
+ Ha as useCanPublishItem,
100
+ ja as useItemPublishStatus,
101
+ ka as useLocalWalletAccount,
102
+ Ga as usePublishConfig,
103
+ Ja as usePublishProcess,
104
+ Ka as usePublishProcessById,
105
+ Qa as usePublishProcesses,
106
+ Xa as usePublishProcessesNonActiveCount,
107
+ Ya as validateUserOp,
108
+ Za as verifyDataItem,
109
+ _a as verifySignerPermissionRequest,
110
+ $a as wallets,
111
+ as as withdrawDepositTo
4736
112
  };
4737
113
  //# sourceMappingURL=index.js.map