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