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