@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
package/CHANGELOG.md CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## 0.4.31
6
+
7
+ ### Fixed
8
+
9
+ - **First-time modular publish:** Restored automatic session-signer provisioning (`ensureManagedSignerSessionKey`) and unified modular bootstrap (`ensureModularPublishBootstrap`: signer → `setEas` → optional EIP-7702 fallback).
10
+ - **First-time non-modular publish:** `createAttestations` now runs `ensureManagedAccountEasConfigured` before `multiPublish` when `useModularExecutor` is false (required since v0.4.23 per-account routing).
11
+ - **EIP-7702 bootstrap:** `ensureEip7702ModularAccountReady` polls for on-chain bytecode after `deploySmartAccount` timeout before failing.
12
+
13
+ ### Added
14
+
15
+ - **`ensureManagedSignerSessionKey`**, **`ensureModularPublishBootstrap`:** Exported helpers for custom publish entrypoints.
16
+ - **`MODULAR_SIGNER_ACTIVATION_FAILED`:** New `ManagedAccountPublishError` code when session-key setup fails.
17
+
5
18
  ## 0.4.24
6
19
 
7
20
  ### Added
package/README.md CHANGED
@@ -160,9 +160,13 @@ When **`useModularExecutor`** is enabled, `multiPublish` is sent **from** the us
160
160
 
161
161
  **Managed account:** `runModularExecutorPublishPrep()` still ensures the **EIP-4337 managed** publishing contract exists on Optimism Sepolia (and optionally installs the executor module). That is separate from the modular wallet’s EIP-7702 upgrade.
162
162
 
163
- Before the first `multiPublish` on that path, `createAttestations` runs **`ensureManagedAccountEasConfigured`**: it reads **`getEas`** on the ManagedAccount and, if the stored address is zero or does not match **`getPublishConfig().easContractAddress`**, sends **`setEas`** (signed by the same modular EIP-7702 account as `multiPublish`) and waits for the receipt. You can call **`ensureManagedAccountEasConfigured(managedAddress, modularAccount)`** yourself if you build a custom publish entrypoint.
163
+ Before the first `multiPublish` on that path, `createAttestations` runs **`ensureModularPublishBootstrap`**, which:
164
164
 
165
- **Diagnostic helper:** **`defaultApprovedTargetsForModularPublish(managedAddress)`** remains exported for apps that build custom permission flows; the publish package no longer provisions session signers on the managed account automatically.
165
+ 1. Provisions the modular wallet as a **session signer** on the ManagedAccount (`ensureManagedSignerSessionKey` `addSessionKey` signed by the managed EIP-4337 wallet when needed).
166
+ 2. Ensures the ManagedAccount EAS pointer matches config (`ensureManagedAccountEasConfigured`).
167
+ 3. Falls back to **`ensureEip7702ModularAccountReady`** only when session-key setup fails and `autoDeployEip7702ModularAccount` is enabled.
168
+
169
+ **Diagnostic helper:** **`defaultApprovedTargetsForModularPublish(managedAddress)`** remains exported for apps that build custom permission flows.
166
170
 
167
171
  **Resolved config:** Use **`getPublishConfig()`** after `initPublish` / `PublishProvider` for **`autoDeployEip7702ModularAccount`** and other resolved defaults—not only `usePublishConfig()`, which returns the raw `PublishConfig` object.
168
172
 
