@seedprotocol/publish 0.7.0 → 0.7.2-next.593.gd5bd4ea
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.
- package/README.md +1 -1
- package/dist/{chainConfig-DWynbnb8.js → chainConfig-BDMRU4m8.js} +5 -5
- package/dist/chainConfig-BDMRU4m8.js.map +1 -0
- package/dist/collectBatchUids-CnIe9jUB.js.map +1 -1
- package/dist/{ensureAutomationSessionKey-BVmh030S.js → ensureAutomationSessionKey-bw6knEyC.js} +4 -4
- package/dist/ensureAutomationSessionKey-bw6knEyC.js.map +1 -0
- package/dist/{ensureModularPublishBootstrap-DRFhp-O2.js → ensureModularPublishBootstrap-Vc4Jz_B9.js} +5 -5
- package/dist/ensureModularPublishBootstrap-Vc4Jz_B9.js.map +1 -0
- package/dist/{ensureSmartWalletThenPublish-0nKg13WN.js → ensureSmartWalletThenPublish-42iEhiHG.js} +3 -3
- package/dist/ensureSmartWalletThenPublish-42iEhiHG.js.map +1 -0
- package/dist/index.js +6 -14
- package/dist/index.js.map +1 -1
- package/dist/{managedAccountAdmin-B4HkLWWE.js → managedAccountAdmin-B3DPMmhR.js} +4 -4
- package/dist/managedAccountAdmin-B3DPMmhR.js.map +1 -0
- package/dist/{publishAuthorization-C-XYb9Ef.js → publishAuthorization-CAFF5jQ2.js} +1033 -1044
- package/dist/publishAuthorization-CAFF5jQ2.js.map +1 -0
- package/dist/{publishThirdwebClient-BQ_KnMi5.js → publishThirdwebClient-CPzAjnmf.js} +2 -2
- package/dist/publishThirdwebClient-CPzAjnmf.js.map +1 -0
- package/dist/{resolveRevokeAccount-9-OzXVdp.js → resolveRevokeAccount-CkbTpC27.js} +4 -4
- package/dist/resolveRevokeAccount-CkbTpC27.js.map +1 -0
- package/dist/services/publish/actors/createAttestationsDirectToEas.d.ts.map +1 -1
- package/dist/services/publish/actors/rewritingHtmlEmbedded.d.ts.map +1 -1
- package/dist/services/publish/helpers/getPublishUploadData.d.ts +5 -0
- package/dist/services/publish/helpers/getPublishUploadData.d.ts.map +1 -1
- package/dist/thirdweb.js +7 -9
- package/dist/thirdweb.js.map +1 -1
- package/dist/{worker-FmHZbku5.js → worker-CCQ7KBMm.js} +2 -2
- package/dist/{worker-CJRUAOAn.js.map → worker-CCQ7KBMm.js.map} +1 -1
- package/package.json +13 -7
- package/dist/chainConfig-BJ8C_RRz.js +0 -1455
- package/dist/chainConfig-BJ8C_RRz.js.map +0 -1
- package/dist/chainConfig-DWynbnb8.js.map +0 -1
- package/dist/chainConfig-DWzoOtkS.js +0 -1453
- package/dist/chainConfig-DWzoOtkS.js.map +0 -1
- package/dist/chainConfig-DmuPBs3D.js +0 -1455
- package/dist/chainConfig-DmuPBs3D.js.map +0 -1
- package/dist/ensureAutomationSessionKey-BVmh030S.js.map +0 -1
- package/dist/ensureAutomationSessionKey-CxpJY_uH.js +0 -84
- package/dist/ensureAutomationSessionKey-CxpJY_uH.js.map +0 -1
- package/dist/ensureAutomationSessionKey-DwRm4YMJ.js +0 -84
- package/dist/ensureAutomationSessionKey-DwRm4YMJ.js.map +0 -1
- package/dist/ensureAutomationSessionKey-h3zOmDr5.js +0 -84
- package/dist/ensureAutomationSessionKey-h3zOmDr5.js.map +0 -1
- package/dist/ensureModularPublishBootstrap-BImiIFJe.js +0 -23
- package/dist/ensureModularPublishBootstrap-BImiIFJe.js.map +0 -1
- package/dist/ensureModularPublishBootstrap-CmxyX_EN.js +0 -23
- package/dist/ensureModularPublishBootstrap-CmxyX_EN.js.map +0 -1
- package/dist/ensureModularPublishBootstrap-DRFhp-O2.js.map +0 -1
- package/dist/ensureModularPublishBootstrap-DegJnYKL.js +0 -23
- package/dist/ensureModularPublishBootstrap-DegJnYKL.js.map +0 -1
- package/dist/ensureSmartWalletThenPublish-0nKg13WN.js.map +0 -1
- package/dist/ensureSmartWalletThenPublish-BdqeUL6t.js +0 -47
- package/dist/ensureSmartWalletThenPublish-BdqeUL6t.js.map +0 -1
- package/dist/ensureSmartWalletThenPublish-BfEndtFo.js +0 -47
- package/dist/ensureSmartWalletThenPublish-BfEndtFo.js.map +0 -1
- package/dist/ensureSmartWalletThenPublish-DuOYPJFd.js +0 -47
- package/dist/ensureSmartWalletThenPublish-DuOYPJFd.js.map +0 -1
- package/dist/managedAccountAdmin-B4HkLWWE.js.map +0 -1
- package/dist/managedAccountAdmin-ByEX_Eg2.js +0 -28
- package/dist/managedAccountAdmin-ByEX_Eg2.js.map +0 -1
- package/dist/managedAccountAdmin-DS6nniiu.js +0 -28
- package/dist/managedAccountAdmin-DS6nniiu.js.map +0 -1
- package/dist/managedAccountAdmin-DwFI-ZfE.js +0 -28
- package/dist/managedAccountAdmin-DwFI-ZfE.js.map +0 -1
- package/dist/publishAuthorization-C-XYb9Ef.js.map +0 -1
- package/dist/publishAuthorization-CG23g8w2.js +0 -3987
- package/dist/publishAuthorization-CG23g8w2.js.map +0 -1
- package/dist/publishAuthorization-CvK_coYp.js +0 -4011
- package/dist/publishAuthorization-CvK_coYp.js.map +0 -1
- package/dist/publishAuthorization-DgDI4zor.js +0 -4011
- package/dist/publishAuthorization-DgDI4zor.js.map +0 -1
- package/dist/publishThirdwebClient-BQ_KnMi5.js.map +0 -1
- package/dist/publishThirdwebClient-BmqsJCjp.js +0 -18
- package/dist/publishThirdwebClient-BmqsJCjp.js.map +0 -1
- package/dist/publishThirdwebClient-CO18ST7C.js +0 -18
- package/dist/publishThirdwebClient-CO18ST7C.js.map +0 -1
- package/dist/publishThirdwebClient-D-K2WEeM.js +0 -18
- package/dist/publishThirdwebClient-D-K2WEeM.js.map +0 -1
- package/dist/resolveRevokeAccount-9-OzXVdp.js.map +0 -1
- package/dist/resolveRevokeAccount-CXa5XlOv.js +0 -38
- package/dist/resolveRevokeAccount-CXa5XlOv.js.map +0 -1
- package/dist/resolveRevokeAccount-DsNod8ti.js +0 -38
- package/dist/resolveRevokeAccount-DsNod8ti.js.map +0 -1
- package/dist/resolveRevokeAccount-QgZ6YZuS.js +0 -38
- package/dist/resolveRevokeAccount-QgZ6YZuS.js.map +0 -1
- package/dist/worker-CJRUAOAn.js +0 -69
- package/dist/worker-CN7zg73B.js +0 -69
- package/dist/worker-CN7zg73B.js.map +0 -1
- package/dist/worker-FmHZbku5.js.map +0 -1
- package/dist/worker-qoGuo876.js +0 -69
- package/dist/worker-qoGuo876.js.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
-
import { At as t, B as n, Ct as r, D as i, Dt as a, Et as o, F as s, G as c, H as l, I as u, J as d, K as f, L as p, O as m, Ot as h, P as g, Q as
|
|
3
|
-
import { t as
|
|
4
|
-
import { BaseArweaveClient as
|
|
2
|
+
import { At as t, B as n, Ct as r, D as i, Dt as a, Et as o, F as s, G as c, H as l, I as u, J as d, K as f, L as p, O as m, Ot as h, P as g, Q as _, R as v, St as y, V as b, X as x, Y as S, Z as ee, _ as C, _t as te, a as w, at as ne, b as re, bt as ie, c as ae, ct as oe, dt as T, et as se, f as ce, ft as le, h as ue, ht as de, it as fe, j as pe, jt as me, k as he, lt as ge, mt as E, o as D, ot as _e, q as ve, r as ye, rt as be, st as xe, t as O, u as Se, ut as Ce, v as k, wt as we, xt as Te, y as A, yt as Ee, z as De } from "./chainConfig-BDMRU4m8.js";
|
|
3
|
+
import { t as j } from "./publishThirdwebClient-CPzAjnmf.js";
|
|
4
|
+
import { BaseArweaveClient as Oe, BaseDb as ke, BaseFileManager as M, INTERNAL_DATA_TYPES as Ae, Item as N, ModelPropertyDataTypes as je, RelatedItemUnpublishedError as Me, applyPropertyAttestationUidsFromPublish as Ne, arweaveL1FinalizeJobs as Pe, assertLocalDbChain as Fe, getCorrectId as Ie, getEasSchemaForItemProperty as Le, getItemPropertiesFromEas as Re, getPublishDraftGraph as ze, getRelatedItemsForPublish as Be, getSegmentedItemProperties as Ve, getUnpublishedRelatedItems as He, getUploadPipelineTransactionStatus as Ue, htmlEmbeddedImageCoPublish as We, isItemOwned as Ge, isPublishedSeedRef as Ke, itemHasPublishUploadCandidates as qe, listRelationEasPropertyName as Je, normalizeDataType as Ye, normalizeRelationPropertyValue as Xe, prepareHtmlEmbeddedImagesForPublish as Ze, publishProcesses as P, resolvePublishPayloadValues as Qe, resolveSeedIdsFromRefString as $e, rewriteHtmlEmbeddedImagesOnDisk as et, setSchemaUidForModel as tt, setSchemaUidForSchemaDefinition as nt, updateVersionUid as rt, validateItemForPublish as it } from "@seedprotocol/sdk";
|
|
5
5
|
import { BaseError as at, decodeAbiParameters as ot, decodeErrorResult as st, isAddressEqual as ct, parseEther as lt, parseEventLogs as ut, toFunctionSelector as dt, zeroAddress as ft } from "viem";
|
|
6
6
|
import { deploySmartAccount as pt, getContract as mt } from "thirdweb";
|
|
7
|
-
import { ethers as
|
|
7
|
+
import { ethers as F, keccak256 as ht, toUtf8Bytes as gt } from "ethers";
|
|
8
8
|
import { PUBLISH_AUTHORIZATION_DEFAULT_EXPIRATION_SECS as _t, PUBLISH_AUTHORIZATION_SCHEMA_DEF as vt, PUBLISH_AUTHORIZATION_SCHEMA_DEF as yt, PUBLISH_AUTHORIZATION_SCHEMA_NAME as bt, PUBLISH_AUTHORIZATION_SCHEMA_NAME as xt, PUBLISH_AUTHORIZATION_SCOPES as St, PUBLISH_AUTHORIZATION_SCOPES as Ct, assessPublishAuthorization as wt, decodePublishAuthorizationData as Tt, getPublishAuthorizationFromEas as Et, isValidEasAttestationUid as Dt, normalizeBytes32Hex as Ot } from "@seedprotocol/eas";
|
|
9
9
|
import { createContext as kt, useContext as At, useEffect as jt, useRef as Mt, useState as Nt } from "react";
|
|
10
10
|
import Pt from "arweave";
|
|
11
11
|
import { NO_EXPIRATION as Ft, SchemaEncoder as It, SchemaRegistry as Lt, ZERO_ADDRESS as Rt, ZERO_BYTES32 as zt } from "@ethereum-attestation-service/eas-sdk";
|
|
12
|
-
import { assign as
|
|
13
|
-
import
|
|
14
|
-
import { and as Wt, desc as Gt, eq as
|
|
12
|
+
import { assign as I, createActor as Bt, enqueueActions as Vt, fromCallback as Ht, fromPromise as L, setup as Ut } from "xstate";
|
|
13
|
+
import R from "debug";
|
|
14
|
+
import { and as Wt, desc as Gt, eq as z } from "drizzle-orm";
|
|
15
15
|
import { createWallet as Kt, inAppWallet as qt } from "thirdweb/wallets";
|
|
16
16
|
import { useActiveAccount as Jt } from "thirdweb/react";
|
|
17
17
|
import { estimateUserOpGas as Yt, getPaymasterAndData as Xt } from "thirdweb/wallets/smart";
|
|
@@ -180,8 +180,8 @@ var $t = [
|
|
|
180
180
|
type: "uint256"
|
|
181
181
|
}]
|
|
182
182
|
},
|
|
183
|
-
...
|
|
184
|
-
...
|
|
183
|
+
...y,
|
|
184
|
+
...we
|
|
185
185
|
];
|
|
186
186
|
function en(e) {
|
|
187
187
|
if (e instanceof at) return e.walk((e) => {
|
|
@@ -212,7 +212,7 @@ function an(e, t) {
|
|
|
212
212
|
}
|
|
213
213
|
function on(e) {
|
|
214
214
|
let { txHash: t, revertData: n, sender: r, cause: i } = e, a = !!n && n !== "0x";
|
|
215
|
-
return new
|
|
215
|
+
return new E(an(t, n), a ? "USEROP_REVERTED" : "USEROP_FAILED_NO_REASON", r, i);
|
|
216
216
|
}
|
|
217
217
|
function sn(e) {
|
|
218
218
|
let t = [];
|
|
@@ -234,21 +234,21 @@ function un(e, t) {
|
|
|
234
234
|
let i = n.signature;
|
|
235
235
|
if (n.name === "AbiErrorSignatureNotFoundError" && typeof i == "string") {
|
|
236
236
|
let n = ln(i);
|
|
237
|
-
if (n) return new
|
|
237
|
+
if (n) return new E(`The publish transaction reverted with ${n} (its arguments were not decoded).`, "USEROP_REVERTED", t, e);
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
return e;
|
|
241
241
|
}
|
|
242
242
|
//#endregion
|
|
243
243
|
//#region src/helpers/blockchain.ts
|
|
244
|
-
var
|
|
245
|
-
let e =
|
|
244
|
+
var B = () => {
|
|
245
|
+
let e = Oe.getArweaveJsApiConfig(), t = Pt;
|
|
246
246
|
return Object.keys(t).includes("default") && t.default ? t.default.init(e) : t.init(e);
|
|
247
247
|
};
|
|
248
248
|
//#endregion
|
|
249
249
|
//#region src/helpers/schemaRegistry.ts
|
|
250
|
-
async function
|
|
251
|
-
return
|
|
250
|
+
async function V(e) {
|
|
251
|
+
return be(e);
|
|
252
252
|
}
|
|
253
253
|
function dn(e) {
|
|
254
254
|
return d(e);
|
|
@@ -280,11 +280,11 @@ function pn(e) {
|
|
|
280
280
|
}
|
|
281
281
|
//#endregion
|
|
282
282
|
//#region src/services/publish/helpers/ensureEasSchemas.ts
|
|
283
|
-
var
|
|
284
|
-
function
|
|
283
|
+
var H = "0x0000000000000000000000000000000000000000", mn = !0, hn = "bytes32 schemaId,string name", gn = "bytes32 version", _n = /* @__PURE__ */ new Set();
|
|
284
|
+
function vn(e) {
|
|
285
285
|
return e.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
|
|
286
286
|
}
|
|
287
|
-
async function
|
|
287
|
+
async function yn(e) {
|
|
288
288
|
let { itemRelationProperties: t, itemImageProperties: n, itemListProperties: r } = await Ve(e), i = /* @__PURE__ */ new Set();
|
|
289
289
|
e.modelName && i.add(e.modelName);
|
|
290
290
|
for (let e of t) {
|
|
@@ -293,7 +293,7 @@ async function vn(e) {
|
|
|
293
293
|
}
|
|
294
294
|
for (let e of n) {
|
|
295
295
|
let t = Ye(e.propertyDef?.dataType);
|
|
296
|
-
t ===
|
|
296
|
+
t === je.File ? i.add("File") : t === je.Html ? i.add("Html") : i.add("Image");
|
|
297
297
|
}
|
|
298
298
|
for (let e of r) {
|
|
299
299
|
let t = e.propertyDef?.ref;
|
|
@@ -301,98 +301,94 @@ async function vn(e) {
|
|
|
301
301
|
}
|
|
302
302
|
return i;
|
|
303
303
|
}
|
|
304
|
-
async function
|
|
304
|
+
async function bn(e, t) {
|
|
305
305
|
let n = await e.sendTransaction(t);
|
|
306
|
-
await
|
|
306
|
+
await T(n.transactionHash);
|
|
307
307
|
}
|
|
308
|
-
function
|
|
308
|
+
function xn(e) {
|
|
309
309
|
let t = Ye(e);
|
|
310
|
-
return
|
|
310
|
+
return Ae[t]?.eas ?? "string";
|
|
311
311
|
}
|
|
312
|
-
function
|
|
312
|
+
function Sn(e, t) {
|
|
313
313
|
if (e) throw Error(`schema "${t}" is not registered; automation keys can't register schemas. Call ensureEasSchemasForItem with the owner wallet first.`);
|
|
314
314
|
}
|
|
315
|
-
async function
|
|
316
|
-
let e =
|
|
317
|
-
if (
|
|
318
|
-
let t = Lt.getSchemaUID(
|
|
319
|
-
for (let [e, t] of n) await
|
|
315
|
+
async function Cn() {
|
|
316
|
+
let e = ye().id;
|
|
317
|
+
if (_n.has(e)) return;
|
|
318
|
+
let t = Lt.getSchemaUID(gn, H, mn), n = [[hn, o], [gn, t]], r = [];
|
|
319
|
+
for (let [e, t] of n) await V(t) || r.push(`"${e}" (${t})`);
|
|
320
320
|
if (r.length > 0) throw Error(`Seed base schema${r.length > 1 ? "s" : ""} ${r.join(" and ")} not registered on chain ${e}. The protocol registers base schemas for each supported chain (seed-protocol: bun run seed:ensure-schemas).`);
|
|
321
|
-
|
|
321
|
+
_n.add(e);
|
|
322
322
|
}
|
|
323
|
-
async function
|
|
323
|
+
async function wn(e, t) {
|
|
324
324
|
if (typeof t?.blockSchemaRegistration == "boolean") return t.blockSchemaRegistration;
|
|
325
325
|
let n = t?.managedAddress?.trim();
|
|
326
326
|
if (!n || !i(e)) return !1;
|
|
327
|
-
let { isAutomationSessionActive: r } = await import("./ensureAutomationSessionKey-
|
|
327
|
+
let { isAutomationSessionActive: r } = await import("./ensureAutomationSessionKey-bw6knEyC.js").then((e) => e.n);
|
|
328
328
|
return r(n, e.signer.address);
|
|
329
329
|
}
|
|
330
|
-
async function wn(e, t, n) {
|
|
331
|
-
await Tn(e, t, n);
|
|
332
|
-
}
|
|
333
330
|
async function Tn(e, t, n) {
|
|
334
|
-
|
|
331
|
+
await En(e, t, n);
|
|
332
|
+
}
|
|
333
|
+
async function En(e, t, n) {
|
|
334
|
+
let r = await wn(t, n), a = i(t) ? t.txSender : he(t) ? t : (() => {
|
|
335
335
|
throw Error("@seedprotocol/publish: ensureEasSchemasForItem requires a PublishWallet or SeedTxSender");
|
|
336
336
|
})();
|
|
337
|
-
await
|
|
337
|
+
await Cn();
|
|
338
338
|
let { itemBasicProperties: o, itemRelationProperties: s, itemImageProperties: c, itemListProperties: l } = await Ve(e), u = [
|
|
339
339
|
...o,
|
|
340
340
|
...s,
|
|
341
341
|
...c,
|
|
342
342
|
...l
|
|
343
|
-
], d = /* @__PURE__ */ new Set(), f = await
|
|
343
|
+
], d = /* @__PURE__ */ new Set(), f = await yn(e), p = /* @__PURE__ */ new Set();
|
|
344
344
|
for (let e of f) {
|
|
345
|
-
let t = `bytes32 ${
|
|
346
|
-
if (await
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
345
|
+
let t = `bytes32 ${vn(e)}`, n = Lt.getSchemaUID(t, H, mn);
|
|
346
|
+
if (await V(n)) tt({
|
|
347
|
+
modelName: e,
|
|
348
|
+
schemaUid: n
|
|
349
|
+
});
|
|
350
|
+
else if (p.has(n)) tt({
|
|
351
|
+
modelName: e,
|
|
352
|
+
schemaUid: n
|
|
353
|
+
});
|
|
354
|
+
else {
|
|
355
|
+
Sn(r, t);
|
|
356
|
+
try {
|
|
357
|
+
await bn(a, dn({
|
|
358
|
+
schema: t,
|
|
359
|
+
resolverAddress: H,
|
|
360
|
+
revocable: mn
|
|
361
|
+
}));
|
|
362
|
+
} catch (t) {
|
|
363
|
+
throw Error(`Failed to register EAS schema for model ${e}: ${t instanceof Error ? t.message : String(t)}`);
|
|
364
|
+
}
|
|
365
|
+
try {
|
|
366
|
+
await bn(a, pn({
|
|
367
|
+
schemaUid: n,
|
|
368
|
+
schemaName: vn(e)
|
|
369
|
+
}));
|
|
370
|
+
} catch (t) {
|
|
371
|
+
throw Error(`Failed to name EAS schema for model ${e}: ${t instanceof Error ? t.message : String(t)}`);
|
|
372
|
+
}
|
|
373
|
+
p.add(n), tt({
|
|
355
374
|
modelName: e,
|
|
356
375
|
schemaUid: n
|
|
357
376
|
});
|
|
358
|
-
continue;
|
|
359
377
|
}
|
|
360
|
-
xn(r, t);
|
|
361
|
-
try {
|
|
362
|
-
await yn(a, dn({
|
|
363
|
-
schema: t,
|
|
364
|
-
resolverAddress: V,
|
|
365
|
-
revocable: H
|
|
366
|
-
}));
|
|
367
|
-
} catch (t) {
|
|
368
|
-
throw Error(`Failed to register EAS schema for model ${e}: ${t instanceof Error ? t.message : String(t)}`);
|
|
369
|
-
}
|
|
370
|
-
try {
|
|
371
|
-
await yn(a, pn({
|
|
372
|
-
schemaUid: n,
|
|
373
|
-
schemaName: _n(e)
|
|
374
|
-
}));
|
|
375
|
-
} catch (t) {
|
|
376
|
-
throw Error(`Failed to name EAS schema for model ${e}: ${t instanceof Error ? t.message : String(t)}`);
|
|
377
|
-
}
|
|
378
|
-
p.add(n), tt({
|
|
379
|
-
modelName: e,
|
|
380
|
-
schemaUid: n
|
|
381
|
-
});
|
|
382
378
|
}
|
|
383
|
-
let m = "string storage_transaction_id", h = Lt.getSchemaUID(m,
|
|
384
|
-
if (await
|
|
379
|
+
let m = "string storage_transaction_id", h = Lt.getSchemaUID(m, H, mn);
|
|
380
|
+
if (await V(h)) nt({
|
|
385
381
|
text: m,
|
|
386
382
|
schemaUid: h
|
|
387
383
|
});
|
|
388
384
|
else if (!d.has(h) && (f.has("Image") || f.has("File") || f.has("Html"))) {
|
|
389
|
-
|
|
385
|
+
Sn(r, m);
|
|
390
386
|
try {
|
|
391
|
-
await
|
|
387
|
+
await bn(a, dn({
|
|
392
388
|
schema: m,
|
|
393
|
-
resolverAddress:
|
|
394
|
-
revocable:
|
|
395
|
-
})), await
|
|
389
|
+
resolverAddress: H,
|
|
390
|
+
revocable: mn
|
|
391
|
+
})), await bn(a, pn({
|
|
396
392
|
schemaUid: h,
|
|
397
393
|
schemaName: "storage_transaction_id"
|
|
398
394
|
}));
|
|
@@ -406,7 +402,7 @@ async function Tn(e, t, n) {
|
|
|
406
402
|
}
|
|
407
403
|
for (let e of u) {
|
|
408
404
|
if (!e.propertyDef) continue;
|
|
409
|
-
let t =
|
|
405
|
+
let t = xn(e.propertyDef.dataType), n = e, i = Je(e.propertyName, e.propertyDef), o = i ?? (n.storagePropertyName && n.storagePropertyName.length > 0 ? n.storagePropertyName : e.propertyName), s = vn(o), c = `${t} ${s}`;
|
|
410
406
|
if (i && !s.endsWith("_ids")) throw Error(`Refusing to register "${c}" for list-relation property ${e.propertyName}: list relations attest as <singular>_<ref>_ids.`);
|
|
411
407
|
let l = [
|
|
412
408
|
"string",
|
|
@@ -420,13 +416,13 @@ async function Tn(e, t, n) {
|
|
|
420
416
|
"uint64",
|
|
421
417
|
"uint128",
|
|
422
418
|
"uint256"
|
|
423
|
-
].includes(t) ? t : void 0, u = await
|
|
419
|
+
].includes(t) ? t : void 0, u = await Le({
|
|
424
420
|
schemaUid: i ? void 0 : e.schemaUid,
|
|
425
421
|
propertyName: o,
|
|
426
422
|
easDataType: l
|
|
427
423
|
});
|
|
428
424
|
if (u) {
|
|
429
|
-
let e = await
|
|
425
|
+
let e = await V(u.id);
|
|
430
426
|
if (e && e.schema === c) {
|
|
431
427
|
nt({
|
|
432
428
|
text: c,
|
|
@@ -435,68 +431,64 @@ async function Tn(e, t, n) {
|
|
|
435
431
|
continue;
|
|
436
432
|
}
|
|
437
433
|
}
|
|
438
|
-
let f = Lt.getSchemaUID(c,
|
|
439
|
-
if (await
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
434
|
+
let f = Lt.getSchemaUID(c, H, mn);
|
|
435
|
+
if (await V(f)) nt({
|
|
436
|
+
text: c,
|
|
437
|
+
schemaUid: f
|
|
438
|
+
});
|
|
439
|
+
else if (d.has(f)) nt({
|
|
440
|
+
text: c,
|
|
441
|
+
schemaUid: f
|
|
442
|
+
});
|
|
443
|
+
else {
|
|
444
|
+
Sn(r, c);
|
|
445
|
+
try {
|
|
446
|
+
await bn(a, dn({
|
|
447
|
+
schema: c,
|
|
448
|
+
resolverAddress: H,
|
|
449
|
+
revocable: mn
|
|
450
|
+
}));
|
|
451
|
+
} catch (t) {
|
|
452
|
+
throw Error(`Failed to register EAS schema for property ${e.propertyName}: ${t instanceof Error ? t.message : String(t)}`);
|
|
453
|
+
}
|
|
454
|
+
try {
|
|
455
|
+
await bn(a, pn({
|
|
456
|
+
schemaUid: f,
|
|
457
|
+
schemaName: s
|
|
458
|
+
}));
|
|
459
|
+
} catch (t) {
|
|
460
|
+
throw Error(`Failed to name EAS schema for property ${e.propertyName}: ${t instanceof Error ? t.message : String(t)}`);
|
|
461
|
+
}
|
|
462
|
+
d.add(f), nt({
|
|
448
463
|
text: c,
|
|
449
464
|
schemaUid: f
|
|
450
465
|
});
|
|
451
|
-
continue;
|
|
452
466
|
}
|
|
453
|
-
xn(r, c);
|
|
454
|
-
try {
|
|
455
|
-
await yn(a, dn({
|
|
456
|
-
schema: c,
|
|
457
|
-
resolverAddress: V,
|
|
458
|
-
revocable: H
|
|
459
|
-
}));
|
|
460
|
-
} catch (t) {
|
|
461
|
-
throw Error(`Failed to register EAS schema for property ${e.propertyName}: ${t instanceof Error ? t.message : String(t)}`);
|
|
462
|
-
}
|
|
463
|
-
try {
|
|
464
|
-
await yn(a, pn({
|
|
465
|
-
schemaUid: f,
|
|
466
|
-
schemaName: s
|
|
467
|
-
}));
|
|
468
|
-
} catch (t) {
|
|
469
|
-
throw Error(`Failed to name EAS schema for property ${e.propertyName}: ${t instanceof Error ? t.message : String(t)}`);
|
|
470
|
-
}
|
|
471
|
-
d.add(f), nt({
|
|
472
|
-
text: c,
|
|
473
|
-
schemaUid: f
|
|
474
|
-
});
|
|
475
467
|
}
|
|
476
468
|
let g = await Be(e);
|
|
477
|
-
for (let e of g) await
|
|
469
|
+
for (let e of g) await En(e, t, {
|
|
478
470
|
managedAddress: n?.managedAddress,
|
|
479
471
|
blockSchemaRegistration: r
|
|
480
472
|
});
|
|
481
473
|
}
|
|
482
474
|
//#endregion
|
|
483
475
|
//#region src/services/publish/actors/utils.ts
|
|
484
|
-
var U = "0x" + "0".repeat(64),
|
|
476
|
+
var U = "0x" + "0".repeat(64), Dn = async (e) => {
|
|
485
477
|
let t;
|
|
486
478
|
try {
|
|
487
|
-
t = await
|
|
479
|
+
t = await N.find({ seedLocalId: e });
|
|
488
480
|
} catch {}
|
|
489
481
|
return t || new Promise((t) => {
|
|
490
482
|
let n = setInterval(() => {
|
|
491
483
|
try {
|
|
492
|
-
|
|
484
|
+
N.find({ seedLocalId: e }).then((e) => {
|
|
493
485
|
e && (clearInterval(n), t(e));
|
|
494
486
|
});
|
|
495
487
|
} catch {}
|
|
496
488
|
}, 200);
|
|
497
489
|
});
|
|
498
490
|
};
|
|
499
|
-
function
|
|
491
|
+
function On(e) {
|
|
500
492
|
if (!e || typeof e != "object") return;
|
|
501
493
|
let t = e;
|
|
502
494
|
if (Array.isArray(t.data_root)) return {
|
|
@@ -511,7 +503,7 @@ function Dn(e) {
|
|
|
511
503
|
}))
|
|
512
504
|
};
|
|
513
505
|
}
|
|
514
|
-
function
|
|
506
|
+
function kn(e) {
|
|
515
507
|
return {
|
|
516
508
|
data_root: Array.from(e.data_root),
|
|
517
509
|
chunks: e.chunks.map((e) => ({
|
|
@@ -526,21 +518,21 @@ function On(e) {
|
|
|
526
518
|
}
|
|
527
519
|
//#endregion
|
|
528
520
|
//#region src/services/publish/actors/createArweaveTransactions.ts
|
|
529
|
-
var
|
|
521
|
+
var An = L(async ({ input: { context: e } }) => {
|
|
530
522
|
let { item: t } = e;
|
|
531
|
-
t.getPublishUploads || (t = await
|
|
523
|
+
t.getPublishUploads || (t = await Dn(t.seedLocalId));
|
|
532
524
|
let n = {};
|
|
533
525
|
e.arweaveUploadTags?.length && (n.arweaveUploadTags = e.arweaveUploadTags);
|
|
534
526
|
let r = e.htmlEmbeddedDeferredHtmlSeedLocalIds;
|
|
535
527
|
r?.length && (n.deferHtmlStorageSeedLocalIds = r);
|
|
536
|
-
let i = await t.getPublishUploads(Object.keys(n).length ? n : void 0), a =
|
|
528
|
+
let i = await t.getPublishUploads(Object.keys(n).length ? n : void 0), a = D(), o = e.signArweaveTransactions ?? a.signArweaveTransactions, s = e.arweaveJwk ?? a.arweaveJwk, c = i.map((e) => ({
|
|
537
529
|
versionLocalId: e.versionLocalId,
|
|
538
530
|
itemPropertyName: e.itemPropertyName,
|
|
539
531
|
transactionJson: e.transactionToSign.toJSON()
|
|
540
532
|
})), l;
|
|
541
533
|
if (o) l = await o(c);
|
|
542
534
|
else if (s) {
|
|
543
|
-
let e =
|
|
535
|
+
let e = B(), t = s;
|
|
544
536
|
l = [];
|
|
545
537
|
for (let n of c) {
|
|
546
538
|
let r = e.transactions.fromRaw(n.transactionJson);
|
|
@@ -549,17 +541,17 @@ var kn = I(async ({ input: { context: e } }) => {
|
|
|
549
541
|
l.push({
|
|
550
542
|
transaction: {
|
|
551
543
|
...i,
|
|
552
|
-
chunks: r.chunks ?
|
|
544
|
+
chunks: r.chunks ? kn(r.chunks) : void 0
|
|
553
545
|
},
|
|
554
546
|
versionId: n.versionLocalId,
|
|
555
547
|
modelName: n.itemPropertyName
|
|
556
548
|
});
|
|
557
549
|
}
|
|
558
550
|
} else throw Error("Arweave signing not configured. Provide signArweaveTransactions or arweaveJwk at createPublish or in PublishProvider config.");
|
|
559
|
-
let u =
|
|
551
|
+
let u = B();
|
|
560
552
|
return {
|
|
561
553
|
arweaveTransactions: l.map((e) => {
|
|
562
|
-
let { chunks: t, ...n } = e.transaction, r = { ...n }, i =
|
|
554
|
+
let { chunks: t, ...n } = e.transaction, r = { ...n }, i = On(t);
|
|
563
555
|
return i && (r.chunks = i), {
|
|
564
556
|
transaction: u.transactions.fromRaw(r),
|
|
565
557
|
versionId: e.versionId,
|
|
@@ -568,21 +560,21 @@ var kn = I(async ({ input: { context: e } }) => {
|
|
|
568
560
|
}),
|
|
569
561
|
publishUploads: i
|
|
570
562
|
};
|
|
571
|
-
}),
|
|
563
|
+
}), jn = L(async ({ input: { context: e } }) => {
|
|
572
564
|
let { item: t } = e;
|
|
573
|
-
t.getPublishUploads || (t = await
|
|
565
|
+
t.getPublishUploads || (t = await Dn(t.seedLocalId));
|
|
574
566
|
let n = {};
|
|
575
567
|
e.arweaveUploadTags?.length && (n.arweaveUploadTags = e.arweaveUploadTags);
|
|
576
568
|
let r = e.htmlEmbeddedDeferredHtmlSeedLocalIds;
|
|
577
569
|
r?.length && (n.onlyHtmlStorageSeedLocalIds = r);
|
|
578
|
-
let i = await t.getPublishUploads(Object.keys(n).length ? n : void 0), a =
|
|
570
|
+
let i = await t.getPublishUploads(Object.keys(n).length ? n : void 0), a = D(), o = e.signArweaveTransactions ?? a.signArweaveTransactions, s = e.arweaveJwk ?? a.arweaveJwk, c = i.map((e) => ({
|
|
579
571
|
versionLocalId: e.versionLocalId,
|
|
580
572
|
itemPropertyName: e.itemPropertyName,
|
|
581
573
|
transactionJson: e.transactionToSign.toJSON()
|
|
582
574
|
})), l;
|
|
583
575
|
if (o) l = await o(c);
|
|
584
576
|
else if (s) {
|
|
585
|
-
let e =
|
|
577
|
+
let e = B(), t = s;
|
|
586
578
|
l = [];
|
|
587
579
|
for (let n of c) {
|
|
588
580
|
let r = e.transactions.fromRaw(n.transactionJson);
|
|
@@ -591,17 +583,17 @@ var kn = I(async ({ input: { context: e } }) => {
|
|
|
591
583
|
l.push({
|
|
592
584
|
transaction: {
|
|
593
585
|
...i,
|
|
594
|
-
chunks: r.chunks ?
|
|
586
|
+
chunks: r.chunks ? kn(r.chunks) : void 0
|
|
595
587
|
},
|
|
596
588
|
versionId: n.versionLocalId,
|
|
597
589
|
modelName: n.itemPropertyName
|
|
598
590
|
});
|
|
599
591
|
}
|
|
600
592
|
} else throw Error("Arweave signing not configured. Provide signArweaveTransactions or arweaveJwk at createPublish or in PublishProvider config.");
|
|
601
|
-
let u =
|
|
593
|
+
let u = B();
|
|
602
594
|
return {
|
|
603
595
|
arweaveTransactions: l.map((e) => {
|
|
604
|
-
let { chunks: t, ...n } = e.transaction, r = { ...n }, i =
|
|
596
|
+
let { chunks: t, ...n } = e.transaction, r = { ...n }, i = On(t);
|
|
605
597
|
return i && (r.chunks = i), {
|
|
606
598
|
transaction: u.transactions.fromRaw(r),
|
|
607
599
|
versionId: e.versionId,
|
|
@@ -610,13 +602,13 @@ var kn = I(async ({ input: { context: e } }) => {
|
|
|
610
602
|
}),
|
|
611
603
|
publishUploads: i
|
|
612
604
|
};
|
|
613
|
-
}),
|
|
605
|
+
}), Mn = L(async ({ input: { context: e } }) => {
|
|
614
606
|
let t = e.htmlEmbeddedDataUriPolicy ?? "materialize";
|
|
615
607
|
return { deferredHtmlSeedLocalIds: (await Ze(e.item, t)).deferredHtmlSeedLocalIds };
|
|
616
608
|
});
|
|
617
609
|
//#endregion
|
|
618
610
|
//#region src/services/publish/actors/rewritingHtmlEmbedded.ts
|
|
619
|
-
function
|
|
611
|
+
function Nn(e, t) {
|
|
620
612
|
let n = [], r = Math.min(e?.length ?? 0, t?.length ?? 0);
|
|
621
613
|
for (let i = 0; i < r; i++) {
|
|
622
614
|
let r = e[i], a = t[i], o = r.transaction?.id;
|
|
@@ -628,10 +620,10 @@ function Mn(e, t) {
|
|
|
628
620
|
}
|
|
629
621
|
return n;
|
|
630
622
|
}
|
|
631
|
-
var
|
|
632
|
-
let t =
|
|
633
|
-
await et(e.item.seedLocalId, t);
|
|
634
|
-
}),
|
|
623
|
+
var Pn = L(async ({ input: { context: e } }) => {
|
|
624
|
+
let t = Nn(e.htmlEmbeddedPhase1ArweaveTransactions, e.htmlEmbeddedPhase1PublishUploads);
|
|
625
|
+
await et(e.item.seedLocalId, t, e.htmlEmbeddedDeferredHtmlSeedLocalIds);
|
|
626
|
+
}), Fn = (e, t, n) => {
|
|
635
627
|
let r = [];
|
|
636
628
|
return e && r.push({
|
|
637
629
|
name: "Content-SHA-256",
|
|
@@ -640,10 +632,10 @@ var Nn = I(async ({ input: { context: e } }) => {
|
|
|
640
632
|
name: "Content-Type",
|
|
641
633
|
value: t
|
|
642
634
|
}), n?.length && r.push(...n), r;
|
|
643
|
-
},
|
|
635
|
+
}, In = async (e) => {
|
|
644
636
|
let t = (e instanceof Uint8Array, new Uint8Array(e)), n = await crypto.subtle.digest("SHA-256", t);
|
|
645
637
|
return Array.from(new Uint8Array(n)).map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
646
|
-
},
|
|
638
|
+
}, Ln = {
|
|
647
639
|
png: "image/png",
|
|
648
640
|
jpg: "image/jpeg",
|
|
649
641
|
jpeg: "image/jpeg",
|
|
@@ -654,20 +646,20 @@ var Nn = I(async ({ input: { context: e } }) => {
|
|
|
654
646
|
htm: "text/html",
|
|
655
647
|
json: "application/json",
|
|
656
648
|
txt: "text/plain"
|
|
657
|
-
},
|
|
649
|
+
}, Rn = (e) => {
|
|
658
650
|
let t = e.split(".").pop()?.toLowerCase();
|
|
659
|
-
return t ?
|
|
660
|
-
},
|
|
651
|
+
return t ? Ln[t] : void 0;
|
|
652
|
+
}, zn = async (e) => typeof Blob < "u" && e instanceof Blob ? new Uint8Array(await e.arrayBuffer()) : new Uint8Array(e), Bn = (e) => {
|
|
661
653
|
switch (e) {
|
|
662
|
-
case "Image": return
|
|
663
|
-
case "File": return
|
|
664
|
-
case "Html": return
|
|
665
|
-
case "Json": return
|
|
666
|
-
default: return
|
|
667
|
-
}
|
|
668
|
-
},
|
|
669
|
-
function
|
|
670
|
-
let t =
|
|
654
|
+
case "Image": return M.getFilesPath("images");
|
|
655
|
+
case "File": return M.getFilesPath("files");
|
|
656
|
+
case "Html": return M.getFilesPath("html");
|
|
657
|
+
case "Json": return M.getFilesPath("json");
|
|
658
|
+
default: return M.getFilesPath("images");
|
|
659
|
+
}
|
|
660
|
+
}, Vn = /^data:(image\/[a-zA-Z0-9.+-]+);base64,([\s\S]*)$/i;
|
|
661
|
+
function Hn(e) {
|
|
662
|
+
let t = Vn.exec((e ?? "").trim());
|
|
671
663
|
if (!t) return null;
|
|
672
664
|
try {
|
|
673
665
|
let e = t[1].toLowerCase().trim(), n = t[2].replace(/\s/g, "");
|
|
@@ -679,11 +671,11 @@ function Vn(e) {
|
|
|
679
671
|
return null;
|
|
680
672
|
}
|
|
681
673
|
}
|
|
682
|
-
var
|
|
674
|
+
var Un = async (e, t, n, r) => {
|
|
683
675
|
let i = r?.arweaveUploadTags, a = e.itemProperty, o = [];
|
|
684
676
|
for (let t of e.childProperties) {
|
|
685
677
|
let e = t.localStoragePath;
|
|
686
|
-
e && !e.endsWith("undefined") && await
|
|
678
|
+
e && !e.endsWith("undefined") && await M.pathExists(e) && o.push({
|
|
687
679
|
propertyName: t.propertyName,
|
|
688
680
|
localStoragePath: e
|
|
689
681
|
});
|
|
@@ -691,14 +683,14 @@ var Hn = async (e, t, n, r) => {
|
|
|
691
683
|
let s;
|
|
692
684
|
if ((!o || o.length === 0) && n?.localStoragePath) {
|
|
693
685
|
let e = n.localStoragePath;
|
|
694
|
-
if (e && !e.endsWith("undefined") && await
|
|
695
|
-
s = await
|
|
686
|
+
if (e && !e.endsWith("undefined") && await M.pathExists(e)) try {
|
|
687
|
+
s = await zn(await M.readFileAsBuffer(e));
|
|
696
688
|
} catch {
|
|
697
|
-
s = await
|
|
689
|
+
s = await zn((await M.getFs()).readFileSync(e));
|
|
698
690
|
}
|
|
699
691
|
}
|
|
700
692
|
if (o.length > 0) {
|
|
701
|
-
let e = "===FILE_SEPARATOR===", t = "", n = await
|
|
693
|
+
let e = "===FILE_SEPARATOR===", t = "", n = await M.getFs();
|
|
702
694
|
for (let r of o) {
|
|
703
695
|
let i;
|
|
704
696
|
try {
|
|
@@ -711,40 +703,40 @@ var Hn = async (e, t, n, r) => {
|
|
|
711
703
|
s = typeof document < "u" ? new TextEncoder().encode(t) : new Uint8Array(Buffer.from(t));
|
|
712
704
|
}
|
|
713
705
|
if (!s) return t;
|
|
714
|
-
let c = new Uint8Array(s), l = await
|
|
715
|
-
o.length === 0 && n?.localStoragePath ? u =
|
|
706
|
+
let c = new Uint8Array(s), l = await In(c), u;
|
|
707
|
+
o.length === 0 && n?.localStoragePath ? u = Rn(n.localStoragePath) : o.length > 0 && (u = "application/octet-stream");
|
|
716
708
|
let d = n ? n.localId : a.localId, f = n ? n.propertyName : a.propertyName;
|
|
717
709
|
return t.push({
|
|
718
710
|
data: c,
|
|
719
711
|
contentHash: l,
|
|
720
712
|
contentType: u,
|
|
721
|
-
tags:
|
|
713
|
+
tags: Fn(l, u, i),
|
|
722
714
|
itemPropertyName: f,
|
|
723
715
|
itemPropertyLocalId: d,
|
|
724
716
|
seedLocalId: a.seedLocalId,
|
|
725
717
|
versionLocalId: a.versionLocalId
|
|
726
718
|
}), t;
|
|
727
|
-
},
|
|
719
|
+
}, Wn = async (e, t) => {
|
|
728
720
|
let n = [], r = t?.arweaveUploadTags;
|
|
729
721
|
for (let i of e) {
|
|
730
722
|
let e = i.getService().getSnapshot(), a = "context" in e ? e.context : null;
|
|
731
723
|
if (!a) continue;
|
|
732
724
|
let o = a.propertyValue, s = a.refResolvedValue;
|
|
733
725
|
if (!s) continue;
|
|
734
|
-
let { localId: c } =
|
|
726
|
+
let { localId: c } = Ie(o ?? "");
|
|
735
727
|
if (!c) continue;
|
|
736
728
|
let l = i.propertyDef?.refValueType ?? i.propertyDef?.dataType ?? "Image";
|
|
737
|
-
if (l ===
|
|
729
|
+
if (l === je.Html) {
|
|
738
730
|
if (t?.deferHtmlStorageSeedLocalIds?.includes(c) || t?.onlyHtmlStorageSeedLocalIds?.length && !t.onlyHtmlStorageSeedLocalIds.includes(c)) continue;
|
|
739
731
|
} else if (t?.onlyHtmlStorageSeedLocalIds?.length) continue;
|
|
740
|
-
let u = `${
|
|
741
|
-
if (!await
|
|
742
|
-
let d = await
|
|
732
|
+
let u = `${Bn(l)}/${s}`;
|
|
733
|
+
if (!await M.pathExists(u)) continue;
|
|
734
|
+
let d = await zn(await M.readFileAsBuffer(u)), f = await In(d), p = Rn(s);
|
|
743
735
|
n.push({
|
|
744
736
|
data: d,
|
|
745
737
|
contentHash: f,
|
|
746
738
|
contentType: p,
|
|
747
|
-
tags:
|
|
739
|
+
tags: Fn(f, p, r),
|
|
748
740
|
itemPropertyName: i.propertyName,
|
|
749
741
|
itemPropertyLocalId: i.localId,
|
|
750
742
|
seedLocalId: c,
|
|
@@ -753,25 +745,25 @@ var Hn = async (e, t, n, r) => {
|
|
|
753
745
|
}
|
|
754
746
|
return n;
|
|
755
747
|
};
|
|
756
|
-
async function
|
|
757
|
-
let r =
|
|
748
|
+
async function Gn(e, t, n) {
|
|
749
|
+
let r = ke.getAppDb();
|
|
758
750
|
if (!r || n?.onlyHtmlStorageSeedLocalIds?.length) return t;
|
|
759
|
-
let i = await r.select().from(We).where(
|
|
751
|
+
let i = await r.select().from(We).where(z(We.parentSeedLocalId, e.seedLocalId)), a = new Set(t.map((e) => e.seedLocalId));
|
|
760
752
|
for (let e of i) {
|
|
761
753
|
if (a.has(e.imageSeedLocalId)) continue;
|
|
762
|
-
let r = await
|
|
754
|
+
let r = await N.find({
|
|
763
755
|
seedLocalId: e.imageSeedLocalId,
|
|
764
756
|
modelName: "Image"
|
|
765
757
|
});
|
|
766
758
|
if (!r) continue;
|
|
767
|
-
let i = r.internalProperties.storageTransactionId ?? r.allProperties.storageTransactionId, o = i?.getService().getSnapshot(), s = o && "context" in o ? o.context : void 0, c =
|
|
759
|
+
let i = r.internalProperties.storageTransactionId ?? r.allProperties.storageTransactionId, o = i?.getService().getSnapshot(), s = o && "context" in o ? o.context : void 0, c = Hn(typeof s?.propertyValue == "string" ? s.propertyValue ?? "" : ""), l = [];
|
|
768
760
|
if (c && i && i.localId && i.versionLocalId) {
|
|
769
|
-
let e = await
|
|
761
|
+
let e = await In(c.bytes);
|
|
770
762
|
l = [{
|
|
771
763
|
data: c.bytes,
|
|
772
764
|
contentHash: e,
|
|
773
765
|
contentType: c.mimeType,
|
|
774
|
-
tags:
|
|
766
|
+
tags: Fn(e, c.mimeType, n?.arweaveUploadTags),
|
|
775
767
|
itemPropertyName: i.propertyName,
|
|
776
768
|
itemPropertyLocalId: i.localId,
|
|
777
769
|
seedLocalId: r.seedLocalId,
|
|
@@ -782,58 +774,68 @@ async function Wn(e, t, n) {
|
|
|
782
774
|
}
|
|
783
775
|
return t;
|
|
784
776
|
}
|
|
785
|
-
var
|
|
777
|
+
var Kn = (e) => !e.seedUid || e.seedUid === "0x" + "0".repeat(64), qn = async (e, t, n, r) => {
|
|
786
778
|
let { itemUploadProperties: i, itemRelationProperties: a, itemImageProperties: o } = await Ve(e);
|
|
787
779
|
if (r?.onlyHtmlStorageSeedLocalIds?.length) {
|
|
788
|
-
let e = await
|
|
780
|
+
let e = await Wn(o, r);
|
|
789
781
|
t.push(...e);
|
|
790
782
|
} else {
|
|
791
|
-
for (let e of i) t = await
|
|
792
|
-
let a = await
|
|
793
|
-
t.push(...a), (!n ||
|
|
783
|
+
for (let e of i) t = await Un(e, t, n, r);
|
|
784
|
+
let a = await Wn(o, r);
|
|
785
|
+
t.push(...a), (!n || Kn(e)) && (t = await Gn(e, t, r));
|
|
794
786
|
}
|
|
795
787
|
if (r?.skipRelationRecursion) return t;
|
|
788
|
+
let s = new Set(o);
|
|
796
789
|
for (let e of a) {
|
|
790
|
+
if (!s.has(e)) continue;
|
|
797
791
|
let n = e.getService().getSnapshot(), i = "context" in n ? n.context : null;
|
|
798
792
|
if (!i) continue;
|
|
799
793
|
let a = i.propertyValue;
|
|
800
794
|
if (!a || e.uid) continue;
|
|
801
|
-
let { seedLocalId: o, seedUid:
|
|
802
|
-
if (!o && !
|
|
803
|
-
let
|
|
795
|
+
let { seedLocalId: o, seedUid: c } = $e(Xe(a) ?? "");
|
|
796
|
+
if (!o && !c) throw Error(`Invalid relation value for ${e.propertyName}: expected local seed id or 0x uid`);
|
|
797
|
+
let l = await N.find({
|
|
804
798
|
seedLocalId: o,
|
|
805
|
-
seedUid:
|
|
799
|
+
seedUid: c
|
|
806
800
|
});
|
|
807
|
-
if (!
|
|
801
|
+
if (!l) {
|
|
808
802
|
if (Ke(a)) continue;
|
|
809
803
|
throw Error(`No relatedItem found for ${e.propertyName}`);
|
|
810
804
|
}
|
|
811
|
-
t = await
|
|
805
|
+
t = await qn(l, t, e, {
|
|
806
|
+
...r,
|
|
807
|
+
skipRelationRecursion: !0
|
|
808
|
+
});
|
|
812
809
|
}
|
|
813
810
|
return t;
|
|
814
|
-
},
|
|
815
|
-
|
|
816
|
-
let
|
|
811
|
+
}, Jn = async (e, t = [], n, r) => {
|
|
812
|
+
if (t = await qn(e, t, n, r), r?.skipRelationRecursion) return t;
|
|
813
|
+
let { drafts: i } = await ze(e, { strict: !0 });
|
|
814
|
+
for (let { item: e, via: n, viaList: a } of i) t = await qn(e, t, a ? void 0 : n, r);
|
|
815
|
+
return t;
|
|
816
|
+
}, Yn = 3, Xn = new TextEncoder().encode("seed-recovery"), Zn = 32, Qn = 18446744073709551615n;
|
|
817
|
+
function $n(e, t, n) {
|
|
818
|
+
let r = F.solidityPackedKeccak256([
|
|
817
819
|
"uint256",
|
|
818
820
|
"address",
|
|
819
821
|
"uint64"
|
|
820
822
|
], [
|
|
821
823
|
BigInt(t),
|
|
822
824
|
e,
|
|
823
|
-
n &
|
|
825
|
+
n & Qn
|
|
824
826
|
]);
|
|
825
|
-
return
|
|
827
|
+
return F.getBytes(r);
|
|
826
828
|
}
|
|
827
|
-
function
|
|
829
|
+
function er(e) {
|
|
828
830
|
if (e.length === 0) return new Uint8Array([0]);
|
|
829
|
-
if (e.length !==
|
|
831
|
+
if (e.length !== Zn) throw Error(`ANS-104 target/anchor must be empty or ${Zn} bytes, got ${e.length}`);
|
|
830
832
|
let t = /* @__PURE__ */ new Uint8Array(33);
|
|
831
833
|
return t[0] = 1, t.set(e, 1), t;
|
|
832
834
|
}
|
|
833
|
-
function
|
|
835
|
+
function tr(e) {
|
|
834
836
|
return typeof e == "object" && !!e && "privateKey" in e && typeof e.privateKey == "string";
|
|
835
837
|
}
|
|
836
|
-
function
|
|
838
|
+
function nr(e, t, n) {
|
|
837
839
|
let r = e >= 0 ? e << 1 : ~e << 1 | 1, i = n;
|
|
838
840
|
do {
|
|
839
841
|
let e = r & 127;
|
|
@@ -841,10 +843,10 @@ function er(e, t, n) {
|
|
|
841
843
|
} while (r);
|
|
842
844
|
return i - n;
|
|
843
845
|
}
|
|
844
|
-
var
|
|
846
|
+
var rr = (e) => {
|
|
845
847
|
if (!e?.length) return /* @__PURE__ */ new Uint8Array();
|
|
846
848
|
let t = new TextEncoder(), n = /* @__PURE__ */ new Uint8Array(16), r = [], i = (e) => {
|
|
847
|
-
let t =
|
|
849
|
+
let t = nr(e, n, 0);
|
|
848
850
|
r.push(n.slice(0, t));
|
|
849
851
|
};
|
|
850
852
|
i(e.length);
|
|
@@ -856,35 +858,35 @@ var tr = (e) => {
|
|
|
856
858
|
let a = r.reduce((e, t) => e + t.length, 0), o = new Uint8Array(a), s = 0;
|
|
857
859
|
for (let e of r) o.set(e, s), s += e.length;
|
|
858
860
|
return o;
|
|
859
|
-
},
|
|
861
|
+
}, ir = (e) => {
|
|
860
862
|
let t = /* @__PURE__ */ new Uint8Array(8), n = new DataView(t.buffer);
|
|
861
|
-
return n.setUint32(0, e
|
|
863
|
+
return n.setUint32(0, e | 0, !0), n.setUint32(4, Math.floor(e / 4294967296), !0), t;
|
|
862
864
|
};
|
|
863
|
-
async function
|
|
865
|
+
async function ar(e) {
|
|
864
866
|
return new Uint8Array(await crypto.subtle.digest("SHA-384", e));
|
|
865
867
|
}
|
|
866
|
-
function
|
|
868
|
+
function or(e, t) {
|
|
867
869
|
let n = new Uint8Array(e.length + t.length);
|
|
868
870
|
return n.set(e, 0), n.set(t, e.length), n;
|
|
869
871
|
}
|
|
870
|
-
async function
|
|
872
|
+
async function sr(e) {
|
|
871
873
|
let t = new TextEncoder();
|
|
872
874
|
if (Array.isArray(e)) {
|
|
873
|
-
let n = await
|
|
875
|
+
let n = await ar(or(t.encode("list"), t.encode(e.length.toString())));
|
|
874
876
|
for (let t of e) {
|
|
875
|
-
let e = await
|
|
876
|
-
n = await
|
|
877
|
+
let e = await sr(t);
|
|
878
|
+
n = await ar(or(n, e));
|
|
877
879
|
}
|
|
878
880
|
return n;
|
|
879
881
|
}
|
|
880
|
-
return
|
|
882
|
+
return ar(or(await ar(or(t.encode("blob"), t.encode(e.byteLength.toString()))), await ar(e)));
|
|
881
883
|
}
|
|
882
|
-
async function
|
|
884
|
+
async function cr(e, t, n, r, i) {
|
|
883
885
|
let a = new TextEncoder();
|
|
884
|
-
return
|
|
886
|
+
return sr([
|
|
885
887
|
a.encode("dataitem"),
|
|
886
888
|
a.encode("1"),
|
|
887
|
-
a.encode(
|
|
889
|
+
a.encode(Yn.toString()),
|
|
888
890
|
e,
|
|
889
891
|
t,
|
|
890
892
|
n,
|
|
@@ -892,11 +894,11 @@ async function or(e, t, n, r, i) {
|
|
|
892
894
|
i
|
|
893
895
|
]);
|
|
894
896
|
}
|
|
895
|
-
function
|
|
896
|
-
let a =
|
|
897
|
+
function lr(e, t, n, r, i) {
|
|
898
|
+
let a = rr(t), o = ir(t.length), s = ir(a.length), c = [
|
|
897
899
|
e,
|
|
898
|
-
|
|
899
|
-
|
|
900
|
+
er(r),
|
|
901
|
+
er(i),
|
|
900
902
|
o,
|
|
901
903
|
s,
|
|
902
904
|
a,
|
|
@@ -905,25 +907,25 @@ function sr(e, t, n, r, i) {
|
|
|
905
907
|
for (let e of c) u.set(e, d), d += e.length;
|
|
906
908
|
return u;
|
|
907
909
|
}
|
|
908
|
-
async function
|
|
910
|
+
async function ur(e, t) {
|
|
909
911
|
let n = /* @__PURE__ */ new Uint8Array(2);
|
|
910
|
-
new DataView(n.buffer).setUint16(0,
|
|
912
|
+
new DataView(n.buffer).setUint16(0, Yn, !0);
|
|
911
913
|
let r = 67 + t.length, i = new Uint8Array(r);
|
|
912
914
|
i.set(n, 0), i.set(e, 2), i.set(t, 67);
|
|
913
915
|
let a = await crypto.subtle.digest("SHA-256", new Uint8Array(e));
|
|
914
916
|
return {
|
|
915
|
-
id:
|
|
917
|
+
id: gr(new Uint8Array(a)),
|
|
916
918
|
raw: i
|
|
917
919
|
};
|
|
918
920
|
}
|
|
919
|
-
var
|
|
920
|
-
let i =
|
|
921
|
-
return
|
|
922
|
-
},
|
|
923
|
-
let i =
|
|
924
|
-
return
|
|
921
|
+
var dr = async (e, t, n, r = /* @__PURE__ */ new Uint8Array()) => {
|
|
922
|
+
let i = F.SigningKey.computePublicKey(t.privateKey, !1), a = F.getBytes(i), o = rr(n), s = /* @__PURE__ */ new Uint8Array(), c = await cr(a, s, r, o, e);
|
|
923
|
+
return ur(F.getBytes(await t.signMessage(c)), lr(a, n, e, s, r));
|
|
924
|
+
}, fr = async (e, t, n, r = /* @__PURE__ */ new Uint8Array()) => {
|
|
925
|
+
let i = F.hexlify(Xn), a = await t.signMessage({ message: { raw: i } }), o = F.hashMessage(Xn), s = F.SigningKey.recoverPublicKey(o, a), c = F.getBytes(s), l = rr(n), u = /* @__PURE__ */ new Uint8Array(), d = await cr(c, u, r, l, e), f = F.hexlify(d), p = await t.signMessage({ message: { raw: f } });
|
|
926
|
+
return ur(F.getBytes(p), lr(c, n, e, u, r));
|
|
925
927
|
};
|
|
926
|
-
function
|
|
928
|
+
function pr(e) {
|
|
927
929
|
if (e.length < 133) return null;
|
|
928
930
|
let t = e[132];
|
|
929
931
|
if (t !== 0 && t !== 1) return null;
|
|
@@ -936,8 +938,8 @@ function dr(e) {
|
|
|
936
938
|
let a = i === 1;
|
|
937
939
|
return a && e.length < r + 33 ? null : r + (a ? 33 : 1);
|
|
938
940
|
}
|
|
939
|
-
function
|
|
940
|
-
let t =
|
|
941
|
+
function mr(e) {
|
|
942
|
+
let t = pr(e);
|
|
941
943
|
if (t == null) return null;
|
|
942
944
|
let n = e[132] === 1, r = n ? e.slice(133, 165) : /* @__PURE__ */ new Uint8Array(), i = 132 + (n ? 33 : 1);
|
|
943
945
|
return {
|
|
@@ -946,29 +948,29 @@ function fr(e) {
|
|
|
946
948
|
tagsStart: t
|
|
947
949
|
};
|
|
948
950
|
}
|
|
949
|
-
async function
|
|
950
|
-
let t =
|
|
951
|
+
async function hr(e) {
|
|
952
|
+
let t = mr(e);
|
|
951
953
|
if (t == null) return !1;
|
|
952
954
|
let { rawTarget: n, rawAnchor: r, tagsStart: i } = t, a = i + 16;
|
|
953
955
|
if (e.length < a) return !1;
|
|
954
956
|
let o = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
955
|
-
if (o.getUint16(0, !0) !==
|
|
957
|
+
if (o.getUint16(0, !0) !== Yn) return !1;
|
|
956
958
|
let s = e.slice(2, 67), c = e.slice(67, 132), l = Number(o.getUint32(i + 8, !0) + o.getUint32(i + 12, !0) * 4294967296), u = i + 16 + l;
|
|
957
959
|
if (e.length < u) return !1;
|
|
958
960
|
let d = e.slice(i + 16, u), f = e.slice(u);
|
|
959
961
|
try {
|
|
960
|
-
let e = await
|
|
962
|
+
let e = await cr(c, n, r, d, f), t = F.hashMessage(e), i = F.hexlify(s), a = F.SigningKey.recoverPublicKey(t, i), o = F.getBytes(a);
|
|
961
963
|
return o.length === c.length && o.every((e, t) => e === c[t]);
|
|
962
964
|
} catch {
|
|
963
965
|
return !1;
|
|
964
966
|
}
|
|
965
967
|
}
|
|
966
|
-
var
|
|
968
|
+
var gr = (e) => {
|
|
967
969
|
let t = "";
|
|
968
970
|
for (let n of e) t += String.fromCharCode(n);
|
|
969
971
|
return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
970
|
-
},
|
|
971
|
-
async function
|
|
972
|
+
}, _r = R("seedProtocol:createArweaveDataItems");
|
|
973
|
+
async function vr(e, t, n) {
|
|
972
974
|
let r, a;
|
|
973
975
|
if (t) r = (await t(e)).map((e) => ({
|
|
974
976
|
transaction: { id: e.transaction.id },
|
|
@@ -981,14 +983,14 @@ async function gr(e, t, n) {
|
|
|
981
983
|
let a = e[r], s = a.tags, c = /* @__PURE__ */ new Uint8Array(8);
|
|
982
984
|
crypto.getRandomValues(c);
|
|
983
985
|
let l = (new DataView(c.buffer).getBigUint64(0, !1) ^ BigInt(r)) & 18446744073709551615n, u;
|
|
984
|
-
if (
|
|
985
|
-
let e =
|
|
986
|
-
u = await
|
|
986
|
+
if (tr(n)) {
|
|
987
|
+
let e = $n(n.address, o, l);
|
|
988
|
+
u = await dr(a.data, n, s, e);
|
|
987
989
|
} else {
|
|
988
|
-
let e = i(n) ? n.signer : n, t =
|
|
989
|
-
u = await
|
|
990
|
+
let e = i(n) ? n.signer : n, t = $n(e.address, o, l);
|
|
991
|
+
u = await fr(a.data, e, s, t);
|
|
990
992
|
}
|
|
991
|
-
if (!await
|
|
993
|
+
if (!await hr(u.raw)) throw _r("DataItem verification failed: id=%s modelName=%s", u.id, a.itemPropertyName), Error(`DataItem signature verification failed for ${a.itemPropertyName}. The signing key may not match the owner, or the payload may have been modified.`);
|
|
992
994
|
t.push(u);
|
|
993
995
|
}
|
|
994
996
|
a = t, r = t.map((t, n) => ({
|
|
@@ -1010,47 +1012,47 @@ async function gr(e, t, n) {
|
|
|
1010
1012
|
signedDataItems: a
|
|
1011
1013
|
};
|
|
1012
1014
|
}
|
|
1013
|
-
var
|
|
1015
|
+
var yr = L(async ({ input: { context: e } }) => {
|
|
1014
1016
|
let { item: t } = e;
|
|
1015
|
-
t.getPublishUploads || (t = await
|
|
1017
|
+
t.getPublishUploads || (t = await Dn(t.seedLocalId));
|
|
1016
1018
|
let n = {};
|
|
1017
1019
|
e.arweaveUploadTags?.length && (n.arweaveUploadTags = e.arweaveUploadTags);
|
|
1018
1020
|
let r = e.htmlEmbeddedDeferredHtmlSeedLocalIds;
|
|
1019
1021
|
r?.length && (n.deferHtmlStorageSeedLocalIds = r);
|
|
1020
|
-
let i = await
|
|
1021
|
-
return
|
|
1022
|
+
let i = await Jn(t, [], void 0, Object.keys(n).length ? n : void 0), a = D();
|
|
1023
|
+
return vr(i, e.signDataItems ?? a.signDataItems, e.dataItemSigner ?? a.dataItemSigner);
|
|
1022
1024
|
});
|
|
1023
1025
|
//#endregion
|
|
1024
1026
|
//#region src/services/publish/actors/createArweaveDataItemsPhase2.ts
|
|
1025
|
-
async function
|
|
1027
|
+
async function br(e) {
|
|
1026
1028
|
let { item: t } = e;
|
|
1027
|
-
t.getPublishUploads || (t = await
|
|
1029
|
+
t.getPublishUploads || (t = await Dn(t.seedLocalId));
|
|
1028
1030
|
let n = {};
|
|
1029
1031
|
e.arweaveUploadTags?.length && (n.arweaveUploadTags = e.arweaveUploadTags);
|
|
1030
1032
|
let r = e.htmlEmbeddedDeferredHtmlSeedLocalIds;
|
|
1031
1033
|
r?.length && (n.onlyHtmlStorageSeedLocalIds = r);
|
|
1032
|
-
let i = await
|
|
1034
|
+
let i = await Jn(t, [], void 0, Object.keys(n).length ? n : void 0), a = D(), o = e.signDataItems ?? a.signDataItems, s = e.dataItemSigner ?? a.dataItemSigner;
|
|
1033
1035
|
return i.length === 0 ? {
|
|
1034
1036
|
arweaveTransactions: [],
|
|
1035
1037
|
publishUploads: [],
|
|
1036
1038
|
signedDataItems: void 0
|
|
1037
|
-
} :
|
|
1039
|
+
} : vr(i, o, s);
|
|
1038
1040
|
}
|
|
1039
|
-
var
|
|
1040
|
-
function
|
|
1041
|
+
var xr = L(async ({ input: { context: e } }) => br(e)), Sr = 8192;
|
|
1042
|
+
function Cr(e) {
|
|
1041
1043
|
let t = new Uint8Array(e), n = "";
|
|
1042
|
-
for (let e = 0; e < t.length; e +=
|
|
1043
|
-
let r = t.subarray(e, Math.min(e +
|
|
1044
|
+
for (let e = 0; e < t.length; e += Sr) {
|
|
1045
|
+
let r = t.subarray(e, Math.min(e + Sr, t.length));
|
|
1044
1046
|
n += String.fromCharCode.apply(null, r);
|
|
1045
1047
|
}
|
|
1046
1048
|
return btoa(n);
|
|
1047
1049
|
}
|
|
1048
|
-
async function
|
|
1050
|
+
async function wr(e) {
|
|
1049
1051
|
let t = [];
|
|
1050
1052
|
for (let [n, r] of e.entries()) {
|
|
1051
1053
|
let e = r;
|
|
1052
1054
|
if (typeof e == "object" && e && "arrayBuffer" in e) {
|
|
1053
|
-
let r =
|
|
1055
|
+
let r = Cr(await e.arrayBuffer()), i = e;
|
|
1054
1056
|
t.push({
|
|
1055
1057
|
name: n,
|
|
1056
1058
|
value: r,
|
|
@@ -1064,19 +1066,19 @@ async function Sr(e) {
|
|
|
1064
1066
|
}
|
|
1065
1067
|
return t;
|
|
1066
1068
|
}
|
|
1067
|
-
function
|
|
1069
|
+
function Tr(e, t, n) {
|
|
1068
1070
|
let r = ["Upload server returned ", String(e)], i = t && typeof t == "object" && "message" in t ? String(t.message) : t && typeof t == "object" && "error" in t ? String(t.error) : null;
|
|
1069
1071
|
return i ? r.push(`: ${i}`) : n && r.push(` (${n})`), r.join("");
|
|
1070
1072
|
}
|
|
1071
|
-
function
|
|
1073
|
+
function Er(e) {
|
|
1072
1074
|
if (!e) return "Upload server unavailable. Please try again or check your connection.";
|
|
1073
1075
|
let t = e.toLowerCase();
|
|
1074
1076
|
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.";
|
|
1075
1077
|
}
|
|
1076
|
-
async function
|
|
1078
|
+
async function Dr(e, t, n) {
|
|
1077
1079
|
let r = typeof window < "u" ? window.Main : void 0;
|
|
1078
1080
|
if (r?.uploadArweaveStart) {
|
|
1079
|
-
let n = await
|
|
1081
|
+
let n = await wr(t);
|
|
1080
1082
|
return r.uploadArweaveStart(e, n);
|
|
1081
1083
|
}
|
|
1082
1084
|
let i = await fetch(e, {
|
|
@@ -1090,7 +1092,7 @@ async function Tr(e, t, n) {
|
|
|
1090
1092
|
}
|
|
1091
1093
|
//#endregion
|
|
1092
1094
|
//#region src/services/publish/actors/sendReimbursementRequest.ts
|
|
1093
|
-
var
|
|
1095
|
+
var Or = L(async ({ input: { context: e, event: t } }) => {
|
|
1094
1096
|
let { arweaveTransactions: n = [], transactionKeys: r, reimbursementTransactionId: i } = e;
|
|
1095
1097
|
if (i) return { transactionId: i };
|
|
1096
1098
|
let a = n.map(({ transaction: e }) => e), o = new FormData();
|
|
@@ -1102,19 +1104,19 @@ var Er = I(async ({ input: { context: e, event: t } }) => {
|
|
|
1102
1104
|
let s = new Blob([JSON.stringify(r)], { type: "application/json" });
|
|
1103
1105
|
o.append(`${e.id}-json`, s, `${e.id}-json`);
|
|
1104
1106
|
}
|
|
1105
|
-
let { uploadApiBaseUrl: s } =
|
|
1107
|
+
let { uploadApiBaseUrl: s } = D(), { status: c, body: l, message: u } = await Dr(`${s}/api/upload/arweave/start`, o, s);
|
|
1106
1108
|
if (c >= 300 || c < 200) {
|
|
1107
1109
|
let e = c === 0 ? u : null;
|
|
1108
1110
|
e && console.error("[upload]", e);
|
|
1109
|
-
let t = c === 0 ?
|
|
1111
|
+
let t = c === 0 ? Er(e) : Tr(c, l, r);
|
|
1110
1112
|
throw Error(t);
|
|
1111
1113
|
}
|
|
1112
1114
|
return l;
|
|
1113
|
-
}),
|
|
1115
|
+
}), kr = L(async ({ input: { context: e, event: t } }) => {
|
|
1114
1116
|
let { requestResponse: n, reimbursementTransactionId: r } = e;
|
|
1115
1117
|
if (!n) throw Error("No request response");
|
|
1116
1118
|
if (!r) throw Error("No reimbursement transaction id");
|
|
1117
|
-
let i =
|
|
1119
|
+
let i = B();
|
|
1118
1120
|
await new Promise((e, t) => {
|
|
1119
1121
|
let n = setInterval(async () => {
|
|
1120
1122
|
let t;
|
|
@@ -1126,14 +1128,14 @@ var Er = I(async ({ input: { context: e, event: t } }) => {
|
|
|
1126
1128
|
t && t.confirmed && (clearInterval(n), e());
|
|
1127
1129
|
}, 5e3);
|
|
1128
1130
|
});
|
|
1129
|
-
}), W =
|
|
1130
|
-
function
|
|
1131
|
+
}), W = R("seedProtocol:services:publish:actors");
|
|
1132
|
+
function Ar(e) {
|
|
1131
1133
|
if (e instanceof Uint8Array) return e;
|
|
1132
1134
|
if (e instanceof ArrayBuffer) return new Uint8Array(e);
|
|
1133
1135
|
throw Error("Transaction data must be Uint8Array or ArrayBuffer for upload resume");
|
|
1134
1136
|
}
|
|
1135
|
-
var
|
|
1136
|
-
let n = t.context, r = (n.arweaveTransactions ?? []).map(({ transaction: e }) => e), i =
|
|
1137
|
+
var jr = Ht(({ sendBack: e, input: t }) => {
|
|
1138
|
+
let n = t.context, r = (n.arweaveTransactions ?? []).map(({ transaction: e }) => e), i = B(), a = n.uploaderState && typeof n.currentTransactionIndex == "number", o = a ? n.currentTransactionIndex : 0;
|
|
1137
1139
|
(async () => {
|
|
1138
1140
|
let t = r.length;
|
|
1139
1141
|
for (let s = o; s < t; s++) {
|
|
@@ -1143,7 +1145,7 @@ var kr = Ht(({ sendBack: e, input: t }) => {
|
|
|
1143
1145
|
if (!await i.transactions.verify(l)) throw Error("Transaction verification failed");
|
|
1144
1146
|
let u, d = n.uploaderState;
|
|
1145
1147
|
if (a && s === o && d) {
|
|
1146
|
-
let e = l.data, t = e instanceof Uint8Array ? e :
|
|
1148
|
+
let e = l.data, t = e instanceof Uint8Array ? e : Ar(e);
|
|
1147
1149
|
u = await i.transactions.getUploader(d, t);
|
|
1148
1150
|
} else u = await i.transactions.getUploader(l, l.data);
|
|
1149
1151
|
for (; !u.isComplete;) {
|
|
@@ -1172,20 +1174,20 @@ var kr = Ht(({ sendBack: e, input: t }) => {
|
|
|
1172
1174
|
error: t
|
|
1173
1175
|
});
|
|
1174
1176
|
});
|
|
1175
|
-
}),
|
|
1176
|
-
if (
|
|
1177
|
+
}), Mr = 12e4, Nr = Function("s", "return import(s)"), Pr = null, Fr = async () => {
|
|
1178
|
+
if (Pr) return Pr;
|
|
1177
1179
|
if (typeof window < "u") return null;
|
|
1178
1180
|
try {
|
|
1179
|
-
let e = await
|
|
1180
|
-
return
|
|
1181
|
+
let e = await Nr(`node:${["fs", "promises"].join("/")}`);
|
|
1182
|
+
return Pr = {
|
|
1181
1183
|
readFile: e.readFile,
|
|
1182
1184
|
stat: e.stat
|
|
1183
|
-
},
|
|
1185
|
+
}, Pr;
|
|
1184
1186
|
} catch {
|
|
1185
1187
|
return null;
|
|
1186
1188
|
}
|
|
1187
|
-
},
|
|
1188
|
-
let { signedDataItems: n } = t, { uploadApiBaseUrl: r, useArweaveBundler: i } =
|
|
1189
|
+
}, Ir = Ht(({ sendBack: e, input: { context: t } }) => {
|
|
1190
|
+
let { signedDataItems: n } = t, { uploadApiBaseUrl: r, useArweaveBundler: i } = D();
|
|
1189
1191
|
if (!i || !r) {
|
|
1190
1192
|
e({
|
|
1191
1193
|
type: "uploadError",
|
|
@@ -1194,14 +1196,10 @@ var kr = Ht(({ sendBack: e, input: t }) => {
|
|
|
1194
1196
|
return;
|
|
1195
1197
|
}
|
|
1196
1198
|
let a = `${r.replace(/\/$/, "")}/api/upload/arweave/batch`;
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
});
|
|
1202
|
-
return;
|
|
1203
|
-
}
|
|
1204
|
-
(async () => {
|
|
1199
|
+
!n || n.length === 0 ? e({
|
|
1200
|
+
type: "uploadComplete",
|
|
1201
|
+
result: "done"
|
|
1202
|
+
}) : (async () => {
|
|
1205
1203
|
let e = n, t = e.length, r = Array(t).fill(null), i = async (e, t) => {
|
|
1206
1204
|
let n = e;
|
|
1207
1205
|
if (n.raw != null && (n.raw instanceof Uint8Array || Buffer.isBuffer(n.raw))) return n.raw.byteLength;
|
|
@@ -1210,7 +1208,7 @@ var kr = Ht(({ sendBack: e, input: t }) => {
|
|
|
1210
1208
|
return r[t] = a, a.length;
|
|
1211
1209
|
}
|
|
1212
1210
|
if (n.filename != null) {
|
|
1213
|
-
let e = await
|
|
1211
|
+
let e = await Fr();
|
|
1214
1212
|
if (!e) throw Error("DataItem.filename requires Node.js fs access. In browser runtime, provide DataItem.raw or DataItem.getRaw().");
|
|
1215
1213
|
return (await e.stat(n.filename)).size;
|
|
1216
1214
|
}
|
|
@@ -1229,20 +1227,15 @@ var kr = Ht(({ sendBack: e, input: t }) => {
|
|
|
1229
1227
|
continue;
|
|
1230
1228
|
}
|
|
1231
1229
|
let a = e[n];
|
|
1232
|
-
if (a.raw != null && (a.raw instanceof Uint8Array || Buffer.isBuffer(a.raw)))
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
}
|
|
1236
|
-
if (a.filename != null) {
|
|
1237
|
-
let e = await Nr();
|
|
1230
|
+
if (a.raw != null && (a.raw instanceof Uint8Array || Buffer.isBuffer(a.raw))) c.writeUInt32BE(t, l), l += 4, c.set(a.raw, l), l += t;
|
|
1231
|
+
else if (a.filename != null) {
|
|
1232
|
+
let e = await Fr();
|
|
1238
1233
|
if (!e) throw Error("DataItem.filename requires Node.js fs access. In browser runtime, provide DataItem.raw or DataItem.getRaw().");
|
|
1239
1234
|
let t = await e.readFile(a.filename);
|
|
1240
1235
|
c.writeUInt32BE(t.length, l), l += 4, t.copy(c, l), l += t.length;
|
|
1241
|
-
|
|
1242
|
-
}
|
|
1243
|
-
throw Error("Cannot get raw bytes from DataItem");
|
|
1236
|
+
} else throw Error("Cannot get raw bytes from DataItem");
|
|
1244
1237
|
}
|
|
1245
|
-
let u = new AbortController(), d = setTimeout(() => u.abort(),
|
|
1238
|
+
let u = new AbortController(), d = setTimeout(() => u.abort(), Mr), f;
|
|
1246
1239
|
try {
|
|
1247
1240
|
f = await fetch(a, {
|
|
1248
1241
|
method: "POST",
|
|
@@ -1251,7 +1244,7 @@ var kr = Ht(({ sendBack: e, input: t }) => {
|
|
|
1251
1244
|
signal: u.signal
|
|
1252
1245
|
});
|
|
1253
1246
|
} catch (e) {
|
|
1254
|
-
throw clearTimeout(d), e instanceof Error && e.name === "AbortError" ? Error(`Arweave batch upload timed out after ${
|
|
1247
|
+
throw clearTimeout(d), e instanceof Error && e.name === "AbortError" ? Error(`Arweave batch upload timed out after ${Mr / 1e3}s (upload API did not respond). Check uploadApiBaseUrl and network.`) : e;
|
|
1255
1248
|
}
|
|
1256
1249
|
if (clearTimeout(d), !f.ok) throw Error(`Batch upload failed: ${f.status}`);
|
|
1257
1250
|
let p = await f.json().catch(() => ({})), m = typeof p.failed == "number" ? p.failed : 0;
|
|
@@ -1269,18 +1262,18 @@ var kr = Ht(({ sendBack: e, input: t }) => {
|
|
|
1269
1262
|
});
|
|
1270
1263
|
//#endregion
|
|
1271
1264
|
//#region src/services/publish/helpers/receiptAttestationMs.ts
|
|
1272
|
-
async function
|
|
1265
|
+
async function Lr(e) {
|
|
1273
1266
|
let t = e?.blockNumber;
|
|
1274
|
-
return t == null ? Date.now() : await
|
|
1267
|
+
return t == null ? Date.now() : await _e(t) ?? Date.now();
|
|
1275
1268
|
}
|
|
1276
1269
|
//#endregion
|
|
1277
1270
|
//#region src/services/publish/actors/seedUidHelpers.ts
|
|
1278
1271
|
function G(e) {
|
|
1279
1272
|
return e == null || e === "" ? U : ("0x" + (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0").padStart(64, "0").slice(-64)).toLowerCase();
|
|
1280
1273
|
}
|
|
1281
|
-
function
|
|
1274
|
+
function Rr(e, t) {
|
|
1282
1275
|
if (!e.logs?.length) return [];
|
|
1283
|
-
let n = t ?
|
|
1276
|
+
let n = t ? Te : r;
|
|
1284
1277
|
try {
|
|
1285
1278
|
let t = ut({
|
|
1286
1279
|
abi: n,
|
|
@@ -1306,8 +1299,8 @@ function Ir(e, t) {
|
|
|
1306
1299
|
}
|
|
1307
1300
|
//#endregion
|
|
1308
1301
|
//#region src/services/publish/actors/multiPublishReceipt.ts
|
|
1309
|
-
var K = (e) => !e || G(e) === U,
|
|
1310
|
-
function
|
|
1302
|
+
var K = (e) => !e || G(e) === U, zr = (e, t) => !!e && !!t && G(e) === G(t);
|
|
1303
|
+
function Br(e) {
|
|
1311
1304
|
let t = [];
|
|
1312
1305
|
for (let n of e.listOfAttestations ?? []) {
|
|
1313
1306
|
let e = Array.isArray(n?.data) ? n.data.length : 1, r = typeof n?._propertyName == "string" && n._propertyName !== "" ? n._propertyName : void 0;
|
|
@@ -1318,12 +1311,12 @@ function Rr(e) {
|
|
|
1318
1311
|
}
|
|
1319
1312
|
return t;
|
|
1320
1313
|
}
|
|
1321
|
-
function
|
|
1314
|
+
function Vr(e, t, n) {
|
|
1322
1315
|
let i = t.toLowerCase(), a = e.logs?.filter((e) => e.address && e.address.toLowerCase() === i);
|
|
1323
1316
|
if (!a?.length) return [];
|
|
1324
1317
|
try {
|
|
1325
1318
|
return n ? ut({
|
|
1326
|
-
abi:
|
|
1319
|
+
abi: Te,
|
|
1327
1320
|
eventName: "SeedPublished",
|
|
1328
1321
|
logs: a,
|
|
1329
1322
|
strict: !1
|
|
@@ -1351,22 +1344,22 @@ function zr(e, t, n) {
|
|
|
1351
1344
|
return [];
|
|
1352
1345
|
}
|
|
1353
1346
|
}
|
|
1354
|
-
function
|
|
1355
|
-
let { receipt: t, requests: n, useModularExecutor: r, easContractAddress: i, contractAddressForEvents: a } = e, o =
|
|
1347
|
+
function Hr(e) {
|
|
1348
|
+
let { receipt: t, requests: n, useModularExecutor: r, easContractAddress: i, contractAddressForEvents: a } = e, o = Rr(t, r), s = new Set(o.map((e) => G(e.attestationUid))), c = /* @__PURE__ */ new Set();
|
|
1356
1349
|
for (let e of n) K(e.seedUid) && e.seedSchemaUid && c.add(G(e.seedSchemaUid)), K(e.versionUid) && e.versionSchemaUid && c.add(G(e.versionSchemaUid));
|
|
1357
1350
|
let l = p(t, i).filter((e) => !s.has(G(e.uid)) && !c.has(G(e.schemaUid))).map((e) => ({
|
|
1358
1351
|
schemaUid: e.schemaUid,
|
|
1359
1352
|
attestationUid: e.uid
|
|
1360
|
-
})), u =
|
|
1353
|
+
})), u = Vr(t, a, r), d = n.map(Br), f = n.reduce((e, t) => e + +!!K(t.seedUid) + +!!K(t.versionUid), 0), m = d.reduce((e, t) => e + t.length, 0), h = m > 0 && o.length >= f + m, g = 0, _ = 0, v = 0, y = (e) => {
|
|
1361
1354
|
let t = o[g];
|
|
1362
|
-
if (t) return g += 1,
|
|
1355
|
+
if (t) return g += 1, zr(t.schemaUid, e) ? t.attestationUid : void 0;
|
|
1363
1356
|
};
|
|
1364
1357
|
return n.map((e, t) => {
|
|
1365
1358
|
let n = d[t], i = { propertyPairs: [] };
|
|
1366
|
-
K(e.seedUid) && (i.seedUid =
|
|
1359
|
+
K(e.seedUid) && (i.seedUid = y(e.seedSchemaUid)), K(e.versionUid) && (i.versionUid = y(e.versionSchemaUid));
|
|
1367
1360
|
let a = [];
|
|
1368
|
-
h ? (a = o.slice(g, g + n.length), g += n.length) : l.length && (a = l.slice(
|
|
1369
|
-
let s = !r || n.length > 0 ? u[
|
|
1361
|
+
h ? (a = o.slice(g, g + n.length), g += n.length) : l.length && (a = l.slice(_, _ + n.length), _ += n.length);
|
|
1362
|
+
let s = !r || n.length > 0 ? u[v++] : void 0;
|
|
1370
1363
|
if (s) {
|
|
1371
1364
|
if (r) K(e.seedUid) && !i.seedUid && (i.seedUid = s.seedUid), K(e.versionUid) && !i.versionUid && (i.versionUid = s.versionUid);
|
|
1372
1365
|
else if (s.uids?.length) {
|
|
@@ -1377,7 +1370,7 @@ function Br(e) {
|
|
|
1377
1370
|
}
|
|
1378
1371
|
return n.forEach((e, t) => {
|
|
1379
1372
|
let n = a[t];
|
|
1380
|
-
if (!n || K(n.attestationUid) || n.schemaUid && !
|
|
1373
|
+
if (!n || K(n.attestationUid) || n.schemaUid && !zr(n.schemaUid, e.schema)) return;
|
|
1381
1374
|
let r = n.schemaUid ?? e.schema;
|
|
1382
1375
|
r && i.propertyPairs.push({
|
|
1383
1376
|
schemaUid: r,
|
|
@@ -1389,32 +1382,32 @@ function Br(e) {
|
|
|
1389
1382
|
}
|
|
1390
1383
|
//#endregion
|
|
1391
1384
|
//#region src/services/publish/actors/persistSeedUid.ts
|
|
1392
|
-
var
|
|
1393
|
-
function
|
|
1385
|
+
var Ur = R("seedProtocol:services:publish:actors:persistSeedUid"), Wr = "0x" + "0".repeat(64), Gr = 15e3;
|
|
1386
|
+
function Kr(e, t) {
|
|
1394
1387
|
let n = e.seedLocalId, r = n ? t.find((e) => e?.localId === n) : void 0, i = r ? r.seedUid : t[0]?.seedUid;
|
|
1395
|
-
i && i !==
|
|
1388
|
+
i && i !== Wr && (e.seedUid = i);
|
|
1396
1389
|
}
|
|
1397
|
-
async function
|
|
1390
|
+
async function qr(e, t, n) {
|
|
1398
1391
|
let r = e.persistSeedUid;
|
|
1399
1392
|
if (typeof r != "function") return;
|
|
1400
|
-
let i = new Promise((e, t) => setTimeout(() => t(/* @__PURE__ */ Error("persistSeedUid timed out")),
|
|
1393
|
+
let i = new Promise((e, t) => setTimeout(() => t(/* @__PURE__ */ Error("persistSeedUid timed out")), Gr));
|
|
1401
1394
|
try {
|
|
1402
1395
|
await Promise.race([r.call(e, t, n), i]);
|
|
1403
1396
|
} catch (e) {
|
|
1404
|
-
|
|
1397
|
+
Ur("persistSeedUid failed (attestations already on-chain):", e);
|
|
1405
1398
|
}
|
|
1406
1399
|
}
|
|
1407
1400
|
//#endregion
|
|
1408
1401
|
//#region src/services/publish/actors/publishRequestNormalize.ts
|
|
1409
|
-
var
|
|
1410
|
-
if (e == null) return "0x" + "0".repeat(
|
|
1411
|
-
if (typeof e == "string") return "0x" + (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0").padStart(
|
|
1402
|
+
var Jr = 64, q = (e) => {
|
|
1403
|
+
if (e == null) return "0x" + "0".repeat(Jr);
|
|
1404
|
+
if (typeof e == "string") return "0x" + (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0").padStart(Jr, "0").slice(-64);
|
|
1412
1405
|
if (e instanceof Uint8Array || typeof ArrayBuffer < "u" && e instanceof ArrayBuffer) {
|
|
1413
1406
|
let t = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1414
|
-
return "0x" + Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("").padStart(
|
|
1407
|
+
return "0x" + Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("").padStart(Jr, "0").slice(-64);
|
|
1415
1408
|
}
|
|
1416
|
-
return "0x" + "0".repeat(
|
|
1417
|
-
},
|
|
1409
|
+
return "0x" + "0".repeat(Jr);
|
|
1410
|
+
}, Yr = (e) => {
|
|
1418
1411
|
if (e == null || typeof e == "string" && (e === "" || e === "0x")) return "0x";
|
|
1419
1412
|
if (typeof e == "string") {
|
|
1420
1413
|
let t = (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0");
|
|
@@ -1426,17 +1419,17 @@ var Kr = 64, q = (e) => {
|
|
|
1426
1419
|
}
|
|
1427
1420
|
return "0x";
|
|
1428
1421
|
};
|
|
1429
|
-
function
|
|
1422
|
+
function Xr(e) {
|
|
1430
1423
|
let t = new Set(e.map((e) => e?.localId).filter((e) => !!e));
|
|
1431
1424
|
return e.some((e) => (e?.listOfAttestations ?? []).some((e) => {
|
|
1432
1425
|
let n = e;
|
|
1433
1426
|
return n._unresolvedValue && t.has(n._unresolvedValue) ? !0 : Array.isArray(n._rawListIdsForResolve) ? n._rawListIdsForResolve.some((e) => e && t.has(String(e).trim())) : !1;
|
|
1434
1427
|
}));
|
|
1435
1428
|
}
|
|
1436
|
-
function
|
|
1429
|
+
function Zr(e, t) {
|
|
1437
1430
|
return (e ?? []).filter((e) => e.publishLocalId && t.has(e.publishLocalId));
|
|
1438
1431
|
}
|
|
1439
|
-
var
|
|
1432
|
+
var Qr = {
|
|
1440
1433
|
recipient: Rt,
|
|
1441
1434
|
expirationTime: BigInt(0),
|
|
1442
1435
|
revocable: !0,
|
|
@@ -1444,7 +1437,7 @@ var Xr = {
|
|
|
1444
1437
|
data: U,
|
|
1445
1438
|
value: BigInt(0)
|
|
1446
1439
|
};
|
|
1447
|
-
function
|
|
1440
|
+
function $r(e) {
|
|
1448
1441
|
let t = (e?.listOfAttestations ?? []).map((e) => {
|
|
1449
1442
|
let t = Array.isArray(e?.data) ? e.data : [];
|
|
1450
1443
|
return {
|
|
@@ -1452,7 +1445,7 @@ function Zr(e) {
|
|
|
1452
1445
|
data: t.map((e) => ({
|
|
1453
1446
|
...e,
|
|
1454
1447
|
refUID: q(e?.refUID),
|
|
1455
|
-
data:
|
|
1448
|
+
data: Yr(e?.data),
|
|
1456
1449
|
expirationTime: e?.expirationTime == null ? BigInt(0) : BigInt(e.expirationTime),
|
|
1457
1450
|
value: e?.value == null ? BigInt(0) : BigInt(e.value)
|
|
1458
1451
|
})),
|
|
@@ -1473,7 +1466,7 @@ function Zr(e) {
|
|
|
1473
1466
|
propertiesToUpdate: n
|
|
1474
1467
|
};
|
|
1475
1468
|
}
|
|
1476
|
-
function
|
|
1469
|
+
function ei(e, t) {
|
|
1477
1470
|
for (let n of e) for (let e of n?.propertiesToUpdate ?? []) {
|
|
1478
1471
|
let n = e?.publishLocalId, r = q(e?.propertySchemaUid);
|
|
1479
1472
|
if (!n || !r) continue;
|
|
@@ -1481,22 +1474,22 @@ function Qr(e, t) {
|
|
|
1481
1474
|
if (!i?.listOfAttestations) continue;
|
|
1482
1475
|
let a = i.listOfAttestations.find((e) => q(e?.schema)?.toLowerCase() === r?.toLowerCase());
|
|
1483
1476
|
a && (!Array.isArray(a.data) || a.data.length === 0) && (a.data = [{
|
|
1484
|
-
...
|
|
1477
|
+
...Qr,
|
|
1485
1478
|
refUID: U
|
|
1486
1479
|
}]);
|
|
1487
1480
|
}
|
|
1488
1481
|
}
|
|
1489
1482
|
//#endregion
|
|
1490
1483
|
//#region src/services/publish/actors/recordMultiPublishReceipt.ts
|
|
1491
|
-
var
|
|
1492
|
-
async function
|
|
1493
|
-
let { receipt: t, requests: n, rootSeedLocalId: r, useModularExecutor: i, contractAddressForEvents: a, publisherAddress: o } = e, { easContractAddress: s } =
|
|
1484
|
+
var ti = R("seedProtocol:services:publish:actors:recordMultiPublishReceipt"), J = (e) => !e || q(e) === U, ni = (e) => J(e) ? void 0 : q(e);
|
|
1485
|
+
async function ri(e) {
|
|
1486
|
+
let { receipt: t, requests: n, rootSeedLocalId: r, useModularExecutor: i, contractAddressForEvents: a, publisherAddress: o } = e, { easContractAddress: s } = D(), c = Hr({
|
|
1494
1487
|
receipt: t,
|
|
1495
1488
|
requests: n,
|
|
1496
1489
|
useModularExecutor: i,
|
|
1497
1490
|
easContractAddress: s,
|
|
1498
1491
|
contractAddressForEvents: a
|
|
1499
|
-
}), l = await
|
|
1492
|
+
}), l = await Lr(t);
|
|
1500
1493
|
for (let e = 0; e < n.length; e++) {
|
|
1501
1494
|
let t = n[e], r = c[e].versionUid;
|
|
1502
1495
|
t.localId && J(t.versionUid) && !J(r) && await rt({
|
|
@@ -1508,16 +1501,16 @@ async function ti(e) {
|
|
|
1508
1501
|
}
|
|
1509
1502
|
for (let e = 0; e < n.length; e++) {
|
|
1510
1503
|
let t = n[e], { propertyPairs: r, versionUid: i } = c[e];
|
|
1511
|
-
t.localId && r.length && await
|
|
1504
|
+
t.localId && r.length && await Ne({
|
|
1512
1505
|
seedLocalId: t.localId,
|
|
1513
1506
|
attestationCreatedAtMs: l ?? null,
|
|
1514
|
-
versionUid:
|
|
1507
|
+
versionUid: ni(t.versionUid) ?? ni(i) ?? null,
|
|
1515
1508
|
pairs: r
|
|
1516
1509
|
});
|
|
1517
1510
|
}
|
|
1518
1511
|
for (let e = 0; e < n.length; e++) {
|
|
1519
1512
|
let t = n[e], i = c[e].seedUid;
|
|
1520
|
-
t.localId && t.localId !== r && J(t.seedUid) && !J(i) && await
|
|
1513
|
+
t.localId && t.localId !== r && J(t.seedUid) && !J(i) && await ii({
|
|
1521
1514
|
seedLocalId: t.localId,
|
|
1522
1515
|
seedUid: i,
|
|
1523
1516
|
publisherAddress: o,
|
|
@@ -1536,43 +1529,43 @@ async function ti(e) {
|
|
|
1536
1529
|
})
|
|
1537
1530
|
};
|
|
1538
1531
|
}
|
|
1539
|
-
async function
|
|
1532
|
+
async function ii(e) {
|
|
1540
1533
|
let { seedLocalId: t, seedUid: n, publisherAddress: r, attestationCreatedAtMs: i } = e;
|
|
1541
1534
|
try {
|
|
1542
|
-
let e = await
|
|
1535
|
+
let e = await N.find({ seedLocalId: t });
|
|
1543
1536
|
if (!e) {
|
|
1544
|
-
|
|
1537
|
+
ti("related item %s not found; its seed uid is not recorded", t);
|
|
1545
1538
|
return;
|
|
1546
1539
|
}
|
|
1547
|
-
e.seedUid = n, await
|
|
1540
|
+
e.seedUid = n, await qr(e, r, i);
|
|
1548
1541
|
} catch (e) {
|
|
1549
|
-
|
|
1542
|
+
ti("recording seed uid of related item %s failed: %O", t, e);
|
|
1550
1543
|
}
|
|
1551
1544
|
}
|
|
1552
1545
|
//#endregion
|
|
1553
1546
|
//#region src/helpers/seedPaymaster.ts
|
|
1554
|
-
var
|
|
1555
|
-
function
|
|
1547
|
+
var ai = 12000n;
|
|
1548
|
+
function oi(e) {
|
|
1556
1549
|
return "paymasterAndData" in e && e.paymasterAndData ? e.paymasterAndData : "0x";
|
|
1557
1550
|
}
|
|
1558
|
-
function
|
|
1551
|
+
function si(e, t, n) {
|
|
1559
1552
|
return async (r) => {
|
|
1560
|
-
if (
|
|
1553
|
+
if (k("paymaster hook called (userOp from thirdweb; callGasLimit is tx.gas or 0)", {
|
|
1561
1554
|
sender: r.sender,
|
|
1562
1555
|
chainId: t.id,
|
|
1563
1556
|
bundlerUrl: n ?? "(thirdweb default)",
|
|
1564
1557
|
entryPoint: "initCode" in r ? "v0.6" : "v0.7",
|
|
1565
|
-
...
|
|
1558
|
+
...C(r)
|
|
1566
1559
|
}), !("initCode" in r)) throw Error("@seedprotocol/publish: the managed account sent an EntryPoint v0.7 UserOp; its sponsored gas handling only supports EntryPoint v0.6.");
|
|
1567
1560
|
let i = typeof e == "function" ? e() : e, a = await Xt({
|
|
1568
1561
|
userOp: r,
|
|
1569
1562
|
client: i,
|
|
1570
1563
|
chain: t
|
|
1571
1564
|
});
|
|
1572
|
-
|
|
1565
|
+
k("1/3 paymaster sponsored (limits here are ignored)", C(a));
|
|
1573
1566
|
let o = {
|
|
1574
1567
|
...r,
|
|
1575
|
-
paymasterAndData:
|
|
1568
|
+
paymasterAndData: oi(a)
|
|
1576
1569
|
}, s = await Yt({
|
|
1577
1570
|
userOp: o,
|
|
1578
1571
|
options: {
|
|
@@ -1581,11 +1574,11 @@ function ai(e, t, n) {
|
|
|
1581
1574
|
bundlerUrl: n
|
|
1582
1575
|
}
|
|
1583
1576
|
});
|
|
1584
|
-
|
|
1585
|
-
let c = s.callGasLimit *
|
|
1586
|
-
o.callGasLimit = r.callGasLimit > c ? r.callGasLimit : c, o.verificationGasLimit = s.verificationGasLimit, o.preVerificationGas = s.preVerificationGas,
|
|
1587
|
-
...
|
|
1588
|
-
headroomBps:
|
|
1577
|
+
k("2/3 bundler estimate (callGasLimit includes thirdweb's +50k)", C(s));
|
|
1578
|
+
let c = s.callGasLimit * ai / 10000n;
|
|
1579
|
+
o.callGasLimit = r.callGasLimit > c ? r.callGasLimit : c, o.verificationGasLimit = s.verificationGasLimit, o.preVerificationGas = s.preVerificationGas, k("raised limits sent to the paymaster for signing", {
|
|
1580
|
+
...C(o),
|
|
1581
|
+
headroomBps: ai,
|
|
1589
1582
|
raisedEstimate: c,
|
|
1590
1583
|
txGas: r.callGasLimit
|
|
1591
1584
|
});
|
|
@@ -1594,65 +1587,65 @@ function ai(e, t, n) {
|
|
|
1594
1587
|
client: i,
|
|
1595
1588
|
chain: t
|
|
1596
1589
|
});
|
|
1597
|
-
if (
|
|
1598
|
-
...
|
|
1590
|
+
if (k("3/3 paymaster signed", C(l)), l.callGasLimit && l.verificationGasLimit && l.preVerificationGas) return k("returning to thirdweb: the PAYMASTER's own limits (its signature covers them)", {
|
|
1591
|
+
...C(l),
|
|
1599
1592
|
requestedCallGasLimit: o.callGasLimit
|
|
1600
1593
|
}), l;
|
|
1601
1594
|
let u = {
|
|
1602
|
-
paymasterAndData:
|
|
1595
|
+
paymasterAndData: oi(l),
|
|
1603
1596
|
callGasLimit: o.callGasLimit,
|
|
1604
1597
|
verificationGasLimit: o.verificationGasLimit,
|
|
1605
1598
|
preVerificationGas: o.preVerificationGas
|
|
1606
1599
|
};
|
|
1607
|
-
return
|
|
1600
|
+
return k("returning to thirdweb: our raised limits (thirdweb should send exactly these)", C(u)), u;
|
|
1608
1601
|
};
|
|
1609
1602
|
}
|
|
1610
1603
|
//#endregion
|
|
1611
1604
|
//#region src/helpers/thirdweb.ts
|
|
1612
|
-
var
|
|
1613
|
-
ExternalWalletsForDeploy: () =>
|
|
1614
|
-
appMetadata: () =>
|
|
1615
|
-
deployManagedAccountViaFactory: () =>
|
|
1616
|
-
deploySmartWalletContract: () =>
|
|
1617
|
-
getConnectedAccount: () =>
|
|
1618
|
-
getConnectedManagedAccountAddress: () =>
|
|
1619
|
-
getConnectedModularAccount: () =>
|
|
1620
|
-
getManagedAccountWallet: () =>
|
|
1621
|
-
getModularAccountWallet: () =>
|
|
1622
|
-
getSharedPublishInAppWalletStorage: () =>
|
|
1623
|
-
getSmartWalletAddressForAdmin: () =>
|
|
1624
|
-
getWalletsForConnectButton: () =>
|
|
1625
|
-
isSmartWalletDeployed: () =>
|
|
1626
|
-
pollSmartWalletDeployed: () =>
|
|
1627
|
-
resolveSmartWalletForPublish: () =>
|
|
1628
|
-
syncPublishInAppAuthToken: () =>
|
|
1629
|
-
useActiveSmartWalletContract: () =>
|
|
1630
|
-
useLocalWalletAccount: () =>
|
|
1631
|
-
wallets: () =>
|
|
1632
|
-
}),
|
|
1633
|
-
function
|
|
1634
|
-
return
|
|
1635
|
-
getItem: async (e) => typeof window > "u" ? null : localStorage.getItem(
|
|
1605
|
+
var ci = /* @__PURE__ */ e({
|
|
1606
|
+
ExternalWalletsForDeploy: () => Si,
|
|
1607
|
+
appMetadata: () => Ti,
|
|
1608
|
+
deployManagedAccountViaFactory: () => wi,
|
|
1609
|
+
deploySmartWalletContract: () => Ci,
|
|
1610
|
+
getConnectedAccount: () => Di,
|
|
1611
|
+
getConnectedManagedAccountAddress: () => Ei,
|
|
1612
|
+
getConnectedModularAccount: () => Oi,
|
|
1613
|
+
getManagedAccountWallet: () => Mi,
|
|
1614
|
+
getModularAccountWallet: () => Pi,
|
|
1615
|
+
getSharedPublishInAppWalletStorage: () => fi,
|
|
1616
|
+
getSmartWalletAddressForAdmin: () => vi,
|
|
1617
|
+
getWalletsForConnectButton: () => Fi,
|
|
1618
|
+
isSmartWalletDeployed: () => yi,
|
|
1619
|
+
pollSmartWalletDeployed: () => bi,
|
|
1620
|
+
resolveSmartWalletForPublish: () => xi,
|
|
1621
|
+
syncPublishInAppAuthToken: () => pi,
|
|
1622
|
+
useActiveSmartWalletContract: () => _i,
|
|
1623
|
+
useLocalWalletAccount: () => gi,
|
|
1624
|
+
wallets: () => hi
|
|
1625
|
+
}), li = R("permaPress:helpers:thirdweb"), ui = "seedProtocol:inAppPublish:", di = null;
|
|
1626
|
+
function fi() {
|
|
1627
|
+
return di ||= {
|
|
1628
|
+
getItem: async (e) => typeof window > "u" ? null : localStorage.getItem(ui + e),
|
|
1636
1629
|
setItem: async (e, t) => {
|
|
1637
|
-
typeof window
|
|
1630
|
+
typeof window < "u" && localStorage.setItem(ui + e, t);
|
|
1638
1631
|
},
|
|
1639
1632
|
removeItem: async (e) => {
|
|
1640
|
-
typeof window
|
|
1633
|
+
typeof window < "u" && localStorage.removeItem(ui + e);
|
|
1641
1634
|
}
|
|
1642
|
-
},
|
|
1635
|
+
}, di;
|
|
1643
1636
|
}
|
|
1644
|
-
function
|
|
1637
|
+
function pi() {
|
|
1645
1638
|
if (typeof window > "u") return {
|
|
1646
1639
|
syncedBareToPrefixed: !1,
|
|
1647
1640
|
syncedPrefixedToBare: !1
|
|
1648
1641
|
};
|
|
1649
|
-
let { thirdwebClientId: e } =
|
|
1642
|
+
let { thirdwebClientId: e } = D();
|
|
1650
1643
|
if (!e) return {
|
|
1651
1644
|
syncedBareToPrefixed: !1,
|
|
1652
1645
|
syncedPrefixedToBare: !1
|
|
1653
1646
|
};
|
|
1654
1647
|
try {
|
|
1655
|
-
let t = `walletToken-${e}`, n = `${
|
|
1648
|
+
let t = `walletToken-${e}`, n = `${ui}${t}`, r = localStorage.getItem(t), i = localStorage.getItem(n), a = !1, o = !1;
|
|
1656
1649
|
return r && !i && (localStorage.setItem(n, r), a = !0), i && !r && (localStorage.setItem(t, i), o = !0), i && r && r !== i && (localStorage.setItem(t, i), o = !0), {
|
|
1657
1650
|
syncedBareToPrefixed: a,
|
|
1658
1651
|
syncedPrefixedToBare: o
|
|
@@ -1664,102 +1657,102 @@ function di() {
|
|
|
1664
1657
|
};
|
|
1665
1658
|
}
|
|
1666
1659
|
}
|
|
1667
|
-
async function
|
|
1668
|
-
|
|
1669
|
-
let t =
|
|
1660
|
+
async function mi(e = A()) {
|
|
1661
|
+
pi();
|
|
1662
|
+
let t = Mi();
|
|
1670
1663
|
return await t.autoConnect({
|
|
1671
|
-
client:
|
|
1664
|
+
client: j(),
|
|
1672
1665
|
chain: e
|
|
1673
1666
|
}), t;
|
|
1674
1667
|
}
|
|
1675
|
-
var
|
|
1668
|
+
var hi = [Kt("io.metamask")], gi = () => {
|
|
1676
1669
|
let [e, t] = Nt(null);
|
|
1677
1670
|
return Kt("io.metamask"), Mt(!1), jt(() => {}, []), e;
|
|
1678
|
-
},
|
|
1671
|
+
}, _i = () => {
|
|
1679
1672
|
let e = Jt(), [t, n] = Nt(null);
|
|
1680
1673
|
return jt(() => {
|
|
1681
1674
|
e && e.address && n(mt({
|
|
1682
|
-
client:
|
|
1683
|
-
chain:
|
|
1675
|
+
client: j(),
|
|
1676
|
+
chain: A(),
|
|
1684
1677
|
address: e.address
|
|
1685
1678
|
}));
|
|
1686
1679
|
}, [e]), t;
|
|
1687
1680
|
};
|
|
1688
|
-
async function
|
|
1689
|
-
return
|
|
1681
|
+
async function vi(e, t = "0x") {
|
|
1682
|
+
return _(e, t);
|
|
1690
1683
|
}
|
|
1691
|
-
async function
|
|
1692
|
-
return
|
|
1684
|
+
async function yi(e) {
|
|
1685
|
+
return oe(e);
|
|
1693
1686
|
}
|
|
1694
|
-
async function
|
|
1695
|
-
return
|
|
1687
|
+
async function bi(e, t, n) {
|
|
1688
|
+
return ge(e, t, n);
|
|
1696
1689
|
}
|
|
1697
|
-
async function
|
|
1690
|
+
async function xi(e) {
|
|
1698
1691
|
if (!e) return { needsDeploy: !0 };
|
|
1699
|
-
if (await
|
|
1692
|
+
if (await yi(e.address)) return {
|
|
1700
1693
|
address: e.address,
|
|
1701
1694
|
account: e
|
|
1702
1695
|
};
|
|
1703
|
-
let t = await
|
|
1704
|
-
return await
|
|
1696
|
+
let t = await vi(e.address);
|
|
1697
|
+
return await yi(t) ? {
|
|
1705
1698
|
address: t,
|
|
1706
1699
|
account: e
|
|
1707
1700
|
} : { needsDeploy: !0 };
|
|
1708
1701
|
}
|
|
1709
|
-
var
|
|
1702
|
+
var Si = [Kt("io.metamask"), Kt("me.rainbow")], Ci = async (e) => {
|
|
1710
1703
|
let t = mt({
|
|
1711
|
-
client:
|
|
1712
|
-
chain:
|
|
1704
|
+
client: j(),
|
|
1705
|
+
chain: A(),
|
|
1713
1706
|
address: e.address
|
|
1714
1707
|
}), n = await pt({
|
|
1715
1708
|
smartAccount: e,
|
|
1716
|
-
chain:
|
|
1717
|
-
client:
|
|
1709
|
+
chain: A(),
|
|
1710
|
+
client: j(),
|
|
1718
1711
|
accountContract: t
|
|
1719
1712
|
});
|
|
1720
|
-
return
|
|
1713
|
+
return li("deploySmartAccount result:", n), n;
|
|
1721
1714
|
};
|
|
1722
|
-
async function
|
|
1723
|
-
let { asThirdwebPublishWallet: t } = await import("./chainConfig-
|
|
1715
|
+
async function wi(e) {
|
|
1716
|
+
let { asThirdwebPublishWallet: t } = await import("./chainConfig-BDMRU4m8.js").then((e) => e.g), n = t(e.signingAccount), r = b(e.adminAddress, e.data ?? "0x");
|
|
1724
1717
|
await n.txSender.sendTransaction(r);
|
|
1725
1718
|
}
|
|
1726
|
-
var
|
|
1719
|
+
var Ti = {
|
|
1727
1720
|
name: "Seed Protocol",
|
|
1728
1721
|
description: "Seed Protocol",
|
|
1729
1722
|
url: "https://seedprotocol.io"
|
|
1730
1723
|
};
|
|
1731
|
-
async function
|
|
1732
|
-
let t = (await
|
|
1724
|
+
async function Ei(e = A()) {
|
|
1725
|
+
let t = (await mi(e)).getAccount();
|
|
1733
1726
|
if (!t) throw Error("Failed to get managed account");
|
|
1734
1727
|
return t.address;
|
|
1735
1728
|
}
|
|
1736
|
-
async function
|
|
1729
|
+
async function Di() {
|
|
1737
1730
|
try {
|
|
1738
|
-
let e =
|
|
1731
|
+
let e = Pi();
|
|
1739
1732
|
return await e.autoConnect({
|
|
1740
|
-
client:
|
|
1741
|
-
chain:
|
|
1733
|
+
client: j(),
|
|
1734
|
+
chain: A()
|
|
1742
1735
|
}), e.getAccount() ?? null;
|
|
1743
1736
|
} catch {
|
|
1744
1737
|
return null;
|
|
1745
1738
|
}
|
|
1746
1739
|
}
|
|
1747
|
-
async function
|
|
1748
|
-
return
|
|
1740
|
+
async function Oi() {
|
|
1741
|
+
return Di();
|
|
1749
1742
|
}
|
|
1750
|
-
function
|
|
1751
|
-
let t =
|
|
1743
|
+
function ki(e) {
|
|
1744
|
+
let t = A(e).id, n = e.managedAccountFactoryAddress ?? h[t];
|
|
1752
1745
|
if (!n) throw Error(`@seedprotocol/publish: no ManagedAccount factory is known for chain ${t}. Pass managedAccountFactoryAddress in publish config, or use the EOA / direct EAS path.`);
|
|
1753
1746
|
return n;
|
|
1754
1747
|
}
|
|
1755
|
-
var
|
|
1748
|
+
var Ai = [
|
|
1756
1749
|
"farcaster",
|
|
1757
1750
|
"email",
|
|
1758
1751
|
"passkey",
|
|
1759
1752
|
"phone"
|
|
1760
|
-
],
|
|
1761
|
-
let t = e ??
|
|
1762
|
-
if (!i &&
|
|
1753
|
+
], ji = null, Mi = (e) => {
|
|
1754
|
+
let t = e ?? w(), n = A(t ?? void 0), r = t ? ki(t) : ae(), { bundlerUrl: i, sponsorGas: a } = Se(t);
|
|
1755
|
+
if (!i && re(n)) throw Error(`@seedprotocol/publish: chain ${n.id} is local, so Thirdweb's hosted bundler cannot reach it. Set PublishConfig.thirdweb.bundlerUrl to the chain's bundler (seedTwinConfig does this for the twin).`);
|
|
1763
1756
|
let o = [
|
|
1764
1757
|
n.id,
|
|
1765
1758
|
n.rpc,
|
|
@@ -1767,16 +1760,16 @@ var Oi = [
|
|
|
1767
1760
|
i ?? "",
|
|
1768
1761
|
a
|
|
1769
1762
|
].join("|").toLowerCase();
|
|
1770
|
-
return
|
|
1763
|
+
return ji?.key !== o && (k("managed wallet built", {
|
|
1771
1764
|
chainId: n.id,
|
|
1772
1765
|
sponsorGas: a,
|
|
1773
1766
|
bundlerUrl: i ?? "(thirdweb default)",
|
|
1774
1767
|
paymasterHook: a ? "installed" : "none (thirdweb estimates callGasLimit itself)"
|
|
1775
|
-
}),
|
|
1768
|
+
}), ji = {
|
|
1776
1769
|
key: o,
|
|
1777
1770
|
wallet: qt({
|
|
1778
|
-
storage:
|
|
1779
|
-
auth: { options: [...
|
|
1771
|
+
storage: fi(),
|
|
1772
|
+
auth: { options: [...Ai] },
|
|
1780
1773
|
executionMode: {
|
|
1781
1774
|
mode: "EIP4337",
|
|
1782
1775
|
smartAccount: {
|
|
@@ -1785,63 +1778,63 @@ var Oi = [
|
|
|
1785
1778
|
sponsorGas: a,
|
|
1786
1779
|
...i || a ? { overrides: {
|
|
1787
1780
|
...i ? { bundlerUrl: i } : {},
|
|
1788
|
-
...a ? { paymaster:
|
|
1781
|
+
...a ? { paymaster: si(j, n, i) } : {}
|
|
1789
1782
|
} } : {}
|
|
1790
1783
|
}
|
|
1791
1784
|
}
|
|
1792
1785
|
})
|
|
1793
|
-
}),
|
|
1794
|
-
},
|
|
1795
|
-
let t = e ??
|
|
1786
|
+
}), ji.wallet;
|
|
1787
|
+
}, Ni = null, Pi = (e) => {
|
|
1788
|
+
let t = e ?? w(), { modularWalletMode: n, sponsorGas: r } = Se(t);
|
|
1796
1789
|
if (n === "EIP7702") {
|
|
1797
|
-
let e =
|
|
1798
|
-
if (
|
|
1790
|
+
let e = A(t ?? void 0);
|
|
1791
|
+
if (re(e)) throw Error(`@seedprotocol/publish: chain ${e.id} is local, and Thirdweb's EIP-7702 mode needs its hosted bundler, which cannot reach it. Set PublishConfig.thirdweb.modularWalletMode to 'EOA' and fund the in-app EOA (seedTwinConfig does this for the twin).`);
|
|
1799
1792
|
}
|
|
1800
1793
|
let i = `${n}|${r}`;
|
|
1801
|
-
return
|
|
1794
|
+
return Ni?.key !== i && (Ni = {
|
|
1802
1795
|
key: i,
|
|
1803
1796
|
wallet: qt({
|
|
1804
|
-
storage:
|
|
1805
|
-
auth: { options: [...
|
|
1797
|
+
storage: fi(),
|
|
1798
|
+
auth: { options: [...Ai] },
|
|
1806
1799
|
executionMode: n === "EOA" ? { mode: "EOA" } : {
|
|
1807
1800
|
mode: "EIP7702",
|
|
1808
1801
|
sponsorGas: r
|
|
1809
1802
|
}
|
|
1810
1803
|
})
|
|
1811
|
-
}),
|
|
1812
|
-
},
|
|
1813
|
-
let t = e ??
|
|
1814
|
-
return t?.useModularExecutor ? [
|
|
1815
|
-
},
|
|
1816
|
-
function
|
|
1817
|
-
let e =
|
|
1804
|
+
}), Ni.wallet;
|
|
1805
|
+
}, Fi = (e) => {
|
|
1806
|
+
let t = e ?? w() ?? void 0;
|
|
1807
|
+
return t?.useModularExecutor ? [Pi(t)] : [Mi(t)];
|
|
1808
|
+
}, Ii = "This ManagedAccount predates the Seed executor router extension, so the Seed executor cannot act for it and publish automation is not available for this account.", Li = "The Seed executor is not installed for this ManagedAccount, so automation session keys cannot publish through it. The account admin installs it (installSeedExecutor), which enrollPublishAutomation does.", Ri = "The Seed executor module is configured with a different EAS contract for this ManagedAccount than publish config. Automation session keys cannot change it.", zi = "Could not read the Seed executor module state for this ManagedAccount.";
|
|
1809
|
+
function Bi() {
|
|
1810
|
+
let e = D().modularAccountModuleContract?.trim();
|
|
1818
1811
|
if (!e || !/^0x[0-9a-fA-F]{40}$/.test(e)) throw Error("@seedprotocol/publish: publish automation requires PublishConfig.modularAccountModuleContract (executor module).");
|
|
1819
1812
|
return e;
|
|
1820
1813
|
}
|
|
1821
|
-
async function
|
|
1822
|
-
return await
|
|
1814
|
+
async function Vi(e) {
|
|
1815
|
+
return await ne(e) === null;
|
|
1823
1816
|
}
|
|
1824
|
-
async function
|
|
1825
|
-
let n =
|
|
1817
|
+
async function Hi(e, t = {}) {
|
|
1818
|
+
let n = Bi(), r = e, i, a;
|
|
1826
1819
|
if (t.installedEas) i = !0, a = t.installedEas;
|
|
1827
1820
|
else try {
|
|
1828
|
-
i = await
|
|
1821
|
+
i = await Ce(() => ee(n, r), Boolean, { attempts: t.readAttempts ?? 1 }), a = i ? await x(n, r) : ft;
|
|
1829
1822
|
} catch (t) {
|
|
1830
|
-
throw new
|
|
1823
|
+
throw new E(zi, "AUTOMATION_UNSUPPORTED_ACCOUNT", e, t);
|
|
1831
1824
|
}
|
|
1832
1825
|
if (!i) {
|
|
1833
|
-
let t = await
|
|
1834
|
-
throw new
|
|
1826
|
+
let t = await Vi(r) ? Ii : Li;
|
|
1827
|
+
throw new E(t, "AUTOMATION_UNSUPPORTED_ACCOUNT", e);
|
|
1835
1828
|
}
|
|
1836
|
-
let o =
|
|
1837
|
-
if (o && a.toLowerCase() !== o) throw new
|
|
1829
|
+
let o = D().easContractAddress?.toLowerCase();
|
|
1830
|
+
if (o && a.toLowerCase() !== o) throw new E(Ri, "AUTOMATION_UNSUPPORTED_ACCOUNT", e);
|
|
1838
1831
|
}
|
|
1839
|
-
function
|
|
1832
|
+
function Ui(e) {
|
|
1840
1833
|
let t = e instanceof at ? `${e.shortMessage} ${e.details} ${e.message}` : String(e);
|
|
1841
1834
|
return /insufficient funds|insufficient balance/i.test(t);
|
|
1842
1835
|
}
|
|
1843
|
-
async function
|
|
1844
|
-
let { managedAddress: t, tx: n, action: r, code: i = "AUTOMATION_PREFLIGHT_FAILED", requireSimulation: a = !0 } = e, o = (e) =>
|
|
1836
|
+
async function Wi(e) {
|
|
1837
|
+
let { managedAddress: t, tx: n, action: r, code: i = "AUTOMATION_PREFLIGHT_FAILED", requireSimulation: a = !0 } = e, o = (e) => xe().call({
|
|
1845
1838
|
account: t,
|
|
1846
1839
|
to: n.to,
|
|
1847
1840
|
data: n.data,
|
|
@@ -1855,68 +1848,68 @@ async function Hi(e) {
|
|
|
1855
1848
|
try {
|
|
1856
1849
|
await o(!1);
|
|
1857
1850
|
} catch (e) {
|
|
1858
|
-
if (!
|
|
1851
|
+
if (!Ui(e)) throw e;
|
|
1859
1852
|
await o(!0);
|
|
1860
1853
|
}
|
|
1861
1854
|
} catch (e) {
|
|
1862
1855
|
let n = tn(e);
|
|
1863
1856
|
if (!n && !a) return;
|
|
1864
1857
|
let o = n ? rn(en(e)) : "could not be simulated";
|
|
1865
|
-
throw new
|
|
1858
|
+
throw new E(`Simulated ${r} from ${t} ${o}; nothing was sent.`, i, t, e);
|
|
1866
1859
|
}
|
|
1867
1860
|
}
|
|
1868
1861
|
//#endregion
|
|
1869
1862
|
//#region src/helpers/ensureExecutorModule.ts
|
|
1870
|
-
var
|
|
1871
|
-
async function
|
|
1863
|
+
var Gi = () => `The executor module could not be installed on your publishing account on ${O()}. Reconnect and try again, or contact support if this persists.`;
|
|
1864
|
+
async function Ki(e, t, n) {
|
|
1872
1865
|
let { modularAccountModuleContract: r } = n;
|
|
1873
|
-
if (!r || !await
|
|
1874
|
-
let i = await
|
|
1875
|
-
return i ?
|
|
1866
|
+
if (!r || !await oe(e)) return { status: "skipped" };
|
|
1867
|
+
let i = await ne(e);
|
|
1868
|
+
return i ? qi(e, i.executor, r) : { status: "skipped" };
|
|
1876
1869
|
}
|
|
1877
|
-
async function
|
|
1878
|
-
if (t.toLowerCase() !== n.trim().toLowerCase()) throw new
|
|
1870
|
+
async function qi(e, t, n) {
|
|
1871
|
+
if (t.toLowerCase() !== n.trim().toLowerCase()) throw new E(`Your publishing account's Seed executor is ${t}, but publish config sets modularAccountModuleContract to ${n}. Point modularAccountModuleContract at the account's executor.`, "EXECUTOR_MODULE_NOT_INSTALLED", e);
|
|
1879
1872
|
let r = e, i, a, o;
|
|
1880
1873
|
try {
|
|
1881
|
-
if (await
|
|
1882
|
-
let { getManagedAccountAdmin: n } = await import("./managedAccountAdmin-
|
|
1874
|
+
if (await fe(r, t)) return { status: "already-installed" };
|
|
1875
|
+
let { getManagedAccountAdmin: n } = await import("./managedAccountAdmin-B3DPMmhR.js").then((e) => e.n), s = ue(await n(e));
|
|
1883
1876
|
i = s.txSender.address;
|
|
1884
1877
|
let c = await s.txSender.sendTransaction(f(r));
|
|
1885
1878
|
o = c.transactionHash;
|
|
1886
1879
|
try {
|
|
1887
|
-
a = await
|
|
1880
|
+
a = await T(c.transactionHash);
|
|
1888
1881
|
} catch (e) {
|
|
1889
|
-
if (!(e instanceof
|
|
1882
|
+
if (!(e instanceof de)) throw e;
|
|
1890
1883
|
}
|
|
1891
1884
|
} catch (t) {
|
|
1892
|
-
throw t instanceof
|
|
1885
|
+
throw t instanceof E ? t : new E(Gi(), "EXECUTOR_MODULE_NOT_INSTALLED", e, t);
|
|
1893
1886
|
}
|
|
1894
|
-
let s = a &&
|
|
1887
|
+
let s = a && Ji(a, r, t);
|
|
1895
1888
|
if (s) return {
|
|
1896
1889
|
status: "installed",
|
|
1897
1890
|
eas: s,
|
|
1898
1891
|
transactionHash: o
|
|
1899
1892
|
};
|
|
1900
|
-
let c = await
|
|
1893
|
+
let c = await Yi(r, i);
|
|
1901
1894
|
if (c === "already-installed") return { status: "already-installed" };
|
|
1902
|
-
throw new
|
|
1895
|
+
throw new E(`installSeedExecutor in transaction ${o} did not install the Seed executor on ${e}${c ? `: ${c}` : ""}.`, "EXECUTOR_MODULE_NOT_INSTALLED", e);
|
|
1903
1896
|
}
|
|
1904
|
-
function
|
|
1897
|
+
function Ji(e, t, n) {
|
|
1905
1898
|
if (ut({
|
|
1906
|
-
abi:
|
|
1899
|
+
abi: ie,
|
|
1907
1900
|
eventName: "SeedExecutorInstalled",
|
|
1908
1901
|
logs: e.logs,
|
|
1909
1902
|
strict: !1
|
|
1910
1903
|
}).some((e) => ct(e.address, t) && e.args.executor && ct(e.args.executor, n))) return ut({
|
|
1911
|
-
abi:
|
|
1904
|
+
abi: y,
|
|
1912
1905
|
eventName: "ModuleInitialized",
|
|
1913
1906
|
logs: e.logs,
|
|
1914
1907
|
strict: !1
|
|
1915
1908
|
}).find((e) => ct(e.address, n) && e.args.account && ct(e.args.account, t))?.args.eas;
|
|
1916
1909
|
}
|
|
1917
|
-
async function
|
|
1910
|
+
async function Yi(e, t) {
|
|
1918
1911
|
try {
|
|
1919
|
-
await
|
|
1912
|
+
await Wi({
|
|
1920
1913
|
managedAddress: t,
|
|
1921
1914
|
tx: f(e),
|
|
1922
1915
|
action: "installSeedExecutor",
|
|
@@ -1924,26 +1917,26 @@ async function qi(e, t) {
|
|
|
1924
1917
|
});
|
|
1925
1918
|
return;
|
|
1926
1919
|
} catch (e) {
|
|
1927
|
-
let t = rn(en(e instanceof
|
|
1920
|
+
let t = rn(en(e instanceof E ? e.underlyingCause : e));
|
|
1928
1921
|
return t === "reverted with SeedExecutorAlreadyInstalled" ? "already-installed" : t;
|
|
1929
1922
|
}
|
|
1930
1923
|
}
|
|
1931
1924
|
//#endregion
|
|
1932
1925
|
//#region src/helpers/ensureManagedAccountReady.ts
|
|
1933
|
-
var
|
|
1934
|
-
async function
|
|
1935
|
-
let { useModularExecutor: e } =
|
|
1926
|
+
var Xi = () => `Could not connect the managed publishing account on ${O()}. Reconnect with the same sign-in method and try again.`, Zi = () => `Your publishing smart account is not deployed on ${O()} yet. Complete wallet setup, enable autoDeployManagedAccount in config if appropriate, then try again.`, Qi = () => `The managed account could not be confirmed on ${O()} after deployment. Wait a moment and retry, or check your network connection.`, $i = () => `Automatic deployment of the managed publishing account failed on ${O()}. Retry or deploy the account through your wallet provider.`;
|
|
1927
|
+
async function ea() {
|
|
1928
|
+
let { useModularExecutor: e } = D();
|
|
1936
1929
|
if (!e) return { kind: "skip" };
|
|
1937
1930
|
let t;
|
|
1938
1931
|
try {
|
|
1939
|
-
t = await
|
|
1932
|
+
t = await Ei(A());
|
|
1940
1933
|
} catch (e) {
|
|
1941
1934
|
return {
|
|
1942
1935
|
kind: "unavailable",
|
|
1943
1936
|
cause: e
|
|
1944
1937
|
};
|
|
1945
1938
|
}
|
|
1946
|
-
return await
|
|
1939
|
+
return await yi(t) ? {
|
|
1947
1940
|
kind: "ready",
|
|
1948
1941
|
managedAddress: t
|
|
1949
1942
|
} : {
|
|
@@ -1951,87 +1944,87 @@ async function Qi() {
|
|
|
1951
1944
|
managedAddress: t
|
|
1952
1945
|
};
|
|
1953
1946
|
}
|
|
1954
|
-
async function
|
|
1955
|
-
|
|
1956
|
-
let e =
|
|
1947
|
+
async function ta() {
|
|
1948
|
+
pi();
|
|
1949
|
+
let e = Mi();
|
|
1957
1950
|
await e.autoConnect({
|
|
1958
|
-
client:
|
|
1959
|
-
chain:
|
|
1951
|
+
client: j(),
|
|
1952
|
+
chain: A()
|
|
1960
1953
|
});
|
|
1961
1954
|
let t = e.getAccount();
|
|
1962
|
-
if (!t) throw new
|
|
1955
|
+
if (!t) throw new E(Xi(), "MANAGED_ACCOUNT_UNAVAILABLE");
|
|
1963
1956
|
return t;
|
|
1964
1957
|
}
|
|
1965
|
-
var
|
|
1966
|
-
async function
|
|
1958
|
+
var na = 9e4;
|
|
1959
|
+
async function ra(e) {
|
|
1967
1960
|
let t;
|
|
1968
1961
|
try {
|
|
1969
|
-
await Promise.race([
|
|
1970
|
-
t = setTimeout(() => n(/* @__PURE__ */ Error(`Managed account deploy timed out after ${
|
|
1962
|
+
await Promise.race([Ci(e), new Promise((e, n) => {
|
|
1963
|
+
t = setTimeout(() => n(/* @__PURE__ */ Error(`Managed account deploy timed out after ${na / 1e3}s`)), na);
|
|
1971
1964
|
})]);
|
|
1972
1965
|
} finally {
|
|
1973
1966
|
t != null && clearTimeout(t);
|
|
1974
1967
|
}
|
|
1975
1968
|
}
|
|
1976
|
-
async function
|
|
1977
|
-
let t =
|
|
1969
|
+
async function ia(e) {
|
|
1970
|
+
let t = D(), n = await ta(), { fromThirdwebAccount: r } = await import("./chainConfig-BDMRU4m8.js").then((e) => e.g), i = {
|
|
1978
1971
|
managedAddress: e,
|
|
1979
1972
|
managedSigningAccount: r(n)
|
|
1980
1973
|
};
|
|
1981
1974
|
try {
|
|
1982
1975
|
if (t.deployManagedAccount) await t.deployManagedAccount(i);
|
|
1983
1976
|
else {
|
|
1984
|
-
let e = await
|
|
1977
|
+
let e = await Oi();
|
|
1985
1978
|
if (e) {
|
|
1986
|
-
let t =
|
|
1979
|
+
let t = Pi();
|
|
1987
1980
|
await t.autoConnect({
|
|
1988
|
-
client:
|
|
1989
|
-
chain:
|
|
1990
|
-
}), await
|
|
1981
|
+
client: j(),
|
|
1982
|
+
chain: A()
|
|
1983
|
+
}), await wi({
|
|
1991
1984
|
adminAddress: t.getAdminAccount?.()?.address ?? e.address,
|
|
1992
1985
|
signingAccount: e
|
|
1993
1986
|
});
|
|
1994
|
-
} else await
|
|
1987
|
+
} else await ra(n);
|
|
1995
1988
|
}
|
|
1996
1989
|
} catch (t) {
|
|
1997
|
-
if (await
|
|
1998
|
-
throw new
|
|
1990
|
+
if (await bi(e, /UserOp|user operation/i.test(Ee(t)) ? 15 : 5)) return;
|
|
1991
|
+
throw new E($i(), "MANAGED_ACCOUNT_NOT_DEPLOYED", e, t);
|
|
1999
1992
|
}
|
|
2000
|
-
if (!await
|
|
1993
|
+
if (!await bi(e)) throw new E(Qi(), "MANAGED_ACCOUNT_NOT_DEPLOYED", e);
|
|
2001
1994
|
}
|
|
2002
|
-
async function
|
|
2003
|
-
let e =
|
|
1995
|
+
async function aa() {
|
|
1996
|
+
let e = D();
|
|
2004
1997
|
if (!e.useModularExecutor) throw Error("runModularExecutorPublishPrep: useModularExecutor is false");
|
|
2005
|
-
let t = await
|
|
1998
|
+
let t = await ea();
|
|
2006
1999
|
if (t.kind === "unavailable") return {
|
|
2007
2000
|
ok: !1,
|
|
2008
|
-
error: new
|
|
2001
|
+
error: new E(Xi(), "MANAGED_ACCOUNT_UNAVAILABLE", void 0, t.cause)
|
|
2009
2002
|
};
|
|
2010
2003
|
if (t.kind === "not_deployed") {
|
|
2011
2004
|
if (e.autoDeployManagedAccount) {
|
|
2012
2005
|
try {
|
|
2013
|
-
await
|
|
2006
|
+
await ia(t.managedAddress);
|
|
2014
2007
|
} catch (e) {
|
|
2015
2008
|
return {
|
|
2016
2009
|
ok: !1,
|
|
2017
|
-
error:
|
|
2010
|
+
error: te(e) ? e : new E($i(), "MANAGED_ACCOUNT_NOT_DEPLOYED", t.managedAddress, e)
|
|
2018
2011
|
};
|
|
2019
2012
|
}
|
|
2020
|
-
if (t = await
|
|
2013
|
+
if (t = await ea(), t.kind !== "ready") return {
|
|
2021
2014
|
ok: !1,
|
|
2022
|
-
error: new
|
|
2015
|
+
error: new E(Qi(), "MANAGED_ACCOUNT_NOT_DEPLOYED", t.kind === "not_deployed" ? t.managedAddress : void 0)
|
|
2023
2016
|
};
|
|
2024
2017
|
} else return {
|
|
2025
2018
|
ok: !1,
|
|
2026
|
-
error: new
|
|
2019
|
+
error: new E(Zi(), "MANAGED_ACCOUNT_NOT_DEPLOYED", t.managedAddress)
|
|
2027
2020
|
};
|
|
2028
2021
|
}
|
|
2029
2022
|
if (t.kind === "ready") {
|
|
2030
2023
|
if (e.modularAccountModuleContract) try {
|
|
2031
|
-
let n = await
|
|
2032
|
-
await
|
|
2024
|
+
let n = await ta();
|
|
2025
|
+
await Ki(t.managedAddress, n, e);
|
|
2033
2026
|
} catch (e) {
|
|
2034
|
-
console.warn(`[@seedprotocol/publish] Executor module setup failed on ${
|
|
2027
|
+
console.warn(`[@seedprotocol/publish] Executor module setup failed on ${O()}; publishing continues, but publish automation needs it.`, e);
|
|
2035
2028
|
}
|
|
2036
2029
|
return {
|
|
2037
2030
|
ok: !0,
|
|
@@ -2042,18 +2035,18 @@ async function ra() {
|
|
|
2042
2035
|
}
|
|
2043
2036
|
//#endregion
|
|
2044
2037
|
//#region src/helpers/resolvePublishWallet.ts
|
|
2045
|
-
function
|
|
2038
|
+
function oa(e) {
|
|
2046
2039
|
if (i(e.wallet)) return e.wallet;
|
|
2047
2040
|
if (i(e.account)) return e.account;
|
|
2048
|
-
let t =
|
|
2041
|
+
let t = pe();
|
|
2049
2042
|
if (t) return t;
|
|
2050
2043
|
throw Error("@seedprotocol/publish: no PublishWallet available. Pass fromEthersWallet / fromEip1193Provider / fromThirdwebAccount, or call setPublishWallet / useSeedWallet.");
|
|
2051
2044
|
}
|
|
2052
2045
|
//#endregion
|
|
2053
2046
|
//#region src/services/publish/helpers/verifyArweaveTransactionsExist.ts
|
|
2054
|
-
async function
|
|
2047
|
+
async function sa(e) {
|
|
2055
2048
|
if (e.length === 0) return;
|
|
2056
|
-
let { arweaveUploadVerificationBaseUrl: t } =
|
|
2049
|
+
let { arweaveUploadVerificationBaseUrl: t } = D(), n = await Promise.all(e.map((e) => Ue(t, e)));
|
|
2057
2050
|
for (let t = 0; t < e.length; t++) {
|
|
2058
2051
|
let r = e[t], i = n[t];
|
|
2059
2052
|
if (i) {
|
|
@@ -2067,13 +2060,13 @@ async function aa(e) {
|
|
|
2067
2060
|
}
|
|
2068
2061
|
//#endregion
|
|
2069
2062
|
//#region src/services/arweaveL1Finalize/enqueue.ts
|
|
2070
|
-
var
|
|
2071
|
-
async function
|
|
2072
|
-
let { useArweaveBundler: t } =
|
|
2063
|
+
var ca = "pending_l1";
|
|
2064
|
+
async function la(e) {
|
|
2065
|
+
let { useArweaveBundler: t } = D();
|
|
2073
2066
|
if (!t) return;
|
|
2074
2067
|
let n = e.arweaveTransactions ?? [], r = e.publishUploads ?? [];
|
|
2075
2068
|
if (n.length === 0 || n.length !== r.length) return;
|
|
2076
|
-
let i =
|
|
2069
|
+
let i = ke.getAppDb();
|
|
2077
2070
|
if (!i) return;
|
|
2078
2071
|
let a = Date.now();
|
|
2079
2072
|
for (let e = 0; e < n.length; e++) {
|
|
@@ -2081,12 +2074,12 @@ async function sa(e) {
|
|
|
2081
2074
|
if (!o) continue;
|
|
2082
2075
|
let s = t.transaction?.id;
|
|
2083
2076
|
if (s && typeof s == "string") try {
|
|
2084
|
-
await i.insert(
|
|
2077
|
+
await i.insert(Pe).values({
|
|
2085
2078
|
seedLocalId: o.seedLocalId,
|
|
2086
2079
|
dataItemId: s,
|
|
2087
2080
|
versionLocalId: o.versionLocalId ?? null,
|
|
2088
2081
|
itemPropertyName: o.itemPropertyName ?? null,
|
|
2089
|
-
phase:
|
|
2082
|
+
phase: ca,
|
|
2090
2083
|
createdAt: a,
|
|
2091
2084
|
updatedAt: a
|
|
2092
2085
|
}).onConflictDoNothing();
|
|
@@ -2095,54 +2088,54 @@ async function sa(e) {
|
|
|
2095
2088
|
}
|
|
2096
2089
|
//#endregion
|
|
2097
2090
|
//#region src/helpers/ensureManagedAccountEasConfigured.ts
|
|
2098
|
-
var
|
|
2099
|
-
function
|
|
2091
|
+
var ua = () => `Could not verify or set the EAS contract address on your publishing account on ${O()}.`, da = "ManagedAccount EAS pointer does not match publish config. Configure EAS with the user’s ManagedAccount wallet before automation publish (session keys cannot call setEas).", fa = (e) => `Your publishing account's Seed extension uses EAS ${e}, but publish config sets easContractAddress to a different contract. The extension's EAS is fixed at deployment; fix easContractAddress.`;
|
|
2092
|
+
function pa(e) {
|
|
2100
2093
|
return e.toLowerCase();
|
|
2101
2094
|
}
|
|
2102
|
-
function
|
|
2103
|
-
let { easContractAddress: t } =
|
|
2104
|
-
if (!n || n ===
|
|
2095
|
+
function ma(e) {
|
|
2096
|
+
let { easContractAddress: t } = D(), n = pa(t);
|
|
2097
|
+
if (!n || n === pa(ft)) throw new E("Publish config is missing a valid easContractAddress.", "MANAGED_ACCOUNT_SET_EAS_FAILED", e);
|
|
2105
2098
|
return n;
|
|
2106
2099
|
}
|
|
2107
|
-
async function
|
|
2100
|
+
async function ha(e) {
|
|
2108
2101
|
try {
|
|
2109
|
-
let t = await
|
|
2110
|
-
return
|
|
2102
|
+
let t = await se(e);
|
|
2103
|
+
return pa(typeof t == "string" ? t : String(t));
|
|
2111
2104
|
} catch (t) {
|
|
2112
|
-
throw new
|
|
2105
|
+
throw new E(ua(), "MANAGED_ACCOUNT_SET_EAS_FAILED", e, t);
|
|
2113
2106
|
}
|
|
2114
2107
|
}
|
|
2115
|
-
async function
|
|
2116
|
-
let t =
|
|
2117
|
-
if (await
|
|
2108
|
+
async function ga(e) {
|
|
2109
|
+
let t = ma(e);
|
|
2110
|
+
if (await ha(e) !== t) throw new E(da, "MANAGED_ACCOUNT_SET_EAS_FAILED", e);
|
|
2118
2111
|
}
|
|
2119
|
-
async function
|
|
2120
|
-
let n =
|
|
2112
|
+
async function _a(e, t) {
|
|
2113
|
+
let n = ma(e), r = await ha(e);
|
|
2121
2114
|
if (r !== n) {
|
|
2122
|
-
if (r !==
|
|
2115
|
+
if (r !== pa(ft)) throw new E(fa(r), "MANAGED_ACCOUNT_SET_EAS_FAILED", e);
|
|
2123
2116
|
try {
|
|
2124
|
-
let n = typeof t == "function" ? await t() : t, r = i(n) ? n.txSender :
|
|
2117
|
+
let n = typeof t == "function" ? await t() : t, r = i(n) ? n.txSender : he(n) ? n : (() => {
|
|
2125
2118
|
throw Error("@seedprotocol/publish: ensureManagedAccountEasConfigured requires PublishWallet or SeedTxSender");
|
|
2126
|
-
})(), { easContractAddress: a } =
|
|
2127
|
-
await
|
|
2119
|
+
})(), { easContractAddress: a } = D(), o = S(e, a), s = await r.sendTransaction(o);
|
|
2120
|
+
await T(s.transactionHash);
|
|
2128
2121
|
} catch (t) {
|
|
2129
|
-
throw new
|
|
2122
|
+
throw new E(ua(), "MANAGED_ACCOUNT_SET_EAS_FAILED", e, t);
|
|
2130
2123
|
}
|
|
2131
2124
|
}
|
|
2132
2125
|
}
|
|
2133
2126
|
//#endregion
|
|
2134
2127
|
//#region src/services/publish/actors/createAttestations.ts
|
|
2135
|
-
var
|
|
2136
|
-
function
|
|
2128
|
+
var va = R("seedProtocol:services:publish:actors");
|
|
2129
|
+
function ya(e) {
|
|
2137
2130
|
return !!e && /^0x[0-9a-fA-F]{40}$/.test(e.trim());
|
|
2138
2131
|
}
|
|
2139
|
-
function
|
|
2132
|
+
function ba(e) {
|
|
2140
2133
|
let { useModularExecutor: t, publisherAddress: n, modularAccountModuleContract: r, managedAddress: i, routeToExecutorModule: a } = e;
|
|
2141
2134
|
if (t) {
|
|
2142
2135
|
if (!i) throw Error("resolvePublishRouting: managedAddress is required when useModularExecutor is true");
|
|
2143
2136
|
let e = r?.trim();
|
|
2144
2137
|
if (a) {
|
|
2145
|
-
if (!
|
|
2138
|
+
if (!ya(e)) throw Error("resolvePublishRouting: modularAccountModuleContract is required when routeToExecutorModule is true");
|
|
2146
2139
|
return {
|
|
2147
2140
|
txTargetAddress: e,
|
|
2148
2141
|
contractAddressForEvents: e
|
|
@@ -2158,18 +2151,18 @@ function va(e) {
|
|
|
2158
2151
|
contractAddressForEvents: n
|
|
2159
2152
|
};
|
|
2160
2153
|
}
|
|
2161
|
-
var
|
|
2162
|
-
let { address: t, account: n, wallet: r } = e, i = e.arweaveTransactions ?? [], a = e.publishUploads ?? [], { item: o } = e, { modularAccountModuleContract: s, useModularExecutor: l } =
|
|
2154
|
+
var xa = L(async ({ input: { context: e } }) => {
|
|
2155
|
+
let { address: t, account: n, wallet: r } = e, i = e.arweaveTransactions ?? [], a = e.publishUploads ?? [], { item: o } = e, { modularAccountModuleContract: s, useModularExecutor: l } = D();
|
|
2163
2156
|
if (!t || typeof t != "string" || !t.trim()) throw Error("No wallet address for publish. Connect a wallet and try again.");
|
|
2164
2157
|
if (!r && !n) throw Error("Wallet session is missing. Reconnect your wallet and retry the publish.");
|
|
2165
|
-
if (!l && !await
|
|
2158
|
+
if (!l && !await oe(t)) throw Error("EOA publishing must use the direct EAS path (multiPublish requires a deployed publisher contract). If you see this, attestation routing is misconfigured.");
|
|
2166
2159
|
if (!o?.seedLocalId) throw Error("Attestation recovery failed: Item data is missing. Delete this publish record and try a full publish from the beginning.");
|
|
2167
|
-
if (typeof o.getPublishUploads != "function" && (o = await
|
|
2168
|
-
let u =
|
|
2160
|
+
if (typeof o.getPublishUploads != "function" && (o = await Dn(o.seedLocalId)), i.length !== a.length) throw Error("Attestation recovery failed: Arweave transaction data is missing or incomplete. Delete this publish record and try a full publish from the beginning.");
|
|
2161
|
+
let u = ba({
|
|
2169
2162
|
useModularExecutor: !1,
|
|
2170
2163
|
publisherAddress: t
|
|
2171
|
-
}), d =
|
|
2172
|
-
await
|
|
2164
|
+
}), d = oa(e), f = !1;
|
|
2165
|
+
await Tn(o, d, { managedAddress: t });
|
|
2173
2166
|
let p = i.map((e, t) => {
|
|
2174
2167
|
let n = e.transaction?.id;
|
|
2175
2168
|
if (!n || typeof n != "string") throw Error("Attestation recovery failed: Arweave transaction data did not survive restore. Delete this publish record and try a full publish from the beginning.");
|
|
@@ -2180,40 +2173,40 @@ var ya = I(async ({ input: { context: e } }) => {
|
|
|
2180
2173
|
txId: n
|
|
2181
2174
|
};
|
|
2182
2175
|
});
|
|
2183
|
-
await
|
|
2176
|
+
await sa(p.map((e) => e.txId));
|
|
2184
2177
|
let m = await o.getPublishPayload(p, { publishMode: e.publishMode ?? "patch" }), h = Array.isArray(m) ? m : [m];
|
|
2185
2178
|
if (l) {
|
|
2186
2179
|
let e = d?.signer?.address, n = !1;
|
|
2187
2180
|
if (t && e) {
|
|
2188
|
-
let { isAutomationSessionActive: r } = await import("./ensureAutomationSessionKey-
|
|
2181
|
+
let { isAutomationSessionActive: r } = await import("./ensureAutomationSessionKey-bw6knEyC.js").then((e) => e.n);
|
|
2189
2182
|
n = await r(t, e);
|
|
2190
2183
|
}
|
|
2191
2184
|
if (n) {
|
|
2192
2185
|
let e = s?.trim();
|
|
2193
|
-
if (!
|
|
2194
|
-
u =
|
|
2186
|
+
if (!ya(e)) throw Error("@seedprotocol/publish: automation publish requires PublishConfig.modularAccountModuleContract (executor module). Session keys are module-only and cannot call the ManagedAccount directly.");
|
|
2187
|
+
u = ba({
|
|
2195
2188
|
useModularExecutor: l,
|
|
2196
2189
|
publisherAddress: t,
|
|
2197
2190
|
modularAccountModuleContract: e,
|
|
2198
2191
|
managedAddress: t,
|
|
2199
2192
|
routeToExecutorModule: !0
|
|
2200
|
-
}), f = !0, await
|
|
2193
|
+
}), f = !0, await Hi(t);
|
|
2201
2194
|
} else {
|
|
2202
|
-
let e = await
|
|
2195
|
+
let e = await aa();
|
|
2203
2196
|
if (!e.ok) throw e.error;
|
|
2204
|
-
u =
|
|
2197
|
+
u = ba({
|
|
2205
2198
|
useModularExecutor: l,
|
|
2206
2199
|
publisherAddress: t,
|
|
2207
2200
|
modularAccountModuleContract: s,
|
|
2208
2201
|
managedAddress: e.managedAddress
|
|
2209
2202
|
});
|
|
2210
|
-
let { ensureModularPublishBootstrap: n } = await import("./ensureModularPublishBootstrap-
|
|
2203
|
+
let { ensureModularPublishBootstrap: n } = await import("./ensureModularPublishBootstrap-Vc4Jz_B9.js").then((e) => e.n), { fromThirdwebAccount: r } = await import("./chainConfig-BDMRU4m8.js").then((e) => e.g);
|
|
2211
2204
|
d = r(await n(e.managedAddress));
|
|
2212
2205
|
}
|
|
2213
|
-
} else await
|
|
2206
|
+
} else await _a(t, d);
|
|
2214
2207
|
let g = async (e) => {
|
|
2215
|
-
let n = u.txTargetAddress, r = f ? c(n, e, 5000000n) :
|
|
2216
|
-
await
|
|
2208
|
+
let n = u.txTargetAddress, r = f ? c(n, e, 5000000n) : ve(n, e, 5000000n);
|
|
2209
|
+
await Wi(f ? {
|
|
2217
2210
|
managedAddress: t,
|
|
2218
2211
|
tx: r,
|
|
2219
2212
|
action: "multiPublish via the executor module"
|
|
@@ -2229,21 +2222,21 @@ var ya = I(async ({ input: { context: e } }) => {
|
|
|
2229
2222
|
} catch (e) {
|
|
2230
2223
|
throw un(e, d.txSender.address);
|
|
2231
2224
|
}
|
|
2232
|
-
},
|
|
2233
|
-
if (
|
|
2225
|
+
}, _ = h.length > 1 && Xr(h), v, y = null, b = [];
|
|
2226
|
+
if (_) {
|
|
2234
2227
|
let e = structuredClone(h), n = {}, r = {};
|
|
2235
2228
|
for (let i = 0; i < e.length; i++) {
|
|
2236
2229
|
e = await Qe(e, n);
|
|
2237
|
-
let a = e[i], s = /* @__PURE__ */ new Set([a.localId]), c =
|
|
2230
|
+
let a = e[i], s = /* @__PURE__ */ new Set([a.localId]), c = $r({
|
|
2238
2231
|
...a,
|
|
2239
|
-
propertiesToUpdate:
|
|
2232
|
+
propertiesToUpdate: Zr(a.propertiesToUpdate, s)
|
|
2240
2233
|
}), d = /* @__PURE__ */ new Map([[c.localId, c]]);
|
|
2241
|
-
|
|
2242
|
-
let f = await g([c]), p = await
|
|
2234
|
+
ei([c], d);
|
|
2235
|
+
let f = await g([c]), p = await T(f.transactionHash);
|
|
2243
2236
|
if (!p) throw Error("Failed to send transaction");
|
|
2244
|
-
|
|
2245
|
-
for (let e of
|
|
2246
|
-
let { requests: [m] } = await
|
|
2237
|
+
y = p;
|
|
2238
|
+
for (let e of Rr(p, l)) e.attestationUid && b.push(e.attestationUid);
|
|
2239
|
+
let { requests: [m] } = await ri({
|
|
2247
2240
|
receipt: p,
|
|
2248
2241
|
requests: [c],
|
|
2249
2242
|
rootSeedLocalId: o.seedLocalId,
|
|
@@ -2256,25 +2249,25 @@ var ya = I(async ({ input: { context: e } }) => {
|
|
|
2256
2249
|
h && q(h) !== U && (n[a.localId] = h, e[i] = {
|
|
2257
2250
|
...e[i],
|
|
2258
2251
|
seedUid: h
|
|
2259
|
-
},
|
|
2252
|
+
}, b.push(h));
|
|
2260
2253
|
}
|
|
2261
2254
|
for (let t of e) {
|
|
2262
2255
|
let e = t?.localId, r = t?.seedUid;
|
|
2263
2256
|
e && r && q(r) !== U && (n[e] = q(r));
|
|
2264
2257
|
}
|
|
2265
|
-
|
|
2258
|
+
v = (await Qe(structuredClone(h), n)).map((e) => $r({
|
|
2266
2259
|
...e,
|
|
2267
2260
|
seedUid: n[e.localId] ?? e.seedUid,
|
|
2268
2261
|
versionUid: r[e.localId] ?? e.versionUid
|
|
2269
2262
|
}));
|
|
2270
2263
|
} else {
|
|
2271
|
-
let e = h.map((e) =>
|
|
2272
|
-
|
|
2273
|
-
let n = Array.isArray(m) ? e : [e[0]], r = await g(n), i = await
|
|
2264
|
+
let e = h.map((e) => $r(e));
|
|
2265
|
+
ei(e, new Map(e.map((e) => [e?.localId, e])));
|
|
2266
|
+
let n = Array.isArray(m) ? e : [e[0]], r = await g(n), i = await T(r.transactionHash);
|
|
2274
2267
|
if (!i) throw Error("Failed to send transaction");
|
|
2275
|
-
|
|
2276
|
-
for (let e of
|
|
2277
|
-
|
|
2268
|
+
y = i;
|
|
2269
|
+
for (let e of Rr(i, l)) e.attestationUid && b.push(e.attestationUid);
|
|
2270
|
+
v = (await ri({
|
|
2278
2271
|
receipt: i,
|
|
2279
2272
|
requests: n,
|
|
2280
2273
|
rootSeedLocalId: o.seedLocalId,
|
|
@@ -2283,51 +2276,51 @@ var ya = I(async ({ input: { context: e } }) => {
|
|
|
2283
2276
|
publisherAddress: t
|
|
2284
2277
|
})).requests;
|
|
2285
2278
|
}
|
|
2286
|
-
|
|
2287
|
-
let
|
|
2288
|
-
|
|
2279
|
+
Kr(o, v);
|
|
2280
|
+
let x = o, S = v.find((e) => e?.localId === o.seedLocalId)?.seedUid;
|
|
2281
|
+
S && S !== U && await qr(x, t, y ? await Lr(y) : void 0), va("requestData", m), la(e);
|
|
2289
2282
|
try {
|
|
2290
2283
|
let { clearHtmlEmbeddedImageCoPublishRows: e } = await import("@seedprotocol/sdk"), t = /* @__PURE__ */ new Set([o.seedLocalId]);
|
|
2291
|
-
for (let e of
|
|
2284
|
+
for (let e of v) e?.localId && t.add(e.localId);
|
|
2292
2285
|
for (let n of t) await e(n);
|
|
2293
2286
|
} catch {}
|
|
2294
|
-
let { collectPublishedBatch:
|
|
2295
|
-
for (let e of
|
|
2287
|
+
let { collectPublishedBatch: ee } = await import("./collectBatchUids-CnIe9jUB.js").then((e) => e.t), C = v.find((e) => e?.localId === o.seedLocalId) ?? v[0];
|
|
2288
|
+
for (let e of v) e?.seedUid && b.push(String(e.seedUid)), e?.versionUid && b.push(String(e.versionUid));
|
|
2296
2289
|
return {
|
|
2297
2290
|
easPayload: m,
|
|
2298
|
-
publishedBatch:
|
|
2299
|
-
seedUid: String(
|
|
2300
|
-
versionUid:
|
|
2301
|
-
extraUids:
|
|
2291
|
+
publishedBatch: C?.seedUid ? ee({
|
|
2292
|
+
seedUid: String(C.seedUid),
|
|
2293
|
+
versionUid: C.versionUid ? String(C.versionUid) : void 0,
|
|
2294
|
+
extraUids: b
|
|
2302
2295
|
}) : null
|
|
2303
2296
|
};
|
|
2304
|
-
}),
|
|
2305
|
-
async function
|
|
2297
|
+
}), Sa = R("seedProtocol:services:publish:verifyAttestations"), Ca = "0x" + "0".repeat(64), wa = 64, Ta = (e) => e == null ? "0x" + "0".repeat(wa) : typeof e == "string" ? "0x" + (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0").padStart(wa, "0").slice(-64) : "0x" + "0".repeat(wa), Ea = 5e3, Da = 6;
|
|
2298
|
+
async function Oa({ normalizedRequests: e, item: t }) {
|
|
2306
2299
|
let n = t.seedLocalId;
|
|
2307
2300
|
for (let t of e) {
|
|
2308
|
-
if (t.listOfAttestations.length === 0 || t.versionUid ===
|
|
2309
|
-
let e = t.listOfAttestations.map((e) =>
|
|
2310
|
-
for (let e = 1; e <=
|
|
2311
|
-
e > 1 && await new Promise((e) => setTimeout(e,
|
|
2301
|
+
if (t.listOfAttestations.length === 0 || t.versionUid === Ca) continue;
|
|
2302
|
+
let e = t.listOfAttestations.map((e) => Ta(e.schema).toLowerCase()), r = [], i;
|
|
2303
|
+
for (let e = 1; e <= Da; e++) try {
|
|
2304
|
+
e > 1 && await new Promise((e) => setTimeout(e, Ea)), r = await Re({ versionUids: [t.versionUid] });
|
|
2312
2305
|
break;
|
|
2313
2306
|
} catch (t) {
|
|
2314
|
-
if (i = t,
|
|
2307
|
+
if (i = t, Sa("verifyAttestations attempt %d failed:", e, t), e === Da) throw Sa("verifyAttestations: giving up after %d attempts", Da), i;
|
|
2315
2308
|
}
|
|
2316
|
-
let a = r.map((e) => e.schemaId ?
|
|
2317
|
-
if (e.filter((e) => !o.has(e)).length > 0) throw new
|
|
2309
|
+
let a = r.map((e) => e.schemaId ? Ta(e.schemaId).toLowerCase() : "").filter(Boolean), o = new Set(a);
|
|
2310
|
+
if (e.filter((e) => !o.has(e)).length > 0) throw new le(`Publish verification failed: Seed and Version attestations were created, but property/metadata attestations are missing or incomplete. Expected ${e.length} property attestations for schema(s) ${e.join(", ")}; found ${a.length}. Use PublishManager.retryAttestations('${n}') to retry.`, n, e, a, "METADATA_PROPERTIES_MISSING");
|
|
2318
2311
|
}
|
|
2319
2312
|
}
|
|
2320
2313
|
//#endregion
|
|
2321
2314
|
//#region src/services/publish/actors/createAttestationsDirectToEas.ts
|
|
2322
|
-
var
|
|
2323
|
-
if (e == null) return "0x" + "0".repeat(
|
|
2324
|
-
if (typeof e == "string") return "0x" + (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0").padStart(
|
|
2315
|
+
var ka = R("seedProtocol:services:publish:createAttestationsDirectToEas"), Aa = 64, Y = (e) => {
|
|
2316
|
+
if (e == null) return "0x" + "0".repeat(Aa);
|
|
2317
|
+
if (typeof e == "string") return "0x" + (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0").padStart(Aa, "0").slice(-64);
|
|
2325
2318
|
if (e instanceof Uint8Array || typeof ArrayBuffer < "u" && e instanceof ArrayBuffer) {
|
|
2326
2319
|
let t = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
2327
|
-
return "0x" + Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("").padStart(
|
|
2320
|
+
return "0x" + Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("").padStart(Aa, "0").slice(-64);
|
|
2328
2321
|
}
|
|
2329
|
-
return "0x" + "0".repeat(
|
|
2330
|
-
},
|
|
2322
|
+
return "0x" + "0".repeat(Aa);
|
|
2323
|
+
}, ja = (e) => {
|
|
2331
2324
|
if (e == null || typeof e == "string" && (e === "" || e === "0x")) return "0x";
|
|
2332
2325
|
if (typeof e == "string") {
|
|
2333
2326
|
let t = (e.startsWith("0x") ? e.slice(2) : e).replace(/[^0-9a-fA-F]/g, "0");
|
|
@@ -2338,28 +2331,40 @@ var Da = L("seedProtocol:services:publish:createAttestationsDirectToEas"), Oa =
|
|
|
2338
2331
|
return "0x" + Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("");
|
|
2339
2332
|
}
|
|
2340
2333
|
return "0x";
|
|
2341
|
-
},
|
|
2334
|
+
}, Ma = async (e) => {
|
|
2342
2335
|
let t;
|
|
2343
2336
|
try {
|
|
2344
|
-
t = await
|
|
2337
|
+
t = await N.find({ seedLocalId: e });
|
|
2345
2338
|
} catch {}
|
|
2346
2339
|
return t || new Promise((t) => {
|
|
2347
2340
|
let n = setInterval(() => {
|
|
2348
2341
|
try {
|
|
2349
|
-
|
|
2342
|
+
N.find({ seedLocalId: e }).then((e) => {
|
|
2350
2343
|
e && (clearInterval(n), t(e));
|
|
2351
2344
|
});
|
|
2352
2345
|
} catch {}
|
|
2353
2346
|
}, 200);
|
|
2354
2347
|
});
|
|
2355
|
-
},
|
|
2348
|
+
}, Na = (e) => Array.isArray(e?._rawListIdsForResolve) || e?._easDataType === "bytes32[]" || typeof e?._schemaDef == "string" && e._schemaDef.startsWith("bytes32[]"), Pa = (e) => Array.isArray(e?._rawListIdsForResolve) && e._rawListIdsForResolve.length > 0 || !!e?._unresolvedValue;
|
|
2349
|
+
async function Fa(e, t, n) {
|
|
2350
|
+
let r = e?.listOfAttestations ?? [];
|
|
2351
|
+
if (!r.some(Pa)) return;
|
|
2352
|
+
let [i] = await Qe([e], n);
|
|
2353
|
+
r.forEach((e, n) => {
|
|
2354
|
+
let r = i?.listOfAttestations?.[n];
|
|
2355
|
+
if (!Pa(e) || !r || Pa(r)) return;
|
|
2356
|
+
let a = Array.isArray(r.data) ? r.data[0]?.data : r.data?.data, o = t.listOfAttestations[n]?.data?.[0];
|
|
2357
|
+
o && a != null && (o.data = ja(a));
|
|
2358
|
+
});
|
|
2359
|
+
}
|
|
2360
|
+
var Ia = L(async ({ input: { context: e, event: t } }) => {
|
|
2356
2361
|
let { address: n, account: r, wallet: i } = e, a = e.arweaveTransactions ?? [], o = e.publishUploads ?? [], { item: c } = e;
|
|
2357
2362
|
if (!n || typeof n != "string" || !n.trim()) throw Error("No wallet address for publish. Connect a wallet and try again.");
|
|
2358
2363
|
if (!i && !r) throw Error("Wallet session is missing. Reconnect your wallet and retry the publish.");
|
|
2359
2364
|
if (!c?.seedLocalId) throw Error("Attestation recovery failed: Item data is missing. Delete this publish record and try a full publish from the beginning.");
|
|
2360
|
-
if (typeof c.getPublishUploads != "function" && (c = await
|
|
2361
|
-
let l =
|
|
2362
|
-
await
|
|
2365
|
+
if (typeof c.getPublishUploads != "function" && (c = await Ma(c.seedLocalId)), a.length !== o.length) throw Error("Attestation recovery failed: Arweave transaction data is missing or incomplete. Delete this publish record and try a full publish from the beginning.");
|
|
2366
|
+
let l = oa(e), d = l.txSender;
|
|
2367
|
+
await Tn(c, l, { managedAddress: n });
|
|
2363
2368
|
let f = a.map((e, t) => {
|
|
2364
2369
|
let n = e.transaction?.id;
|
|
2365
2370
|
if (!n || typeof n != "string") throw Error("Attestation recovery failed: Arweave transaction data did not survive restore. Delete this publish record and try a full publish from the beginning.");
|
|
@@ -2370,8 +2375,8 @@ var Da = L("seedProtocol:services:publish:createAttestationsDirectToEas"), Oa =
|
|
|
2370
2375
|
txId: n
|
|
2371
2376
|
};
|
|
2372
2377
|
});
|
|
2373
|
-
await
|
|
2374
|
-
let m = await c.getPublishPayload(f, { publishMode: e.publishMode ?? "patch" }), h =
|
|
2378
|
+
await sa(f.map((e) => e.txId));
|
|
2379
|
+
let m = await c.getPublishPayload(f, { publishMode: e.publishMode ?? "patch" }), h = Array.isArray(m) ? m : [m], _ = h.map((e) => {
|
|
2375
2380
|
let t = (e?.listOfAttestations ?? []).map((e) => {
|
|
2376
2381
|
let t = Array.isArray(e?.data) ? e.data : [];
|
|
2377
2382
|
return {
|
|
@@ -2379,10 +2384,11 @@ var Da = L("seedProtocol:services:publish:createAttestationsDirectToEas"), Oa =
|
|
|
2379
2384
|
data: t.map((e) => ({
|
|
2380
2385
|
...e,
|
|
2381
2386
|
refUID: Y(e?.refUID),
|
|
2382
|
-
data:
|
|
2387
|
+
data: ja(e?.data)
|
|
2383
2388
|
})),
|
|
2384
2389
|
...typeof e?._propertyName == "string" && e._propertyName !== "" ? { _propertyName: e._propertyName } : {},
|
|
2385
|
-
...typeof e?._propertyNameForSchema == "string" && e._propertyNameForSchema !== "" ? { _propertyNameForSchema: e._propertyNameForSchema } : {}
|
|
2390
|
+
...typeof e?._propertyNameForSchema == "string" && e._propertyNameForSchema !== "" ? { _propertyNameForSchema: e._propertyNameForSchema } : {},
|
|
2391
|
+
...Na(e) ? { _isList: !0 } : {}
|
|
2386
2392
|
};
|
|
2387
2393
|
}), n = (e?.propertiesToUpdate ?? []).map((e) => ({
|
|
2388
2394
|
...e,
|
|
@@ -2397,7 +2403,7 @@ var Da = L("seedProtocol:services:publish:createAttestationsDirectToEas"), Oa =
|
|
|
2397
2403
|
listOfAttestations: t,
|
|
2398
2404
|
propertiesToUpdate: n
|
|
2399
2405
|
};
|
|
2400
|
-
}),
|
|
2406
|
+
}), y = new Map(_.map((e) => [e.localId, e])), b = {
|
|
2401
2407
|
recipient: Rt,
|
|
2402
2408
|
expirationTime: BigInt(0),
|
|
2403
2409
|
revocable: !0,
|
|
@@ -2405,64 +2411,66 @@ var Da = L("seedProtocol:services:publish:createAttestationsDirectToEas"), Oa =
|
|
|
2405
2411
|
data: g,
|
|
2406
2412
|
value: BigInt(0)
|
|
2407
2413
|
};
|
|
2408
|
-
for (let e of
|
|
2414
|
+
for (let e of _) for (let t of e.propertiesToUpdate ?? []) {
|
|
2409
2415
|
let e = t.publishLocalId, n = Y(t.propertySchemaUid);
|
|
2410
2416
|
if (!e || !n) continue;
|
|
2411
|
-
let r =
|
|
2417
|
+
let r = y.get(e);
|
|
2412
2418
|
if (!r?.listOfAttestations) continue;
|
|
2413
2419
|
let i = r.listOfAttestations.find((e) => Y(e?.schema)?.toLowerCase() === n?.toLowerCase());
|
|
2414
|
-
i && (!Array.isArray(i.data) || i.data.length === 0) && (i.data = [{
|
|
2415
|
-
...
|
|
2420
|
+
i && !i._isList && (!Array.isArray(i.data) || i.data.length === 0) && (i.data = [{
|
|
2421
|
+
...b,
|
|
2416
2422
|
refUID: g
|
|
2417
2423
|
}]);
|
|
2418
2424
|
}
|
|
2419
|
-
let
|
|
2420
|
-
for (let e
|
|
2421
|
-
|
|
2425
|
+
let x = Date.now(), S = [], ee = /* @__PURE__ */ new Map(), C = {};
|
|
2426
|
+
for (let e of _) e.localId && e.seedUid !== g && (C[e.localId] = e.seedUid);
|
|
2427
|
+
for (let e = 0; e < _.length; e++) {
|
|
2428
|
+
let t = _[e], r = t.seedUid, i = t.versionUid;
|
|
2422
2429
|
if (r === g) {
|
|
2423
|
-
let e =
|
|
2430
|
+
let e = v({
|
|
2424
2431
|
schema: t.seedSchemaUid,
|
|
2425
2432
|
data: {
|
|
2426
2433
|
refUID: g,
|
|
2427
2434
|
data: s(t.seedSchemaUid),
|
|
2428
2435
|
revocable: t.seedIsRevocable
|
|
2429
2436
|
}
|
|
2430
|
-
}), n = await d.sendTransaction(e), i = await
|
|
2437
|
+
}), n = await d.sendTransaction(e), i = await T(n.transactionHash);
|
|
2431
2438
|
if (!i) throw Error("Failed to create Seed attestation");
|
|
2432
|
-
|
|
2433
|
-
let { easContractAddress: a } =
|
|
2439
|
+
x = await Lr(i);
|
|
2440
|
+
let { easContractAddress: a } = D(), o = u(i, a);
|
|
2434
2441
|
if (!o || o === g) throw Error("Failed to get Seed UID from attestation receipt");
|
|
2435
|
-
r = o, t.seedUid = o, t.localId &&
|
|
2442
|
+
r = o, t.seedUid = o, t.localId && (ee.set(t.localId, {
|
|
2436
2443
|
seedUid: o,
|
|
2437
|
-
attestationMs:
|
|
2438
|
-
}),
|
|
2439
|
-
} else r !== g &&
|
|
2444
|
+
attestationMs: x
|
|
2445
|
+
}), C[t.localId] = o), S.push(o), ka("created Seed attestation", r);
|
|
2446
|
+
} else r !== g && S.push(r);
|
|
2440
2447
|
if (r !== g && i === g) {
|
|
2441
|
-
let e =
|
|
2448
|
+
let e = v({
|
|
2442
2449
|
schema: t.versionSchemaUid,
|
|
2443
2450
|
data: {
|
|
2444
2451
|
refUID: r,
|
|
2445
2452
|
data: s(t.versionSchemaUid),
|
|
2446
2453
|
revocable: !0
|
|
2447
2454
|
}
|
|
2448
|
-
}), a = await d.sendTransaction(e), o = await
|
|
2455
|
+
}), a = await d.sendTransaction(e), o = await T(a.transactionHash);
|
|
2449
2456
|
if (!o) throw Error("Failed to create Version attestation");
|
|
2450
|
-
|
|
2451
|
-
let { easContractAddress: c } =
|
|
2457
|
+
x = await Lr(o);
|
|
2458
|
+
let { easContractAddress: c } = D(), l = u(o, c);
|
|
2452
2459
|
if (!l || l === g) throw Error("Failed to get Version UID from attestation receipt");
|
|
2453
|
-
i = l, t.versionUid = l,
|
|
2460
|
+
i = l, t.versionUid = l, S.push(l), await rt({
|
|
2454
2461
|
seedLocalId: t.localId,
|
|
2455
2462
|
versionUid: l,
|
|
2456
2463
|
publisher: n,
|
|
2457
|
-
attestationCreatedAt:
|
|
2458
|
-
}),
|
|
2459
|
-
} else i !== g &&
|
|
2464
|
+
attestationCreatedAt: x
|
|
2465
|
+
}), ka("created Version attestation", i);
|
|
2466
|
+
} else i !== g && S.push(i);
|
|
2460
2467
|
for (let e of t.listOfAttestations) for (let t of e.data) t.refUID = i;
|
|
2468
|
+
await Fa(h[e], t, C);
|
|
2461
2469
|
for (let e of t.propertiesToUpdate ?? []) {
|
|
2462
|
-
let t =
|
|
2470
|
+
let t = y.get(e.publishLocalId);
|
|
2463
2471
|
if (!t?.listOfAttestations) continue;
|
|
2464
2472
|
let n = Y(e.propertySchemaUid), i = t.listOfAttestations.find((e) => Y(e?.schema)?.toLowerCase() === n?.toLowerCase());
|
|
2465
|
-
i?.data?.[0] && (i.data[0].data = s(r));
|
|
2473
|
+
i?.data?.[0] && !i._isList && (i.data[0].data = s(r));
|
|
2466
2474
|
}
|
|
2467
2475
|
let a = t.listOfAttestations.map((e) => ({
|
|
2468
2476
|
schema: e.schema,
|
|
@@ -2476,15 +2484,15 @@ var Da = L("seedProtocol:services:publish:createAttestationsDirectToEas"), Oa =
|
|
|
2476
2484
|
}))
|
|
2477
2485
|
}));
|
|
2478
2486
|
if (a.length > 0) {
|
|
2479
|
-
let n =
|
|
2487
|
+
let n = De(a), r = await d.sendTransaction(n), o = await T(r.transactionHash);
|
|
2480
2488
|
if (!o) throw Error("Failed to create property attestations");
|
|
2481
|
-
|
|
2482
|
-
let { easContractAddress: s } =
|
|
2483
|
-
for (let e of c) e.uid &&
|
|
2489
|
+
x = await Lr(o), ka("created property attestations for request", e);
|
|
2490
|
+
let { easContractAddress: s } = D(), c = p(o, s);
|
|
2491
|
+
for (let e of c) e.uid && S.push(e.uid);
|
|
2484
2492
|
let l = t.listOfAttestations, u = c.length === l.length;
|
|
2485
|
-
await
|
|
2493
|
+
await Ne({
|
|
2486
2494
|
seedLocalId: t.localId,
|
|
2487
|
-
attestationCreatedAtMs:
|
|
2495
|
+
attestationCreatedAtMs: x ?? null,
|
|
2488
2496
|
versionUid: i === g ? null : i,
|
|
2489
2497
|
pairs: c.map((e, t) => ({
|
|
2490
2498
|
schemaUid: e.schemaUid,
|
|
@@ -2494,127 +2502,123 @@ var Da = L("seedProtocol:services:publish:createAttestationsDirectToEas"), Oa =
|
|
|
2494
2502
|
});
|
|
2495
2503
|
}
|
|
2496
2504
|
}
|
|
2497
|
-
|
|
2498
|
-
let
|
|
2499
|
-
|
|
2500
|
-
for (let [e, { seedUid: t, attestationMs: r }] of
|
|
2505
|
+
Kr(c, _);
|
|
2506
|
+
let te = c, w = _.find((e) => e.localId === c.seedLocalId) ?? _[0];
|
|
2507
|
+
w?.seedUid && w.seedUid !== g && await qr(te, n, ee.get(w.localId)?.attestationMs ?? x);
|
|
2508
|
+
for (let [e, { seedUid: t, attestationMs: r }] of ee) e !== w?.localId && await ii({
|
|
2501
2509
|
seedLocalId: e,
|
|
2502
2510
|
seedUid: t,
|
|
2503
2511
|
publisherAddress: n,
|
|
2504
2512
|
attestationCreatedAtMs: r
|
|
2505
2513
|
});
|
|
2506
2514
|
try {
|
|
2507
|
-
await
|
|
2508
|
-
normalizedRequests:
|
|
2515
|
+
await Oa({
|
|
2516
|
+
normalizedRequests: _,
|
|
2509
2517
|
item: c
|
|
2510
2518
|
});
|
|
2511
2519
|
} catch (e) {
|
|
2512
|
-
throw e instanceof
|
|
2520
|
+
throw e instanceof le || ka("verifyAttestations failed (non-verification error):", e), e;
|
|
2513
2521
|
}
|
|
2514
|
-
|
|
2522
|
+
ka("direct EAS publish complete"), la(e);
|
|
2515
2523
|
try {
|
|
2516
2524
|
let { clearHtmlEmbeddedImageCoPublishRows: e } = await import("@seedprotocol/sdk"), t = /* @__PURE__ */ new Set([c.seedLocalId]);
|
|
2517
|
-
for (let e of
|
|
2525
|
+
for (let e of _) e?.localId && t.add(e.localId);
|
|
2518
2526
|
for (let n of t) await e(n);
|
|
2519
2527
|
} catch {}
|
|
2520
|
-
let { collectPublishedBatch:
|
|
2528
|
+
let { collectPublishedBatch: ne } = await import("./collectBatchUids-CnIe9jUB.js").then((e) => e.t), re = w;
|
|
2521
2529
|
return {
|
|
2522
2530
|
easPayload: m,
|
|
2523
|
-
publishedBatch:
|
|
2524
|
-
seedUid: String(
|
|
2525
|
-
versionUid:
|
|
2526
|
-
extraUids:
|
|
2531
|
+
publishedBatch: re?.seedUid ? ne({
|
|
2532
|
+
seedUid: String(re.seedUid),
|
|
2533
|
+
versionUid: re.versionUid ? String(re.versionUid) : void 0,
|
|
2534
|
+
extraUids: S
|
|
2527
2535
|
}) : null
|
|
2528
2536
|
};
|
|
2529
|
-
}),
|
|
2537
|
+
}), La = async (e) => {
|
|
2530
2538
|
let t;
|
|
2531
2539
|
try {
|
|
2532
|
-
t = await
|
|
2540
|
+
t = await N.find({ seedLocalId: e });
|
|
2533
2541
|
} catch {}
|
|
2534
2542
|
return t || new Promise((t) => {
|
|
2535
2543
|
let n = setInterval(() => {
|
|
2536
|
-
|
|
2544
|
+
N.find({ seedLocalId: e }).then((e) => {
|
|
2537
2545
|
e && (clearInterval(n), t(e));
|
|
2538
2546
|
}).catch(() => {});
|
|
2539
2547
|
}, 200);
|
|
2540
2548
|
});
|
|
2541
2549
|
};
|
|
2542
|
-
async function
|
|
2543
|
-
let t = typeof e.getPublishUploads == "function" ? e : await
|
|
2550
|
+
async function Ra(e) {
|
|
2551
|
+
let t = typeof e.getPublishUploads == "function" ? e : await La(e.seedLocalId);
|
|
2544
2552
|
return await qe(t);
|
|
2545
2553
|
}
|
|
2546
2554
|
//#endregion
|
|
2547
2555
|
//#region src/services/publish/actors/checking.ts
|
|
2548
2556
|
var X = /* @__PURE__ */ new Set();
|
|
2549
|
-
async function
|
|
2550
|
-
let t =
|
|
2551
|
-
return t.useDirectEas ? "directEas" : t.useModularExecutor || await
|
|
2557
|
+
async function za(e) {
|
|
2558
|
+
let t = D();
|
|
2559
|
+
return t.useDirectEas ? "directEas" : t.useModularExecutor || await oe(e) ? "multiPublish" : "directEas";
|
|
2552
2560
|
}
|
|
2553
|
-
var
|
|
2561
|
+
var Ba = Ht(({ sendBack: e, input: { context: t } }) => {
|
|
2554
2562
|
let { item: n, account: r, wallet: i, publishMode: a, address: o } = t;
|
|
2555
2563
|
return (async () => {
|
|
2556
|
-
if (!await Ge(n)) {
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
if (X.has(n.seedLocalId)) {
|
|
2561
|
-
e({ type: "redundantPublishProcess" });
|
|
2562
|
-
return;
|
|
2563
|
-
}
|
|
2564
|
-
X.add(n.seedLocalId);
|
|
2565
|
-
try {
|
|
2566
|
-
await Ie(), await ue();
|
|
2567
|
-
let t = await He(n, { publishMode: a ?? "patch" });
|
|
2568
|
-
if (t.length > 0) {
|
|
2569
|
-
X.delete(n.seedLocalId), e({
|
|
2570
|
-
type: "validationFailed",
|
|
2571
|
-
errors: new Ne(t).validationErrors
|
|
2572
|
-
});
|
|
2573
|
-
return;
|
|
2574
|
-
}
|
|
2575
|
-
let s = i ?? r;
|
|
2576
|
-
s && await wn(n, s, { managedAddress: typeof o == "string" ? o : void 0 });
|
|
2577
|
-
let c = await it(n, [], { publishMode: a ?? "patch" });
|
|
2578
|
-
if (!c.isValid) {
|
|
2579
|
-
X.delete(n.seedLocalId), e({
|
|
2580
|
-
type: "validationFailed",
|
|
2581
|
-
errors: c.errors
|
|
2582
|
-
});
|
|
2583
|
-
return;
|
|
2584
|
-
}
|
|
2585
|
-
if (!o || typeof o != "string" || !o.trim()) {
|
|
2586
|
-
X.delete(n.seedLocalId), e({
|
|
2587
|
-
type: "validationFailed",
|
|
2588
|
-
errors: [{ message: "No publisher address for publish. Connect a wallet and try again." }]
|
|
2589
|
-
});
|
|
2590
|
-
return;
|
|
2591
|
-
}
|
|
2592
|
-
let l;
|
|
2564
|
+
if (!await Ge(n)) e({ type: "notOwner" });
|
|
2565
|
+
else if (X.has(n.seedLocalId)) e({ type: "redundantPublishProcess" });
|
|
2566
|
+
else {
|
|
2567
|
+
X.add(n.seedLocalId);
|
|
2593
2568
|
try {
|
|
2594
|
-
|
|
2569
|
+
await Fe(), await ce();
|
|
2570
|
+
let t = await He(n, { publishMode: a ?? "patch" });
|
|
2571
|
+
if (t.length > 0) {
|
|
2572
|
+
X.delete(n.seedLocalId), e({
|
|
2573
|
+
type: "validationFailed",
|
|
2574
|
+
errors: new Me(t).validationErrors
|
|
2575
|
+
});
|
|
2576
|
+
return;
|
|
2577
|
+
}
|
|
2578
|
+
let s = i ?? r;
|
|
2579
|
+
s && await Tn(n, s, { managedAddress: typeof o == "string" ? o : void 0 });
|
|
2580
|
+
let c = await it(n, [], { publishMode: a ?? "patch" });
|
|
2581
|
+
if (!c.isValid) {
|
|
2582
|
+
X.delete(n.seedLocalId), e({
|
|
2583
|
+
type: "validationFailed",
|
|
2584
|
+
errors: c.errors
|
|
2585
|
+
});
|
|
2586
|
+
return;
|
|
2587
|
+
}
|
|
2588
|
+
if (!o || typeof o != "string" || !o.trim()) {
|
|
2589
|
+
X.delete(n.seedLocalId), e({
|
|
2590
|
+
type: "validationFailed",
|
|
2591
|
+
errors: [{ message: "No publisher address for publish. Connect a wallet and try again." }]
|
|
2592
|
+
});
|
|
2593
|
+
return;
|
|
2594
|
+
}
|
|
2595
|
+
let l;
|
|
2596
|
+
try {
|
|
2597
|
+
l = await za(o.trim());
|
|
2598
|
+
} catch (t) {
|
|
2599
|
+
X.delete(n.seedLocalId), e({
|
|
2600
|
+
type: "checkingFailed",
|
|
2601
|
+
error: Error(`Could not verify whether the publisher is a deployed contract on ${O()}. Check your RPC connection and retry.`, { cause: t })
|
|
2602
|
+
});
|
|
2603
|
+
return;
|
|
2604
|
+
}
|
|
2605
|
+
let u = await Ra(n), d = D().useArweaveBundler, f = { attestationStrategy: l };
|
|
2606
|
+
e(u ? d ? {
|
|
2607
|
+
type: "validPublishProcessBundler",
|
|
2608
|
+
...f
|
|
2609
|
+
} : {
|
|
2610
|
+
type: "validPublishProcess",
|
|
2611
|
+
...f
|
|
2612
|
+
} : {
|
|
2613
|
+
type: "skipArweave",
|
|
2614
|
+
...f
|
|
2615
|
+
});
|
|
2595
2616
|
} catch (t) {
|
|
2596
|
-
X.delete(n.seedLocalId), e({
|
|
2617
|
+
X.delete(n.seedLocalId), console.error("[checking] failed", t), e({
|
|
2597
2618
|
type: "checkingFailed",
|
|
2598
|
-
error:
|
|
2619
|
+
error: t instanceof Error ? t : Error(String(t))
|
|
2599
2620
|
});
|
|
2600
|
-
return;
|
|
2601
2621
|
}
|
|
2602
|
-
let u = await Na(n), d = T().useArweaveBundler, f = { attestationStrategy: l };
|
|
2603
|
-
e(u ? d ? {
|
|
2604
|
-
type: "validPublishProcessBundler",
|
|
2605
|
-
...f
|
|
2606
|
-
} : {
|
|
2607
|
-
type: "validPublishProcess",
|
|
2608
|
-
...f
|
|
2609
|
-
} : {
|
|
2610
|
-
type: "skipArweave",
|
|
2611
|
-
...f
|
|
2612
|
-
});
|
|
2613
|
-
} catch (t) {
|
|
2614
|
-
X.delete(n.seedLocalId), console.error("[checking] failed", t), e({
|
|
2615
|
-
type: "checkingFailed",
|
|
2616
|
-
error: t instanceof Error ? t : Error(String(t))
|
|
2617
|
-
});
|
|
2618
2622
|
}
|
|
2619
2623
|
})().catch((t) => {
|
|
2620
2624
|
X.delete(n.seedLocalId), console.error("[checking] unhandled rejection", t), e({
|
|
@@ -2624,101 +2628,101 @@ var Fa = Ht(({ sendBack: e, input: { context: t } }) => {
|
|
|
2624
2628
|
}), () => {
|
|
2625
2629
|
X.delete(n.seedLocalId);
|
|
2626
2630
|
};
|
|
2627
|
-
}), { SUCCESS:
|
|
2628
|
-
function
|
|
2631
|
+
}), { SUCCESS: Va, FAILURE: Z } = me;
|
|
2632
|
+
function Ha(e) {
|
|
2629
2633
|
let t = e.attestationStrategy;
|
|
2630
|
-
return t === "directEas" || t !== "multiPublish" &&
|
|
2634
|
+
return t === "directEas" || t !== "multiPublish" && D().useDirectEas;
|
|
2631
2635
|
}
|
|
2632
|
-
function
|
|
2636
|
+
function Ua(e) {
|
|
2633
2637
|
let t = e.attestationStrategy;
|
|
2634
|
-
return t === "multiPublish" || t !== "directEas" && !
|
|
2638
|
+
return t === "multiPublish" || t !== "directEas" && !D().useDirectEas;
|
|
2635
2639
|
}
|
|
2636
2640
|
function Q(e) {
|
|
2637
2641
|
let t = e;
|
|
2638
2642
|
return t.error ?? t.data;
|
|
2639
2643
|
}
|
|
2640
|
-
var
|
|
2644
|
+
var Wa = Ut({
|
|
2641
2645
|
types: {
|
|
2642
2646
|
context: {},
|
|
2643
2647
|
input: {}
|
|
2644
2648
|
},
|
|
2645
2649
|
actors: {
|
|
2646
|
-
createArweaveTransactions:
|
|
2647
|
-
createArweaveTransactionsPhase2:
|
|
2648
|
-
createArweaveDataItems:
|
|
2649
|
-
createArweaveDataItemsPhase2:
|
|
2650
|
-
sendReimbursementRequest:
|
|
2651
|
-
pollForConfirmation:
|
|
2652
|
-
uploadData:
|
|
2653
|
-
uploadViaBundler:
|
|
2654
|
-
createAttestations:
|
|
2655
|
-
createAttestationsDirectToEas:
|
|
2656
|
-
checking:
|
|
2657
|
-
preparingHtmlEmbedded:
|
|
2658
|
-
rewritingHtmlEmbedded:
|
|
2650
|
+
createArweaveTransactions: An,
|
|
2651
|
+
createArweaveTransactionsPhase2: jn,
|
|
2652
|
+
createArweaveDataItems: yr,
|
|
2653
|
+
createArweaveDataItemsPhase2: xr,
|
|
2654
|
+
sendReimbursementRequest: Or,
|
|
2655
|
+
pollForConfirmation: kr,
|
|
2656
|
+
uploadData: jr,
|
|
2657
|
+
uploadViaBundler: Ir,
|
|
2658
|
+
createAttestations: xa,
|
|
2659
|
+
createAttestationsDirectToEas: Ia,
|
|
2660
|
+
checking: Ba,
|
|
2661
|
+
preparingHtmlEmbedded: Mn,
|
|
2662
|
+
rewritingHtmlEmbedded: Pn
|
|
2659
2663
|
},
|
|
2660
2664
|
actions: {
|
|
2661
2665
|
handleError: ({ event: e }) => {
|
|
2662
2666
|
let t = Q(e);
|
|
2663
2667
|
t == null ? console.error("Unknown error (full event):", e) : console.error(t);
|
|
2664
2668
|
},
|
|
2665
|
-
assignErrorCreatingArweaveTransactions:
|
|
2669
|
+
assignErrorCreatingArweaveTransactions: I({
|
|
2666
2670
|
error: ({ event: e }) => Q(e),
|
|
2667
2671
|
errorStep: () => "creatingArweaveTransactions"
|
|
2668
2672
|
}),
|
|
2669
|
-
assignErrorCreatingArweaveDataItems:
|
|
2673
|
+
assignErrorCreatingArweaveDataItems: I({
|
|
2670
2674
|
error: ({ event: e }) => Q(e),
|
|
2671
2675
|
errorStep: () => "creatingArweaveDataItems"
|
|
2672
2676
|
}),
|
|
2673
|
-
assignErrorSendingReimbursementRequest:
|
|
2677
|
+
assignErrorSendingReimbursementRequest: I({
|
|
2674
2678
|
error: ({ event: e }) => Q(e),
|
|
2675
2679
|
errorStep: () => "sendingReimbursementRequest"
|
|
2676
2680
|
}),
|
|
2677
|
-
assignErrorPollingForConfirmation:
|
|
2681
|
+
assignErrorPollingForConfirmation: I({
|
|
2678
2682
|
error: ({ event: e }) => Q(e),
|
|
2679
2683
|
errorStep: () => "pollingForConfirmation"
|
|
2680
2684
|
}),
|
|
2681
|
-
assignErrorUploadingData:
|
|
2685
|
+
assignErrorUploadingData: I({
|
|
2682
2686
|
error: ({ event: e }) => Q(e),
|
|
2683
2687
|
errorStep: () => "uploadingData"
|
|
2684
2688
|
}),
|
|
2685
|
-
assignErrorPreparingHtmlEmbedded:
|
|
2689
|
+
assignErrorPreparingHtmlEmbedded: I({
|
|
2686
2690
|
error: ({ event: e }) => Q(e),
|
|
2687
2691
|
errorStep: () => "preparingHtmlEmbedded"
|
|
2688
2692
|
}),
|
|
2689
|
-
assignErrorRewritingHtmlEmbedded:
|
|
2693
|
+
assignErrorRewritingHtmlEmbedded: I({
|
|
2690
2694
|
error: ({ event: e }) => Q(e),
|
|
2691
2695
|
errorStep: () => "rewritingHtmlEmbedded"
|
|
2692
2696
|
}),
|
|
2693
|
-
assignErrorCreatingArweaveTransactionsPhase2:
|
|
2697
|
+
assignErrorCreatingArweaveTransactionsPhase2: I({
|
|
2694
2698
|
error: ({ event: e }) => Q(e),
|
|
2695
2699
|
errorStep: () => "creatingArweaveTransactionsPhase2"
|
|
2696
2700
|
}),
|
|
2697
|
-
assignErrorUploadingDataPhase2:
|
|
2701
|
+
assignErrorUploadingDataPhase2: I({
|
|
2698
2702
|
error: ({ event: e }) => Q(e),
|
|
2699
2703
|
errorStep: () => "uploadingDataPhase2"
|
|
2700
2704
|
}),
|
|
2701
|
-
assignErrorUploadingViaBundler:
|
|
2705
|
+
assignErrorUploadingViaBundler: I({
|
|
2702
2706
|
error: ({ event: e }) => Q(e),
|
|
2703
2707
|
errorStep: () => "uploadingViaBundler"
|
|
2704
2708
|
}),
|
|
2705
|
-
assignErrorCreatingArweaveDataItemsPhase2:
|
|
2709
|
+
assignErrorCreatingArweaveDataItemsPhase2: I({
|
|
2706
2710
|
error: ({ event: e }) => Q(e),
|
|
2707
2711
|
errorStep: () => "creatingArweaveDataItemsPhase2"
|
|
2708
2712
|
}),
|
|
2709
|
-
assignErrorUploadingViaBundlerPhase2:
|
|
2713
|
+
assignErrorUploadingViaBundlerPhase2: I({
|
|
2710
2714
|
error: ({ event: e }) => Q(e),
|
|
2711
2715
|
errorStep: () => "uploadingViaBundlerPhase2"
|
|
2712
2716
|
}),
|
|
2713
|
-
assignErrorCreatingAttestations:
|
|
2717
|
+
assignErrorCreatingAttestations: I({
|
|
2714
2718
|
error: ({ event: e }) => Q(e),
|
|
2715
2719
|
errorStep: () => "creatingAttestations"
|
|
2716
2720
|
}),
|
|
2717
|
-
assignErrorCreatingAttestationsDirectToEas:
|
|
2721
|
+
assignErrorCreatingAttestationsDirectToEas: I({
|
|
2718
2722
|
error: ({ event: e }) => Q(e),
|
|
2719
2723
|
errorStep: () => "creatingAttestationsDirectToEas"
|
|
2720
2724
|
}),
|
|
2721
|
-
assignAccountFromRetry:
|
|
2725
|
+
assignAccountFromRetry: I({
|
|
2722
2726
|
wallet: ({ event: e }) => {
|
|
2723
2727
|
let t = e;
|
|
2724
2728
|
return t.wallet ?? t.account;
|
|
@@ -2728,18 +2732,18 @@ var za = Ut({
|
|
|
2728
2732
|
return t.wallet ?? t.account;
|
|
2729
2733
|
}
|
|
2730
2734
|
}),
|
|
2731
|
-
assignErrorNotOwner:
|
|
2735
|
+
assignErrorNotOwner: I({
|
|
2732
2736
|
error: () => /* @__PURE__ */ Error("Item is read-only: you do not own this item. Only the publisher can publish."),
|
|
2733
2737
|
errorStep: () => "checking"
|
|
2734
2738
|
}),
|
|
2735
|
-
assignErrorValidationFailed:
|
|
2739
|
+
assignErrorValidationFailed: I({
|
|
2736
2740
|
error: ({ event: e }) => {
|
|
2737
2741
|
let t = e.errors ?? [], n = t.length > 0 ? `Validation failed (${t.length} error${t.length === 1 ? "" : "s"}):\n${t.map((e) => e.message).join("\n")}` : "Validation failed", r = Error(n);
|
|
2738
2742
|
return r.validationErrors = t, r;
|
|
2739
2743
|
},
|
|
2740
2744
|
errorStep: () => "checking"
|
|
2741
2745
|
}),
|
|
2742
|
-
assignErrorCheckingFailed:
|
|
2746
|
+
assignErrorCheckingFailed: I({
|
|
2743
2747
|
error: ({ event: e }) => {
|
|
2744
2748
|
let t = e.error;
|
|
2745
2749
|
return t instanceof Error ? t : Error(String(t ?? "Publish check failed"));
|
|
@@ -2769,24 +2773,24 @@ var za = Ut({
|
|
|
2769
2773
|
},
|
|
2770
2774
|
validPublishProcess: {
|
|
2771
2775
|
target: "preparingHtmlEmbedded",
|
|
2772
|
-
actions:
|
|
2776
|
+
actions: I({ attestationStrategy: ({ event: e }) => e.attestationStrategy })
|
|
2773
2777
|
},
|
|
2774
2778
|
validPublishProcessBundler: {
|
|
2775
2779
|
target: "preparingHtmlEmbedded",
|
|
2776
|
-
actions:
|
|
2780
|
+
actions: I({ attestationStrategy: ({ event: e }) => e.attestationStrategy })
|
|
2777
2781
|
},
|
|
2778
2782
|
skipArweave: [{
|
|
2779
|
-
guard: ({ context: e }) =>
|
|
2783
|
+
guard: ({ context: e }) => Ha(e),
|
|
2780
2784
|
target: "creatingAttestationsDirectToEas",
|
|
2781
|
-
actions:
|
|
2785
|
+
actions: I({
|
|
2782
2786
|
arweaveTransactions: () => [],
|
|
2783
2787
|
publishUploads: () => [],
|
|
2784
2788
|
attestationStrategy: ({ event: e }) => e.attestationStrategy
|
|
2785
2789
|
})
|
|
2786
2790
|
}, {
|
|
2787
|
-
guard: ({ context: e }) =>
|
|
2791
|
+
guard: ({ context: e }) => Ua(e),
|
|
2788
2792
|
target: "creatingAttestations",
|
|
2789
|
-
actions:
|
|
2793
|
+
actions: I({
|
|
2790
2794
|
arweaveTransactions: () => [],
|
|
2791
2795
|
publishUploads: () => [],
|
|
2792
2796
|
attestationStrategy: ({ event: e }) => e.attestationStrategy
|
|
@@ -2802,12 +2806,12 @@ var za = Ut({
|
|
|
2802
2806
|
src: "preparingHtmlEmbedded",
|
|
2803
2807
|
input: ({ context: e }) => ({ context: e }),
|
|
2804
2808
|
onDone: [{
|
|
2805
|
-
guard: () =>
|
|
2809
|
+
guard: () => D().useArweaveBundler,
|
|
2806
2810
|
target: "creatingArweaveDataItems",
|
|
2807
|
-
actions:
|
|
2811
|
+
actions: I({ htmlEmbeddedDeferredHtmlSeedLocalIds: ({ event: e }) => e.output.deferredHtmlSeedLocalIds })
|
|
2808
2812
|
}, {
|
|
2809
2813
|
target: "creatingArweaveTransactions",
|
|
2810
|
-
actions:
|
|
2814
|
+
actions: I({ htmlEmbeddedDeferredHtmlSeedLocalIds: ({ event: e }) => e.output.deferredHtmlSeedLocalIds })
|
|
2811
2815
|
}],
|
|
2812
2816
|
onError: {
|
|
2813
2817
|
target: Z,
|
|
@@ -2822,7 +2826,7 @@ var za = Ut({
|
|
|
2822
2826
|
}),
|
|
2823
2827
|
onDone: {
|
|
2824
2828
|
target: "sendingReimbursementRequest",
|
|
2825
|
-
actions:
|
|
2829
|
+
actions: I({
|
|
2826
2830
|
arweaveTransactions: ({ event: e }) => e.output.arweaveTransactions,
|
|
2827
2831
|
publishUploads: ({ event: e }) => e.output.publishUploads
|
|
2828
2832
|
})
|
|
@@ -2840,7 +2844,7 @@ var za = Ut({
|
|
|
2840
2844
|
}),
|
|
2841
2845
|
onDone: {
|
|
2842
2846
|
target: "uploadingViaBundler",
|
|
2843
|
-
actions:
|
|
2847
|
+
actions: I({
|
|
2844
2848
|
arweaveTransactions: ({ event: e }) => e.output.arweaveTransactions,
|
|
2845
2849
|
publishUploads: ({ event: e }) => e.output.publishUploads,
|
|
2846
2850
|
signedDataItems: ({ event: e }) => e.output.signedDataItems
|
|
@@ -2859,7 +2863,7 @@ var za = Ut({
|
|
|
2859
2863
|
}),
|
|
2860
2864
|
onDone: {
|
|
2861
2865
|
target: "pollingForConfirmation",
|
|
2862
|
-
actions:
|
|
2866
|
+
actions: I({
|
|
2863
2867
|
requestResponse: ({ event: e }) => e.output,
|
|
2864
2868
|
reimbursementTransactionId: ({ event: e }) => e.output.transactionId
|
|
2865
2869
|
})
|
|
@@ -2877,7 +2881,7 @@ var za = Ut({
|
|
|
2877
2881
|
}),
|
|
2878
2882
|
onDone: {
|
|
2879
2883
|
target: "uploadingData",
|
|
2880
|
-
actions:
|
|
2884
|
+
actions: I({ reimbursementConfirmed: !0 })
|
|
2881
2885
|
},
|
|
2882
2886
|
onError: {
|
|
2883
2887
|
target: "failure",
|
|
@@ -2888,9 +2892,9 @@ var za = Ut({
|
|
|
2888
2892
|
on: {
|
|
2889
2893
|
uploadComplete: [
|
|
2890
2894
|
{
|
|
2891
|
-
guard: ({ context: e }) =>
|
|
2895
|
+
guard: ({ context: e }) => Ha(e),
|
|
2892
2896
|
target: "creatingAttestationsDirectToEas",
|
|
2893
|
-
actions:
|
|
2897
|
+
actions: I({
|
|
2894
2898
|
completionPercentage: 100,
|
|
2895
2899
|
signedDataItems: () => void 0,
|
|
2896
2900
|
arweaveUploadData: () => void 0
|
|
@@ -2899,7 +2903,7 @@ var za = Ut({
|
|
|
2899
2903
|
{
|
|
2900
2904
|
guard: (e) => (e.context?.htmlEmbeddedDeferredHtmlSeedLocalIds?.length ?? 0) > 0,
|
|
2901
2905
|
target: "rewritingHtmlEmbedded",
|
|
2902
|
-
actions:
|
|
2906
|
+
actions: I({
|
|
2903
2907
|
htmlEmbeddedPhase1PublishUploads: ({ context: e }) => e.publishUploads ?? [],
|
|
2904
2908
|
htmlEmbeddedPhase1ArweaveTransactions: ({ context: e }) => e.arweaveTransactions ?? [],
|
|
2905
2909
|
signedDataItems: () => void 0,
|
|
@@ -2907,9 +2911,9 @@ var za = Ut({
|
|
|
2907
2911
|
})
|
|
2908
2912
|
},
|
|
2909
2913
|
{
|
|
2910
|
-
guard: ({ context: e }) =>
|
|
2914
|
+
guard: ({ context: e }) => Ua(e),
|
|
2911
2915
|
target: "creatingAttestations",
|
|
2912
|
-
actions:
|
|
2916
|
+
actions: I({
|
|
2913
2917
|
completionPercentage: 100,
|
|
2914
2918
|
signedDataItems: () => void 0,
|
|
2915
2919
|
arweaveUploadData: () => void 0
|
|
@@ -2934,7 +2938,7 @@ var za = Ut({
|
|
|
2934
2938
|
}),
|
|
2935
2939
|
onDone: {
|
|
2936
2940
|
target: "uploadingViaBundlerPhase2",
|
|
2937
|
-
actions:
|
|
2941
|
+
actions: I({
|
|
2938
2942
|
arweaveTransactions: ({ event: e }) => e.output.arweaveTransactions,
|
|
2939
2943
|
publishUploads: ({ event: e }) => e.output.publishUploads,
|
|
2940
2944
|
signedDataItems: ({ event: e }) => e.output.signedDataItems,
|
|
@@ -2950,17 +2954,17 @@ var za = Ut({
|
|
|
2950
2954
|
uploadingViaBundlerPhase2: {
|
|
2951
2955
|
on: {
|
|
2952
2956
|
uploadComplete: [{
|
|
2953
|
-
guard: ({ context: e }) =>
|
|
2957
|
+
guard: ({ context: e }) => Ha(e),
|
|
2954
2958
|
target: "creatingAttestationsDirectToEas",
|
|
2955
|
-
actions:
|
|
2959
|
+
actions: I({
|
|
2956
2960
|
completionPercentage: 100,
|
|
2957
2961
|
signedDataItems: () => void 0,
|
|
2958
2962
|
arweaveUploadData: () => void 0
|
|
2959
2963
|
})
|
|
2960
2964
|
}, {
|
|
2961
|
-
guard: ({ context: e }) =>
|
|
2965
|
+
guard: ({ context: e }) => Ua(e),
|
|
2962
2966
|
target: "creatingAttestations",
|
|
2963
|
-
actions:
|
|
2967
|
+
actions: I({
|
|
2964
2968
|
completionPercentage: 100,
|
|
2965
2969
|
signedDataItems: () => void 0,
|
|
2966
2970
|
arweaveUploadData: () => void 0,
|
|
@@ -2980,29 +2984,29 @@ var za = Ut({
|
|
|
2980
2984
|
},
|
|
2981
2985
|
uploadingData: {
|
|
2982
2986
|
on: {
|
|
2983
|
-
updatePercentage: { actions:
|
|
2987
|
+
updatePercentage: { actions: I({
|
|
2984
2988
|
completionPercentage: ({ event: e }) => e.completionPercentage,
|
|
2985
2989
|
uploaderState: ({ event: e }) => e.uploaderState,
|
|
2986
2990
|
currentTransactionIndex: ({ event: e }) => e.currentTransactionIndex
|
|
2987
2991
|
}) },
|
|
2988
2992
|
uploadComplete: [
|
|
2989
2993
|
{
|
|
2990
|
-
guard: ({ context: e }) =>
|
|
2994
|
+
guard: ({ context: e }) => Ha(e),
|
|
2991
2995
|
target: "creatingAttestationsDirectToEas",
|
|
2992
|
-
actions:
|
|
2996
|
+
actions: I({ completionPercentage: 100 })
|
|
2993
2997
|
},
|
|
2994
2998
|
{
|
|
2995
2999
|
guard: (e) => (e.context?.htmlEmbeddedDeferredHtmlSeedLocalIds?.length ?? 0) > 0,
|
|
2996
3000
|
target: "rewritingHtmlEmbedded",
|
|
2997
|
-
actions:
|
|
3001
|
+
actions: I({
|
|
2998
3002
|
htmlEmbeddedPhase1PublishUploads: ({ context: e }) => e.publishUploads ?? [],
|
|
2999
3003
|
htmlEmbeddedPhase1ArweaveTransactions: ({ context: e }) => e.arweaveTransactions ?? []
|
|
3000
3004
|
})
|
|
3001
3005
|
},
|
|
3002
3006
|
{
|
|
3003
|
-
guard: ({ context: e }) =>
|
|
3007
|
+
guard: ({ context: e }) => Ua(e),
|
|
3004
3008
|
target: "creatingAttestations",
|
|
3005
|
-
actions:
|
|
3009
|
+
actions: I({ completionPercentage: 100 })
|
|
3006
3010
|
}
|
|
3007
3011
|
],
|
|
3008
3012
|
uploadError: {
|
|
@@ -3019,10 +3023,10 @@ var za = Ut({
|
|
|
3019
3023
|
src: "rewritingHtmlEmbedded",
|
|
3020
3024
|
input: ({ context: e }) => ({ context: e }),
|
|
3021
3025
|
onDone: [{
|
|
3022
|
-
guard: () => !
|
|
3026
|
+
guard: () => !D().useArweaveBundler,
|
|
3023
3027
|
target: "creatingArweaveTransactionsPhase2"
|
|
3024
3028
|
}, {
|
|
3025
|
-
guard: () =>
|
|
3029
|
+
guard: () => D().useArweaveBundler,
|
|
3026
3030
|
target: "creatingArweaveDataItemsPhase2"
|
|
3027
3031
|
}],
|
|
3028
3032
|
onError: {
|
|
@@ -3038,7 +3042,7 @@ var za = Ut({
|
|
|
3038
3042
|
}),
|
|
3039
3043
|
onDone: {
|
|
3040
3044
|
target: "uploadingDataPhase2",
|
|
3041
|
-
actions:
|
|
3045
|
+
actions: I({
|
|
3042
3046
|
arweaveTransactions: ({ event: e }) => e.output.arweaveTransactions,
|
|
3043
3047
|
publishUploads: ({ event: e }) => e.output.publishUploads,
|
|
3044
3048
|
uploaderState: () => void 0,
|
|
@@ -3052,19 +3056,19 @@ var za = Ut({
|
|
|
3052
3056
|
} },
|
|
3053
3057
|
uploadingDataPhase2: {
|
|
3054
3058
|
on: {
|
|
3055
|
-
updatePercentage: { actions:
|
|
3059
|
+
updatePercentage: { actions: I({
|
|
3056
3060
|
completionPercentage: ({ event: e }) => e.completionPercentage,
|
|
3057
3061
|
uploaderState: ({ event: e }) => e.uploaderState,
|
|
3058
3062
|
currentTransactionIndex: ({ event: e }) => e.currentTransactionIndex
|
|
3059
3063
|
}) },
|
|
3060
3064
|
uploadComplete: [{
|
|
3061
|
-
guard: ({ context: e }) =>
|
|
3065
|
+
guard: ({ context: e }) => Ha(e),
|
|
3062
3066
|
target: "creatingAttestationsDirectToEas",
|
|
3063
|
-
actions:
|
|
3067
|
+
actions: I({ completionPercentage: 100 })
|
|
3064
3068
|
}, {
|
|
3065
|
-
guard: ({ context: e }) =>
|
|
3069
|
+
guard: ({ context: e }) => Ua(e),
|
|
3066
3070
|
target: "creatingAttestations",
|
|
3067
|
-
actions:
|
|
3071
|
+
actions: I({
|
|
3068
3072
|
completionPercentage: 100,
|
|
3069
3073
|
publishUploads: ({ context: e }) => [...e.htmlEmbeddedPhase1PublishUploads ?? [], ...e.publishUploads ?? []],
|
|
3070
3074
|
arweaveTransactions: ({ context: e }) => [...e.htmlEmbeddedPhase1ArweaveTransactions ?? [], ...e.arweaveTransactions ?? []]
|
|
@@ -3087,8 +3091,8 @@ var za = Ut({
|
|
|
3087
3091
|
event: t
|
|
3088
3092
|
}),
|
|
3089
3093
|
onDone: {
|
|
3090
|
-
target:
|
|
3091
|
-
actions:
|
|
3094
|
+
target: Va,
|
|
3095
|
+
actions: I({
|
|
3092
3096
|
easPayload: ({ event: e }) => e.output?.easPayload,
|
|
3093
3097
|
publishedBatch: ({ event: e }) => e.output?.publishedBatch ?? null
|
|
3094
3098
|
})
|
|
@@ -3109,8 +3113,8 @@ var za = Ut({
|
|
|
3109
3113
|
event: t
|
|
3110
3114
|
}),
|
|
3111
3115
|
onDone: {
|
|
3112
|
-
target:
|
|
3113
|
-
actions:
|
|
3116
|
+
target: Va,
|
|
3117
|
+
actions: I({
|
|
3114
3118
|
easPayload: ({ event: e }) => e.output?.easPayload,
|
|
3115
3119
|
publishedBatch: ({ event: e }) => e.output?.publishedBatch ?? null
|
|
3116
3120
|
})
|
|
@@ -3130,7 +3134,7 @@ var za = Ut({
|
|
|
3130
3134
|
},
|
|
3131
3135
|
type: "final"
|
|
3132
3136
|
},
|
|
3133
|
-
[
|
|
3137
|
+
[Va]: {
|
|
3134
3138
|
entry: ({ context: e }) => {
|
|
3135
3139
|
let t = e.publishedBatch, n = e.onPublished;
|
|
3136
3140
|
if (!n || !t?.seedUid) return;
|
|
@@ -3151,42 +3155,38 @@ var za = Ut({
|
|
|
3151
3155
|
type: "final"
|
|
3152
3156
|
}
|
|
3153
3157
|
}
|
|
3154
|
-
}),
|
|
3158
|
+
}), Ga = I(({ context: e, event: t }) => {
|
|
3155
3159
|
let n = t, r = n.publishProcesses ?? /* @__PURE__ */ new Map(), i = n.subscriptions ?? /* @__PURE__ */ new Map();
|
|
3156
3160
|
return {
|
|
3157
3161
|
publishProcesses: new Map(r),
|
|
3158
3162
|
subscriptions: new Map(i)
|
|
3159
3163
|
};
|
|
3160
|
-
}),
|
|
3161
|
-
function
|
|
3162
|
-
|
|
3164
|
+
}), Ka = null;
|
|
3165
|
+
function qa(e) {
|
|
3166
|
+
Ka = e;
|
|
3163
3167
|
}
|
|
3164
|
-
function
|
|
3165
|
-
return
|
|
3168
|
+
function Ja() {
|
|
3169
|
+
return Ka;
|
|
3166
3170
|
}
|
|
3167
3171
|
//#endregion
|
|
3168
3172
|
//#region src/services/publishManager/actors/subscribe.ts
|
|
3169
|
-
var
|
|
3170
|
-
function
|
|
3173
|
+
var Ya = R("seedProtocol:services:PublishManager:actors:subscribe");
|
|
3174
|
+
function Xa(e) {
|
|
3171
3175
|
let t = e.value;
|
|
3172
3176
|
return typeof t == "string" ? t : t && typeof t == "object" ? Object.keys(t)[0] ?? "" : "";
|
|
3173
3177
|
}
|
|
3174
|
-
function
|
|
3178
|
+
function Za(e) {
|
|
3175
3179
|
return a.includes(e);
|
|
3176
3180
|
}
|
|
3177
|
-
var
|
|
3178
|
-
let i =
|
|
3181
|
+
var Qa = Ht(({ receive: e, input: { publishProcess: n, seedLocalId: r } }) => {
|
|
3182
|
+
let i = Ja(), a = null, o = () => {
|
|
3179
3183
|
a != null && (clearInterval(a), a = null);
|
|
3180
3184
|
}, s = (e) => {
|
|
3181
|
-
let s =
|
|
3182
|
-
|
|
3185
|
+
let s = Xa(e);
|
|
3186
|
+
Za(s) && a == null && i ? a = setInterval(() => {
|
|
3183
3187
|
try {
|
|
3184
3188
|
let e = n.getSnapshot();
|
|
3185
|
-
if (e.status === "done") {
|
|
3186
|
-
o();
|
|
3187
|
-
return;
|
|
3188
|
-
}
|
|
3189
|
-
if (!Ka(Ga(e))) {
|
|
3189
|
+
if (e.status === "done" || !Za(Xa(e))) {
|
|
3190
3190
|
o();
|
|
3191
3191
|
return;
|
|
3192
3192
|
}
|
|
@@ -3194,53 +3194,49 @@ var qa = Ht(({ receive: e, input: { publishProcess: n, seedLocalId: r } }) => {
|
|
|
3194
3194
|
return;
|
|
3195
3195
|
}
|
|
3196
3196
|
i?.savePublish(r, n);
|
|
3197
|
-
}, t) :
|
|
3197
|
+
}, t) : Za(s) || o();
|
|
3198
3198
|
}, c = n.subscribe(async (e) => {
|
|
3199
|
-
|
|
3199
|
+
Ya("Publish state:", e.value), i && (e.status === "done" ? (o(), i.savePublish(r, n, { triggerPublishDone: !0 })) : (i.savePublish(r, n), s(e)));
|
|
3200
3200
|
});
|
|
3201
3201
|
e(({ type: e }) => {
|
|
3202
|
-
e === "UNSUBSCRIBE" && (
|
|
3202
|
+
e === "UNSUBSCRIBE" && (Ya("Received UNSUBSCRIBE event"), o(), c.unsubscribe(), i?.removeSubscription(r));
|
|
3203
3203
|
});
|
|
3204
|
-
}),
|
|
3205
|
-
function
|
|
3206
|
-
let t =
|
|
3207
|
-
return
|
|
3204
|
+
}), $a = /* @__PURE__ */ new Map(), eo = 1;
|
|
3205
|
+
function to(e) {
|
|
3206
|
+
let t = eo++;
|
|
3207
|
+
return $a.set(t, e), t;
|
|
3208
3208
|
}
|
|
3209
|
-
function
|
|
3209
|
+
function no(e, t) {
|
|
3210
3210
|
if (e == null) return;
|
|
3211
|
-
let n =
|
|
3212
|
-
n && (
|
|
3211
|
+
let n = $a.get(e);
|
|
3212
|
+
n && ($a.delete(e), n(t));
|
|
3213
3213
|
}
|
|
3214
3214
|
//#endregion
|
|
3215
3215
|
//#region src/services/publishManager/actions/createPublish.ts
|
|
3216
|
-
function
|
|
3216
|
+
function ro(e) {
|
|
3217
3217
|
if (e) {
|
|
3218
3218
|
if (i(e)) return e;
|
|
3219
3219
|
if (m(e)) {
|
|
3220
|
-
let t =
|
|
3220
|
+
let t = pe();
|
|
3221
3221
|
if (t && t.signer.address.toLowerCase() === e.address.toLowerCase()) return t;
|
|
3222
3222
|
throw Error("@seedprotocol/publish: createPublish requires a PublishWallet (signer + txSender). Use fromEthersWallet, fromEip1193Provider, or fromThirdwebAccount.");
|
|
3223
3223
|
}
|
|
3224
3224
|
throw Error("@seedprotocol/publish: createPublish account must be a PublishWallet. Thirdweb Account must be wrapped with fromThirdwebAccount from @seedprotocol/publish/thirdweb.");
|
|
3225
3225
|
}
|
|
3226
3226
|
}
|
|
3227
|
-
function
|
|
3227
|
+
function io(e) {
|
|
3228
3228
|
if (e) {
|
|
3229
|
-
if (e instanceof
|
|
3229
|
+
if (e instanceof F.Wallet) return e;
|
|
3230
3230
|
if (i(e)) return e.signer;
|
|
3231
3231
|
if (m(e)) return e;
|
|
3232
3232
|
}
|
|
3233
3233
|
}
|
|
3234
|
-
var
|
|
3234
|
+
var ao = Vt(({ event: e, enqueue: t }) => {
|
|
3235
3235
|
let { item: n, address: r, account: i, options: a, createToken: o } = e;
|
|
3236
|
-
|
|
3237
|
-
console.warn("[createPublish] No valid wallet address; skipping spawn."), Za(o, void 0);
|
|
3238
|
-
return;
|
|
3239
|
-
}
|
|
3240
|
-
t.assign(({ context: e, spawn: t }) => {
|
|
3236
|
+
r != null && typeof r == "string" && r.trim().length > 0 ? (t.assign(({ context: e, spawn: t }) => {
|
|
3241
3237
|
let { publishProcesses: s } = e;
|
|
3242
|
-
if (s && s.has(n.seedLocalId)) return console.warn(`Publish process with seedLocalId "${n.seedLocalId}" already exists.`),
|
|
3243
|
-
let c = typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `run_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`, l =
|
|
3238
|
+
if (s && s.has(n.seedLocalId)) return console.warn(`Publish process with seedLocalId "${n.seedLocalId}" already exists.`), no(o, void 0), e;
|
|
3239
|
+
let c = typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `run_${Date.now()}_${Math.random().toString(36).slice(2, 11)}`, l = D(), u = [...l.arweaveUploadTags ?? [], ...a?.arweaveUploadTags ?? []], d = ro(i) ?? pe() ?? void 0, f = t(Wa, { input: {
|
|
3244
3240
|
item: n,
|
|
3245
3241
|
address: r,
|
|
3246
3242
|
wallet: d,
|
|
@@ -3248,7 +3244,7 @@ var eo = Vt(({ event: e, enqueue: t }) => {
|
|
|
3248
3244
|
modelName: n.modelName,
|
|
3249
3245
|
schemaId: n.schemaUid,
|
|
3250
3246
|
signDataItems: a?.signDataItems,
|
|
3251
|
-
dataItemSigner:
|
|
3247
|
+
dataItemSigner: io(a?.dataItemSigner),
|
|
3252
3248
|
signArweaveTransactions: a?.signArweaveTransactions,
|
|
3253
3249
|
arweaveJwk: a?.arweaveJwk,
|
|
3254
3250
|
publishMode: a?.publishMode ?? "patch",
|
|
@@ -3259,7 +3255,7 @@ var eo = Vt(({ event: e, enqueue: t }) => {
|
|
|
3259
3255
|
} });
|
|
3260
3256
|
s.set(n.seedLocalId, f);
|
|
3261
3257
|
let p = new Map(e.settledPublishes);
|
|
3262
|
-
return p.delete(n.seedLocalId),
|
|
3258
|
+
return p.delete(n.seedLocalId), no(o, f), {
|
|
3263
3259
|
...e,
|
|
3264
3260
|
publishProcesses: s,
|
|
3265
3261
|
settledPublishes: p
|
|
@@ -3268,7 +3264,7 @@ var eo = Vt(({ event: e, enqueue: t }) => {
|
|
|
3268
3264
|
let { subscriptions: r, publishProcesses: i } = e, a = i.get(n.seedLocalId);
|
|
3269
3265
|
if (!a) return console.warn(`Publish process with seedLocalId "${n.seedLocalId}" does not exist.`), e;
|
|
3270
3266
|
if (r.has(n.seedLocalId)) return console.warn(`Subscription with seedLocalId "${n.seedLocalId}" already exists.`), e;
|
|
3271
|
-
let o = t(
|
|
3267
|
+
let o = t(Qa, { input: {
|
|
3272
3268
|
publishProcess: a,
|
|
3273
3269
|
seedLocalId: n.seedLocalId
|
|
3274
3270
|
} });
|
|
@@ -3276,14 +3272,14 @@ var eo = Vt(({ event: e, enqueue: t }) => {
|
|
|
3276
3272
|
...e,
|
|
3277
3273
|
subscriptions: new Map(r)
|
|
3278
3274
|
};
|
|
3279
|
-
});
|
|
3280
|
-
}),
|
|
3275
|
+
})) : (console.warn("[createPublish] No valid wallet address; skipping spawn."), no(o, void 0));
|
|
3276
|
+
}), oo = ({ context: e, event: t }) => {
|
|
3281
3277
|
let { seedLocalId: n, account: r } = t, a = e.publishProcesses.get(n);
|
|
3282
3278
|
if (!a) {
|
|
3283
3279
|
console.warn(`Publish process with seedLocalId "${n}" does not exist.`);
|
|
3284
3280
|
return;
|
|
3285
3281
|
}
|
|
3286
|
-
let o = r == null ?
|
|
3282
|
+
let o = r == null ? pe() ?? void 0 : i(r) ? r : void 0;
|
|
3287
3283
|
r != null && !o && console.warn("[retryAttestations] account must be a PublishWallet. Use fromThirdwebAccount / fromEip1193Provider / fromEthersWallet."), a.send({
|
|
3288
3284
|
type: "retry",
|
|
3289
3285
|
account: o,
|
|
@@ -3292,32 +3288,32 @@ var eo = Vt(({ event: e, enqueue: t }) => {
|
|
|
3292
3288
|
};
|
|
3293
3289
|
//#endregion
|
|
3294
3290
|
//#region src/services/publishManager/actions/stopScopedOrStandaloneChild.ts
|
|
3295
|
-
function
|
|
3291
|
+
function so(e, t, n) {
|
|
3296
3292
|
t._parent === e ? n.stopChild(t) : t.stop();
|
|
3297
3293
|
}
|
|
3298
3294
|
//#endregion
|
|
3299
3295
|
//#region src/services/publishManager/actors/savePublish.ts
|
|
3300
|
-
var
|
|
3301
|
-
function
|
|
3302
|
-
let n = (
|
|
3303
|
-
return
|
|
3296
|
+
var co = R("seedProtocol:services:PublishManager:actors:savePublish"), lo = /* @__PURE__ */ new Map();
|
|
3297
|
+
function uo(e, t) {
|
|
3298
|
+
let n = (lo.get(e) ?? Promise.resolve()).then(t);
|
|
3299
|
+
return lo.set(e, n.catch(() => {})), n;
|
|
3304
3300
|
}
|
|
3305
|
-
function
|
|
3301
|
+
function fo(e) {
|
|
3306
3302
|
return e === "completed" || e === "failed" || e === "interrupted";
|
|
3307
3303
|
}
|
|
3308
|
-
function
|
|
3304
|
+
function po(e) {
|
|
3309
3305
|
return e.status === "done" ? e.value === "success" ? "completed" : e.value === "failure" ? "failed" : "completed" : "in_progress";
|
|
3310
3306
|
}
|
|
3311
|
-
var
|
|
3312
|
-
function
|
|
3307
|
+
var mo = 500, ho = 2e3, go = 100;
|
|
3308
|
+
function _o(e) {
|
|
3313
3309
|
return JSON.stringify(e, (e, t) => typeof t == "bigint" ? t.toString() : t);
|
|
3314
3310
|
}
|
|
3315
|
-
function
|
|
3311
|
+
function vo(e) {
|
|
3316
3312
|
if (typeof e != "object" || !e) return;
|
|
3317
3313
|
let t = e, n = t.snapshot, r = (t.context ?? n?.context)?.publishRunId;
|
|
3318
3314
|
return typeof r == "string" && r.length > 0 ? r : void 0;
|
|
3319
3315
|
}
|
|
3320
|
-
function
|
|
3316
|
+
function yo(e) {
|
|
3321
3317
|
if (e instanceof Error) return e.message;
|
|
3322
3318
|
if (typeof e == "object") {
|
|
3323
3319
|
let t = e.message;
|
|
@@ -3325,21 +3321,21 @@ function mo(e) {
|
|
|
3325
3321
|
}
|
|
3326
3322
|
return String(e);
|
|
3327
3323
|
}
|
|
3328
|
-
function
|
|
3324
|
+
function bo(e) {
|
|
3329
3325
|
if (typeof e != "object" || !e) return;
|
|
3330
3326
|
let t = e.code;
|
|
3331
|
-
return typeof t == "string" && t.length > 0 ? t.slice(0,
|
|
3327
|
+
return typeof t == "string" && t.length > 0 ? t.slice(0, go) : void 0;
|
|
3332
3328
|
}
|
|
3333
|
-
function
|
|
3329
|
+
function xo(e, t) {
|
|
3334
3330
|
if (!e?.error || t !== "failed" && t !== "in_progress") return {};
|
|
3335
|
-
let n = e.error, r =
|
|
3336
|
-
if (n instanceof Error && n.stack) o = n.stack.slice(0,
|
|
3331
|
+
let n = e.error, r = yo(n)?.slice(0, mo), i = e.errorStep, a = bo(n), o;
|
|
3332
|
+
if (n instanceof Error && n.stack) o = n.stack.slice(0, ho);
|
|
3337
3333
|
else if (typeof n == "object" && n) try {
|
|
3338
|
-
o = JSON.stringify(n).slice(0,
|
|
3334
|
+
o = JSON.stringify(n).slice(0, ho);
|
|
3339
3335
|
} catch {
|
|
3340
|
-
o = String(n).slice(0,
|
|
3336
|
+
o = String(n).slice(0, ho);
|
|
3341
3337
|
}
|
|
3342
|
-
else n != null && (o = String(n).slice(0,
|
|
3338
|
+
else n != null && (o = String(n).slice(0, ho));
|
|
3343
3339
|
return {
|
|
3344
3340
|
...r === void 0 ? {} : { errorMessage: r },
|
|
3345
3341
|
errorStep: i,
|
|
@@ -3347,17 +3343,17 @@ function go(e, t) {
|
|
|
3347
3343
|
errorCode: a ?? null
|
|
3348
3344
|
};
|
|
3349
3345
|
}
|
|
3350
|
-
function
|
|
3351
|
-
return
|
|
3352
|
-
let t =
|
|
3346
|
+
function So(e) {
|
|
3347
|
+
return uo(e, async () => {
|
|
3348
|
+
let t = ke.getAppDb();
|
|
3353
3349
|
if (!t) {
|
|
3354
|
-
|
|
3350
|
+
co("markInProgressPublishInterrupted: DB not ready, skipping");
|
|
3355
3351
|
return;
|
|
3356
3352
|
}
|
|
3357
|
-
let n = await t.select().from(
|
|
3353
|
+
let n = await t.select().from(P).where(Wt(z(P.seedLocalId, e), z(P.status, "in_progress"))).orderBy(Gt(P.updatedAt)).limit(1);
|
|
3358
3354
|
if (n.length === 0) return;
|
|
3359
3355
|
let r = Date.now();
|
|
3360
|
-
await t.update(
|
|
3356
|
+
await t.update(P).set({
|
|
3361
3357
|
status: "interrupted",
|
|
3362
3358
|
completedAt: r,
|
|
3363
3359
|
updatedAt: r,
|
|
@@ -3365,45 +3361,45 @@ function _o(e) {
|
|
|
3365
3361
|
errorStep: null,
|
|
3366
3362
|
errorDetails: null,
|
|
3367
3363
|
errorCode: null
|
|
3368
|
-
}).where(
|
|
3364
|
+
}).where(z(P.id, n[0].id));
|
|
3369
3365
|
});
|
|
3370
3366
|
}
|
|
3371
|
-
var
|
|
3372
|
-
|
|
3367
|
+
var Co = Ht(({ sendBack: e, input: { persistedSnapshot: t, seedLocalId: n, triggerPublishDone: r } }) => {
|
|
3368
|
+
co("savePublish seedLocalId", n);
|
|
3373
3369
|
let i = t;
|
|
3374
|
-
|
|
3375
|
-
let a =
|
|
3370
|
+
uo(n, async () => {
|
|
3371
|
+
let a = ke.getAppDb();
|
|
3376
3372
|
if (!a) {
|
|
3377
|
-
|
|
3373
|
+
co("savePublish: DB not ready, skipping"), e({
|
|
3378
3374
|
type: "SAVE_PUBLISH_DONE",
|
|
3379
3375
|
seedLocalId: n,
|
|
3380
3376
|
triggerPublishDone: r
|
|
3381
3377
|
});
|
|
3382
3378
|
return;
|
|
3383
3379
|
}
|
|
3384
|
-
let o = await a.select().from(
|
|
3380
|
+
let o = await a.select().from(P).where(Wt(z(P.seedLocalId, n), z(P.status, "in_progress"))).orderBy(Gt(P.updatedAt)).limit(1), s = typeof t == "string" ? t : _o(t), c = po(i), l = Date.now(), u = xo(i.context, c);
|
|
3385
3381
|
if (o.length > 0) {
|
|
3386
3382
|
let e = o[0];
|
|
3387
|
-
await a.update(
|
|
3383
|
+
await a.update(P).set({
|
|
3388
3384
|
persistedSnapshot: s,
|
|
3389
3385
|
status: c,
|
|
3390
3386
|
updatedAt: l,
|
|
3391
3387
|
...i.status === "done" && c !== "in_progress" ? { completedAt: l } : {},
|
|
3392
3388
|
...u
|
|
3393
|
-
}).where(
|
|
3389
|
+
}).where(z(P.id, e.id));
|
|
3394
3390
|
} else {
|
|
3395
|
-
let e =
|
|
3391
|
+
let e = vo(i);
|
|
3396
3392
|
if (e != null && c === "in_progress" && i.status !== "done") {
|
|
3397
|
-
let t = (await a.select().from(
|
|
3398
|
-
if (t &&
|
|
3399
|
-
if (
|
|
3400
|
-
|
|
3393
|
+
let t = (await a.select().from(P).where(z(P.seedLocalId, n)).orderBy(Gt(P.startedAt)).limit(1))[0];
|
|
3394
|
+
if (t && fo(t.status)) try {
|
|
3395
|
+
if (vo(JSON.parse(t.persistedSnapshot)) === e) {
|
|
3396
|
+
co("savePublish: skip stale insert — same publishRunId as latest terminal row", n, e);
|
|
3401
3397
|
return;
|
|
3402
3398
|
}
|
|
3403
3399
|
} catch {}
|
|
3404
3400
|
}
|
|
3405
3401
|
let t = i.context?.item, r = i.context?.modelName ?? t?.modelName ?? "", o = i.context?.schemaId ?? t?.schemaId;
|
|
3406
|
-
await a.insert(
|
|
3402
|
+
await a.insert(P).values({
|
|
3407
3403
|
seedLocalId: n,
|
|
3408
3404
|
modelName: r,
|
|
3409
3405
|
schemaId: o ?? null,
|
|
@@ -3422,62 +3418,59 @@ var vo = Ht(({ sendBack: e, input: { persistedSnapshot: t, seedLocalId: n, trigg
|
|
|
3422
3418
|
triggerPublishDone: r
|
|
3423
3419
|
});
|
|
3424
3420
|
}).catch((t) => {
|
|
3425
|
-
|
|
3421
|
+
co("savePublish error", t), e({
|
|
3426
3422
|
type: "SAVE_PUBLISH_DONE",
|
|
3427
3423
|
seedLocalId: n,
|
|
3428
3424
|
triggerPublishDone: r
|
|
3429
3425
|
});
|
|
3430
3426
|
});
|
|
3431
|
-
}),
|
|
3432
|
-
function
|
|
3427
|
+
}), wo = R("seedProtocol:PublishManager:publishLocks"), To = () => typeof navigator < "u" ? navigator.locks : void 0, Eo = /* @__PURE__ */ new Map();
|
|
3428
|
+
function Do(e) {
|
|
3433
3429
|
return `seed:publish:${e}`;
|
|
3434
3430
|
}
|
|
3435
|
-
async function
|
|
3436
|
-
if (
|
|
3437
|
-
let t =
|
|
3431
|
+
async function Oo(e) {
|
|
3432
|
+
if (Eo.has(e)) return !0;
|
|
3433
|
+
let t = To();
|
|
3438
3434
|
return !t || new Promise((n, r) => {
|
|
3439
|
-
t.request(
|
|
3435
|
+
t.request(Do(e), {
|
|
3440
3436
|
mode: "exclusive",
|
|
3441
3437
|
ifAvailable: !0
|
|
3442
3438
|
}, (t) => {
|
|
3443
|
-
if (!t)
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
return new Promise((t) => {
|
|
3448
|
-
xo.set(e, () => {
|
|
3449
|
-
xo.delete(e), t();
|
|
3439
|
+
if (!t) n(!1);
|
|
3440
|
+
else return new Promise((t) => {
|
|
3441
|
+
Eo.set(e, () => {
|
|
3442
|
+
Eo.delete(e), t();
|
|
3450
3443
|
}), n(!0);
|
|
3451
3444
|
});
|
|
3452
3445
|
}).catch((t) => {
|
|
3453
|
-
|
|
3446
|
+
wo(`publish lock request for ${e} failed`, t), r(t);
|
|
3454
3447
|
});
|
|
3455
3448
|
});
|
|
3456
3449
|
}
|
|
3457
|
-
function
|
|
3458
|
-
|
|
3450
|
+
function ko(e) {
|
|
3451
|
+
Eo.get(e)?.();
|
|
3459
3452
|
}
|
|
3460
|
-
function
|
|
3461
|
-
for (let e of [...
|
|
3453
|
+
function Ao() {
|
|
3454
|
+
for (let e of [...Eo.values()]) e();
|
|
3462
3455
|
}
|
|
3463
|
-
function
|
|
3464
|
-
return
|
|
3456
|
+
function jo(e) {
|
|
3457
|
+
return Eo.has(e);
|
|
3465
3458
|
}
|
|
3466
3459
|
//#endregion
|
|
3467
3460
|
//#region src/services/publishManager/actions/stopPublish.ts
|
|
3468
|
-
var
|
|
3461
|
+
var Mo = Vt(({ context: e, event: t, enqueue: n, self: r }) => {
|
|
3469
3462
|
let { publishProcesses: i, subscriptions: a } = e, { seedLocalId: o } = t;
|
|
3470
|
-
|
|
3463
|
+
So(o).catch((e) => {
|
|
3471
3464
|
console.warn(`[stopPublish] Failed to mark publish_processes row interrupted for "${o}":`, e);
|
|
3472
|
-
}),
|
|
3465
|
+
}), ko(o);
|
|
3473
3466
|
let s = i.get(o);
|
|
3474
3467
|
if (!s) {
|
|
3475
3468
|
console.warn(`Publish process with seedLocalId "${o}" does not exist.`);
|
|
3476
3469
|
return;
|
|
3477
3470
|
}
|
|
3478
|
-
|
|
3471
|
+
so(r, s, n);
|
|
3479
3472
|
let c = a.get(o);
|
|
3480
|
-
c &&
|
|
3473
|
+
c && so(r, c, n);
|
|
3481
3474
|
let l = new Map(i);
|
|
3482
3475
|
l.delete(o);
|
|
3483
3476
|
let u = new Map(a);
|
|
@@ -3485,16 +3478,16 @@ var Do = Vt(({ context: e, event: t, enqueue: n, self: r }) => {
|
|
|
3485
3478
|
publishProcesses: l,
|
|
3486
3479
|
subscriptions: u
|
|
3487
3480
|
});
|
|
3488
|
-
}),
|
|
3489
|
-
|
|
3490
|
-
|
|
3481
|
+
}), No = R("seedProtocol:PublishManager:index"), Po = Vt(({ context: e, enqueue: t, self: n }) => {
|
|
3482
|
+
No("Stopping all actors..."), e.publishProcesses.forEach((e) => {
|
|
3483
|
+
so(n, e, t);
|
|
3491
3484
|
}), e.subscriptions.forEach((e) => {
|
|
3492
|
-
|
|
3493
|
-
}),
|
|
3485
|
+
so(n, e, t);
|
|
3486
|
+
}), Ao(), t.assign({
|
|
3494
3487
|
publishProcesses: /* @__PURE__ */ new Map(),
|
|
3495
3488
|
subscriptions: /* @__PURE__ */ new Map()
|
|
3496
3489
|
});
|
|
3497
|
-
}),
|
|
3490
|
+
}), Fo = Vt(({ context: e, event: t, enqueue: n }) => {
|
|
3498
3491
|
let { seedLocalId: r } = t, i = e.publishProcesses.get(r);
|
|
3499
3492
|
if (!i) {
|
|
3500
3493
|
console.warn(`Publish process with seedLocalId "${r}" does not exist.`);
|
|
@@ -3510,35 +3503,35 @@ var Do = Vt(({ context: e, event: t, enqueue: n, self: r }) => {
|
|
|
3510
3503
|
publishProcesses: o,
|
|
3511
3504
|
subscriptions: s
|
|
3512
3505
|
});
|
|
3513
|
-
}),
|
|
3506
|
+
}), Io = I(({ context: e, event: t }) => {
|
|
3514
3507
|
let { subscriptions: n } = e, { seedLocalId: r, newSubscription: i } = t;
|
|
3515
3508
|
return i && n.set(r, i), { subscriptions: new Map(n) };
|
|
3516
|
-
}),
|
|
3517
|
-
function
|
|
3509
|
+
}), Lo = ["signedDataItems", "arweaveUploadData"];
|
|
3510
|
+
function Ro(e) {
|
|
3518
3511
|
if (typeof e != "object" || !e) return e;
|
|
3519
3512
|
let t = { ...e };
|
|
3520
|
-
for (let e of
|
|
3513
|
+
for (let e of Lo) delete t[e];
|
|
3521
3514
|
return t;
|
|
3522
3515
|
}
|
|
3523
|
-
function
|
|
3516
|
+
function zo(e) {
|
|
3524
3517
|
if (typeof e != "object" || !e) return e;
|
|
3525
3518
|
let t = e, n = { ...t };
|
|
3526
|
-
t.context != null && typeof t.context == "object" && (n.context =
|
|
3519
|
+
t.context != null && typeof t.context == "object" && (n.context = Ro(t.context));
|
|
3527
3520
|
let r = t.snapshot;
|
|
3528
3521
|
if (typeof r == "object" && r) {
|
|
3529
3522
|
let e = r, t = { ...e };
|
|
3530
|
-
e.context != null && typeof e.context == "object" && (t.context =
|
|
3523
|
+
e.context != null && typeof e.context == "object" && (t.context = Ro(e.context)), n.snapshot = t;
|
|
3531
3524
|
}
|
|
3532
3525
|
return n;
|
|
3533
3526
|
}
|
|
3534
|
-
function
|
|
3527
|
+
function Bo(e) {
|
|
3535
3528
|
try {
|
|
3536
|
-
return
|
|
3529
|
+
return zo(e.getPersistedSnapshot?.() ?? e.getSnapshot());
|
|
3537
3530
|
} catch {
|
|
3538
3531
|
let t = e.getSnapshot(), n = t.context;
|
|
3539
|
-
if (!n?.item) return
|
|
3532
|
+
if (!n?.item) return zo(t);
|
|
3540
3533
|
let r = n.item;
|
|
3541
|
-
return
|
|
3534
|
+
return zo({
|
|
3542
3535
|
...t,
|
|
3543
3536
|
context: {
|
|
3544
3537
|
...n,
|
|
@@ -3551,13 +3544,13 @@ function Fo(e) {
|
|
|
3551
3544
|
});
|
|
3552
3545
|
}
|
|
3553
3546
|
}
|
|
3554
|
-
var
|
|
3547
|
+
var Vo = I(({ context: e, event: t, spawn: n }) => {
|
|
3555
3548
|
let { publishProcesses: r } = e, { seedLocalId: i, publishProcess: a, triggerPublishDone: o } = t;
|
|
3556
3549
|
if (!a) return e;
|
|
3557
3550
|
let s = new Map(r);
|
|
3558
3551
|
s.set(i, a);
|
|
3559
|
-
let c =
|
|
3560
|
-
return n(
|
|
3552
|
+
let c = Bo(a);
|
|
3553
|
+
return n(Co, {
|
|
3561
3554
|
id: `savePublish_${i}_${Date.now()}`,
|
|
3562
3555
|
input: {
|
|
3563
3556
|
persistedSnapshot: c,
|
|
@@ -3565,9 +3558,9 @@ var Io = F(({ context: e, event: t, spawn: n }) => {
|
|
|
3565
3558
|
triggerPublishDone: o
|
|
3566
3559
|
}
|
|
3567
3560
|
}), { publishProcesses: s };
|
|
3568
|
-
}),
|
|
3561
|
+
}), Ho = I(({ context: e, event: t }) => {
|
|
3569
3562
|
let { publishProcesses: n, subscriptions: r, settledPublishes: i } = e, a = t.seedLocalId;
|
|
3570
|
-
|
|
3563
|
+
ko(a);
|
|
3571
3564
|
let o = r.get(a);
|
|
3572
3565
|
o && o.send({ type: "UNSUBSCRIBE" });
|
|
3573
3566
|
let s = n.get(a), c = new Map(n);
|
|
@@ -3580,32 +3573,32 @@ var Io = F(({ context: e, event: t, spawn: n }) => {
|
|
|
3580
3573
|
subscriptions: l,
|
|
3581
3574
|
settledPublishes: u
|
|
3582
3575
|
};
|
|
3583
|
-
}),
|
|
3576
|
+
}), Uo = I(({ context: e, event: t }) => {
|
|
3584
3577
|
let { subscriptions: n } = e, r = t.seedLocalId, i = new Map(n);
|
|
3585
3578
|
return i.delete(r), { subscriptions: i };
|
|
3586
|
-
}),
|
|
3587
|
-
function
|
|
3579
|
+
}), Wo = 6e4, Go = 2e3;
|
|
3580
|
+
function Ko(e, t) {
|
|
3588
3581
|
let n = typeof process < "u" ? process.env[e] : void 0;
|
|
3589
3582
|
if (n == null || n === "") return t;
|
|
3590
3583
|
let r = Number(n);
|
|
3591
3584
|
return Number.isFinite(r) && r >= 0 ? r : t;
|
|
3592
3585
|
}
|
|
3593
|
-
async function
|
|
3586
|
+
async function qo(e, t) {
|
|
3594
3587
|
let n = Date.now() + e;
|
|
3595
3588
|
for (; Date.now() < n;) {
|
|
3596
3589
|
try {
|
|
3597
|
-
if (
|
|
3590
|
+
if (ke.isAppDbReady() && ke.getAppDb()) return !0;
|
|
3598
3591
|
} catch {}
|
|
3599
3592
|
await new Promise((e) => setTimeout(e, t));
|
|
3600
3593
|
}
|
|
3601
3594
|
return !1;
|
|
3602
3595
|
}
|
|
3603
|
-
function
|
|
3596
|
+
function Jo(e) {
|
|
3604
3597
|
let t = e.value;
|
|
3605
3598
|
return typeof t == "string" ? t : t && typeof t == "object" ? Object.keys(t)[0] ?? "" : "";
|
|
3606
3599
|
}
|
|
3607
|
-
function
|
|
3608
|
-
let t =
|
|
3600
|
+
function Yo(e) {
|
|
3601
|
+
let t = Jo(e);
|
|
3609
3602
|
if (t === "pollingForConfirmation" && (!e.context?.reimbursementTransactionId || !e.context?.requestResponse)) return !1;
|
|
3610
3603
|
if (t === "uploadingData") {
|
|
3611
3604
|
let t = e.context?.arweaveTransactions, n = e.context?.publishUploads;
|
|
@@ -3613,40 +3606,36 @@ function Wo(e) {
|
|
|
3613
3606
|
}
|
|
3614
3607
|
return !0;
|
|
3615
3608
|
}
|
|
3616
|
-
function
|
|
3609
|
+
function Xo(e) {
|
|
3617
3610
|
return typeof e == "object" && !!e && "xstate$$type" in e && e.xstate$$type === 1 && typeof e.id == "string";
|
|
3618
3611
|
}
|
|
3619
|
-
function
|
|
3612
|
+
function Zo(e, t, n) {
|
|
3620
3613
|
e.context = e.context ?? {};
|
|
3621
3614
|
let r = e.context.item;
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
};
|
|
3628
|
-
return;
|
|
3629
|
-
}
|
|
3630
|
-
e.context.item = {
|
|
3615
|
+
Xo(r) ? e.context.item = {
|
|
3616
|
+
seedLocalId: t,
|
|
3617
|
+
modelName: e.context.modelName ?? n.modelName ?? "",
|
|
3618
|
+
schemaId: e.context.schemaId ?? n.schemaId ?? void 0
|
|
3619
|
+
} : e.context.item = {
|
|
3631
3620
|
...typeof r == "object" && r && !Array.isArray(r) ? r : {},
|
|
3632
3621
|
seedLocalId: t,
|
|
3633
3622
|
modelName: r?.modelName ?? e.context.modelName ?? n.modelName ?? "",
|
|
3634
3623
|
schemaId: r?.schemaId ?? e.context.schemaId ?? n.schemaId ?? void 0
|
|
3635
3624
|
};
|
|
3636
3625
|
}
|
|
3637
|
-
var
|
|
3626
|
+
var Qo = Ht(({ sendBack: e, input: { context: t } }) => {
|
|
3638
3627
|
let n = async () => {
|
|
3639
3628
|
let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
|
|
3640
|
-
if (!await
|
|
3629
|
+
if (!await qo(Ko("SEED_PUBLISH_RESTORE_WAIT_MS", Wo), Ko("SEED_PUBLISH_RESTORE_POLL_MS", Go))) return {
|
|
3641
3630
|
newPublishProcesses: e,
|
|
3642
3631
|
newSubscriptions: t
|
|
3643
3632
|
};
|
|
3644
|
-
let n =
|
|
3633
|
+
let n = ke.getAppDb();
|
|
3645
3634
|
if (!n) return {
|
|
3646
3635
|
newPublishProcesses: e,
|
|
3647
3636
|
newSubscriptions: t
|
|
3648
3637
|
};
|
|
3649
|
-
let r = await n.select().from(
|
|
3638
|
+
let r = await n.select().from(P).where(z(P.status, "in_progress")), i = /* @__PURE__ */ new Map(), a = [...r].sort((e, t) => (t.updatedAt ?? t.createdAt ?? 0) - (e.updatedAt ?? e.createdAt ?? 0));
|
|
3650
3639
|
for (let e of a) i.has(e.seedLocalId) || i.set(e.seedLocalId, e);
|
|
3651
3640
|
let o = Array.from(i.values());
|
|
3652
3641
|
for (let n of o) {
|
|
@@ -3658,12 +3647,12 @@ var qo = Ht(({ sendBack: e, input: { context: t } }) => {
|
|
|
3658
3647
|
}
|
|
3659
3648
|
if (r.status === "done") continue;
|
|
3660
3649
|
let i = r.context?.item?.seedLocalId ?? n.seedLocalId;
|
|
3661
|
-
if (!i || !
|
|
3662
|
-
|
|
3663
|
-
let a = Bt(
|
|
3650
|
+
if (!i || !Yo(r) || !await Oo(i)) continue;
|
|
3651
|
+
Zo(r, i, n);
|
|
3652
|
+
let a = Bt(Wa, {
|
|
3664
3653
|
snapshot: r,
|
|
3665
3654
|
input: void 0
|
|
3666
|
-
}), o = Bt(
|
|
3655
|
+
}), o = Bt(Qa, { input: {
|
|
3667
3656
|
publishProcess: a,
|
|
3668
3657
|
seedLocalId: i
|
|
3669
3658
|
} });
|
|
@@ -3692,32 +3681,32 @@ var qo = Ht(({ sendBack: e, input: { context: t } }) => {
|
|
|
3692
3681
|
subscriptions: n
|
|
3693
3682
|
});
|
|
3694
3683
|
});
|
|
3695
|
-
}),
|
|
3684
|
+
}), $o = I(({ context: e, event: t }) => ({ pendingCreates: [...e.pendingCreates ?? [], t] })), es = Vt(({ context: e, enqueue: t }) => {
|
|
3696
3685
|
let n = e.pendingCreates ?? [];
|
|
3697
3686
|
if (n.length !== 0) {
|
|
3698
3687
|
t.assign({ pendingCreates: [] });
|
|
3699
3688
|
for (let e of n) t.raise(e);
|
|
3700
3689
|
}
|
|
3701
|
-
}),
|
|
3690
|
+
}), ts = R("seedProtocol:PublishManager:index"), ns = Ut({
|
|
3702
3691
|
types: {
|
|
3703
3692
|
context: {},
|
|
3704
3693
|
input: {},
|
|
3705
3694
|
events: {}
|
|
3706
3695
|
},
|
|
3707
|
-
actors: { restoreFromDb:
|
|
3696
|
+
actors: { restoreFromDb: Qo },
|
|
3708
3697
|
actions: {
|
|
3709
|
-
assignRestoreFromDb:
|
|
3710
|
-
createPublish:
|
|
3711
|
-
queueCreatePublish:
|
|
3712
|
-
drainPendingCreates:
|
|
3713
|
-
addSubscription:
|
|
3714
|
-
requestSavePublish:
|
|
3715
|
-
publishDone:
|
|
3716
|
-
removeSubscription:
|
|
3717
|
-
retryAttestations:
|
|
3718
|
-
stopPublish:
|
|
3719
|
-
stopAll:
|
|
3720
|
-
query:
|
|
3698
|
+
assignRestoreFromDb: Ga,
|
|
3699
|
+
createPublish: ao,
|
|
3700
|
+
queueCreatePublish: $o,
|
|
3701
|
+
drainPendingCreates: es,
|
|
3702
|
+
addSubscription: Io,
|
|
3703
|
+
requestSavePublish: Vo,
|
|
3704
|
+
publishDone: Ho,
|
|
3705
|
+
removeSubscription: Uo,
|
|
3706
|
+
retryAttestations: oo,
|
|
3707
|
+
stopPublish: Mo,
|
|
3708
|
+
stopAll: Po,
|
|
3709
|
+
query: Fo
|
|
3721
3710
|
}
|
|
3722
3711
|
}).createMachine({
|
|
3723
3712
|
id: "publishManager",
|
|
@@ -3761,24 +3750,24 @@ var qo = Ht(({ sendBack: e, input: { context: t } }) => {
|
|
|
3761
3750
|
}
|
|
3762
3751
|
}
|
|
3763
3752
|
}
|
|
3764
|
-
}), $ = Bt(
|
|
3753
|
+
}), $ = Bt(ns, { input: {
|
|
3765
3754
|
publishProcesses: /* @__PURE__ */ new Map(),
|
|
3766
3755
|
subscriptions: /* @__PURE__ */ new Map(),
|
|
3767
3756
|
pendingCreates: [],
|
|
3768
3757
|
settledPublishes: /* @__PURE__ */ new Map()
|
|
3769
|
-
} }),
|
|
3770
|
-
function
|
|
3771
|
-
if (!
|
|
3758
|
+
} }), rs = !1;
|
|
3759
|
+
function is() {
|
|
3760
|
+
if (!rs) {
|
|
3772
3761
|
try {
|
|
3773
3762
|
$.start();
|
|
3774
3763
|
} catch (e) {
|
|
3775
3764
|
let t = e instanceof Error ? e.message : String(e);
|
|
3776
3765
|
if (!/already started/i.test(t)) throw e;
|
|
3777
3766
|
}
|
|
3778
|
-
|
|
3767
|
+
rs = !0;
|
|
3779
3768
|
}
|
|
3780
3769
|
}
|
|
3781
|
-
|
|
3770
|
+
qa({
|
|
3782
3771
|
savePublish: (e, t, n) => {
|
|
3783
3772
|
$.send({
|
|
3784
3773
|
type: "REQUEST_SAVE_PUBLISH",
|
|
@@ -3800,30 +3789,30 @@ Ha({
|
|
|
3800
3789
|
});
|
|
3801
3790
|
}
|
|
3802
3791
|
});
|
|
3803
|
-
var
|
|
3804
|
-
|
|
3792
|
+
var as = $.subscribe((e) => {
|
|
3793
|
+
ts("PublishManager snapshot:", e);
|
|
3805
3794
|
});
|
|
3806
|
-
typeof document < "u" && (
|
|
3807
|
-
|
|
3795
|
+
typeof document < "u" && (is(), window.addEventListener("load", () => {
|
|
3796
|
+
ts("PublishManager started");
|
|
3808
3797
|
}), window.addEventListener("beforeunload", () => {
|
|
3809
|
-
|
|
3798
|
+
as.unsubscribe(), $.stop();
|
|
3810
3799
|
}));
|
|
3811
|
-
var
|
|
3800
|
+
var os = {
|
|
3812
3801
|
getService: () => $,
|
|
3813
|
-
ready: () => (
|
|
3802
|
+
ready: () => (is(), $.getSnapshot().value === "active" ? Promise.resolve() : new Promise((e) => {
|
|
3814
3803
|
let t = $.subscribe((n) => {
|
|
3815
3804
|
n.value === "active" && (t.unsubscribe(), e());
|
|
3816
3805
|
});
|
|
3817
3806
|
$.getSnapshot().value === "active" && (t.unsubscribe(), e());
|
|
3818
3807
|
})),
|
|
3819
3808
|
createPublish: async (e, t, n, r) => {
|
|
3820
|
-
let { seedLocalId: i } = e, a =
|
|
3821
|
-
if (!await
|
|
3809
|
+
let { seedLocalId: i } = e, a = jo(i);
|
|
3810
|
+
if (!await Oo(i)) {
|
|
3822
3811
|
console.warn(`[createPublish] "${i}" is already publishing in another tab; skipping.`);
|
|
3823
3812
|
return;
|
|
3824
3813
|
}
|
|
3825
3814
|
let o = await new Promise((i) => {
|
|
3826
|
-
let a =
|
|
3815
|
+
let a = to(i);
|
|
3827
3816
|
$.send({
|
|
3828
3817
|
type: "CREATE_PUBLISH",
|
|
3829
3818
|
item: e,
|
|
@@ -3833,7 +3822,7 @@ var ts = {
|
|
|
3833
3822
|
createToken: a
|
|
3834
3823
|
});
|
|
3835
3824
|
});
|
|
3836
|
-
return !o && !a &&
|
|
3825
|
+
return !o && !a && ko(i), o;
|
|
3837
3826
|
},
|
|
3838
3827
|
retryAttestations: (e, t) => $.send({
|
|
3839
3828
|
type: "RETRY_ATTESTATIONS",
|
|
@@ -3870,26 +3859,26 @@ var ts = {
|
|
|
3870
3859
|
};
|
|
3871
3860
|
//#endregion
|
|
3872
3861
|
//#region src/helpers/approvedTargetsForAutomationPublish.ts
|
|
3873
|
-
function
|
|
3874
|
-
let e =
|
|
3862
|
+
function ss() {
|
|
3863
|
+
let e = D().modularAccountModuleContract?.trim();
|
|
3875
3864
|
if (!e || !/^0x[0-9a-fA-F]{40}$/.test(e)) throw Error("@seedprotocol/publish: session keys require PublishConfig.modularAccountModuleContract (their only approved target is the Seed executor module).");
|
|
3876
3865
|
return [e.toLowerCase()];
|
|
3877
3866
|
}
|
|
3878
3867
|
//#endregion
|
|
3879
3868
|
//#region src/helpers/automationSessionKeyPermissions.ts
|
|
3880
|
-
var
|
|
3881
|
-
function
|
|
3869
|
+
var cs = "publish,revoke";
|
|
3870
|
+
function ls(e) {
|
|
3882
3871
|
let t = {
|
|
3883
|
-
approvedTargets:
|
|
3872
|
+
approvedTargets: ss(),
|
|
3884
3873
|
nativeTokenLimitPerTransaction: 0
|
|
3885
3874
|
};
|
|
3886
3875
|
return typeof e?.expiresAt == "number" && e.expiresAt > 0 && (t.expiresAt = Math.trunc(e.expiresAt)), t;
|
|
3887
3876
|
}
|
|
3888
|
-
function
|
|
3877
|
+
function us(e, t = cs) {
|
|
3889
3878
|
let n = `${[...e.approvedTargets].map((e) => e.toLowerCase()).sort().join(",")}|${e.nativeTokenLimitPerTransaction}|${e.expiresAt ?? 0}|${t.trim()}`;
|
|
3890
3879
|
return ht(gt(n));
|
|
3891
3880
|
}
|
|
3892
|
-
function
|
|
3881
|
+
function ds(e) {
|
|
3893
3882
|
let t = {
|
|
3894
3883
|
approvedTargets: e.approvedTargets,
|
|
3895
3884
|
nativeTokenLimitPerTransaction: e.nativeTokenLimitPerTransaction
|
|
@@ -3901,36 +3890,36 @@ function os(e) {
|
|
|
3901
3890
|
}
|
|
3902
3891
|
//#endregion
|
|
3903
3892
|
//#region src/services/publishAuthorization/index.ts
|
|
3904
|
-
var
|
|
3905
|
-
function
|
|
3893
|
+
var fs = "0x0000000000000000000000000000000000000000", ps = !0, ms = "0x0000000000000000000000000000000000000000";
|
|
3894
|
+
function hs(e) {
|
|
3906
3895
|
if (i(e)) return e.txSender;
|
|
3907
|
-
if (
|
|
3896
|
+
if (he(e)) return e;
|
|
3908
3897
|
throw Error("@seedprotocol/publish: publish authorization write APIs require a PublishWallet or SeedTxSender");
|
|
3909
3898
|
}
|
|
3910
|
-
async function
|
|
3899
|
+
async function gs(e, t) {
|
|
3911
3900
|
let n = await e.sendTransaction(t);
|
|
3912
|
-
return
|
|
3901
|
+
return T(n.transactionHash);
|
|
3913
3902
|
}
|
|
3914
|
-
function
|
|
3903
|
+
function _s(e, t) {
|
|
3915
3904
|
let n = t.trim();
|
|
3916
3905
|
if (!/^0x[0-9a-fA-F]{40}$/.test(n)) throw Error(`@seedprotocol/publish: ${e} must be a valid address`);
|
|
3917
3906
|
return n;
|
|
3918
3907
|
}
|
|
3919
|
-
function
|
|
3920
|
-
return Lt.getSchemaUID(vt,
|
|
3908
|
+
function vs() {
|
|
3909
|
+
return Lt.getSchemaUID(vt, fs, ps);
|
|
3921
3910
|
}
|
|
3922
|
-
async function
|
|
3923
|
-
let t =
|
|
3924
|
-
return await
|
|
3911
|
+
async function ys(e) {
|
|
3912
|
+
let t = hs(e), n = vs();
|
|
3913
|
+
return await V(n) || (await gs(t, dn({
|
|
3925
3914
|
schema: vt,
|
|
3926
|
-
resolverAddress:
|
|
3927
|
-
revocable:
|
|
3928
|
-
})), await
|
|
3915
|
+
resolverAddress: fs,
|
|
3916
|
+
revocable: ps
|
|
3917
|
+
})), await gs(t, pn({
|
|
3929
3918
|
schemaUid: n,
|
|
3930
3919
|
schemaName: bt
|
|
3931
3920
|
}))), n;
|
|
3932
3921
|
}
|
|
3933
|
-
function
|
|
3922
|
+
function bs(e) {
|
|
3934
3923
|
return new It(vt).encodeData([
|
|
3935
3924
|
{
|
|
3936
3925
|
name: "identity",
|
|
@@ -3969,10 +3958,10 @@ function hs(e) {
|
|
|
3969
3958
|
}
|
|
3970
3959
|
]);
|
|
3971
3960
|
}
|
|
3972
|
-
async function
|
|
3973
|
-
let t =
|
|
3961
|
+
async function xs(e) {
|
|
3962
|
+
let t = hs(e.wallet), n = e.ensureSchema === !1 ? vs() : await ys(e.wallet), r = _s("identity", e.identity), i = _s("sessionKey", e.sessionKey), a = e.app?.trim() ? _s("app", e.app) : ms, o = e.grantedAt ?? Math.floor(Date.now() / 1e3), s = typeof e.expiresAt == "number" && e.expiresAt > 0 ? Math.trunc(e.expiresAt) : 0, c = e.scopes ?? St, l = Ot(e.permissionsHash ?? us(ls({ expiresAt: s > 0 ? s : void 0 }), c === St ? "publish,revoke" : c));
|
|
3974
3963
|
if (l === zt) throw Error("@seedprotocol/publish: attestPublishAuthorization requires a non-zero permissionsHash");
|
|
3975
|
-
let d = typeof e.expirationTime == "number" && e.expirationTime > 0 ? e.expirationTime : s > 0 ? s : o + _t, f =
|
|
3964
|
+
let d = typeof e.expirationTime == "number" && e.expirationTime > 0 ? e.expirationTime : s > 0 ? s : o + _t, f = bs({
|
|
3976
3965
|
identity: r,
|
|
3977
3966
|
sessionKey: i,
|
|
3978
3967
|
app: a,
|
|
@@ -3980,7 +3969,7 @@ async function gs(e) {
|
|
|
3980
3969
|
grantedAt: o,
|
|
3981
3970
|
expiresAt: s,
|
|
3982
3971
|
permissionsHash: l
|
|
3983
|
-
}), p = await
|
|
3972
|
+
}), p = await gs(t, v({
|
|
3984
3973
|
schema: n,
|
|
3985
3974
|
data: {
|
|
3986
3975
|
recipient: i,
|
|
@@ -3992,7 +3981,7 @@ async function gs(e) {
|
|
|
3992
3981
|
}
|
|
3993
3982
|
}));
|
|
3994
3983
|
if (!p) throw Error("@seedprotocol/publish: attestPublishAuthorization failed — no receipt");
|
|
3995
|
-
let { easContractAddress: m } =
|
|
3984
|
+
let { easContractAddress: m } = D(), h = u(p, m);
|
|
3996
3985
|
if (!h || !Dt(h)) throw Error("@seedprotocol/publish: attestPublishAuthorization failed — could not parse attestation UID");
|
|
3997
3986
|
return {
|
|
3998
3987
|
uid: h,
|
|
@@ -4003,15 +3992,15 @@ async function gs(e) {
|
|
|
4003
3992
|
expirationTime: d
|
|
4004
3993
|
};
|
|
4005
3994
|
}
|
|
4006
|
-
async function
|
|
4007
|
-
let t =
|
|
3995
|
+
async function Ss(e) {
|
|
3996
|
+
let t = hs(e.wallet), r = e.schemaUid ?? vs(), i = Ot(e.uid);
|
|
4008
3997
|
if (!Dt(i)) throw Error("@seedprotocol/publish: revokePublishAuthorization requires a valid attestation uid");
|
|
4009
|
-
if (!await
|
|
3998
|
+
if (!await gs(t, n([{
|
|
4010
3999
|
schema: r,
|
|
4011
4000
|
data: [{ uid: i }]
|
|
4012
4001
|
}]))) throw Error("@seedprotocol/publish: revokePublishAuthorization failed — no receipt");
|
|
4013
4002
|
}
|
|
4014
|
-
async function
|
|
4003
|
+
async function Cs(e) {
|
|
4015
4004
|
let t = (await Et({
|
|
4016
4005
|
identities: e.identities,
|
|
4017
4006
|
excludeRevoked: !1
|
|
@@ -4029,6 +4018,6 @@ async function vs(e) {
|
|
|
4029
4018
|
};
|
|
4030
4019
|
}
|
|
4031
4020
|
//#endregion
|
|
4032
|
-
export {
|
|
4021
|
+
export { B as $, Ei as A, pi as B, Hi as C, wi as D, Ti as E, vi as F, ai as G, _i as H, Fi as I, hr as J, si as K, yi as L, Mi as M, Pi as N, Ci as O, fi as P, dn as Q, bi as R, Ki as S, Si as T, gi as U, ci as V, hi as W, pn as X, Tn as Y, V as Z, ga as _, xs as a, aa as b, vs as c, ls as d, on as et, us as f, Wa as g, os as h, Cs as i, Oi as j, Di as k, Ss as l, ss as m, xt as n, Qt as nt, bs as o, ds as p, $n as q, Ct as r, ys as s, yt as t, Zt as tt, cs as u, _a as v, Wi as w, ia as x, ea as y, xi as z };
|
|
4033
4022
|
|
|
4034
|
-
//# sourceMappingURL=publishAuthorization-
|
|
4023
|
+
//# sourceMappingURL=publishAuthorization-CAFF5jQ2.js.map
|