@seedprotocol/publish 0.6.9 → 0.7.0

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