@@ -0,0 +1,442 @@
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
+ var R = 5, z = 6e3;
96
+ async function B(e, t = R, n = z) {
97
+ for (let r = 0; r < t; r++) {
98
+ if (await L(e)) return !0;
99
+ r < t - 1 && await new Promise((e) => {
100
+ setTimeout(e, n);
101
+ });
102
+ }
103
+ return !1;
104
+ }
105
+ async function me(e) {
106
+ if (!e) return { needsDeploy: !0 };
107
+ if (await L(e.address)) return {
108
+ address: e.address,
109
+ account: e
110
+ };
111
+ let t = await I(e.address);
112
+ return await L(t) ? {
113
+ address: t,
114
+ account: e
115
+ } : { needsDeploy: !0 };
116
+ }
117
+ var he = [_("io.metamask"), _("me.rainbow")], ge = async (e) => {
118
+ let t = f({
119
+ client: M(),
120
+ chain: S,
121
+ address: e.address
122
+ }), n = await d({
123
+ smartAccount: e,
124
+ chain: S,
125
+ client: M(),
126
+ accountContract: t
127
+ });
128
+ return fe("deploySmartAccount result:", n), n;
129
+ }, _e = {
130
+ name: "Seed Protocol",
131
+ description: "Seed Protocol",
132
+ url: "https://seedprotocol.io"
133
+ };
134
+ async function V(e = S) {
135
+ let t = W();
136
+ await t.autoConnect({
137
+ client: M(),
138
+ chain: e
139
+ });
140
+ let n = t.getAccount();
141
+ if (!n) throw Error("Failed to get managed account");
142
+ return n.address;
143
+ }
144
+ async function H() {
145
+ try {
146
+ let e = K();
147
+ return await e.autoConnect({
148
+ client: M(),
149
+ chain: S
150
+ }), e.getAccount() ?? null;
151
+ } catch {
152
+ return null;
153
+ }
154
+ }
155
+ async function ve() {
156
+ return H();
157
+ }
158
+ var U = null, W = () => (U ||= v({
159
+ storage: A(),
160
+ auth: { options: [
161
+ "farcaster",
162
+ "email",
163
+ "passkey",
164
+ "phone"
165
+ ] },
166
+ executionMode: {
167
+ mode: "EIP4337",
168
+ smartAccount: {
169
+ chain: S,
170
+ factoryAddress: T,
171
+ gasless: !0
172
+ }
173
+ }
174
+ }), U), G = null, K = () => (G ||= v({
175
+ storage: A(),
176
+ auth: { options: [
177
+ "farcaster",
178
+ "email",
179
+ "passkey",
180
+ "phone"
181
+ ] },
182
+ executionMode: {
183
+ mode: "EIP7702",
184
+ sponsorGas: !0
185
+ }
186
+ }), G), q = null, ye = () => (q ||= $().useModularExecutor ? [K()] : [W()], q), be = [
187
+ {
188
+ type: "error",
189
+ name: "AccessDenied",
190
+ inputs: []
191
+ },
192
+ {
193
+ type: "error",
194
+ name: "AlreadyRevoked",
195
+ inputs: []
196
+ },
197
+ {
198
+ type: "error",
199
+ name: "InvalidRevocation",
200
+ inputs: []
201
+ },
202
+ {
203
+ type: "error",
204
+ name: "InvalidRevocations",
205
+ inputs: []
206
+ },
207
+ {
208
+ type: "error",
209
+ name: "InvalidSchema",
210
+ inputs: []
211
+ },
212
+ {
213
+ type: "error",
214
+ name: "Irrevocable",
215
+ inputs: []
216
+ },
217
+ {
218
+ type: "error",
219
+ name: "NotFound",
220
+ inputs: []
221
+ },
222
+ {
223
+ type: "error",
224
+ name: "NotPayable",
225
+ inputs: []
226
+ },
227
+ {
228
+ type: "error",
229
+ name: "InsufficientValue",
230
+ inputs: []
231
+ },
232
+ {
233
+ type: "error",
234
+ name: "InvalidLength",
235
+ inputs: []
236
+ }
237
+ ], xe = () => h({ signature: "event Attested(address indexed recipient, address indexed attester, bytes32 uid, bytes32 indexed schemaUID)" }), J = "0x" + "0".repeat(64);
238
+ function Se(e, t, n) {
239
+ let { easContractAddress: r } = $();
240
+ return m({
241
+ contract: f({
242
+ client: e,
243
+ chain: t,
244
+ address: r
245
+ }),
246
+ method: "function attest((bytes32 schema,(address recipient,uint64 expirationTime,bool revocable,bytes32 refUID,bytes data,uint256 value) data) request) payable returns (bytes32)",
247
+ params: [{
248
+ schema: n.schema,
249
+ data: {
250
+ recipient: n.data.recipient ?? "0x0000000000000000000000000000000000000000",
251
+ expirationTime: n.data.expirationTime ?? 0n,
252
+ revocable: n.data.revocable ?? !0,
253
+ refUID: n.data.refUID,
254
+ data: n.data.data,
255
+ value: n.data.value ?? 0n
256
+ }
257
+ }]
258
+ });
259
+ }
260
+ function Ce(e, t, n) {
261
+ let { easContractAddress: r } = $();
262
+ return m({
263
+ contract: f({
264
+ client: e,
265
+ chain: t,
266
+ address: r
267
+ }),
268
+ method: "function multiAttest((bytes32 schema,(address recipient,uint64 expirationTime,bool revocable,bytes32 refUID,bytes data,uint256 value)[] data)[] requests) payable returns (bytes32[])",
269
+ params: [n]
270
+ });
271
+ }
272
+ function we(e) {
273
+ return oe([{ type: "bytes32" }], [e]);
274
+ }
275
+ function Te(e, t) {
276
+ return Y(e, t)[0]?.uid;
277
+ }
278
+ function Y(e, t) {
279
+ if (!e.logs?.length) return [];
280
+ let n = t.toLowerCase(), r = e.logs.filter((e) => e.address && e.address.toLowerCase() === n);
281
+ if (!r.length) return [];
282
+ try {
283
+ let e = p({
284
+ logs: r,
285
+ events: [xe()],
286
+ strict: !1
287
+ }), t = [];
288
+ for (let n of e) {
289
+ let e = n?.args?.uid, r = n?.args?.schemaUID;
290
+ !e || e === J || r && t.push({
291
+ schemaUid: r,
292
+ uid: e
293
+ });
294
+ }
295
+ return t;
296
+ } catch {
297
+ return [];
298
+ }
299
+ }
300
+ function Ee(e, t, n) {
301
+ let { easContractAddress: r } = $();
302
+ return m({
303
+ contract: f({
304
+ client: e,
305
+ chain: t,
306
+ address: r,
307
+ abi: [...be]
308
+ }),
309
+ method: "function multiRevoke((bytes32 schema,(bytes32 uid,uint256 value)[] data)[] multiRequests) payable",
310
+ params: [n.map((e) => ({
311
+ schema: e.schema,
312
+ data: e.data.map((e) => ({
313
+ uid: e.uid,
314
+ value: e.value ?? 0n
315
+ }))
316
+ }))]
317
+ });
318
+ }
319
+ //#endregion
320
+ //#region src/helpers/resolveRevokeAccount.ts
321
+ async function X(e) {
322
+ let { account: t, attester: n } = e;
323
+ if (!n || t.address.toLowerCase() === n.toLowerCase()) return t;
324
+ let i = r();
325
+ if (i) {
326
+ let e = await i(), t = n.toLowerCase();
327
+ if (e?.some((e) => e?.toLowerCase() === t)) throw Error("Revocation not supported for items published via the modular executor.");
328
+ }
329
+ try {
330
+ let e = await I(t.address);
331
+ if (n.toLowerCase() === e.toLowerCase() && await L(e)) {
332
+ let e = W();
333
+ await e.autoConnect({
334
+ client: M(),
335
+ chain: S
336
+ });
337
+ let t = e.getAccount();
338
+ if (t) return t;
339
+ }
340
+ } catch {}
341
+ return t;
342
+ }
343
+ //#endregion
344
+ //#region src/services/revoke/revokeAttestations.ts
345
+ async function De(e) {
346
+ let { seedLocalId: r, seedUid: s, seedSchemaUid: c } = e, l = await H();
347
+ if (!l) throw Error("No wallet connected. Connect a wallet to revoke attestations.");
348
+ let u = await X({
349
+ account: l,
350
+ attester: await n({
351
+ seedLocalId: r,
352
+ seedUid: s
353
+ })
354
+ }), 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();
355
+ for (let { uid: e, schemaUid: t } of p) {
356
+ if (!o(e)) continue;
357
+ let n = h.get(t) ?? [];
358
+ n.push(e), h.set(t, n);
359
+ }
360
+ let g = [];
361
+ for (let [e, t] of h) t.length > 0 && g.push({
362
+ schema: e,
363
+ data: t.map((e) => ({ uid: e }))
364
+ });
365
+ m.length > 0 && g.push({
366
+ schema: t,
367
+ data: m.map((e) => ({ uid: e }))
368
+ }), g.push({
369
+ schema: c,
370
+ data: [{ uid: s }]
371
+ });
372
+ for (let e of g) {
373
+ if (e.data.length === 0) continue;
374
+ let t = Ee(d, S, [e]);
375
+ try {
376
+ await ne({
377
+ client: d,
378
+ chain: S,
379
+ transactionHash: (await te({
380
+ account: u,
381
+ transaction: t
382
+ })).transactionHash
383
+ });
384
+ } catch (e) {
385
+ let t = e instanceof Error ? e.message : String(e);
386
+ if (t.includes("AccessDenied") || t.includes("0x4ca88867")) throw Error("Only the original attester can revoke attestations. Connect the wallet that published this item.");
387
+ if (t.includes("AlreadyRevoked")) continue;
388
+ throw e;
389
+ }
390
+ }
391
+ await ee({
392
+ seedLocalId: r,
393
+ revokedAt: Math.floor(Date.now() / 1e3)
394
+ });
395
+ }
396
+ //#endregion
397
+ //#region src/config.ts
398
+ var Z = null;
399
+ function Oe(e) {
400
+ Z = e;
401
+ }
402
+ function ke() {
403
+ return Z;
404
+ }
405
+ function Q(e) {
406
+ Oe(e), c(async () => {
407
+ try {
408
+ return await V(S);
409
+ } catch {
410
+ return;
411
+ }
412
+ }), l(De), import("./worker-CaUA-aJd.js").then((e) => {
413
+ e.startArweaveL1FinalizeWorker();
414
+ }), s(async () => e.useModularExecutor && e.modularAccountModuleContract ? [e.modularAccountModuleContract] : []);
415
+ }
416
+ var Ae = Q;
417
+ function $() {
418
+ let t = Z;
419
+ if (!t) throw Error("@seedprotocol/publish: Call initPublish() or ensure PublishProvider is mounted with config before using the publish package");
420
+ let n = t.useArweaveBundler ?? !1, r = t.arweaveUploadVerificationBaseUrl ?? t.uploadApiBaseUrl, i = t.arweaveGraphqlUrl ?? e, a = t.useModularExecutor ?? !1;
421
+ return {
422
+ ...t,
423
+ thirdwebAccountFactoryAddress: T,
424
+ easContractAddress: E,
425
+ useIntegerLocalIds: t.useIntegerLocalIds ?? !1,
426
+ useDirectEas: t.useDirectEas ?? !1,
427
+ modularAccountModuleData: t.modularAccountModuleData ?? "0x",
428
+ useModularExecutor: a,
429
+ useArweaveBundler: n,
430
+ arweaveUploadVerificationBaseUrl: r,
431
+ arweaveGraphqlUrl: i,
432
+ autoDeployManagedAccount: t.autoDeployManagedAccount ?? !1,
433
+ autoDeployEip7702ModularAccount: je(t, a)
434
+ };
435
+ }
436
+ function je(e, t) {
437
+ return e.autoDeployEip7702ModularAccount === !0 ? !0 : e.autoDeployEip7702ModularAccount === !1 ? !1 : t;
438
+ }
439
+ //#endregion
440
+ export { E as A, ye as C, P as D, me as E, ce as F, C as I, se as L, le as M, D as N, N as O, ue as P, I as S, B as T, ve as _, J as a, K as b, Y as c, he as d, _e as f, V as g, H as h, Q as i, w as j, pe as k, Se as l, M as m, ke as n, we as o, ge as p, $ as r, Te as s, Ae as t, Ce as u, F as v, L as w, A as x, W as y };
441
+
442
+ //# sourceMappingURL=config-B4_sw4Ey.js.map