@seedprotocol/publish 0.4.30 → 0.4.31

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 (61) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +6 -2
  3. package/dist/config-B4_sw4Ey.js +442 -0
  4. package/dist/config-B4_sw4Ey.js.map +1 -0
  5. package/dist/config-BcAZza3G.js +432 -0
  6. package/dist/config-BcAZza3G.js.map +1 -0
  7. package/dist/config-BtwOzQP0.js +471 -0
  8. package/dist/config-BtwOzQP0.js.map +1 -0
  9. package/dist/config-CJkIBxtE.js +432 -0
  10. package/dist/config-CJkIBxtE.js.map +1 -0
  11. package/dist/config-DBOagqZ1.js +432 -0
  12. package/dist/config-DBOagqZ1.js.map +1 -0
  13. package/dist/config-Ds5V_P5K.js +557 -0
  14. package/dist/config-Ds5V_P5K.js.map +1 -0
  15. package/dist/config-MpeHT6rf.js +535 -0
  16. package/dist/config-MpeHT6rf.js.map +1 -0
  17. package/dist/config-_R8orn1f.js +454 -0
  18. package/dist/config-_R8orn1f.js.map +1 -0
  19. package/dist/config.d.ts +8 -0
  20. package/dist/config.d.ts.map +1 -1
  21. package/dist/errors.d.ts +3 -2
  22. package/dist/errors.d.ts.map +1 -1
  23. package/dist/helpers/ensureEip7702ModularAccountReady.d.ts.map +1 -1
  24. package/dist/helpers/ensureExecutorModule.d.ts +2 -1
  25. package/dist/helpers/ensureExecutorModule.d.ts.map +1 -1
  26. package/dist/helpers/ensureManagedAccountEasConfigured.d.ts +2 -1
  27. package/dist/helpers/ensureManagedAccountEasConfigured.d.ts.map +1 -1
  28. package/dist/helpers/ensureManagedAccountReady.d.ts +3 -2
  29. package/dist/helpers/ensureManagedAccountReady.d.ts.map +1 -1
  30. package/dist/helpers/ensureManagedSignerSessionKey.d.ts +9 -0
  31. package/dist/helpers/ensureManagedSignerSessionKey.d.ts.map +1 -0
  32. package/dist/helpers/ensureModularPublishBootstrap.d.ts +7 -0
  33. package/dist/helpers/ensureModularPublishBootstrap.d.ts.map +1 -0
  34. package/dist/helpers/ensureSmartWalletThenPublish.d.ts +4 -3
  35. package/dist/helpers/ensureSmartWalletThenPublish.d.ts.map +1 -1
  36. package/dist/helpers/thirdweb.d.ts +18 -1
  37. package/dist/helpers/thirdweb.d.ts.map +1 -1
  38. package/dist/index.d.ts +2 -0
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +5334 -5883
  41. package/dist/index.js.map +1 -1
  42. package/dist/react/ConnectButton.d.ts.map +1 -1
  43. package/dist/services/publish/actors/createAttestations.d.ts.map +1 -1
  44. package/dist/services/publish/index.d.ts.map +1 -1
  45. package/dist/worker-BCxmY47A.js +69 -0
  46. package/dist/worker-BCxmY47A.js.map +1 -0
  47. package/dist/worker-CaUA-aJd.js +69 -0
  48. package/dist/worker-CaUA-aJd.js.map +1 -0
  49. package/dist/worker-D9Pq_HWb.js +69 -0
  50. package/dist/worker-D9Pq_HWb.js.map +1 -0
  51. package/dist/worker-DFRFhbL9.js +69 -0
  52. package/dist/worker-DFRFhbL9.js.map +1 -0
  53. package/dist/worker-DFc2aG0v.js +69 -0
  54. package/dist/worker-DFc2aG0v.js.map +1 -0
  55. package/dist/worker-DL5ecOQf.js +69 -0
  56. package/dist/worker-DL5ecOQf.js.map +1 -0
  57. package/dist/worker-OeOnFu0v.js +69 -0
  58. package/dist/worker-OeOnFu0v.js.map +1 -0
  59. package/dist/worker-TgcK7QlX.js +69 -0
  60. package/dist/worker-TgcK7QlX.js.map +1 -0
  61. package/package.json +6 -6
