@seedprotocol/publish 0.6.9 → 0.6.10

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