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