@@ -0,0 +1,471 @@
1
+ import { DEFAULT_ARWEAVE_GRAPHQL_URL as e, VERSION_SCHEMA_UID_OPTIMISM_SEPOLIA as t, getAttesterForSeed as n, getGetAdditionalSyncAddresses as r, getMetadataAttestationUidsForSeedUid as i, getVersionsForSeedUid as a, isValidEasAttestationUid as o, setAdditionalSyncAddresses as s, setGetPublisherForNewSeeds as c, setRevokeExecutor as l, updateSeedRevokedAt as u } from "@seedprotocol/sdk";
2
+ import { createThirdwebClient as d, deploySmartAccount as f, getContract as p, parseEventLogs as m, prepareContractCall as h, prepareEvent as g, readContract as _, sendTransaction as v, waitForReceipt as ee } from "thirdweb";
3
+ import { createWallet as y, inAppWallet as b } from "thirdweb/wallets";
4
+ import { useActiveAccount as te } from "thirdweb/react";
5
+ import { isContractDeployed as x } from "thirdweb/utils";
6
+ import { useEffect as S, useRef as ne, useState as C } from "react";
7
+ import { optimismSepolia as w } from "thirdweb/chains";
8
+ import re from "debug";
9
+ import { encodeAbiParameters as ie } from "viem";
10
+ //#region src/helpers/constants.ts
11
+ var ae = "0x4200000000000000000000000000000000000020", T = "0x44d562ac1d7cd77e232978687fea027ace48f719cf1d58c7888e509663bb87fc", E = "0x76f47d88bfaf670f5208911181fcdc0e160cb16d", D = "0x4200000000000000000000000000000000000021", O = "0xcd8c945872df8e664e55cf8885c85ea3ea8f2148", oe = O, se = {
12
+ SUCCESS: "success",
13
+ FAILURE: "failure"
14
+ }, ce = [
15
+ "pollingForConfirmation",
16
+ "uploadingData",
17
+ "uploadingViaBundler",
18
+ "uploadingViaBundlerPhase2"
19
+ ], le = 3e4;
20
+ //#endregion
21
+ //#region src/helpers/thirdweb/11155420/0x76f47d88bfaf670f5208911181fcdc0e160cb16d.ts
22
+ async function ue(e) {
23
+ return _({
24
+ contract: e.contract,
25
+ method: [
26
+ "0x8878ed33",
27
+ [{
28
+ type: "address",
29
+ name: "_adminSigner"
30
+ }, {
31
+ type: "bytes",
32
+ name: "_data"
33
+ }],
34
+ [{ type: "address" }]
35
+ ],
36
+ params: [e.adminSigner, e.data]
37
+ });
38
+ }
39
+ function de(e) {
40
+ return h({
41
+ contract: e.contract,
42
+ method: [
43
+ "0xd8fd8f44",
44
+ [{
45
+ type: "address",
46
+ name: "_admin"
47
+ }, {
48
+ type: "bytes",
49
+ name: "_data"
50
+ }],
51
+ [{ type: "address" }]
52
+ ],
53
+ params: [e.admin, e.data]
54
+ });
55
+ }
56
+ //#endregion
57
+ //#region src/helpers/thirdweb.ts
58
+ var fe = re("permaPress:helpers:thirdweb"), k = "seedProtocol:inAppPublish:", A = null;
59
+ function j() {
60
+ return A ||= {
61
+ getItem: async (e) => typeof window > "u" ? null : localStorage.getItem(k + e),
62
+ setItem: async (e, t) => {
63
+ typeof window > "u" || localStorage.setItem(k + e, t);
64
+ },
65
+ removeItem: async (e) => {
66
+ typeof window > "u" || localStorage.removeItem(k + e);
67
+ }
68
+ }, A;
69
+ }
70
+ var M = null;
71
+ function N() {
72
+ if (!M) {
73
+ let { thirdwebClientId: e } = $();
74
+ M = d({ clientId: e });
75
+ }
76
+ return M;
77
+ }
78
+ var pe = [y("io.metamask")], P = () => {
79
+ let [e, t] = C(null);
80
+ return y("io.metamask"), ne(!1), S(() => {}, []), e;
81
+ }, F = () => {
82
+ let e = te(), [t, n] = C(null);
83
+ return S(() => {
84
+ !e || !e.address || n(p({
85
+ client: N(),
86
+ chain: w,
87
+ address: e.address
88
+ }));
89
+ }, [e]), t;
90
+ }, I = () => {
91
+ let { thirdwebAccountFactoryAddress: e } = $();
92
+ return p({
93
+ client: N(),
94
+ chain: w,
95
+ address: e
96
+ });
97
+ };
98
+ async function L(e, t = "0x") {
99
+ return ue({
100
+ contract: I(),
101
+ adminSigner: e,
102
+ data: t
103
+ });
104
+ }
105
+ async function R(e) {
106
+ return x(p({
107
+ client: N(),
108
+ chain: w,
109
+ address: e
110
+ }));
111
+ }
112
+ var z = 5, B = 6e3;
113
+ async function me(e, t = z, n = B) {
114
+ for (let r = 0; r < t; r++) {
115
+ if (await R(e)) return !0;
116
+ r < t - 1 && await new Promise((e) => {
117
+ setTimeout(e, n);
118
+ });
119
+ }
120
+ return !1;
121
+ }
122
+ async function he(e) {
123
+ if (!e) return { needsDeploy: !0 };
124
+ if (await R(e.address)) return {
125
+ address: e.address,
126
+ account: e
127
+ };
128
+ let t = await L(e.address);
129
+ return await R(t) ? {
130
+ address: t,
131
+ account: e
132
+ } : { needsDeploy: !0 };
133
+ }
134
+ var ge = [y("io.metamask"), y("me.rainbow")], _e = async (e) => {
135
+ let t = p({
136
+ client: N(),
137
+ chain: w,
138
+ address: e.address
139
+ }), n = await f({
140
+ smartAccount: e,
141
+ chain: w,
142
+ client: N(),
143
+ accountContract: t
144
+ });
145
+ return fe("deploySmartAccount result:", n), n;
146
+ };
147
+ async function ve(e) {
148
+ let t = de({
149
+ contract: I(),
150
+ admin: e.adminAddress,
151
+ data: e.data ?? "0x"
152
+ });
153
+ await v({
154
+ account: e.signingAccount,
155
+ transaction: t
156
+ });
157
+ }
158
+ var ye = {
159
+ name: "Seed Protocol",
160
+ description: "Seed Protocol",
161
+ url: "https://seedprotocol.io"
162
+ };
163
+ async function V(e = w) {
164
+ let t = W();
165
+ await t.autoConnect({
166
+ client: N(),
167
+ chain: e
168
+ });
169
+ let n = t.getAccount();
170
+ if (!n) throw Error("Failed to get managed account");
171
+ return n.address;
172
+ }
173
+ async function H() {
174
+ try {
175
+ let e = K();
176
+ return await e.autoConnect({
177
+ client: N(),
178
+ chain: w
179
+ }), e.getAccount() ?? null;
180
+ } catch {
181
+ return null;
182
+ }
183
+ }
184
+ async function be() {
185
+ return H();
186
+ }
187
+ var U = null, W = () => (U ||= b({
188
+ storage: j(),
189
+ auth: { options: [
190
+ "farcaster",
191
+ "email",
192
+ "passkey",
193
+ "phone"
194
+ ] },
195
+ executionMode: {
196
+ mode: "EIP4337",
197
+ smartAccount: {
198
+ chain: w,
199
+ factoryAddress: E,
200
+ gasless: !0
201
+ }
202
+ }
203
+ }), U), G = null, K = () => (G ||= b({
204
+ storage: j(),
205
+ auth: { options: [
206
+ "farcaster",
207
+ "email",
208
+ "passkey",
209
+ "phone"
210
+ ] },
211
+ executionMode: {
212
+ mode: "EIP7702",
213
+ sponsorGas: !0
214
+ }
215
+ }), G), q = null, xe = () => (q ||= $().useModularExecutor ? [K()] : [W()], q), Se = [
216
+ {
217
+ type: "error",
218
+ name: "AccessDenied",
219
+ inputs: []
220
+ },
221
+ {
222
+ type: "error",
223
+ name: "AlreadyRevoked",
224
+ inputs: []
225
+ },
226
+ {
227
+ type: "error",
228
+ name: "InvalidRevocation",
229
+ inputs: []
230
+ },
231
+ {
232
+ type: "error",
233
+ name: "InvalidRevocations",
234
+ inputs: []
235
+ },
236
+ {
237
+ type: "error",
238
+ name: "InvalidSchema",
239
+ inputs: []
240
+ },
241
+ {
242
+ type: "error",
243
+ name: "Irrevocable",
244
+ inputs: []
245
+ },
246
+ {
247
+ type: "error",
248
+ name: "NotFound",
249
+ inputs: []
250
+ },
251
+ {
252
+ type: "error",
253
+ name: "NotPayable",
254
+ inputs: []
255
+ },
256
+ {
257
+ type: "error",
258
+ name: "InsufficientValue",
259
+ inputs: []
260
+ },
261
+ {
262
+ type: "error",
263
+ name: "InvalidLength",
264
+ inputs: []
265
+ }
266
+ ], Ce = () => g({ signature: "event Attested(address indexed recipient, address indexed attester, bytes32 uid, bytes32 indexed schemaUID)" }), J = "0x" + "0".repeat(64);
267
+ function we(e, t, n) {
268
+ let { easContractAddress: r } = $();
269
+ return h({
270
+ contract: p({
271
+ client: e,
272
+ chain: t,
273
+ address: r
274
+ }),
275
+ method: "function attest((bytes32 schema,(address recipient,uint64 expirationTime,bool revocable,bytes32 refUID,bytes data,uint256 value) data) request) payable returns (bytes32)",
276
+ params: [{
277
+ schema: n.schema,
278
+ data: {
279
+ recipient: n.data.recipient ?? "0x0000000000000000000000000000000000000000",
280
+ expirationTime: n.data.expirationTime ?? 0n,
281
+ revocable: n.data.revocable ?? !0,
282
+ refUID: n.data.refUID,
283
+ data: n.data.data,
284
+ value: n.data.value ?? 0n
285
+ }
286
+ }]
287
+ });
288
+ }
289
+ function Te(e, t, n) {
290
+ let { easContractAddress: r } = $();
291
+ return h({
292
+ contract: p({
293
+ client: e,
294
+ chain: t,
295
+ address: r
296
+ }),
297
+ method: "function multiAttest((bytes32 schema,(address recipient,uint64 expirationTime,bool revocable,bytes32 refUID,bytes data,uint256 value)[] data)[] requests) payable returns (bytes32[])",
298
+ params: [n]
299
+ });
300
+ }
301
+ function Ee(e) {
302
+ return ie([{ type: "bytes32" }], [e]);
303
+ }
304
+ function De(e, t) {
305
+ return Y(e, t)[0]?.uid;
306
+ }
307
+ function Y(e, t) {
308
+ if (!e.logs?.length) return [];
309
+ let n = t.toLowerCase(), r = e.logs.filter((e) => e.address && e.address.toLowerCase() === n);
310
+ if (!r.length) return [];
311
+ try {
312
+ let e = m({
313
+ logs: r,
314
+ events: [Ce()],
315
+ strict: !1
316
+ }), t = [];
317
+ for (let n of e) {
318
+ let e = n?.args?.uid, r = n?.args?.schemaUID;
319
+ !e || e === J || r && t.push({
320
+ schemaUid: r,
321
+ uid: e
322
+ });
323
+ }
324
+ return t;
325
+ } catch {
326
+ return [];
327
+ }
328
+ }
329
+ function Oe(e, t, n) {
330
+ let { easContractAddress: r } = $();
331
+ return h({
332
+ contract: p({
333
+ client: e,
334
+ chain: t,
335
+ address: r,
336
+ abi: [...Se]
337
+ }),
338
+ method: "function multiRevoke((bytes32 schema,(bytes32 uid,uint256 value)[] data)[] multiRequests) payable",
339
+ params: [n.map((e) => ({
340
+ schema: e.schema,
341
+ data: e.data.map((e) => ({
342
+ uid: e.uid,
343
+ value: e.value ?? 0n
344
+ }))
345
+ }))]
346
+ });
347
+ }
348
+ //#endregion
349
+ //#region src/helpers/resolveRevokeAccount.ts
350
+ async function ke(e) {
351
+ let { account: t, attester: n } = e;
352
+ if (!n || t.address.toLowerCase() === n.toLowerCase()) return t;
353
+ let i = r();
354
+ if (i) {
355
+ let e = await i(), t = n.toLowerCase();
356
+ if (e?.some((e) => e?.toLowerCase() === t)) throw Error("Revocation not supported for items published via the modular executor.");
357
+ }
358
+ try {
359
+ let e = await L(t.address);
360
+ if (n.toLowerCase() === e.toLowerCase() && await R(e)) {
361
+ let e = W();
362
+ await e.autoConnect({
363
+ client: N(),
364
+ chain: w
365
+ });
366
+ let t = e.getAccount();
367
+ if (t) return t;
368
+ }
369
+ } catch {}
370
+ return t;
371
+ }
372
+ //#endregion
373
+ //#region src/services/revoke/revokeAttestations.ts
374
+ async function X(e) {
375
+ let { seedLocalId: r, seedUid: s, seedSchemaUid: c } = e, l = await H();
376
+ if (!l) throw Error("No wallet connected. Connect a wallet to revoke attestations.");
377
+ let d = await ke({
378
+ account: l,
379
+ attester: await n({
380
+ seedLocalId: r,
381
+ seedUid: s
382
+ })
383
+ }), f = N(), [p, m] = await Promise.all([a(s), i(s)]), h = p.map((e) => e.uid).filter((e) => o(e)), g = /* @__PURE__ */ new Map();
384
+ for (let { uid: e, schemaUid: t } of m) {
385
+ if (!o(e)) continue;
386
+ let n = g.get(t) ?? [];
387
+ n.push(e), g.set(t, n);
388
+ }
389
+ let _ = [];
390
+ for (let [e, t] of g) t.length > 0 && _.push({
391
+ schema: e,
392
+ data: t.map((e) => ({ uid: e }))
393
+ });
394
+ h.length > 0 && _.push({
395
+ schema: t,
396
+ data: h.map((e) => ({ uid: e }))
397
+ }), _.push({
398
+ schema: c,
399
+ data: [{ uid: s }]
400
+ });
401
+ for (let e of _) {
402
+ if (e.data.length === 0) continue;
403
+ let t = Oe(f, w, [e]);
404
+ try {
405
+ await ee({
406
+ client: f,
407
+ chain: w,
408
+ transactionHash: (await v({
409
+ account: d,
410
+ transaction: t
411
+ })).transactionHash
412
+ });
413
+ } catch (e) {
414
+ let t = e instanceof Error ? e.message : String(e);
415
+ if (t.includes("AccessDenied") || t.includes("0x4ca88867")) throw Error("Only the original attester can revoke attestations. Connect the wallet that published this item.");
416
+ if (t.includes("AlreadyRevoked")) continue;
417
+ throw e;
418
+ }
419
+ }
420
+ await u({
421
+ seedLocalId: r,
422
+ revokedAt: Math.floor(Date.now() / 1e3)
423
+ });
424
+ }
425
+ //#endregion
426
+ //#region src/config.ts
427
+ var Z = null;
428
+ function Ae(e) {
429
+ Z = e;
430
+ }
431
+ function je() {
432
+ return Z;
433
+ }
434
+ function Q(e) {
435
+ Ae(e), c(async () => {
436
+ try {
437
+ return await V(w);
438
+ } catch {
439
+ return;
440
+ }
441
+ }), l(X), import("./worker-BCxmY47A.js").then((e) => {
442
+ e.startArweaveL1FinalizeWorker();
443
+ }), s(async () => e.useModularExecutor && e.modularAccountModuleContract ? [e.modularAccountModuleContract] : []);
444
+ }
445
+ var Me = Q;
446
+ function $() {
447
+ let t = Z;
448
+ if (!t) throw Error("@seedprotocol/publish: Call initPublish() or ensure PublishProvider is mounted with config before using the publish package");
449
+ let n = t.useArweaveBundler ?? !1, r = t.arweaveUploadVerificationBaseUrl ?? t.uploadApiBaseUrl, i = t.arweaveGraphqlUrl ?? e, a = t.useModularExecutor ?? !1;
450
+ return {
451
+ ...t,
452
+ thirdwebAccountFactoryAddress: E,
453
+ easContractAddress: D,
454
+ useIntegerLocalIds: t.useIntegerLocalIds ?? !1,
455
+ useDirectEas: t.useDirectEas ?? !1,
456
+ modularAccountModuleData: t.modularAccountModuleData ?? "0x",
457
+ useModularExecutor: a,
458
+ useArweaveBundler: n,
459
+ arweaveUploadVerificationBaseUrl: r,
460
+ arweaveGraphqlUrl: i,
461
+ autoDeployManagedAccount: t.autoDeployManagedAccount ?? !1,
462
+ autoDeployEip7702ModularAccount: Ne(t, a)
463
+ };
464
+ }
465
+ function Ne(e, t) {
466
+ return e.autoDeployEip7702ModularAccount === !0 ? !0 : e.autoDeployEip7702ModularAccount === !1 ? !1 : t;
467
+ }
468
+ //#endregion
469
+ export { pe as A, L as C, he as D, me as E, le as F, se as I, ae as L, T as M, ce as N, F as O, O as P, oe as R, j as S, R as T, V as _, J as a, W as b, Y as c, ge as d, ye as f, H as g, N as h, Q as i, D as j, P as k, we as l, _e as m, je as n, Ee as o, ve as p, $ as r, De as s, Me as t, Te as u, be as v, xe as w, K as x, I as y };
470
+
471
+ //# sourceMappingURL=config-BtwOzQP0.js.map