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