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