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