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