@laceio/sdk 0.1.0 → 0.1.1-canary.1

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 (411) hide show
  1. package/README.md +1 -1
  2. package/dist/{Ed25519PublicKey-lvu1s54U.cjs → Address-AMKTo-dA.cjs} +17150 -61
  3. package/dist/{Ed25519PublicKey-CjnuAYRR.js → Address-_c_-9hLC.js} +16955 -264
  4. package/dist/{Bip32Account-r3KAhCgU.js → Bip32Account-CaW1zC9Y.js} +4 -5
  5. package/dist/{Bip32Account-Cz3h0ZUa.cjs → Bip32Account-DOaGmKpv.cjs} +4 -5
  6. package/dist/Cardano-B-gyqBBD.js +311 -0
  7. package/dist/Cardano-BQ_af0Y3.cjs +322 -0
  8. package/dist/Ed25519PublicKey-B3QcR0J2.cjs +88 -0
  9. package/dist/Ed25519PublicKey-DIE19xHg.js +83 -0
  10. package/dist/InMemoryKeyAgent-Bc_xZY-v.cjs +652 -0
  11. package/dist/InMemoryKeyAgent-D8T3vtXy.js +631 -0
  12. package/dist/{PaymentAddress-DhbtuYb7.cjs → PaymentAddress-B4n1KZMx.cjs} +1 -2
  13. package/dist/{PaymentAddress-xSmGUQ-8.js → PaymentAddress-Cml3EA1n.js} +1 -2
  14. package/dist/Percent-Cfuw5YyL.cjs +11 -0
  15. package/dist/Percent-DpvyJ_93.js +5 -0
  16. package/dist/SodiumBip32Ed25519-BaD-kjyx.cjs +380 -0
  17. package/dist/SodiumBip32Ed25519-DCikAMsl.js +363 -0
  18. package/dist/{TransactionBuilder-CeJTNzm-.cjs → TransactionBuilder-BakTJvsJ.cjs} +59 -89
  19. package/dist/{TransactionBuilder-DGNDM4kt.js → TransactionBuilder-D2ErwVWv.js} +5 -71
  20. package/dist/_md-6zV2Cme0.cjs +684 -0
  21. package/dist/_md-gbUqlhqd.js +399 -0
  22. package/dist/_web-crypto-random-bytes-BvzwTYPG.js +197 -0
  23. package/dist/acc-module-NL_8mEHH.cjs +27654 -0
  24. package/dist/acc-module-ur8CkBd1.js +27624 -0
  25. package/dist/account-call-BDdWqMAY.js +267 -0
  26. package/dist/account-call-BExOpZoo.js +3 -0
  27. package/dist/account-call-CYYoAS1E.cjs +314 -0
  28. package/dist/account-call-Cvj7viaq.cjs +4 -0
  29. package/dist/account-guards-BeKbV9D1.cjs +41 -0
  30. package/dist/account-guards-qnFXuXSE.js +36 -0
  31. package/dist/{activity-type.stable-ClO9j_PH.cjs → activity-type-BPXxdHBP.cjs} +2 -1
  32. package/dist/{activity-type.stable-Ml0SOYv9.js → activity-type-C1geyPsH.js} +2 -1
  33. package/dist/address-OxwXIwbF.js +15502 -0
  34. package/dist/address-book-address-validator-BqYM0Uyp.cjs +41 -0
  35. package/dist/{address-book-address-validator-BhqRfmlL.cjs → address-book-address-validator-CGIcqn5W.cjs} +5 -4
  36. package/dist/{address-book-address-validator-VqIOB8PY.js → address-book-address-validator-FkkYim3z.js} +6 -4
  37. package/dist/address-book-address-validator-RSx2Jozy.js +39 -0
  38. package/dist/address-lECYBd9-.cjs +13043 -0
  39. package/dist/{apply-vkey-witnesses-Ctzk7eye.cjs → apply-vkey-witnesses-1jyczTkw.cjs} +1 -1
  40. package/dist/{apply-vkey-witnesses-Dfo7XfhL.js → apply-vkey-witnesses-Byb40-yJ.js} +1 -1
  41. package/dist/artefact-loader-De9WJH1J.cjs +183 -0
  42. package/dist/artefact-loader-nlsYFjxU.js +160 -0
  43. package/dist/auto-dismiss-failure-on-success-BWJceNXd.cjs +37 -0
  44. package/dist/auto-dismiss-failure-on-success-Bpod-v4r.js +31 -0
  45. package/dist/bip32-EPpcFrpH.cjs +3851 -0
  46. package/dist/{bip32ed25519-D2In8WzR.cjs → bip32ed25519-CRiG-Kjg.cjs} +5 -4
  47. package/dist/{bip32ed25519-qsLH_eWO.js → bip32ed25519-E-fCUZNv.js} +6 -4
  48. package/dist/bip39-DZomfqeY.js +9 -0
  49. package/dist/bip39-MAck9iod.cjs +26 -0
  50. package/dist/bitcoin-data-provider-D0OT_Uiu.cjs +26 -0
  51. package/dist/bitcoin-data-provider-LN_8oamW.js +21 -0
  52. package/dist/bitcoin.cjs +48 -0
  53. package/dist/bitcoin.d.ts +29805 -1
  54. package/dist/bitcoin.js +22 -0
  55. package/dist/{blake2b-BGHUWMsV.js → blake2b-BL-eR5G2.js} +6 -4
  56. package/dist/{blake2b-DspUqw68.cjs → blake2b-Iy324FwH.cjs} +5 -4
  57. package/dist/{blockfrost-tx-submit-provider-BUEOmdvc.js → blockfrost-tx-submit-provider-BHDLgOIE.js} +9 -162
  58. package/dist/{blockfrost-tx-submit-provider-B5dWbdrZ.cjs → blockfrost-tx-submit-provider-BxC19smv.cjs} +7 -171
  59. package/dist/{blockingWithLatestFrom-BhaE7pnA.js → blockingWithLatestFrom-FUfZFEUG.js} +1 -1
  60. package/dist/{blockingWithLatestFrom-DkuT3G2a.cjs → blockingWithLatestFrom-bmCPgA3c.cjs} +1 -1
  61. package/dist/bn-BFq5a4dk.cjs +2553 -0
  62. package/dist/{SodiumBip32Ed25519-BEfo1Q9m.js → browser-D5jRKv_L.js} +4 -401
  63. package/dist/bytes.vo-CziaOsba.js +24 -0
  64. package/dist/bytes.vo-hecRu3YZ.cjs +35 -0
  65. package/dist/{cardano-network-id-to-network-type-PXvn1ycQ.cjs → cardano-network-id-to-network-type-BwG_d6QP.cjs} +1 -1
  66. package/dist/{cardano-network-id-to-network-type-DHgKhDAK.js → cardano-network-id-to-network-type-CYJheetp.js} +1 -1
  67. package/dist/{cardano-network-id.vo-CbNNKd-k.cjs → cardano-network-id.vo-C5VuBXT3.cjs} +2 -2
  68. package/dist/{cardano-network-id.vo-CTYe-Oix.js → cardano-network-id.vo-CeLJqmb_.js} +2 -2
  69. package/dist/{cardano-tx-id.vo-BMwemq5x.js → cardano-tx-id.vo-DJ70NC0-.js} +1 -1
  70. package/dist/{cardano-tx-id.vo-NY-gCOWJ.cjs → cardano-tx-id.vo-lnyO9XaW.cjs} +1 -1
  71. package/dist/cardano.cjs +31 -24
  72. package/dist/cardano.d.ts +27612 -8128
  73. package/dist/cardano.js +21 -13
  74. package/dist/client-Bw2foG5E.cjs +808 -0
  75. package/dist/const-BB3MccLt.js +153 -0
  76. package/dist/{const-BErUlcZw.cjs → const-BWBAzOmN.cjs} +1 -1
  77. package/dist/const-CSWmOyzn.cjs +42 -0
  78. package/dist/{const-Dy8Ctnpd.cjs → const-D3mCkwrM.cjs} +5 -5
  79. package/dist/const-DW7z3R5k.js +13 -0
  80. package/dist/{const-DeUA7zYl.js → const-DbuUHSzR.js} +5 -5
  81. package/dist/const-DgBzKfz6.cjs +31995 -0
  82. package/dist/{const-DVW6DGkZ.js → const-xGSNCtwQ.js} +1 -1
  83. package/dist/contract-2KVxlHyu.cjs +189 -0
  84. package/dist/contract-DjQqqZLo.js +171 -0
  85. package/dist/create-add-accounts-2mQA0ST2.js +102 -0
  86. package/dist/create-add-accounts-B6mR2NMn.cjs +114 -0
  87. package/dist/{delegation-tx-builder-CF0VunDW.cjs → delegation-tx-builder-Cp30jtj9.cjs} +9 -8
  88. package/dist/{delegation-tx-builder-C8LQxU2R.js → delegation-tx-builder-DUMikSTg.js} +9 -7
  89. package/dist/{deregistration-tx-builder-DcUXA3Ls.cjs → deregistration-tx-builder-B-ZeY-dR.cjs} +10 -9
  90. package/dist/{deregistration-tx-builder-BOBPP8m_.js → deregistration-tx-builder-CRLrK99U.js} +10 -8
  91. package/dist/device-commitment-hex.vo-BIUYUNz1.cjs +31 -0
  92. package/dist/device-commitment-hex.vo-D9FsYLn7.js +26 -0
  93. package/dist/device-key-BToCoS4D.js +2394 -0
  94. package/dist/device-key-D6euvxFi.cjs +2489 -0
  95. package/dist/device-readers-BPDz2oqa.js +3 -0
  96. package/dist/device-readers-CVqmvmLZ.js +145 -0
  97. package/dist/device-readers-DzkDMjPn.cjs +7 -0
  98. package/dist/device-readers-XMZMfFvZ.cjs +168 -0
  99. package/dist/dist-B00GN41m.js +141 -0
  100. package/dist/dist-BA1xnF9O.cjs +4413 -0
  101. package/dist/dist-BmHOXLe8.cjs +3814 -0
  102. package/dist/dist-Br0OVXKt.cjs +535 -0
  103. package/dist/dist-C1JK9C1I.cjs +3452 -0
  104. package/dist/dist-DKEViNEI.cjs +1306 -0
  105. package/dist/dist-Dwqx184a.cjs +43175 -0
  106. package/dist/dist-MJof_Ky1.cjs +145 -0
  107. package/dist/dist-p84sVVJ9.cjs +1394 -0
  108. package/dist/{earn-rewards-tx-builder-BRlTueHS.js → earn-rewards-tx-builder-8G_rouIk.js} +9 -7
  109. package/dist/{earn-rewards-tx-builder-RgO0QUY8.cjs → earn-rewards-tx-builder-cOUNV58E.cjs} +9 -8
  110. package/dist/enc-key-circuits-0Dud78IB.js +13 -0
  111. package/dist/enc-key-circuits-yjPHbuo_.cjs +24 -0
  112. package/dist/english-BZ_ebp2-.cjs +2057 -0
  113. package/dist/envelopes-BmL7onAK.cjs +1721 -0
  114. package/dist/envelopes-CfWTR2uy.js +1620 -0
  115. package/dist/errors-BA3b8aVu.cjs +584 -0
  116. package/dist/errors-pkQdxW-7.js +392 -0
  117. package/dist/experimental.cjs +6875 -0
  118. package/dist/experimental.d.ts +63670 -0
  119. package/dist/experimental.js +6725 -0
  120. package/dist/fees-6C2uEWFK.js +653 -0
  121. package/dist/fees-DtC71fOx.cjs +820 -0
  122. package/dist/gated-call-DLC5PBlN.cjs +736 -0
  123. package/dist/gated-call-DQhT7v2J.js +695 -0
  124. package/dist/gated-call-DdNOQh_Z.js +3 -0
  125. package/dist/gated-call-wAB15GtN.cjs +4 -0
  126. package/dist/grant-circuits-BKJrMSNo.cjs +49 -0
  127. package/dist/grant-circuits-D53wmGyr.js +26 -0
  128. package/dist/grant-rules-fYt80KB1.cjs +7114 -0
  129. package/dist/grant-rules-rG1kJq6l.js +6833 -0
  130. package/dist/grant-status-CDmZpx32.js +296 -0
  131. package/dist/grant-status-CQtwjLsA.cjs +337 -0
  132. package/dist/grants-C5wpNvZJ.cjs +266 -0
  133. package/dist/grants-DY3sN9We.cjs +16 -0
  134. package/dist/grants-ngFtS52g.js +213 -0
  135. package/dist/grants-qpXC94Rk.js +4 -0
  136. package/dist/{group-cardano-addresses-by-account-C-1GHUu8.cjs → group-cardano-addresses-by-account-BGOtPV-Y.cjs} +4 -40
  137. package/dist/{group-cardano-addresses-by-account-p4dXmCoj.js → group-cardano-addresses-by-account-TqvESg9x.js} +6 -37
  138. package/dist/{guarded-transaction-signer-DZSGHp1K.js → guarded-transaction-signer-BbVDE9Nn.js} +12 -18
  139. package/dist/{guarded-transaction-signer-BLSezbfV.cjs → guarded-transaction-signer-DTLjAkif.cjs} +26 -26
  140. package/dist/hex-BVtOKJki.cjs +263 -0
  141. package/dist/hex-CGYJPK_Z.js +192 -0
  142. package/dist/http-client-B7_kBTYn.js +155 -0
  143. package/dist/http-client-DYQ_7Rdf.cjs +167 -0
  144. package/dist/identity-DxPhxkZs.js +239 -0
  145. package/dist/identity-y41Yle03.cjs +274 -0
  146. package/dist/in-memory-wallet-integration-5BKiAvPT.js +20861 -0
  147. package/dist/{in-memory-wallet-integration-CUTa68ET.js → in-memory-wallet-integration-BCOqDgbt.js} +10 -107
  148. package/dist/in-memory-wallet-integration-Bi8I9Dso.js +128 -0
  149. package/dist/in-memory-wallet-integration-Bsl2ONua.cjs +239 -0
  150. package/dist/in-memory-wallet-integration-DZ0CAyvY.cjs +20865 -0
  151. package/dist/{in-memory-wallet-integration-Dw_S7amX.cjs → in-memory-wallet-integration-DsFm8gLk.cjs} +21 -112
  152. package/dist/{in-memory-wallet-integration-Z4Bp_DTv.cjs → in-memory-wallet-integration-aW_SF-go.cjs} +8 -5
  153. package/dist/{in-memory-wallet-integration-B6cbAlvD.js → in-memory-wallet-integration-mIEc8EfR.js} +9 -5
  154. package/dist/index.cjs +95 -58
  155. package/dist/index.d.ts +45146 -13439
  156. package/dist/index.js +55 -28
  157. package/dist/{init-CVi8J0zk.cjs → init-5SfWgCYD.cjs} +3 -3
  158. package/dist/{init-Ci7aqWCf2.cjs → init-8NVWbo302.cjs} +2 -2
  159. package/dist/init-B-C7n6u6.js +5 -0
  160. package/dist/{init-BFMWRf-L.js → init-B-ppfGO-.js} +1 -1
  161. package/dist/{init-IiR093Jw.cjs → init-B2OUhY5T.cjs} +2 -2
  162. package/dist/{init-DXnus199.cjs → init-B6Eg_o6G.cjs} +5 -5
  163. package/dist/{init-4hDl5bpr.js → init-BAWMHL1k.js} +2 -2
  164. package/dist/init-BC2CZZOu2.cjs +2002 -0
  165. package/dist/{init-a228hXnS.cjs → init-BF-a2p6E.cjs} +65 -73
  166. package/dist/{init-fFirX8OY.cjs → init-BFxlQAD8.cjs} +1 -1
  167. package/dist/init-BJE1ry0O.js +17 -0
  168. package/dist/{init-BVnI4z2J.js → init-BPKBVOHU.js} +2 -2
  169. package/dist/{init-bdqZBd-o.js → init-BSP_xcpB.js} +2 -2
  170. package/dist/{init-CFNOn3lo.js → init-BSd7mznK.js} +3 -3
  171. package/dist/{init-MjR4swi6.js → init-BUJTT0MN.js} +36 -43
  172. package/dist/init-BUpFzYsD.cjs +143 -0
  173. package/dist/{init-BvpYHyLH.cjs → init-BZ-WyAIL.cjs} +3 -3
  174. package/dist/init-BZdfdLX7.js +422 -0
  175. package/dist/{init-CJeOys1w.cjs → init-B_HWNXMD.cjs} +2 -2
  176. package/dist/init-BbIMt6xU.cjs +6 -0
  177. package/dist/{init-BYdN1aqE.cjs → init-BewG6swt.cjs} +2 -2
  178. package/dist/{init-Tpn9VkFu.cjs → init-BpwlQ6wF.cjs} +1 -1
  179. package/dist/{init-D5-P0HXK.js → init-BtQOzUjX.js} +1 -1
  180. package/dist/{init-BvGz3qUd2.js → init-CCTscPaY2.js} +2 -2
  181. package/dist/{init-D4hPipCD.cjs → init-CH0yyBof.cjs} +1 -1
  182. package/dist/{init-BX0AZAVH2.js → init-CS98M3iD.js} +2 -2
  183. package/dist/init-CaIkrXal.cjs +121 -0
  184. package/dist/init-CkZy4IMf.cjs +107 -0
  185. package/dist/{init-Drr2f_Pr.js → init-CmfcY7SV.js} +1 -1
  186. package/dist/{init-Kf3_OLv6.js → init-CnJAlks_.js} +1 -1
  187. package/dist/{init-Cdjt_z-b.cjs → init-CqqmtAIK.cjs} +4 -4
  188. package/dist/{init-Bb0avZeZ.js → init-Cu2znmIc.js} +5 -5
  189. package/dist/{init-lcaUSOOG.js → init-CwLZXfTl.js} +1 -1
  190. package/dist/init-Cz5LAizN.js +2001 -0
  191. package/dist/init-D4WM3-Mn.cjs +18 -0
  192. package/dist/init-DJzEpODO.js +2373 -0
  193. package/dist/init-DMi2FGpf.cjs +424 -0
  194. package/dist/{init-BTYLMF9F2.cjs → init-DexLSprL2.cjs} +258 -61
  195. package/dist/init-DfKPgD21.js +106 -0
  196. package/dist/init-DgzRsI-C.js +141 -0
  197. package/dist/init-Dj4Cn7-P.js +4789 -0
  198. package/dist/{init-DFwhgert.cjs → init-DnELgrhn.cjs} +1 -1
  199. package/dist/init-DypZuehC.cjs +2374 -0
  200. package/dist/{init-CX_zLXc6.js → init-IBnizp1U.js} +5 -5
  201. package/dist/init-MDKB6tGI2.cjs +4790 -0
  202. package/dist/{init-DbZ5byj42.js → init-TbB38KNt2.js} +258 -60
  203. package/dist/{init-BgrY29gW.js → init-dsYkC_0B.js} +4 -4
  204. package/dist/{init-DvVgKCaP2.cjs → init-kVOOiU0-.cjs} +2 -2
  205. package/dist/{init-B5BsI3DR.cjs → init-kvn5FlPS.cjs} +7 -7
  206. package/dist/init-vfy9DW_E.js +119 -0
  207. package/dist/{init-BE_6Jyc4.js → init-w7xl6LsP.js} +3 -3
  208. package/dist/{init-DEsWVyn5.cjs → init-wgiBUmyW.cjs} +1 -1
  209. package/dist/{is-retriable-error-DWv_ob-f.js → is-retriable-error-CmFR20pe.js} +1 -1
  210. package/dist/{is-retriable-error-Dtb4JGjd.cjs → is-retriable-error-D2yo0_lS.cjs} +1 -1
  211. package/dist/jubjub-authoriser-BBJcD2uC.js +85 -0
  212. package/dist/jubjub-authoriser-BlXt4Z-D.cjs +86 -0
  213. package/dist/key-source-CcLTx8HK.js +2761 -0
  214. package/dist/key-source-D2tTAag-.cjs +806 -0
  215. package/dist/{key-value-store-DTX1quRS.js → key-value-store-DZcNDB3n.js} +1 -1
  216. package/dist/{key-value-store-B-XRIwaM.cjs → key-value-store-Htj4RgMe.cjs} +1 -1
  217. package/dist/keyDerivation-DcKRUCVh.cjs +274 -0
  218. package/dist/keyDerivation-QGesIMbS.js +4077 -0
  219. package/dist/{lace-context-FpU3iG3f.cjs → lace-context-BN0b_ury.cjs} +4 -4
  220. package/dist/{lace-context-BQvvxVLm.js → lace-context-DMRJ87Vg.js} +4 -4
  221. package/dist/lib-BC-62Byh.cjs +2359 -0
  222. package/dist/lib-JYqcAX0c.js +2354 -0
  223. package/dist/midnight-account-id.vo--Vcx34Xk.cjs +10 -0
  224. package/dist/midnight-account-id.vo-BuB8fiVO.js +5 -0
  225. package/dist/midnight-engine-B7D2hbHo.js +5 -0
  226. package/dist/midnight-engine-D5ikN_5F.cjs +6 -0
  227. package/dist/midnight-wallet-BOdFD6SX.cjs +24 -0
  228. package/dist/midnight-wallet-CAqZrNVe.js +18 -0
  229. package/dist/midnight.cjs +1412 -0
  230. package/dist/midnight.d.ts +28609 -0
  231. package/dist/midnight.js +1355 -0
  232. package/dist/modules-cardano-4IgYsKeN.js +999 -0
  233. package/dist/modules-cardano-Baqj2GZH.cjs +1112 -0
  234. package/dist/node-relay-BEtqi_vU.cjs +49 -0
  235. package/dist/node-relay-CkgpDObu.js +48 -0
  236. package/dist/outputs-5qdW8s-f.js +196 -0
  237. package/dist/outputs-BEM1GPMf.cjs +339 -0
  238. package/dist/{SodiumBip32Ed25519-BQUcrQWX.cjs → pbkdf2-B1veireP.cjs} +6 -411
  239. package/dist/pending-operation-CfTUNQVD.cjs +26 -0
  240. package/dist/pending-operation-Ljijb1Uh.js +21 -0
  241. package/dist/providers--Hg9iF5v.cjs +366 -0
  242. package/dist/providers-DQ5_3h2l.js +343 -0
  243. package/dist/redacted-4SJPqt-G.js +81 -0
  244. package/dist/redacted-DwxIDdIF.cjs +86 -0
  245. package/dist/{reselect-DPML1uFN.cjs → reselect-kP4DaAII.cjs} +1 -1
  246. package/dist/{retry-config-oNtfdyrG.cjs → retry-config-BGv5q5QM.cjs} +1 -1
  247. package/dist/{retry-config-VdbuqBsI.js → retry-config-Bu5Yn5ua.js} +1 -1
  248. package/dist/safe-buffer-CqGpSFCQ.js +43 -0
  249. package/dist/safe-buffer-DbXbwhUQ.cjs +48 -0
  250. package/dist/sdk-Bm9-P0L-.cjs +1445 -0
  251. package/dist/sdk-Cf__6dDe.js +1249 -0
  252. package/dist/sdk-init-9TG1ZvHF.cjs +3795 -0
  253. package/dist/sdk-init-Ce3mD-8F.js +1047 -0
  254. package/dist/secret-box-CSmRp6Tt.js +3777 -0
  255. package/dist/secret-box-ZfbYwBgS.cjs +6970 -0
  256. package/dist/send-proof-progress-DtAcrMP6.cjs +33 -0
  257. package/dist/send-proof-progress-Dx2cUz1B.js +22 -0
  258. package/dist/sha2-DaRJZOjk.cjs +390 -0
  259. package/dist/sha2-c4sB6peD.js +378 -0
  260. package/dist/side-effects-C3BhLrdP.js +768 -0
  261. package/dist/side-effects-DG0R-KFc.cjs +804 -0
  262. package/dist/sign-bitcoin-transaction-with-seed-C7vq9om8.js +147 -0
  263. package/dist/sign-bitcoin-transaction-with-seed-Ds1dwzan.cjs +158 -0
  264. package/dist/signer--2I6poMD.js +2 -0
  265. package/dist/signer-CX21Ups_.cjs +121 -0
  266. package/dist/signer-Cnn9q9oY.js +92 -0
  267. package/dist/signer-DbSxjk0F.cjs +7 -0
  268. package/dist/signer-factory-B5oFuUZ-.cjs +130 -0
  269. package/dist/signer-factory-BAt8FPNc.cjs +281 -0
  270. package/dist/signer-factory-BGE4nL4k.js +129 -0
  271. package/dist/signer-factory-C4pgsiJi.js +281 -0
  272. package/dist/{signer-factory-DySc1wRX.cjs → signer-factory-D95jQIPV.cjs} +9 -6
  273. package/dist/{signer-factory-D4HrwFPl.js → signer-factory-PrpsGX-8.js} +10 -6
  274. package/dist/{slice-BZTQgYSs.js → slice-B-xJcuT1.js} +4 -4
  275. package/dist/slice-B4QOYaOG.cjs +105 -0
  276. package/dist/{slice-CtIMw2YT.cjs → slice-B9QKuhi0.cjs} +3 -3
  277. package/dist/{slice-Bhwmqn1p.cjs → slice-Bf4enJKZ.cjs} +8 -8
  278. package/dist/{slice-DaNVz7_l.js → slice-ByNWnxKS.js} +8 -8
  279. package/dist/{slice-C2UDQrdt.js → slice-C1zOeseG.js} +449 -355
  280. package/dist/{slice-DFLyKRm5.cjs → slice-C4toRM6A.cjs} +2 -2
  281. package/dist/{slice-Cx4dULDA.cjs → slice-C8YVv4Qn.cjs} +1 -1
  282. package/dist/{slice-jnpOgiSZ.cjs → slice-CaMfviYu.cjs} +3 -3
  283. package/dist/{slice-DFvrwUur.js → slice-CgeRsYRg.js} +6 -6
  284. package/dist/{slice-zNEspZND.js → slice-D0VzpMbY.js} +2 -2
  285. package/dist/slice-D14F78Ca.js +87 -0
  286. package/dist/slice-DJelVt0i.js +9013 -0
  287. package/dist/{slice-F6A1YKOF.cjs → slice-DLflttAu.cjs} +479 -366
  288. package/dist/{slice-C96EdeY1.js → slice-DcO-iNz2.js} +1 -1
  289. package/dist/{slice-C19quNWM.cjs → slice-DimtxfAT.cjs} +2 -2
  290. package/dist/{slice-KiNoGwD9.js → slice-DlTEqIoI.js} +1 -1
  291. package/dist/{slice-ws8PccRX.js → slice-Dn0WojD7.js} +3 -3
  292. package/dist/{slice-BLSxLmie.cjs → slice-Dongunf7.cjs} +4 -4
  293. package/dist/{slice-B6vPum19.js → slice-DpufJAjJ.js} +2 -2
  294. package/dist/{slice-exhhmucR.cjs → slice-DtitVc9L.cjs} +7 -7
  295. package/dist/slice-RQRLciQc.cjs +9031 -0
  296. package/dist/{slice-Bjj2t2ut.cjs → slice-WMMMc1Xv.cjs} +2 -2
  297. package/dist/slice-a8VuIqzS.cjs +378 -0
  298. package/dist/slice-bRASyM-m.js +354 -0
  299. package/dist/{slice-CBFrgHSH.js → slice-hNyKbDry.js} +3 -3
  300. package/dist/{InMemoryKeyAgent-pyB2gA-N.cjs → src-BayYMIjw.cjs} +20 -8228
  301. package/dist/{InMemoryKeyAgent-D-3HejxN.js → src-CgINPlSx.js} +29 -4811
  302. package/dist/store-AUlTfcI_.js +37 -0
  303. package/dist/store-C7AneHEY.cjs +66 -0
  304. package/dist/submit-BuBCVi-l.cjs +87 -0
  305. package/dist/submit-D37lxFrK.js +70 -0
  306. package/dist/submit-bitcoin-tx-CE0AD-xH.js +983 -0
  307. package/dist/submit-bitcoin-tx-CK10OTfQ.cjs +1049 -0
  308. package/dist/{subtractValueQuantities-DfZg6oiG.js → subtractValueQuantities-BuDJVxq6.js} +3 -22
  309. package/dist/{subtractValueQuantities-C8qDTtgH.cjs → subtractValueQuantities-CqR606HV.cjs} +2 -32
  310. package/dist/{sync-operation-utils-BrQyWFS_.cjs → sync-operation-utils--Z_IQfyW.cjs} +0 -66
  311. package/dist/{sync-operation-utils-CAaCGvEN.js → sync-operation-utils-BimBpvI3.js} +1 -37
  312. package/dist/token-id-mapper-BVau2RXa.js +16 -0
  313. package/dist/token-id-mapper-CSeLzM4o.cjs +18 -0
  314. package/dist/{token-id-mapper-pDaTxpw2.js → token-id-mapper-ClBeIdJR.js} +2 -2
  315. package/dist/{token-id-mapper-DYcd8hhQ.cjs → token-id-mapper-D0wFdbOy.cjs} +2 -2
  316. package/dist/types-46lh8O9r.js +33 -0
  317. package/dist/types-BhhNR1_B.cjs +50 -0
  318. package/dist/types-BhzypKMS.cjs +15 -0
  319. package/dist/types-DTE1ctDB.js +10 -0
  320. package/dist/types-DXSxXGz0.js +12 -0
  321. package/dist/types-Dls6Z5gV.cjs +23 -0
  322. package/dist/{util-P4PX2muj.cjs → util-D1YlKzrc.cjs} +2 -2
  323. package/dist/{util-CQSJU0wT.js → util-DHxtzUzY.js} +2 -2
  324. package/dist/{utils-Bv4OHT4S.cjs → utils-DYf4iZKX.cjs} +7 -1
  325. package/dist/{utils-DrtzChYN.js → utils-DcnoETEP.js} +2 -2
  326. package/dist/utils-Du0YXRcU.cjs +112 -0
  327. package/dist/utils-fF_rnZe3.js +65 -0
  328. package/dist/v8Signatures-ClGpA8mS.cjs +71 -0
  329. package/dist/{vote-delegation-tx-builder-69gOEkCB.cjs → vote-delegation-tx-builder-BjZxCOd3.cjs} +9 -8
  330. package/dist/{vote-delegation-tx-builder-BRJ_pf-c.js → vote-delegation-tx-builder-DRJwPXkD.js} +9 -7
  331. package/dist/watch-FGE4B_Ge.js +13056 -0
  332. package/dist/watch-imlsRZDp.cjs +52207 -0
  333. package/package.json +95 -3
  334. package/dist/Address-4KjeDt_x.cjs +0 -17269
  335. package/dist/Address-_VPkf7Xh.js +0 -17101
  336. package/dist/account-guards.stable-BKyYPj4z.cjs +0 -10
  337. package/dist/account-guards.stable-BdmQ43vC.js +0 -5
  338. package/dist/init-BR9ZIbED.cjs +0 -378
  339. package/dist/init-B_k1RUN_.cjs +0 -21
  340. package/dist/init-Bs3b5ZQH.js +0 -378
  341. package/dist/init-ChfcrHgG2.cjs +0 -4354
  342. package/dist/init-D1uUMMpG.js +0 -19
  343. package/dist/init-DV1OSZiK.js +0 -4352
  344. package/dist/modules-cardano-BINzpXpk.js +0 -5454
  345. package/dist/modules-cardano-Dt8OwoQb.cjs +0 -5640
  346. package/dist/slice-Caf98m0d2.js +0 -107
  347. package/dist/slice-PM6llajQ2.cjs +0 -125
  348. /package/dist/{BigIntMath-CoJWXt1h.cjs → BigIntMath-CBciEQn2.cjs} +0 -0
  349. /package/dist/{BigIntMath-BWUJOsOW.js → BigIntMath-X3EniYDo.js} +0 -0
  350. /package/dist/{ChainId-sdLmlIRk.cjs → ChainId-CNPSU9nn.cjs} +0 -0
  351. /package/dist/{ChainId-CKbm87yQ.js → ChainId-CeoG8Sov.js} +0 -0
  352. /package/dist/{_polyfill-node.process-4fnlkbBi.cjs → _polyfill-node.process-5UxyjoHG.cjs} +0 -0
  353. /package/dist/{account-id.vo-Xpgnu-av.cjs → account-id.vo-DYZBZQsz.cjs} +0 -0
  354. /package/dist/{account-id.vo-DP0BtOoF.js → account-id.vo-KDTWJ-W5.js} +0 -0
  355. /package/dist/{actions-BNagEO6m.cjs → actions-BnHFVSr_.cjs} +0 -0
  356. /package/dist/{actions-BWTyAr7B.js → actions-Cwj0ApZf.js} +0 -0
  357. /package/dist/{asyncoption-po7-RiA5.cjs → asyncoption-CYcZNBRM.cjs} +0 -0
  358. /package/dist/{asyncoption-CzIVH5Y1.js → asyncoption-DZQGfznq.js} +0 -0
  359. /package/dist/{bignum.vo-DhhZ9HP1.js → bignum.vo-Co6tMH2q.js} +0 -0
  360. /package/dist/{bignum.vo-CpkrIXjH.cjs → bignum.vo-Du-bpvar.cjs} +0 -0
  361. /package/dist/{blockchain-network-id.vo-CbgrAY_K.js → blockchain-network-id.vo-C6Jowh8t.js} +0 -0
  362. /package/dist/{blockchain-network-id.vo-5iC6Kffo.cjs → blockchain-network-id.vo-DEQ14dYj.cjs} +0 -0
  363. /package/dist/{composite-signer-factory-DABpCe1_.js → composite-signer-factory-D9RWY-1V.js} +0 -0
  364. /package/dist/{composite-signer-factory-BizuNPP7.cjs → composite-signer-factory-v4Pxn8bA.cjs} +0 -0
  365. /package/dist/{error-ggOihIfv.cjs → error-B6wj9nPv.cjs} +0 -0
  366. /package/dist/{error-DHKO2iS4.js → error-CvEYL98P.js} +0 -0
  367. /package/dist/{esm-browser-DnXNvpcn.cjs → esm-browser-CZbMeVod.cjs} +0 -0
  368. /package/dist/{esm-browser-BBVQuyQv.js → esm-browser-DpAD_RKv.js} +0 -0
  369. /package/dist/{feature-flag-key.vo-DoGK5Bfh.js → feature-flag-key.vo-9reURsOQ.js} +0 -0
  370. /package/dist/{feature-flag-key.vo-CP1Z9s8e.cjs → feature-flag-key.vo-KTIdnzYX.cjs} +0 -0
  371. /package/dist/{first-state-of-status-Bx4-QQ5m.cjs → first-state-of-status-9ICeDNSa.cjs} +0 -0
  372. /package/dist/{first-state-of-status-D7XzEuSa.js → first-state-of-status-BscbKj_t.js} +0 -0
  373. /package/dist/{init-ZX90nEJe2.js → init-B0hAl9w6.js} +0 -0
  374. /package/dist/{init-4319psUJ.cjs → init-BT67pd9x.cjs} +0 -0
  375. /package/dist/{init-AFUM1TSg.js → init-CHk1fvJ2.js} +0 -0
  376. /package/dist/{init-Dt1Xifg_2.cjs → init-CSURGyW_.cjs} +0 -0
  377. /package/dist/{init-CTQ2g6Xt.js → init-DtxxFaCx.js} +0 -0
  378. /package/dist/{init-BNewLCqw.cjs → init-xzZPlQwB.cjs} +0 -0
  379. /package/dist/{is-redux-persist-state-DxJSsvxB.cjs → is-redux-persist-state-C5luvPEH.cjs} +0 -0
  380. /package/dist/{is-redux-persist-state-Bl2n4VMr.js → is-redux-persist-state-CjcqyCoh.js} +0 -0
  381. /package/dist/{isNotNil-CZxBMfL5.js → isNotNil-Be7gCY0m.js} +0 -0
  382. /package/dist/{isNotNil-C_SO1tcC.cjs → isNotNil-CrYIUFry.cjs} +0 -0
  383. /package/dist/{logging-BvMDKgl0.js → logging-BAMMfn5j.js} +0 -0
  384. /package/dist/{logging-Bh9ikph3.cjs → logging-CbxgIX9V.cjs} +0 -0
  385. /package/dist/{metadatum-B-sxBnSY.cjs → metadatum-BGvFqGPt.cjs} +0 -0
  386. /package/dist/{metadatum-Ego4jVas.js → metadatum-BVocMYy_.js} +0 -0
  387. /package/dist/{repo-slice-BzZQUTj8.cjs → repo-slice-BB_W-6OL.cjs} +0 -0
  388. /package/dist/{repo-slice-vCcQJotS.js → repo-slice-BQlssw9M.js} +0 -0
  389. /package/dist/{reselect-BPkMzw3k.js → reselect-JIgawvPe.js} +0 -0
  390. /package/dist/{serializable-BxFUShKY.js → serializable-F7OtYl8d.js} +0 -0
  391. /package/dist/{serializable-DWgkHhv_.cjs → serializable-n3UoxbZc.cjs} +0 -0
  392. /package/dist/{slice-DY-DNtSi.js → slice-5dGBAz6w.js} +0 -0
  393. /package/dist/{slice-BEFoeqgr.cjs → slice-BzJgg9FS.cjs} +0 -0
  394. /package/dist/{src-CPmX4KUh.cjs → src-CeBNkonz.cjs} +0 -0
  395. /package/dist/{src-XOZXPKxe.js → src-Cv1ifqbe.js} +0 -0
  396. /package/dist/{time-CQPt4FdU.js → time-ByoKevdZ.js} +0 -0
  397. /package/dist/{time-Blvoyh9G.cjs → time-qD7edGU0.cjs} +0 -0
  398. /package/dist/{time.vo-Xln4yGBU.js → time.vo-C17-tYq3.js} +0 -0
  399. /package/dist/{time.vo-rwWwJzmP.cjs → time.vo-TmYE-_Y2.cjs} +0 -0
  400. /package/dist/{toEmpty-CzmoZVLN.cjs → toEmpty-Db6V94Mf.cjs} +0 -0
  401. /package/dist/{toEmpty-DzLd-ZCi.js → toEmpty-Djj-QbpI.js} +0 -0
  402. /package/dist/{token-id.vo-l8fuSpem.cjs → token-id.vo-CZ622zcZ.cjs} +0 -0
  403. /package/dist/{token-id.vo-DMKSaMlc.js → token-id.vo-IDI9C_Qm.js} +0 -0
  404. /package/dist/{types-B61DQoFW.js → types-By-XeXWg.js} +0 -0
  405. /package/dist/{types-CUC-Kcqh.cjs → types-Cn6WlQV6.cjs} +0 -0
  406. /package/dist/{util-BV3iGOrz.cjs → util-Cp1h58uD.cjs} +0 -0
  407. /package/dist/{util-BsQKLorV.js → util-DHppXj7U.js} +0 -0
  408. /package/dist/{util-selector-CKIyoAOz.js → util-selector-BWmHpo92.js} +0 -0
  409. /package/dist/{util-selector-C9H5RsNw.cjs → util-selector-glXkO-jR.cjs} +0 -0
  410. /package/dist/{while-active-CNXeLxre.js → while-active-CDBnUlQA.js} +0 -0
  411. /package/dist/{while-active-BsDWSNrO.cjs → while-active-I2TlHtm7.cjs} +0 -0
@@ -0,0 +1,1412 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_chunk = require("./chunk-9hOWP6kD.cjs");
3
+ const require__polyfill_buffer_patch = require("./_polyfill-buffer-patch-BycQkEkK.cjs");
4
+ require("./dist-MJof_Ky1.cjs");
5
+ require("./Address-AMKTo-dA.cjs");
6
+ require("./serializable-n3UoxbZc.cjs");
7
+ require("./pbkdf2-B1veireP.cjs");
8
+ require("./safe-buffer-DbXbwhUQ.cjs");
9
+ require("./src-BayYMIjw.cjs");
10
+ const require_sdk = require("./sdk-Bm9-P0L-.cjs");
11
+ require("./secret-box-ZfbYwBgS.cjs");
12
+ require("./util-D1YlKzrc.cjs");
13
+ const require_bytes_vo = require("./bytes.vo-hecRu3YZ.cjs");
14
+ const require_time_vo = require("./time.vo-TmYE-_Y2.cjs");
15
+ const require_bignum_vo = require("./bignum.vo-Du-bpvar.cjs");
16
+ const require_asyncoption = require("./asyncoption-CYcZNBRM.cjs");
17
+ const require_key_source = require("./key-source-D2tTAag-.cjs");
18
+ const require_store = require("./store-C7AneHEY.cjs");
19
+ const require_const = require("./const-BWBAzOmN.cjs");
20
+ const require_account_id_vo = require("./account-id.vo-DYZBZQsz.cjs");
21
+ require("./slice-Bf4enJKZ.cjs");
22
+ require("./retry-config-BGv5q5QM.cjs");
23
+ const require_activity_type = require("./activity-type-BPXxdHBP.cjs");
24
+ const require_token_id_vo = require("./token-id.vo-CZ622zcZ.cjs");
25
+ require("./bn-BFq5a4dk.cjs");
26
+ const require_const$1 = require("./const-DgBzKfz6.cjs");
27
+ const require_watch = require("./watch-imlsRZDp.cjs");
28
+ const require_midnight_account_id_vo = require("./midnight-account-id.vo--Vcx34Xk.cjs");
29
+ const require_slice$1 = require("./slice-a8VuIqzS.cjs");
30
+ const require_utils = require("./utils-Du0YXRcU.cjs");
31
+ const require_dist$1 = require("./dist-Br0OVXKt.cjs");
32
+ require("./client-Bw2foG5E.cjs");
33
+ let rxjs = require("rxjs");
34
+ let _reduxjs_toolkit = require("@reduxjs/toolkit");
35
+ let ts_log = require("ts-log");
36
+ let _midnight_ntwrk_ledger_v8 = require("@midnight-ntwrk/ledger-v8");
37
+ _midnight_ntwrk_ledger_v8 = require_chunk.__toESM(_midnight_ntwrk_ledger_v8);
38
+ let lodash_inRange = require("lodash/inRange.js");
39
+ lodash_inRange = require_chunk.__toESM(lodash_inRange);
40
+ let lodash_toLower = require("lodash/toLower.js");
41
+ lodash_toLower = require_chunk.__toESM(lodash_toLower);
42
+ //#region src/create-midnight-accounts.ts
43
+ /**
44
+ * Derives a Midnight account index using the entity's encrypted recovery material.
45
+ * Indexes must be integers in `[0, 2³¹)`. Omitted networks use the integration's
46
+ * defaults. Rejects duplicate accounts, an entity with neither a Midnight
47
+ * seed nor a recovery phrase (a passkey entity), unavailable integration and
48
+ * decryption or derivation errors. Other blockchain accounts are preserved.
49
+ *
50
+ * Returns an updated entity without dispatching. For a new entity, dispatch
51
+ * `wallets.addWallet`; for an existing one, dispatch `wallets.updateWallet`
52
+ * with its updated `accounts` and `blockchainSpecific`.
53
+ */
54
+ const createMidnightAccounts = async (wallet, props) => {
55
+ if (!Number.isInteger(props.accountIndex) || props.accountIndex < 0 || props.accountIndex >= 2 ** 31) throw new RangeError("Midnight account index must be an integer in [0, 2³¹)");
56
+ if (!props.wallet.blockchainSpecific.Midnight?.encryptedSeed && !props.wallet.encryptedRecoveryPhrase) throw new Error("The entity holds no Midnight seed and no recovery phrase: derive the accounts of a passkey entity with createMidnightPasskeyWalletEntity({ accounts })");
57
+ const integration = (await wallet._loadModules("addons.loadInMemoryWalletIntegration")).find((candidate) => candidate.blockchainName === "Midnight");
58
+ if (!integration) throw new Error("Midnight integration is not loaded");
59
+ const { wallet: updated } = await integration.addAccounts(props, { logger: ts_log.dummyLogger });
60
+ const accountIds = updated.accounts.map((account) => account.accountId);
61
+ if (new Set(accountIds).size !== accountIds.length) throw new Error("Midnight account already exists");
62
+ return updated;
63
+ };
64
+ //#endregion
65
+ //#region ../../packages/contract/midnight-context/src/store/index.ts
66
+ var store_default = require_store.inferStoreContext({
67
+ load: async () => Promise.resolve().then(() => require("./init-CkZy4IMf.cjs")),
68
+ context: {
69
+ actions: require_slice$1.midnightContextActions,
70
+ selectors: require_slice$1.midnightContextSelectors
71
+ }
72
+ });
73
+ //#endregion
74
+ //#region ../../packages/contract/midnight-context/src/contract.ts
75
+ const midnightContextStoreContract = require_store.inferContractContext({
76
+ name: require_sdk.ContractName("midnight-context-store"),
77
+ instance: "exactly-one",
78
+ contractType: "store",
79
+ dependsOn: require_store.combineContracts([require_sdk.networkStoreContract, require_sdk.featureStoreContract]),
80
+ mixin: require_sdk.createMixin((laceModule) => ({ store: require_sdk.combineStore(laceModule, store_default) }))
81
+ });
82
+ const midnightDependencyContract = require_store.inferContractContext({
83
+ contractType: "sideEffectDependency",
84
+ name: require_sdk.ContractName("midnight-dependency"),
85
+ instance: "exactly-one"
86
+ });
87
+ //#endregion
88
+ //#region ../../packages/contract/midnight-context/src/midnight-engine-addon.ts
89
+ /**
90
+ * Engine access for code outside the store, such as the SDK's Midnight
91
+ * helpers. Implemented by the headless Midnight engine module only.
92
+ */
93
+ const midnightEngineAddonContract = require_store.inferContractContext({
94
+ name: require_sdk.ContractName("midnight-engine-addon"),
95
+ instance: "exactly-one",
96
+ contractType: "addon",
97
+ provides: { addons: ["loadMidnightEngine"] }
98
+ });
99
+ //#endregion
100
+ //#region ../../packages/contract/midnight-context/src/dust-utils.ts
101
+ /**
102
+ * Determines the designation target type based on NIGHT coin registration and dust balance.
103
+ *
104
+ * TODO: Update when SDK supports distinguishing self vs external designation.
105
+ * Currently, the SDK's `registeredForDustGeneration` flag only indicates that NIGHT is
106
+ * participating in dust generation, but does not specify the target dust address.
107
+ * Until SDK provides this information, we treat all designation as 'self'.
108
+ *
109
+ * @returns 'self' when user has designation (registered NIGHT or dust balance), 'none' otherwise.
110
+ * Note: 'external' is not returned until SDK supports proper detection.
111
+ */
112
+ const getDesignationTargetType = (coins, currentDustValue) => {
113
+ return coins.some((coin) => coin.registeredForDustGeneration === true) || currentDustValue > 0n ? "self" : "none";
114
+ };
115
+ const TOKEN_FORBIDDEN_NAMES = [
116
+ "dust",
117
+ "lace",
118
+ "midnight",
119
+ "tdust",
120
+ "night",
121
+ "tnight"
122
+ ];
123
+ /** Checks reserved and additional excluded names case-insensitively; trim input first. */
124
+ const isForbiddenTokenName = (name, extraExcludedTokenNames = []) => [...TOKEN_FORBIDDEN_NAMES, ...extraExcludedTokenNames.map(lodash_toLower.default)].includes((0, lodash_toLower.default)(name));
125
+ /** Checks case-insensitive display-name collisions; omit the current token from the list. */
126
+ const isTakenTokenName = (name, takenTokenNames = []) => takenTokenNames.map(lodash_toLower.default).includes((0, lodash_toLower.default)(name));
127
+ const createTokenNameValidator = (minLength, maxLength) => (name, excludedNames = []) => {
128
+ const isInvalidNameLength = !(0, lodash_inRange.default)(name.trim().length, minLength, maxLength + 1);
129
+ return !(isForbiddenTokenName(name, excludedNames) || isInvalidNameLength);
130
+ };
131
+ /** Validates display-name length and reserved names; trim before validating and saving. */
132
+ const isTokenFullNameValid = createTokenNameValidator(1, 30);
133
+ /** Validates ticker length and reserved names; trim before validating and saving. */
134
+ const isTokenShortNameValid = createTokenNameValidator(1, 4);
135
+ /** Direct import of this is an anti-pattern. OK for tests. */
136
+ const midnightSyncActions = { midnightSync: {
137
+ requestResync: (0, _reduxjs_toolkit.createAction)("midnight/requestResync"),
138
+ resync: (0, _reduxjs_toolkit.createAction)("midnight/resync"),
139
+ restartWalletWatch: (0, _reduxjs_toolkit.createAction)("midnight/restartWalletWatch"),
140
+ restartAccountWatch: (0, _reduxjs_toolkit.createAction)("midnight/restartAccountWatch")
141
+ } };
142
+ //#endregion
143
+ //#region ../../packages/module/midnight-sync/src/store/prepare-midnight-tx.ts
144
+ const constructDustDesignationTransaction = ({ address, networkId, nightUtxos, nightVerifyingKey, ttl = new Date(Date.now() + require_const$1.defaultTxTtlLength), allowFeePayment }) => {
145
+ const parsedAddress = require_dist$1.MidnightBech32m.parse(address);
146
+ const receiverData = require_dist$1.DustAddress.codec.decode(networkId, parsedAddress).data;
147
+ const currentTime = /* @__PURE__ */ new Date();
148
+ const intent = _midnight_ntwrk_ledger_v8.Intent.new(ttl);
149
+ const totalNightValue = nightUtxos.map(({ utxo: { value } }) => require_bignum_vo.BigNumber.valueOf(value)).reduce((total, value) => total + value, 0n);
150
+ const inputs = nightUtxos.map(({ utxo }) => ({
151
+ ...utxo,
152
+ owner: nightVerifyingKey
153
+ }));
154
+ const outputs = inputs.map((input) => ({
155
+ owner: _midnight_ntwrk_ledger_v8.addressFromKey(nightVerifyingKey),
156
+ type: input.type,
157
+ value: input.value
158
+ }));
159
+ intent.guaranteedUnshieldedOffer = _midnight_ntwrk_ledger_v8.UnshieldedOffer.new(inputs, outputs, []);
160
+ const dustRegistration = new _midnight_ntwrk_ledger_v8.DustRegistration("signature", nightVerifyingKey, receiverData, allowFeePayment ?? totalNightValue);
161
+ intent.dustActions = new _midnight_ntwrk_ledger_v8.DustActions("signature", "pre-proof", currentTime, [], [dustRegistration]);
162
+ return _midnight_ntwrk_ledger_v8.Transaction.fromParts(networkId, void 0, void 0, intent);
163
+ };
164
+ const constructUnshieldedTransaction = ({ networkId, transfers, ttl = new Date(Date.now() + require_const$1.defaultTxTtlLength) }) => {
165
+ const intent = _midnight_ntwrk_ledger_v8.Intent.new(ttl);
166
+ const outputs = transfers.map(({ address, amount, tokenId }) => ({
167
+ value: amount,
168
+ owner: require_dist$1.UnshieldedAddress.codec.decode(networkId, require_dist$1.MidnightBech32m.parse(address)).data.toString("hex"),
169
+ type: tokenId
170
+ }));
171
+ intent.guaranteedUnshieldedOffer = _midnight_ntwrk_ledger_v8.UnshieldedOffer.new([], outputs, []);
172
+ return _midnight_ntwrk_ledger_v8.Transaction.fromParts(networkId, void 0, void 0, intent);
173
+ };
174
+ const constructShieldedTransaction = ({ networkId, transfers }) => {
175
+ const toOffer = ({ address, amount, tokenId }) => {
176
+ const decodedAddress = require_dist$1.ShieldedAddress.codec.decode(networkId, require_dist$1.MidnightBech32m.parse(address));
177
+ const output = _midnight_ntwrk_ledger_v8.ZswapOutput.new(_midnight_ntwrk_ledger_v8.createShieldedCoinInfo(tokenId, amount), 0, decodedAddress.coinPublicKey.toHexString(), decodedAddress.encryptionPublicKey.toHexString());
178
+ return _midnight_ntwrk_ledger_v8.ZswapOffer.fromOutput(output, tokenId, amount);
179
+ };
180
+ const [firstTransfer, ...remainingTransfers] = transfers;
181
+ if (!firstTransfer) throw new Error("At least one token transfer is required");
182
+ const offer = remainingTransfers.map(toOffer).reduce((merged, singleton) => merged.merge(singleton), toOffer(firstTransfer));
183
+ return _midnight_ntwrk_ledger_v8.Transaction.fromParts(networkId, offer);
184
+ };
185
+ /** Normalize token-state IDs and reject a batch before any engine operation. */
186
+ const normalizeMidnightTransfers = (networkId, kind, outputs) => {
187
+ if (kind !== "shielded" && kind !== "unshielded") throw new Error("Unsupported Midnight transfer kind");
188
+ if (outputs.length === 0) throw new Error("At least one token transfer is required");
189
+ return outputs.map(({ to, tokenId, amount }) => {
190
+ if (typeof amount !== "bigint" || amount <= 0n) throw new Error("Transfer amount must be a positive bigint");
191
+ const prefix = `unshielded-${networkId}`;
192
+ if (kind === "unshielded" && !tokenId.startsWith(prefix)) throw new Error("Unshielded token ID must match the transfer kind and network");
193
+ const raw = kind === "unshielded" ? require_utils.fromUnshieldedTokenType(tokenId, networkId) : tokenId;
194
+ if (!/^[0-9a-f]{64}$/.test(raw)) throw new Error("Invalid token ID or token-kind mismatch");
195
+ const parsed = require_dist$1.MidnightBech32m.parse(to);
196
+ if (kind === "shielded") require_dist$1.ShieldedAddress.codec.decode(networkId, parsed);
197
+ else require_dist$1.UnshieldedAddress.codec.decode(networkId, parsed);
198
+ return {
199
+ address: to,
200
+ tokenId: require_token_id_vo.TokenId(raw),
201
+ amount
202
+ };
203
+ });
204
+ };
205
+ /** Keep designation's zero-fee exception identical in headless and UI preparation. */
206
+ const estimatePreparedMidnightFee = (wallet, tx, { isDustDesignation, dustBalance, areKeysAvailable }) => {
207
+ if (isDustDesignation && dustBalance === 0n) return (0, rxjs.of)(0n);
208
+ return areKeysAvailable ? wallet.estimateTransactionFee(tx, { currentTime: /* @__PURE__ */ new Date() }) : wallet.calculateTransactionFee(tx);
209
+ };
210
+ //#endregion
211
+ //#region ../../packages/lib/vendor/src/temenos-attested-prover.ts
212
+ var TemenosAttestationError = class extends require_watch.AttestationError {
213
+ constructor(phase, checkId) {
214
+ super("temenos", phase === "obtain-evidence" ? "evidence" : phase === "fetch-expected-values" ? "policy" : phase === "bind-channel" ? "channel" : "appraisal", checkId ? `Temenos attestation failed: check "${checkId}" of phase "${phase}"` : `Temenos attestation failed at phase "${phase}"`);
215
+ this.phase = phase;
216
+ this.checkId = checkId;
217
+ this.name = "TemenosAttestationError";
218
+ }
219
+ };
220
+ /**
221
+ * `pointerContractAddress` is the one on-chain constant: the pointer's
222
+ * `current` cell names the attestation ledger, so a ledger redeploy is a
223
+ * pointer update, not a Lace release. All Temenos deployments register on the
224
+ * single preprod pointer, whatever network the proof server serves, so this
225
+ * stays on preprod on every network. The caller resolves the ledger
226
+ * indexer from Lace configuration at the start of each attestation run.
227
+ *
228
+ * `wardenTlsCertificate` is empty by design: a browser context cannot pin
229
+ * the transport certificate, so the Warden is reached over public WebPKI
230
+ * TLS — its verdict is defense-in-depth on top of the local checks, not a
231
+ * trust root.
232
+ */
233
+ const SHARED_TEMENOS_DEPLOYMENT = {
234
+ pointerContractAddress: "a58974f1cacda177edfea3bdc76c1cd48d5e3107b9a543b9d65cee6b454c9122",
235
+ wardenUrl: "https://warden.wastedp.io",
236
+ wardenTlsCertificate: ""
237
+ };
238
+ const TEMENOS_PREPROD_DEPLOYMENT = {
239
+ ...SHARED_TEMENOS_DEPLOYMENT,
240
+ proofServerApiUrl: "https://api.proofserver.wastedp.io",
241
+ attestationHost: "attestation.proofserver.wastedp.io",
242
+ akxServerUrl: "https://attestation.proofserver.wastedp.io/tee_attestation",
243
+ applicationId: "afe48970b7083e1b2855acce95a488e93a7c257a34f6275e77ac26f79ac7ad05"
244
+ };
245
+ /**
246
+ * Attestation parameters per network, matching `TEMENOS_PROOF_SERVER_MODES`
247
+ * entry for entry. Values are build-baked and reviewed like code; the
248
+ * persisted mode carries only the URL, so nothing here can be injected via
249
+ * feature-flag payloads.
250
+ */
251
+ const TEMENOS_ATTESTATION_CONFIGS = {
252
+ mainnet: {
253
+ ...SHARED_TEMENOS_DEPLOYMENT,
254
+ proofServerApiUrl: "https://api.proofserver.mainnet.wastedp.io",
255
+ attestationHost: "attestation.proofserver.mainnet.wastedp.io",
256
+ akxServerUrl: "https://attestation.proofserver.mainnet.wastedp.io/tee_attestation",
257
+ applicationId: "70402462424c122c65e2d3d2312757face3974940c9ac5d09249b61028350427"
258
+ },
259
+ preprod: TEMENOS_PREPROD_DEPLOYMENT,
260
+ preview: {
261
+ ...SHARED_TEMENOS_DEPLOYMENT,
262
+ proofServerApiUrl: "https://api.proofserver.preview.wastedp.io",
263
+ attestationHost: "attestation.proofserver.preview.wastedp.io",
264
+ akxServerUrl: "https://attestation.proofserver.preview.wastedp.io/tee_attestation",
265
+ applicationId: "b294b8879607f7d0f5cca3808a4b64aab7992de2a73d1e55dbafb091efca25f2"
266
+ }
267
+ };
268
+ for (const [networkId, mode] of Object.entries(require_const$1.TEMENOS_PROOF_SERVER_MODES)) {
269
+ if (!mode) continue;
270
+ if (TEMENOS_ATTESTATION_CONFIGS[networkId]?.proofServerApiUrl !== mode.url) throw new Error(`TEMENOS_PROOF_SERVER_MODES[${networkId}] ("${mode.url}") has no matching entry in TEMENOS_ATTESTATION_CONFIGS`);
271
+ }
272
+ /** temenos-spec phases 1–5 of the AKX flow, in execution order. */
273
+ const TEMENOS_ATTESTATION_PHASES = [
274
+ "obtain-evidence",
275
+ "fetch-expected-values",
276
+ "verify-locally",
277
+ "warden-verify",
278
+ "bind-channel"
279
+ ];
280
+ const PHASE_MAP = {
281
+ "obtain-evidence": "obtain-evidence",
282
+ "fetch-expected-values": "fetch-expected-values",
283
+ "verify-locally": "verify-locally",
284
+ "warden-verify": "warden-verify",
285
+ "bind-channel": "bind-channel"
286
+ };
287
+ /**
288
+ * `nonce-freshness` belongs to the library's SPKI-pin flow, which Lace never
289
+ * runs (the AKX evidence provider always yields epoch-key evidence) — it has
290
+ * no contract ID, so its events are dropped rather than mislabeled.
291
+ */
292
+ const mapCheckId = (id) => id === "nonce-freshness" ? void 0 : id;
293
+ const mapPhaseEvent = (event) => {
294
+ if (event.status === "check") {
295
+ const id = mapCheckId(event.check.id);
296
+ if (!id) return void 0;
297
+ return {
298
+ type: "check",
299
+ check: {
300
+ id,
301
+ status: event.check.status,
302
+ detail: event.check.detail
303
+ }
304
+ };
305
+ }
306
+ if (event.phase === "prove") return void 0;
307
+ const phase = PHASE_MAP[event.phase];
308
+ switch (event.status) {
309
+ case "started": return {
310
+ type: "phase",
311
+ phase,
312
+ status: "started"
313
+ };
314
+ case "completed": return {
315
+ type: "phase",
316
+ phase,
317
+ status: "completed",
318
+ ...event.detail === void 0 ? {} : { detail: event.detail }
319
+ };
320
+ case "failed": return {
321
+ type: "phase",
322
+ phase,
323
+ status: "failed",
324
+ detail: event.error.message
325
+ };
326
+ }
327
+ };
328
+ const toTemenosAttestationError = (error, fallbackPhase, { LocalCheckFailedError, AttestationVerificationError }) => {
329
+ const mapped = error instanceof LocalCheckFailedError ? new TemenosAttestationError("verify-locally", mapCheckId(error.checkId)) : error instanceof AttestationVerificationError ? new TemenosAttestationError(error.phase === "prove" ? fallbackPhase : PHASE_MAP[error.phase]) : new TemenosAttestationError(fallbackPhase);
330
+ mapped.cause = error;
331
+ return mapped;
332
+ };
333
+ /**
334
+ * `/prove` payloads travel as AEAD records tunneled through the AKX channel.
335
+ * The enclave proxy forwards to `/prove` only, so the session offers nothing
336
+ * else: the public API endpoint is never contacted from this flow.
337
+ */
338
+ const createTunneledSession = (session) => ({
339
+ prove: async (payload) => {
340
+ const response = await session.prove({ body: payload });
341
+ if (response.status !== 200) throw new Error(`Proof server returned ${response.status} through the attested channel`);
342
+ return response.body;
343
+ },
344
+ close: async () => session.close()
345
+ });
346
+ /**
347
+ * {@link createTemenosAttestedProver} with a deployment override that replaces
348
+ * the baked deployment and skips its proof-server URL match. No public entry
349
+ * re-exports it; only tests driving the verifier library's mock fixtures pass
350
+ * the override.
351
+ *
352
+ * @internal
353
+ */
354
+ const createTemenosAttestedProverWith = ({ networkId, proofServerApiUrl, trustRoots, getLedgerIndexerUrl, verifier }, testSeam) => {
355
+ const baked = TEMENOS_ATTESTATION_CONFIGS[networkId];
356
+ const deployment = testSeam?.config ?? (baked?.proofServerApiUrl === proofServerApiUrl ? baked : void 0);
357
+ if (!deployment) throw new Error(`No baked Temenos attestation config on ${networkId} for proof server "${proofServerApiUrl}"`);
358
+ if (!trustRoots?.amdRootCertificates?.length || trustRoots.amdRootCertificates.some((root) => root.trim().length === 0)) throw new require_watch.AttestationError("temenos", "policy", "Temenos requires explicit AMD trust roots");
359
+ const amdRootCertificates = [...trustRoots.amdRootCertificates];
360
+ return {
361
+ id: "temenos",
362
+ operations: ["prove"],
363
+ phases: TEMENOS_ATTESTATION_PHASES,
364
+ establishAttestedSession: async (onEvent) => {
365
+ const config = {
366
+ ...deployment,
367
+ amdRootCertificates,
368
+ indexerUrl: await getLedgerIndexerUrl()
369
+ };
370
+ const operationVerifier = verifier.createVerifier(config);
371
+ let currentPhase = "obtain-evidence";
372
+ try {
373
+ return createTunneledSession(await operationVerifier.establishVerifiedSession((event) => {
374
+ if (event.status === "started" && event.phase !== "prove") currentPhase = PHASE_MAP[event.phase];
375
+ const mapped = mapPhaseEvent(event);
376
+ if (mapped) onEvent(mapped);
377
+ }));
378
+ } catch (error) {
379
+ throw toTemenosAttestationError(error, currentPhase, verifier);
380
+ }
381
+ }
382
+ };
383
+ };
384
+ /**
385
+ * The real Temenos attestation driver: runs the verifier library's full
386
+ * pipeline — evidence from `GET /enclave-key`, expected values from the
387
+ * on-chain registration via the indexer, the nine local checks against
388
+ * explicitly supplied AMD roots, Warden verification, and the AKX
389
+ * attested-channel handshake — then hands back a session that tunnels
390
+ * through that channel. Trust-root sourcing is separate from this adapter.
391
+ * Only the deployment baked for `networkId` is accepted, and only
392
+ * when `proofServerApiUrl` names its proof server.
393
+ */
394
+ const createTemenosAttestedProver = (props) => createTemenosAttestedProverWith(props);
395
+ //#endregion
396
+ //#region ../../packages/module/midnight-sync/src/sdk.ts
397
+ const createMidnightSyncModule = (options) => require_store.inferModuleContext({
398
+ moduleName: require_sdk.ModuleName("midnight-sync"),
399
+ implements: require_store.combineContracts([
400
+ require_sdk.inMemoryIntegrationAddonContract,
401
+ require_sdk.tokensStoreContract,
402
+ require_sdk.syncStoreContract,
403
+ require_sdk.addressesStoreContract,
404
+ midnightContextStoreContract,
405
+ midnightDependencyContract,
406
+ midnightEngineAddonContract,
407
+ require_sdk.signerFactoryAddonContract
408
+ ]),
409
+ dependsOn: require_store.combineContracts([
410
+ require_sdk.activitiesStoreContract,
411
+ require_sdk.failuresStoreContract,
412
+ require_sdk.featureStoreContract,
413
+ require_sdk.networkStoreContract,
414
+ require_sdk.walletActiveStateDependencyContract,
415
+ require_sdk.walletRepoStoreContract
416
+ ]),
417
+ feature: {
418
+ willLoad: (featureFlags) => featureFlags.some((flag) => flag.key === require_watch.FEATURE_FLAG_MIDNIGHT),
419
+ metadata: {
420
+ name: "MidnightSync",
421
+ description: "Midnight engine, wallet lifecycle and signer"
422
+ }
423
+ },
424
+ store: require_store.inferStoreContext({
425
+ load: async () => {
426
+ const { createSdkStoreInit } = await Promise.resolve().then(() => require("./sdk-init-9TG1ZvHF.cjs"));
427
+ return { default: createSdkStoreInit(options) };
428
+ },
429
+ context: {
430
+ actions: midnightSyncActions,
431
+ selectors: {}
432
+ }
433
+ }),
434
+ addons: {
435
+ loadSignerFactory: async () => Promise.resolve().then(() => require("./signer-factory-B5oFuUZ-.cjs")),
436
+ loadMidnightEngine: async () => Promise.resolve().then(() => require("./midnight-engine-D5ikN_5F.cjs")),
437
+ loadInMemoryWalletIntegration: async () => Promise.resolve().then(() => require("./in-memory-wallet-integration-Bsl2ONua.cjs")).then((module) => ({ default: module.inMemoryWalletIntegrationReactNative }))
438
+ }
439
+ });
440
+ //#endregion
441
+ //#region src/midnight-module.ts
442
+ const publicEndpoints = (networkId) => ({
443
+ nodeAddress: `https://rpc.${networkId}.midnight.network`,
444
+ indexerAddress: `https://indexer.${networkId}.midnight.network/api/v4/graphql`
445
+ });
446
+ /**
447
+ * The public Midnight endpoints the SDK syncs through by default. Every other
448
+ * network needs its endpoints from `networks` before `selectMidnightNetwork`
449
+ * accepts it.
450
+ */
451
+ const MIDNIGHT_PUBLIC_ENDPOINTS = {
452
+ [require_const$1.MidnightSDKNetworkIds.MainNet]: publicEndpoints(require_const$1.MidnightSDKNetworkIds.MainNet),
453
+ [require_const$1.MidnightSDKNetworkIds.PreProd]: publicEndpoints(require_const$1.MidnightSDKNetworkIds.PreProd),
454
+ [require_const$1.MidnightSDKNetworkIds.Preview]: publicEndpoints(require_const$1.MidnightSDKNetworkIds.Preview),
455
+ [require_const$1.MidnightSDKNetworkIds.QaNet]: publicEndpoints(require_const$1.MidnightSDKNetworkIds.QaNet)
456
+ };
457
+ /** The public node of Midnight Preview. */
458
+ const MIDNIGHT_PREVIEW_NODE_URL = MIDNIGHT_PUBLIC_ENDPOINTS[require_const$1.MidnightSDKNetworkIds.Preview].nodeAddress;
459
+ /** The public indexer of Midnight Preview. */
460
+ const MIDNIGHT_PREVIEW_INDEXER_URL = MIDNIGHT_PUBLIC_ENDPOINTS[require_const$1.MidnightSDKNetworkIds.Preview].indexerAddress;
461
+ /** A proof server on the consumer's own machine, the default prover. */
462
+ const MIDNIGHT_LOCAL_PROOF_SERVER_URL = "http://localhost:6300";
463
+ const isPublicNetworkId = (networkId) => networkId in MIDNIGHT_PUBLIC_ENDPOINTS;
464
+ const passwordAuth = (password) => {
465
+ const owned = require_bytes_vo.ByteArray.clone(require_bytes_vo.ByteArray(password));
466
+ return {
467
+ authenticate: () => (0, rxjs.of)(true),
468
+ accessAuthSecret: (callback) => {
469
+ const clone = require_sdk.AuthSecret(require_bytes_vo.ByteArray.clone(owned));
470
+ return callback(clone).pipe((0, rxjs.tap)(() => clone.fill(0)), (0, rxjs.finalize)(() => clone.fill(0)));
471
+ }
472
+ };
473
+ };
474
+ const proofServerMode = (url) => {
475
+ const { hostname } = new URL(url);
476
+ return hostname === "localhost" || hostname === "127.0.0.1" ? {
477
+ kind: "local-host",
478
+ url
479
+ } : {
480
+ kind: "delegated",
481
+ url,
482
+ label: hostname
483
+ };
484
+ };
485
+ const defaultProofServers = (proofServerUrl, networks, createAttestedProver) => Object.fromEntries(require_const$1.MidnightSDKNetworkId.map((networkId) => {
486
+ const mode = networks[networkId]?.proofServer ?? proofServerMode(proofServerUrl);
487
+ require_const$1.assertProofServerRouting(mode, !!createAttestedProver);
488
+ return [networkId, mode];
489
+ }));
490
+ const networkOverrides = (networks) => Object.fromEntries(require_const$1.MidnightSDKNetworkId.map((networkId) => {
491
+ const { proofServer: _, ...endpoints } = networks[networkId] ?? {};
492
+ return [networkId, {
493
+ ...isPublicNetworkId(networkId) && MIDNIGHT_PUBLIC_ENDPOINTS[networkId],
494
+ ...endpoints
495
+ }];
496
+ }));
497
+ /** The networks whose overrides carry both endpoints; the contract defaults are not served. */
498
+ const supportedNetworkIds = (overrides) => require_const$1.MidnightSDKNetworkId.filter((networkId) => overrides[networkId]?.nodeAddress !== void 0 && overrides[networkId]?.indexerAddress !== void 0);
499
+ /**
500
+ * The Midnight engine for `createLaceWallet`: syncs every in-memory Midnight
501
+ * account on the active network, persists its state through the loaded
502
+ * storage module and signs with the password instead of a prompt. Loads
503
+ * behind `FEATURE_FLAG_MIDNIGHT`. The password is copied here, but the
504
+ * caller's buffer must stay intact until its last entity helper call that
505
+ * takes the same bytes.
506
+ *
507
+ * The `config` of `createLaceWallet` must then set
508
+ * `defaultMidnightTestnetNetworkId`, the testnet a wallet starts on, as
509
+ * Cardano needs `defaultTestnetChainId`; without a testnet there,
510
+ * `createLaceWallet` rejects.
511
+ */
512
+ const createMidnightModule = ({ password, proofServerUrl = MIDNIGHT_LOCAL_PROOF_SERVER_URL, networks = {}, batchUpdates, createAttestedProver }) => {
513
+ const overrides = networkOverrides(networks);
514
+ return createMidnightSyncModule({
515
+ auth: passwordAuth(password),
516
+ networks: overrides,
517
+ supportedNetworkIds: supportedNetworkIds(overrides),
518
+ defaultProofServers: defaultProofServers(proofServerUrl, networks, createAttestedProver),
519
+ batchUpdates,
520
+ createAttestedProver
521
+ });
522
+ };
523
+ //#endregion
524
+ //#region src/midnight-passkey-wallet-entity.ts
525
+ /**
526
+ * Derives the Midnight accounts of the passkey's words inside one assertion.
527
+ * Unlike the Cardano passkey entity, the result is an `InMemory` wallet: the
528
+ * Midnight engine needs the account keys while it syncs, so each account
529
+ * holds its keys sealed under `password`. The entity holds no recovery
530
+ * phrase and no seed, and no account of another blockchain.
531
+ */
532
+ const createMidnightPasskeyWalletEntity = async (wallet, { keySource, password, walletName, accounts = [] }) => keySource.withPasskeyMnemonic(async (words) => {
533
+ let entity = await require_sdk.createBlockchainWalletEntity(wallet, "Midnight", {
534
+ mnemonicWords: [...words],
535
+ password,
536
+ walletName
537
+ });
538
+ if (entity.accounts.length === 0) throw new Error("No Midnight account derived: load createMidnightModule behind FEATURE_FLAG_MIDNIGHT");
539
+ for (const account of accounts) entity = await createMidnightAccounts(wallet, {
540
+ ...account,
541
+ wallet: entity,
542
+ password
543
+ });
544
+ return withoutSeedMaterial(entity);
545
+ });
546
+ const withoutSeedMaterial = ({ encryptedRecoveryPhrase: _phrase, blockchainSpecific: { Midnight: _seed, ...blockchainSpecific }, ...entity }) => ({
547
+ ...entity,
548
+ blockchainSpecific
549
+ });
550
+ //#endregion
551
+ //#region src/midnight-errors.ts
552
+ /** The loadout has no endpoints for the network: none public, none from `networks`. */
553
+ var MidnightNetworkNotConfiguredError = class extends Error {
554
+ code = "midnight-network-not-configured";
555
+ constructor(networkId) {
556
+ super(`Midnight network "${networkId}" has no endpoints in this loadout: pass networks.${networkId} with nodeAddress and indexerAddress to createMidnightModule`);
557
+ this.name = "MidnightNetworkNotConfiguredError";
558
+ }
559
+ };
560
+ /** No single in-memory Midnight account on the active network answers the request. */
561
+ var MidnightAccountNotFoundError = class extends Error {
562
+ code = "midnight-account-not-found";
563
+ constructor(message) {
564
+ super(message);
565
+ this.name = "MidnightAccountNotFoundError";
566
+ }
567
+ };
568
+ /** The engine did not start the account's wallets within the wait. */
569
+ var MidnightWalletNotReadyError = class extends Error {
570
+ code = "midnight-wallet-not-ready";
571
+ constructor(accountId, timeoutMs) {
572
+ super(`Midnight wallet for account "${accountId}" did not start within ${timeoutMs}ms`);
573
+ this.name = "MidnightWalletNotReadyError";
574
+ }
575
+ };
576
+ /** The account holds no available NIGHT to register for DUST generation. */
577
+ var MidnightNothingToRegisterError = class extends Error {
578
+ code = "midnight-nothing-to-register";
579
+ constructor(accountId) {
580
+ super(`Account "${accountId}" has no available NIGHT to register`);
581
+ this.name = "MidnightNothingToRegisterError";
582
+ }
583
+ };
584
+ /**
585
+ * `submitMidnightTx` stopped waiting for the node to report the transaction final. The engine had already been
586
+ * given the transaction, so it may be on chain or reach it later: look for `activityHash` in the account's
587
+ * activities before submitting again.
588
+ */
589
+ var MidnightSubmitTimeoutError = class extends Error {
590
+ code = "midnight-submit-timeout";
591
+ /** The transaction's hash, which is the `activityId` of its activity. */
592
+ activityHash;
593
+ constructor(activityHash, timeoutMs) {
594
+ super(`Midnight transaction ${activityHash} was not reported final within ${timeoutMs}ms and may still reach the chain`);
595
+ this.name = "MidnightSubmitTimeoutError";
596
+ this.activityHash = activityHash;
597
+ }
598
+ };
599
+ //#endregion
600
+ //#region src/select-midnight-network.ts
601
+ /**
602
+ * Makes `networkId` the active Midnight network. A testnet also becomes the
603
+ * selected testnet, so the wallet's testnet toggle returns to it. Throws
604
+ * `MidnightNetworkNotConfiguredError` for a network the loadout has no
605
+ * endpoints for: one outside `MIDNIGHT_PUBLIC_ENDPOINTS` whose `networks`
606
+ * override lacks `nodeAddress` or `indexerAddress`.
607
+ */
608
+ const selectMidnightNetwork = (wallet, networkId) => {
609
+ if (!(wallet.getState().midnightContext?.supportedNetworksIds ?? []).includes(networkId)) throw new MidnightNetworkNotConfiguredError(networkId);
610
+ if (networkId === require_const$1.MidnightSDKNetworkIds.MainNet) {
611
+ wallet.dispatch("network.setNetworkType", "mainnet");
612
+ return;
613
+ }
614
+ wallet.dispatch("network.setBlockchainNetworks", {
615
+ blockchain: "Midnight",
616
+ mainnet: require_const$1.MidnightNetworkId(require_const$1.MidnightSDKNetworkIds.MainNet),
617
+ testnet: require_const$1.MidnightNetworkId(networkId)
618
+ });
619
+ wallet.dispatch("network.setNetworkType", "testnet");
620
+ };
621
+ //#endregion
622
+ //#region src/midnight-timeouts.ts
623
+ /** The longest delay a timer honours; a longer one, or `Infinity`, fires at once. */
624
+ const MAX_TIMEOUT_MS = 2 ** 31 - 1;
625
+ /**
626
+ * Applies a timeout option's default and refuses a value no timer can honour:
627
+ * not a finite positive number of milliseconds, or above `MAX_TIMEOUT_MS`.
628
+ */
629
+ const resolveTimeoutMs = (name, value, fallback) => {
630
+ const resolved = value ?? fallback;
631
+ if (typeof resolved !== "number" || !Number.isFinite(resolved) || resolved <= 0 || resolved > MAX_TIMEOUT_MS) throw new RangeError(`${name} must be a positive number of milliseconds up to ${MAX_TIMEOUT_MS}; got ${String(resolved)}`);
632
+ return resolved;
633
+ };
634
+ //#endregion
635
+ //#region src/midnight-wallet.ts
636
+ const DEFAULT_START_TIMEOUT_MS = 12e4;
637
+ const resolveMidnightAccountId = async ({ stateObservables }, requestedAccountId) => {
638
+ const wallets = await (0, rxjs.firstValueFrom)(stateObservables.wallets.selectAll$);
639
+ const activeNetworkIds = await (0, rxjs.firstValueFrom)(stateObservables.network.selectAllActiveNetworkIds$);
640
+ const accounts = wallets.flatMap((wallet) => wallet.accounts).filter(require_utils.isInMemoryMidnightAccount).filter((account) => activeNetworkIds.includes(account.blockchainNetworkId));
641
+ if (requestedAccountId) {
642
+ const found = accounts.find((account) => account.accountId === requestedAccountId);
643
+ if (!found) throw new MidnightAccountNotFoundError(`Midnight account "${requestedAccountId}" not found on the active network`);
644
+ return found.accountId;
645
+ }
646
+ if (accounts.length === 0) throw new MidnightAccountNotFoundError("No Midnight accounts found on the active network");
647
+ if (accounts.length > 1) throw new MidnightAccountNotFoundError(`Multiple Midnight accounts found (${accounts.length}) — specify accountId to disambiguate`);
648
+ return accounts[0].accountId;
649
+ };
650
+ /**
651
+ * The engine's wallet for the account, emitted once the engine starts it and
652
+ * again whenever the engine replaces it (a sync reset or a restart). Emits
653
+ * `undefined` while the engine has stopped the account's wallet and not yet
654
+ * replaced it. Resolves the account on subscription and errors with
655
+ * `MidnightAccountNotFoundError`, or with `MidnightWalletNotReadyError` when
656
+ * no wallet arrives within `startTimeout`, at first or after a stop, so a
657
+ * subscriber that was already watching fails the same way a new one would.
658
+ */
659
+ const observeMidnightWallet = (wallet, { accountId, startTimeout: requestedStartTimeout }) => (0, rxjs.defer)(async () => {
660
+ const startTimeout = resolveTimeoutMs("startTimeout", requestedStartTimeout, DEFAULT_START_TIMEOUT_MS);
661
+ const resolvedAccountId = await resolveMidnightAccountId(wallet, accountId);
662
+ const [registry$] = await wallet._loadModules("addons.loadMidnightEngine");
663
+ if (!registry$) throw new MidnightWalletNotReadyError(resolvedAccountId, startTimeout);
664
+ return {
665
+ resolvedAccountId,
666
+ registry$,
667
+ startTimeout
668
+ };
669
+ }).pipe((0, rxjs.switchMap)(({ resolvedAccountId, registry$, startTimeout }) => {
670
+ const notReady = () => (0, rxjs.throwError)(() => new MidnightWalletNotReadyError(resolvedAccountId, startTimeout));
671
+ return registry$.pipe((0, rxjs.map)((wallets) => wallets[resolvedAccountId]), (0, rxjs.distinctUntilChanged)(), (0, rxjs.skipWhile)((candidate) => !candidate), (0, rxjs.timeout)({
672
+ first: startTimeout,
673
+ with: notReady
674
+ }), (0, rxjs.switchMap)((candidate) => candidate ? (0, rxjs.of)(candidate) : (0, rxjs.concat)((0, rxjs.of)(void 0), (0, rxjs.timer)(startTimeout).pipe((0, rxjs.switchMap)(notReady)))));
675
+ }));
676
+ /** The engine's wallet for the account, once the engine has started it. */
677
+ const midnightWalletFor = async (wallet, props) => (0, rxjs.firstValueFrom)(observeMidnightWallet(wallet, props).pipe((0, rxjs.filter)((candidate) => !!candidate)));
678
+ const toError = (error) => error instanceof Error ? error : new Error(String(error));
679
+ /** Runs one engine operation for the account and settles it as a `Result`. */
680
+ const withMidnightWallet = async (wallet, props, operation) => {
681
+ try {
682
+ return require_asyncoption.Ok(await (0, rxjs.firstValueFrom)(operation(await midnightWalletFor(wallet, props))));
683
+ } catch (error) {
684
+ return require_asyncoption.Err(toError(error));
685
+ }
686
+ };
687
+ //#endregion
688
+ //#region src/observe-midnight-balances.ts
689
+ const sumNight = (coins) => coins.filter(({ utxo }) => utxo.type === require_const$1.NIGHT_TOKEN_ID).reduce((sum, { utxo }) => sum + utxo.value, 0n);
690
+ const sameBalances = (a, b) => a.address.unshielded === b.address.unshielded && a.night.available === b.night.available && a.night.pending === b.night.pending && a.dust.balance === b.dust.balance && a.dust.available === b.dust.available && a.synced.unshielded === b.synced.unshielded && a.synced.shielded === b.synced.shielded && a.synced.dust === b.synced.dust;
691
+ const NOT_SYNCED = {
692
+ unshielded: false,
693
+ shielded: false,
694
+ dust: false
695
+ };
696
+ const balancesOf = (midnightWallet) => (0, rxjs.combineLatest)([
697
+ midnightWallet.state(),
698
+ midnightWallet.syncProgress$,
699
+ midnightWallet.address$
700
+ ]).pipe((0, rxjs.map)(([state, progress, address]) => ({
701
+ accountId: midnightWallet.accountId,
702
+ address,
703
+ night: {
704
+ available: sumNight(state.unshielded.availableCoins),
705
+ pending: sumNight(state.unshielded.pendingCoins)
706
+ },
707
+ dust: require_watch.midnightDustBalances(state),
708
+ synced: progress.isStrictlyComplete
709
+ })));
710
+ /**
711
+ * The account's NIGHT and DUST, straight from the engine, from the moment
712
+ * it starts the account's wallets. Balances are complete once `synced`
713
+ * reports the sub-wallet caught up; a transfer needs unshielded and dust.
714
+ * NIGHT is summed from the engine's state, not from the store's token
715
+ * balances; DUST is summed as the store sums it.
716
+ *
717
+ * Follows the engine across a sync reset or restart. While the engine has
718
+ * stopped the account's wallets and not yet replaced them, it repeats the
719
+ * last balances with every `synced` flag false; once the new wallets start,
720
+ * it emits theirs.
721
+ *
722
+ * Cold: the account is resolved on subscription. Errors the subscriber with
723
+ * `MidnightAccountNotFoundError`, or with `MidnightWalletNotReadyError` when
724
+ * no wallets run for `startTimeout`, at first or after a stop.
725
+ */
726
+ const observeMidnightBalances = (wallet, props = {}) => observeMidnightWallet(wallet, props).pipe((0, rxjs.switchMap)((midnightWallet) => midnightWallet ? balancesOf(midnightWallet) : (0, rxjs.of)(void 0)), (0, rxjs.scan)((last, next) => next ?? (last && {
727
+ ...last,
728
+ synced: NOT_SYNCED
729
+ }), void 0), (0, rxjs.filter)((balances) => !!balances), (0, rxjs.distinctUntilChanged)(sameBalances));
730
+ //#endregion
731
+ //#region src/balance-midnight-recipe.ts
732
+ const messageOf = (error) => error instanceof Error ? error.message : String(error);
733
+ /**
734
+ * Releases a recipe the engine built, then rethrows the error that made it
735
+ * useless. The engine reserves a recipe's inputs when it builds it and the
736
+ * caller never receives this recipe, so nothing else could release them. If
737
+ * the release fails too, the error is an `AggregateError` of both failures and
738
+ * the coins stay reserved until a sync reset.
739
+ */
740
+ const releaseThenThrow = (midnightWallet, recipe, error) => (0, rxjs.concat)(midnightWallet.revert(recipe).pipe((0, rxjs.ignoreElements)(), (0, rxjs.catchError)((releaseError) => (0, rxjs.throwError)(() => new AggregateError([error, releaseError], `${messageOf(error)}; the coins it reserved could not be released: ${messageOf(releaseError)}`)))), (0, rxjs.throwError)(() => error));
741
+ /**
742
+ * Pays a built recipe's fee with DUST. The engine books the recipe's inputs
743
+ * when it builds it, so a failure here releases them before the error is
744
+ * returned: the caller has no recipe to discard.
745
+ */
746
+ const balanceMidnightRecipe = (midnightWallet, recipe, ttl) => midnightWallet.balanceUnprovenTransaction(recipe.transaction, {
747
+ ttl,
748
+ tokenKindsToBalance: ["dust"]
749
+ }).pipe((0, rxjs.catchError)((balancingError) => releaseThenThrow(midnightWallet, recipe, balancingError)));
750
+ //#endregion
751
+ //#region src/build-midnight-transfer.ts
752
+ /**
753
+ * Builds an unshielded NIGHT transfer, selecting the inputs and the DUST
754
+ * that pays its fee. The recipe is unsigned and unproven, and reserves its
755
+ * inputs (see `MidnightTxRecipe`): obtain consent from `estimateMidnightFee`,
756
+ * which reserves nothing, before building. When the fee cannot be paid, the
757
+ * inputs the build reserved are released and the balancing error is returned;
758
+ * if that release fails too, the error is an `AggregateError` of both failures
759
+ * and the NIGHT stays reserved until a sync reset.
760
+ */
761
+ const buildMidnightTransfer = async (wallet, { to, amount, ttl, ...account }) => withMidnightWallet(wallet, account, (midnightWallet) => (0, rxjs.defer)(() => {
762
+ normalizeMidnightTransfers(midnightWallet.networkId, "unshielded", [{
763
+ to,
764
+ amount,
765
+ tokenId: require_utils.toUnshieldedTokenType(require_const$1.NIGHT_TOKEN_ID, midnightWallet.networkId)
766
+ }]);
767
+ const resolvedTtl = ttl ?? new Date(Date.now() + 36e5);
768
+ return midnightWallet.transferTransaction([{
769
+ type: "unshielded",
770
+ outputs: [{
771
+ type: require_const$1.NIGHT_TOKEN_ID,
772
+ receiverAddress: require_dist$1.UnshieldedAddress.codec.decode(midnightWallet.networkId, require_dist$1.MidnightBech32m.parse(to)),
773
+ amount
774
+ }]
775
+ }], {
776
+ ttl: resolvedTtl,
777
+ payFees: false
778
+ }).pipe((0, rxjs.switchMap)((recipe) => balanceMidnightRecipe(midnightWallet, recipe, resolvedTtl)));
779
+ }));
780
+ //#endregion
781
+ //#region src/build-midnight-transfers.ts
782
+ /**
783
+ * Builds an unsigned, unproven batch. The engine selects tokens and fee DUST
784
+ * and reserves them (see `MidnightTxRecipe`): obtain consent from
785
+ * `estimateMidnightFee`, which reserves nothing, before building. When the
786
+ * fee cannot be paid, the inputs the build reserved are released and the
787
+ * balancing error is returned; if that release fails too, the error is an
788
+ * `AggregateError` of both failures and the coins stay reserved until a sync
789
+ * reset.
790
+ */
791
+ const buildMidnightTransfers = async (wallet, { kind, outputs, ttl, ...account }) => withMidnightWallet(wallet, account, (engine) => (0, rxjs.defer)(() => {
792
+ const transfers = normalizeMidnightTransfers(engine.networkId, kind, outputs);
793
+ const desiredOutputs = kind === "shielded" ? {
794
+ type: "shielded",
795
+ outputs: transfers.map(({ address, tokenId, amount }) => ({
796
+ type: tokenId,
797
+ amount,
798
+ receiverAddress: require_dist$1.ShieldedAddress.codec.decode(engine.networkId, require_dist$1.MidnightBech32m.parse(address))
799
+ }))
800
+ } : {
801
+ type: "unshielded",
802
+ outputs: transfers.map(({ address, tokenId, amount }) => ({
803
+ type: tokenId,
804
+ amount,
805
+ receiverAddress: require_dist$1.UnshieldedAddress.codec.decode(engine.networkId, require_dist$1.MidnightBech32m.parse(address))
806
+ }))
807
+ };
808
+ const resolvedTtl = ttl ?? new Date(Date.now() + 36e5);
809
+ return engine.transferTransaction([desiredOutputs], {
810
+ ttl: resolvedTtl,
811
+ payFees: false
812
+ }).pipe((0, rxjs.switchMap)((recipe) => balanceMidnightRecipe(engine, recipe, resolvedTtl)));
813
+ }));
814
+ //#endregion
815
+ //#region src/register-midnight-dust.ts
816
+ /**
817
+ * Whether the account already takes part in DUST generation: registered
818
+ * NIGHT, generated DUST, or generation capacity (the contract's
819
+ * `getDesignationTargetType` plus capacity). The engine does not report where
820
+ * registered NIGHT generates, so this covers a designation to the account's
821
+ * own address and to an external one alike.
822
+ */
823
+ const isDesignatedForDust = (state, nightCoins) => getDesignationTargetType(nightCoins.map(({ utxo, meta }) => ({
824
+ status: "available",
825
+ value: require_bignum_vo.BigNumber(utxo.value),
826
+ registeredForDustGeneration: meta.registeredForDustGeneration
827
+ })), state.dust.totalCoins.reduce((sum, coin) => sum + coin.generatedNow, 0n)) !== "none" || state.dust.totalCoins.some((coin) => coin.maxCap > 0n);
828
+ /** Internal unsigned selection shared with fee estimation. */
829
+ const prepareMidnightDustRegistration = (midnightWallet, { dustAddress: destination, ttl }) => (0, rxjs.combineLatest)([midnightWallet.state().pipe((0, rxjs.take)(1)), midnightWallet.address$.pipe((0, rxjs.take)(1))]).pipe((0, rxjs.map)(([state, address]) => {
830
+ if (ttl !== void 0) throw new Error("A DUST registration does not accept ttl: the engine sets its validity window");
831
+ const nightCoins = state.unshielded.availableCoins.filter(({ utxo }) => utxo.type === require_const$1.NIGHT_TOKEN_ID);
832
+ if (nightCoins.length === 0 || nightCoins.every(({ utxo }) => utxo.value <= 0n)) throw new MidnightNothingToRegisterError(midnightWallet.accountId);
833
+ const dustAddress = require_dist$1.DustAddress.codec.decode(midnightWallet.networkId, require_dist$1.MidnightBech32m.parse(destination ?? address.dust));
834
+ if (destination !== void 0 && isDesignatedForDust(state, nightCoins)) throw new Error("DUST destination cannot be changed while the account is designated for DUST generation");
835
+ return {
836
+ state,
837
+ nightCoins,
838
+ dustAddress,
839
+ destination: destination ?? address.dust,
840
+ isRepeatRegistration: nightCoins.some((coin) => coin.meta.registeredForDustGeneration)
841
+ };
842
+ }));
843
+ /**
844
+ * Registers every available NIGHT UTXO. Obtain consumer consent before
845
+ * calling: registration signs internally.
846
+ *
847
+ * - An explicit `dustAddress` is refused while the account is designated for
848
+ * DUST generation (registered NIGHT, generated DUST or generation capacity),
849
+ * so it never redirects an existing designation.
850
+ * - Without `dustAddress` the NIGHT is registered to the account's own DUST
851
+ * address, whatever it is registered to now. NIGHT registered to an external
852
+ * address is therefore re-registered to the account's own address. When some
853
+ * NIGHT is already registered, the registration is balanced with DUST.
854
+ *
855
+ * The returned recipe reserves the NIGHT it registers (see `MidnightTxRecipe`).
856
+ * When the registration cannot be built, the NIGHT it reserved is released
857
+ * and the build error is returned; if that release fails too, the error is an
858
+ * `AggregateError` of both failures, and the NIGHT stays reserved until a
859
+ * sync reset. The wallet library does not release it when the fee query of a
860
+ * first registration fails; it then also stays reserved until a sync reset.
861
+ */
862
+ const registerMidnightDust = async (wallet, { ttl, dustAddress: destination, ...account } = {}) => withMidnightWallet(wallet, account, (midnightWallet) => prepareMidnightDustRegistration(midnightWallet, {
863
+ dustAddress: destination,
864
+ ttl
865
+ }).pipe((0, rxjs.switchMap)(({ nightCoins, dustAddress, isRepeatRegistration }) => {
866
+ const registration$ = midnightWallet.registerNightUtxosForDustGeneration(nightCoins, dustAddress);
867
+ if (!isRepeatRegistration) return registration$;
868
+ return registration$.pipe((0, rxjs.switchMap)((registration) => balanceMidnightRecipe(midnightWallet, registration, new Date(Date.now() + require_const$1.defaultTxTtlLength))));
869
+ })));
870
+ //#endregion
871
+ //#region src/estimate-midnight-fee.ts
872
+ /**
873
+ * Estimates DUST from unsigned preparation, without registering or signing.
874
+ * A first registration with no spendable DUST estimates zero; a repeat
875
+ * registration is estimated like the DUST balancing it performs.
876
+ * Estimates depend on current state/time and are not guaranteed final charges.
877
+ * Insufficient spendable DUST returns an error.
878
+ */
879
+ const estimateMidnightFee = async (wallet, request) => {
880
+ return withMidnightWallet(wallet, request.kind === "transfer" ? request.transfer : request.registration, (engine) => (0, rxjs.defer)(() => {
881
+ return (0, rxjs.combineLatest)([request.kind === "transfer" ? engine.state().pipe((0, rxjs.take)(1), (0, rxjs.map)((state) => {
882
+ const { kind, outputs, ttl } = request.transfer;
883
+ const transfers = normalizeMidnightTransfers(engine.networkId, kind, outputs);
884
+ return {
885
+ state,
886
+ tx: (kind === "shielded" ? constructShieldedTransaction : constructUnshieldedTransaction)({
887
+ networkId: engine.networkId,
888
+ transfers,
889
+ ttl
890
+ }),
891
+ isFirstDesignation: false
892
+ };
893
+ })) : prepareMidnightDustRegistration(engine, request.registration).pipe((0, rxjs.map)(({ state, nightCoins, destination, isRepeatRegistration }) => ({
894
+ state,
895
+ tx: constructDustDesignationTransaction({
896
+ networkId: engine.networkId,
897
+ address: destination,
898
+ nightUtxos: nightCoins,
899
+ nightVerifyingKey: engine.nightVerifyingKey,
900
+ allowFeePayment: isRepeatRegistration ? 0n : void 0
901
+ }),
902
+ isFirstDesignation: !isRepeatRegistration
903
+ }))), engine.areKeysAvailable$.pipe((0, rxjs.take)(1))]).pipe((0, rxjs.switchMap)(([{ state, tx, isFirstDesignation }, areKeysAvailable]) => {
904
+ const availableDust = state.dust.balance(/* @__PURE__ */ new Date());
905
+ return estimatePreparedMidnightFee(engine, tx, {
906
+ isDustDesignation: isFirstDesignation,
907
+ dustBalance: availableDust,
908
+ areKeysAvailable
909
+ }).pipe((0, rxjs.map)((dustFee) => {
910
+ if (dustFee > availableDust) throw new Error("Insufficient spendable DUST");
911
+ return {
912
+ dustFee,
913
+ availableDust
914
+ };
915
+ }));
916
+ }));
917
+ }));
918
+ };
919
+ //#endregion
920
+ //#region ../../packages/lib/vendor/src/midnight-sign-data.ts
921
+ require__polyfill_buffer_patch.init__polyfill_buffer_patch();
922
+ /** Decode the connector transport form, preserving Buffer's permissive hex/base64 handling. */
923
+ const decodeMidnightSignData = (data, encoding) => {
924
+ switch (encoding) {
925
+ case "hex": return new Uint8Array(require__polyfill_buffer_patch.import_buffer.Buffer.from(data, "hex"));
926
+ case "base64": return new Uint8Array(require__polyfill_buffer_patch.import_buffer.Buffer.from(data, "base64"));
927
+ case "text": return new TextEncoder().encode(data);
928
+ default: throw new Error(`Unsupported encoding: ${String(encoding)}`);
929
+ }
930
+ };
931
+ const SIGNED_MESSAGE_PREFIX = "midnight_signed_message:";
932
+ /**
933
+ * Prefixes decoded payload bytes with UTF-8 `midnight_signed_message:<byteLength>:`.
934
+ * The length excludes the prefix; sign and verify these bytes, not the transport encoding.
935
+ */
936
+ const applyMidnightSignedMessagePrefix = (data) => {
937
+ const header = new TextEncoder().encode(`${SIGNED_MESSAGE_PREFIX}${data.length}:`);
938
+ const prefixed = new Uint8Array(header.length + data.length);
939
+ prefixed.set(header, 0);
940
+ prefixed.set(data, header.length);
941
+ return prefixed;
942
+ };
943
+ //#endregion
944
+ //#region src/sign-midnight-data.ts
945
+ /**
946
+ * Signs a connector-compatible message with the selected account's unshielded
947
+ * NIGHT key. Obtain consumer consent for this payload and account before calling;
948
+ * this helper shows no prompt and the module's password unlocks the key.
949
+ *
950
+ * Decodes hex/base64 with Buffer (including permissive malformed input), or text
951
+ * as UTF-8, then prefixes `midnight_signed_message:<byteLength>:`. Empty payloads
952
+ * still receive the prefix. Only the `unshielded` key type is supported.
953
+ * Returns the original payload, signature and verifying key. Account resolution,
954
+ * unsupported options and signing failures settle as `Err<Error>`.
955
+ */
956
+ const signMidnightData = async (wallet, { data, options, ...account }) => withMidnightWallet(wallet, account, (midnightWallet) => (0, rxjs.defer)(() => {
957
+ if (options.keyType !== "unshielded") throw new Error(`Unsupported key type: ${String(options.keyType)}`);
958
+ const bytes = applyMidnightSignedMessagePrefix(decodeMidnightSignData(data, options.encoding));
959
+ return midnightWallet.signData(bytes).pipe((0, rxjs.map)(({ signature, verifyingKey }) => ({
960
+ data,
961
+ signature,
962
+ verifyingKey
963
+ })));
964
+ }));
965
+ //#endregion
966
+ //#region src/discard-midnight-tx.ts
967
+ /**
968
+ * Releases the coins a built recipe holds, so they return to the account's
969
+ * available balance and a later build can select them.
970
+ *
971
+ * Discard only a recipe that never reached proving: consent declined,
972
+ * `signMidnightTx` failed, or `proveMidnightTx` returned
973
+ * `MidnightAccountNotFoundError`, `MidnightWalletNotReadyError` or a
974
+ * `RangeError` for its `proveTimeout`, which are raised before proving. Do
975
+ * not discard after any other `proveMidnightTx`
976
+ * error, including a timeout, nor after it returned a transaction: the engine
977
+ * releases a recipe whose proving fails, and releases a proved transaction
978
+ * that never reaches the chain once its validity window (`ttl`) has passed.
979
+ * Pass the `accountId` the recipe was built with: under another account the
980
+ * release finds no reserved coins and still reports `Ok`. The release works
981
+ * per coin, not per transaction, so discarding a recipe the engine has
982
+ * already released, or one built before a sync reset cleared its
983
+ * reservation, can free coins that a later build reserved
984
+ * for a transaction still in flight. For the same reason, never discard a
985
+ * recipe whose transaction was passed to `submitMidnightTx`.
986
+ */
987
+ const discardMidnightTx = async (wallet, { recipe, ...account }) => withMidnightWallet(wallet, account, (midnightWallet) => (0, rxjs.defer)(() => midnightWallet.revert(recipe)));
988
+ //#endregion
989
+ //#region src/sign-midnight-tx.ts
990
+ /**
991
+ * Signs the recipe's unshielded inputs with the account's NIGHT key. The
992
+ * module's password unlocks the key; no prompt is shown. Obtain consumer consent
993
+ * for the exact transaction and account before invoking this helper.
994
+ */
995
+ const signMidnightTx = async (wallet, { recipe, ...account }) => withMidnightWallet(wallet, account, (midnightWallet) => (0, rxjs.defer)(() => midnightWallet.signRecipe(recipe)));
996
+ //#endregion
997
+ //#region src/prove-midnight-tx.ts
998
+ /** How long every proving helper waits for the proof server unless told otherwise. */
999
+ const DEFAULT_PROVE_TIMEOUT_MS = 10 * 6e4;
1000
+ /** Applies the default `proveTimeout` and refuses a value no timer can honour. */
1001
+ const resolveProveTimeout = (proveTimeout) => resolveTimeoutMs("proveTimeout", proveTimeout, DEFAULT_PROVE_TIMEOUT_MS);
1002
+ /**
1003
+ * Proves the recipe through the proof server the module was configured
1004
+ * with. Timeout stops observation; it does not cancel underlying proving.
1005
+ */
1006
+ const proveMidnightTx = async (wallet, { recipe, onProgress, proveTimeout, ...account }) => withMidnightWallet(wallet, account, (midnightWallet) => {
1007
+ const limit = resolveProveTimeout(proveTimeout);
1008
+ let observer = onProgress;
1009
+ return (0, rxjs.defer)(() => onProgress ? midnightWallet.finalizeRecipe(recipe, (event) => observer?.(event)) : midnightWallet.finalizeRecipe(recipe)).pipe((0, rxjs.timeout)(limit), (0, rxjs.finalize)(() => {
1010
+ observer = void 0;
1011
+ }));
1012
+ });
1013
+ //#endregion
1014
+ //#region ../../packages/module/dapp-connector-midnight/src/store/helpers/derive-pending-activity-from-midnight-tx.ts
1015
+ const utxoKey = (intentHash, outputNo) => `${intentHash}#${outputNo}`;
1016
+ const processOffer = (offer, ownUtxoIndex, ownUserAddressHex) => {
1017
+ if (!offer) return {
1018
+ nightDelta: 0n,
1019
+ isInvolved: false
1020
+ };
1021
+ let nightDelta = 0n;
1022
+ let isInvolved = false;
1023
+ for (const input of offer.inputs) {
1024
+ const own = ownUtxoIndex.get(utxoKey(input.intentHash, input.outputNo));
1025
+ if (!own) continue;
1026
+ isInvolved = true;
1027
+ if (own.utxo.type === "0000000000000000000000000000000000000000000000000000000000000000") nightDelta -= own.utxo.value;
1028
+ }
1029
+ for (const output of offer.outputs) {
1030
+ if (output.owner !== ownUserAddressHex) continue;
1031
+ isInvolved = true;
1032
+ if (output.type === "0000000000000000000000000000000000000000000000000000000000000000") nightDelta += output.value;
1033
+ }
1034
+ return {
1035
+ nightDelta,
1036
+ isInvolved
1037
+ };
1038
+ };
1039
+ const buildOwnUtxoIndex = (nightUtxos) => {
1040
+ const index = /* @__PURE__ */ new Map();
1041
+ for (const entry of nightUtxos) index.set(utxoKey(entry.utxo.intentHash, entry.utxo.outputNo), entry);
1042
+ return index;
1043
+ };
1044
+ const derivePendingActivityFromMidnightTx = ({ deserializedTx, accountId, ownUserAddressHex, nightUtxos, networkId }) => {
1045
+ const ownUtxoIndex = buildOwnUtxoIndex(nightUtxos);
1046
+ let nightAmount = 0n;
1047
+ let isAccountInvolved = false;
1048
+ for (const intent of deserializedTx.intents?.values() ?? []) for (const offer of [intent.guaranteedUnshieldedOffer, intent.fallibleUnshieldedOffer]) {
1049
+ const { nightDelta, isInvolved } = processOffer(offer, ownUtxoIndex, ownUserAddressHex);
1050
+ nightAmount += nightDelta;
1051
+ isAccountInvolved = isAccountInvolved || isInvolved;
1052
+ }
1053
+ if (!isAccountInvolved) return void 0;
1054
+ const tokenBalanceChanges = nightAmount === 0n ? [] : [{
1055
+ tokenId: require_token_id_vo.TokenId(require_utils.toUnshieldedTokenType(require_const$1.NIGHT_TOKEN_ID, networkId)),
1056
+ amount: require_bignum_vo.BigNumber(nightAmount)
1057
+ }];
1058
+ return {
1059
+ accountId,
1060
+ activityId: deserializedTx.transactionHash(),
1061
+ timestamp: require_time_vo.Timestamp(Date.now()),
1062
+ tokenBalanceChanges,
1063
+ type: require_activity_type.ActivityType.Pending
1064
+ };
1065
+ };
1066
+ //#endregion
1067
+ //#region src/submit-midnight-tx.ts
1068
+ const DEFAULT_SUBMIT_TIMEOUT_MS = 5 * 6e4;
1069
+ const PENDING_ROW_STATE_TIMEOUT_MS = 1e4;
1070
+ /** Records the Pending activity unless the account already has a confirmed row for the transaction. */
1071
+ const recordPendingActivity = ({ dispatch, activities, midnightWallet, transaction, utxos }) => {
1072
+ try {
1073
+ const activity = derivePendingActivityFromMidnightTx({
1074
+ deserializedTx: transaction,
1075
+ accountId: midnightWallet.accountId,
1076
+ ownUserAddressHex: (0, _midnight_ntwrk_ledger_v8.addressFromKey)(midnightWallet.nightVerifyingKey),
1077
+ nightUtxos: utxos,
1078
+ networkId: midnightWallet.networkId
1079
+ });
1080
+ if (!activity) return void 0;
1081
+ const current = activities[activity.accountId]?.find((row) => row.activityId === activity.activityId);
1082
+ if (current && current.type !== require_activity_type.ActivityType.Pending) return void 0;
1083
+ dispatch("activities.upsertActivities", {
1084
+ accountId: activity.accountId,
1085
+ activities: [activity]
1086
+ });
1087
+ return activity;
1088
+ } catch {
1089
+ return;
1090
+ }
1091
+ };
1092
+ /**
1093
+ * Submits a proved transaction after consumer authorization and resolves once the node reports it final: the
1094
+ * engine submits at its `Finalized` stage, so `Ok` means the transaction is on chain. `txId` is the engine's
1095
+ * identifier, which is not the activity hash; the activity hash is `transaction.transactionHash()`.
1096
+ *
1097
+ * On an instance that tracks activities, the transaction's Pending activity, keyed by the activity hash, is
1098
+ * recorded when the submission is handed to the engine, before finality; the history sync then replaces it with
1099
+ * the confirmed row. The engine reports no acceptance before finality, so the row is written as soon as the call
1100
+ * is issued. When the engine fails the submission it releases the transaction's coins and the Pending row is
1101
+ * removed; if the transaction reaches the chain anyway, the history sync records it. Tracking failures never fail
1102
+ * a submission.
1103
+ *
1104
+ * An `Err` does not prove that nothing was broadcast. {@link MidnightSubmitTimeoutError} (`code`
1105
+ * `midnight-submit-timeout`) means the node did not report finality within `submitTimeout`: the transaction may
1106
+ * still reach the chain, and its Pending row stays. The SDK keeps listening to the engine's submission after the
1107
+ * timeout, for as long as that submission runs in this process: a failure it reports later removes the row, a
1108
+ * confirmation reaches the history sync. A row whose outcome this process never learns (it ends first) stays
1109
+ * until the history sync confirms it or the consumer removes it. The account-resolution errors
1110
+ * (`MidnightAccountNotFoundError`, `MidnightWalletNotReadyError`) precede the call and so precede any broadcast;
1111
+ * any other error is the engine's, and may also arrive after broadcast. Before retrying, check the account's
1112
+ * activities for the activity hash.
1113
+ */
1114
+ const submitMidnightTx = async (wallet, { transaction, submitTimeout: requestedSubmitTimeout, ...account }) => withMidnightWallet(wallet, account, (midnightWallet) => (0, rxjs.defer)(() => {
1115
+ const submitTimeout = resolveTimeoutMs("submitTimeout", requestedSubmitTimeout, DEFAULT_SUBMIT_TIMEOUT_MS);
1116
+ const { dispatch } = wallet;
1117
+ const activities$ = dispatch ? wallet.stateObservables.activities?.selectAllMap$ : void 0;
1118
+ const latestActivities$ = activities$ ? activities$.pipe((0, rxjs.startWith)(void 0), (0, rxjs.catchError)(() => (0, rxjs.of)(void 0))) : (0, rxjs.of)(void 0);
1119
+ const utxos$ = activities$ ? (0, rxjs.defer)(() => midnightWallet.state()).pipe((0, rxjs.take)(1), (0, rxjs.map)((state) => [...state.unshielded.availableCoins, ...state.unshielded.pendingCoins]), (0, rxjs.defaultIfEmpty)(void 0), (0, rxjs.catchError)(() => (0, rxjs.of)(void 0))) : (0, rxjs.of)(void 0);
1120
+ const removePendingRow = (pending) => {
1121
+ if (!dispatch || !activities$) return;
1122
+ activities$.pipe((0, rxjs.take)(1), (0, rxjs.catchError)(() => (0, rxjs.of)(void 0))).subscribe((latest) => {
1123
+ if ((latest?.[pending.accountId]?.find((row) => row.activityId === pending.activityId))?.type !== require_activity_type.ActivityType.Pending) return;
1124
+ try {
1125
+ dispatch("activities.removeActivities", {
1126
+ accountId: pending.accountId,
1127
+ activityIds: [pending.activityId]
1128
+ });
1129
+ } catch {}
1130
+ });
1131
+ };
1132
+ const settle = (finality$, pending) => {
1133
+ const outcome$ = finality$.pipe((0, rxjs.share)({
1134
+ connector: () => new rxjs.ReplaySubject(1),
1135
+ resetOnError: false,
1136
+ resetOnComplete: false
1137
+ }));
1138
+ if (pending) outcome$.subscribe({
1139
+ next: () => void 0,
1140
+ error: () => {
1141
+ removePendingRow(pending);
1142
+ }
1143
+ });
1144
+ return outcome$.pipe((0, rxjs.timeout)({
1145
+ first: submitTimeout,
1146
+ with: () => (0, rxjs.throwError)(() => new MidnightSubmitTimeoutError(transaction.transactionHash(), submitTimeout))
1147
+ }), (0, rxjs.map)((txId) => ({ txId })));
1148
+ };
1149
+ return utxos$.pipe((0, rxjs.timeout)({
1150
+ first: Math.min(PENDING_ROW_STATE_TIMEOUT_MS, submitTimeout),
1151
+ with: () => (0, rxjs.of)(void 0)
1152
+ }), (0, rxjs.switchMap)((utxos) => {
1153
+ const finality$ = midnightWallet.submitTransaction(transaction);
1154
+ return (0, rxjs.of)(utxos).pipe((0, rxjs.withLatestFrom)(latestActivities$), (0, rxjs.map)(([coins, activities]) => dispatch && activities && coins ? recordPendingActivity({
1155
+ dispatch,
1156
+ activities,
1157
+ midnightWallet,
1158
+ transaction,
1159
+ utxos: coins
1160
+ }) : void 0), (0, rxjs.switchMap)((pending) => settle(finality$, pending)));
1161
+ }));
1162
+ }));
1163
+ //#endregion
1164
+ //#region src/modules-midnight.ts
1165
+ var modules_midnight_exports = /* @__PURE__ */ require_chunk.__exportAll({
1166
+ featureDev: () => require_sdk.sdk_default$2,
1167
+ storageInMemory: () => require_sdk.sdk_default$1,
1168
+ storageWebIndexeddb: () => require_sdk.sdk_default
1169
+ });
1170
+ //#endregion
1171
+ //#region src/midnight-proving-provider.ts
1172
+ const withinTimeout = async (operation, milliseconds) => (0, rxjs.firstValueFrom)((0, rxjs.from)(operation).pipe((0, rxjs.timeout)(milliseconds)));
1173
+ /**
1174
+ * Captures one account identity and resolves its current engine on every use.
1175
+ * No proof-server URL or wallet keys are exposed. Factory failures are `Err`;
1176
+ * `check`/`prove` reject on transport or attestation failure without fallback,
1177
+ * and on timeout.
1178
+ * The consumer must authorize disclosure of the circuit preimage to the configured prover.
1179
+ */
1180
+ const getMidnightProvingProvider = async (wallet, { keyMaterialProvider, proveTimeout: requestedProveTimeout, ...selection }) => {
1181
+ try {
1182
+ const proveTimeout = resolveProveTimeout(requestedProveTimeout);
1183
+ const accountId = await resolveMidnightAccountId(wallet, selection.accountId);
1184
+ const account = {
1185
+ ...selection,
1186
+ accountId
1187
+ };
1188
+ await midnightWalletFor(wallet, account);
1189
+ const provider = require_watch.createProvingProviderFromTransport({
1190
+ check: async (payload) => (await midnightWalletFor(wallet, account)).proofServerTransport.check(payload),
1191
+ prove: async (payload) => (await midnightWalletFor(wallet, account)).proofServerTransport.prove(payload)
1192
+ }, keyMaterialProvider, { onKeyMaterialError: "propagate" });
1193
+ return require_asyncoption.Ok({
1194
+ check: async (serializedPreimage, keyLocation) => withinTimeout(provider.check(serializedPreimage, keyLocation), proveTimeout),
1195
+ prove: async (serializedPreimage, keyLocation, overwriteBindingInput) => withinTimeout(provider.prove(serializedPreimage, keyLocation, overwriteBindingInput), proveTimeout)
1196
+ });
1197
+ } catch (error) {
1198
+ return require_asyncoption.Err(error instanceof Error ? error : new Error(String(error)));
1199
+ }
1200
+ };
1201
+ //#endregion
1202
+ //#region ../../packages/lib/vendor/src/midnight-connector-transaction.ts
1203
+ require__polyfill_buffer_patch.init__polyfill_buffer_patch();
1204
+ /** Deserialize a hex-encoded, proven and bound connector transaction. */
1205
+ const deserializeMidnightSealedTransaction = async (tx) => _midnight_ntwrk_ledger_v8.Transaction.deserialize("signature", "proof", "binding", require__polyfill_buffer_patch.import_buffer.Buffer.from(tx, "hex"));
1206
+ /** Deserialize a hex-encoded, proven connector transaction that is not yet bound. */
1207
+ const deserializeMidnightUnsealedTransaction = async (tx) => _midnight_ntwrk_ledger_v8.Transaction.deserialize("signature", "proof", "pre-binding", require__polyfill_buffer_patch.import_buffer.Buffer.from(tx, "hex"));
1208
+ /**
1209
+ * Groups connector outputs into the wallet SDK's transfer shape, unshielded
1210
+ * first; a kind without outputs is omitted. Throws when a recipient is not a
1211
+ * Bech32m address of its kind on `networkId`.
1212
+ */
1213
+ const groupMidnightConnectorOutputs = (desiredOutputs, networkId) => {
1214
+ const unshielded = [];
1215
+ const shielded = [];
1216
+ for (const { kind, type, recipient, value } of desiredOutputs) {
1217
+ const parsedAddress = require_dist$1.MidnightBech32m.parse(recipient);
1218
+ if (kind === "unshielded") unshielded.push({
1219
+ type,
1220
+ receiverAddress: require_dist$1.UnshieldedAddress.codec.decode(networkId, parsedAddress),
1221
+ amount: value
1222
+ });
1223
+ if (kind === "shielded") shielded.push({
1224
+ type,
1225
+ receiverAddress: require_dist$1.ShieldedAddress.codec.decode(networkId, parsedAddress),
1226
+ amount: value
1227
+ });
1228
+ }
1229
+ const result = [];
1230
+ if (unshielded.length) result.push({
1231
+ type: "unshielded",
1232
+ outputs: unshielded
1233
+ });
1234
+ if (shielded.length) result.push({
1235
+ type: "shielded",
1236
+ outputs: shielded
1237
+ });
1238
+ return result;
1239
+ };
1240
+ /** Sums connector inputs per kind and token type into the wallet SDK's swap shape. */
1241
+ const groupMidnightConnectorInputs = (desiredInputs) => desiredInputs.reduce((inputs, { kind, type, value }) => {
1242
+ if (kind === "shielded" || kind === "unshielded") {
1243
+ const tokens = inputs[kind] ?? {};
1244
+ tokens[type] = (tokens[type] ?? 0n) + value;
1245
+ inputs[kind] = tokens;
1246
+ }
1247
+ return inputs;
1248
+ }, {});
1249
+ //#endregion
1250
+ //#region src/midnight-connector-transactions.ts
1251
+ const validateOptions = (options) => {
1252
+ if (options !== void 0 && (!options || typeof options !== "object" || Array.isArray(options) || options.payFees !== void 0 && typeof options.payFees !== "boolean")) throw new Error("Invalid Midnight fee options");
1253
+ };
1254
+ const validateTokens = (tokens) => {
1255
+ if (!Array.isArray(tokens)) throw new Error("Expected Midnight token array");
1256
+ for (const token of tokens) {
1257
+ if (!token || token.kind !== "shielded" && token.kind !== "unshielded") throw new Error("Unsupported Midnight token kind");
1258
+ if (typeof token.type !== "string" || !/^[\da-f]{64}$/i.test(token.type)) throw new Error("Expected a raw Midnight ledger token type");
1259
+ if (typeof token.value !== "bigint" || token.value < 0n) throw new Error("Expected a non-negative Midnight token value");
1260
+ }
1261
+ };
1262
+ const validateBalance = ({ tx, options }) => {
1263
+ validateOptions(options);
1264
+ if (typeof tx !== "string" || !/^(?:[\da-f]{2})+$/i.test(tx)) throw new Error("Expected a hexadecimal Midnight transaction");
1265
+ };
1266
+ const reservedBy = (recipe) => recipe.type === "UNPROVEN_TRANSACTION" ? recipe : recipe.balancingTransaction && {
1267
+ type: "UNPROVEN_TRANSACTION",
1268
+ transaction: recipe.balancingTransaction
1269
+ };
1270
+ const finalize = async (wallet, recipe, { sign, proveTimeout }) => {
1271
+ const reserved = reservedBy(recipe);
1272
+ const prepared = sign ? await (0, rxjs.firstValueFrom)(wallet.signRecipe(recipe).pipe((0, rxjs.catchError)((signingError) => reserved ? releaseThenThrow(wallet, reserved, signingError) : (0, rxjs.throwError)(() => signingError)))) : recipe;
1273
+ return (0, rxjs.firstValueFrom)(wallet.finalizeRecipe(prepared).pipe((0, rxjs.timeout)(proveTimeout)));
1274
+ };
1275
+ /**
1276
+ * Balances, signs and proves a binding transaction; never submits it.
1277
+ * Obtain consumer consent for the transaction, account and prover disclosure before calling.
1278
+ */
1279
+ const balanceMidnightSealedTransaction = async (wallet, props) => withMidnightWallet(wallet, props, (engine) => (0, rxjs.defer)(async () => {
1280
+ const proveTimeout = resolveProveTimeout(props.proveTimeout);
1281
+ validateBalance(props);
1282
+ const transaction = await deserializeMidnightSealedTransaction(props.tx);
1283
+ return finalize(engine, await (0, rxjs.firstValueFrom)(engine.balanceFinalizedTransaction(transaction, {
1284
+ ttl: new Date(Date.now() + require_const$1.defaultTxTtlLength),
1285
+ tokenKindsToBalance: props.options?.payFees === false ? ["shielded", "unshielded"] : void 0
1286
+ })), {
1287
+ sign: true,
1288
+ proveTimeout
1289
+ });
1290
+ }));
1291
+ /**
1292
+ * Balances, signs and proves a pre-binding transaction; never submits it.
1293
+ * Obtain consumer consent for the transaction, account and prover disclosure before calling.
1294
+ */
1295
+ const balanceMidnightUnsealedTransaction = async (wallet, props) => withMidnightWallet(wallet, props, (engine) => (0, rxjs.defer)(async () => {
1296
+ const proveTimeout = resolveProveTimeout(props.proveTimeout);
1297
+ validateBalance(props);
1298
+ const transaction = await deserializeMidnightUnsealedTransaction(props.tx);
1299
+ return finalize(engine, await (0, rxjs.firstValueFrom)(engine.balanceUnboundTransaction(transaction, {
1300
+ ttl: new Date(Date.now() + require_const$1.defaultTxTtlLength),
1301
+ tokenKindsToBalance: props.options?.payFees === false ? ["shielded", "unshielded"] : void 0
1302
+ })), {
1303
+ sign: true,
1304
+ proveTimeout
1305
+ });
1306
+ }));
1307
+ /**
1308
+ * Builds and proves connector transfers, including mixed token kinds; signs when unshielded outputs exist.
1309
+ * Obtain consumer consent before calling. Returns a native finalized transaction without submitting.
1310
+ * Fees default to enabled; use `buildMidnightTransfers` for separate homogeneous build/sign/prove stages.
1311
+ */
1312
+ const makeMidnightTransfer = async (wallet, props) => withMidnightWallet(wallet, props, (engine) => (0, rxjs.defer)(async () => {
1313
+ const proveTimeout = resolveProveTimeout(props.proveTimeout);
1314
+ validateOptions(props.options);
1315
+ validateTokens(props.desiredOutputs);
1316
+ const outputs = groupMidnightConnectorOutputs(props.desiredOutputs, engine.networkId);
1317
+ const ttl = new Date(Date.now() + require_const$1.defaultTxTtlLength);
1318
+ return finalize(engine, await (0, rxjs.firstValueFrom)(engine.transferTransaction(outputs, {
1319
+ ttl,
1320
+ payFees: false
1321
+ }).pipe((0, rxjs.switchMap)((built) => props.options?.payFees ?? true ? balanceMidnightRecipe(engine, built, ttl) : (0, rxjs.of)(built)))), {
1322
+ sign: outputs.some((output) => output.type === "unshielded"),
1323
+ proveTimeout
1324
+ });
1325
+ }));
1326
+ const assertOutputKindsHaveInputs = (inputs, outputs) => {
1327
+ const missing = outputs.map((output) => output.type).filter((kind) => inputs[kind] === void 0);
1328
+ if (missing.length > 0) throw new Error(`Midnight intent requests ${missing.join(" and ")} outputs without inputs of that kind, which the wallet library would drop`);
1329
+ };
1330
+ /**
1331
+ * Builds and proves an intent, signing when inputs or outputs include unshielded tokens.
1332
+ * Obtain consumer consent before calling. Never submits. `intentId` is accepted but ignored,
1333
+ * matching the existing connector; no intent ordering is guaranteed. Every output kind
1334
+ * needs an input of the same kind: the wallet library builds a leg from its inputs and
1335
+ * drops the outputs of a kind without any, so such a request is refused before anything
1336
+ * is reserved or signed. When the fee cannot be paid, the inputs the build reserved are
1337
+ * released and the balancing error is returned; if that release fails too, the error is
1338
+ * an `AggregateError` of both failures and the coins stay reserved until a sync reset.
1339
+ */
1340
+ const makeMidnightIntent = async (wallet, props) => withMidnightWallet(wallet, props, (engine) => (0, rxjs.defer)(async () => {
1341
+ const proveTimeout = resolveProveTimeout(props.proveTimeout);
1342
+ validateOptions(props.options);
1343
+ if (!props.options || typeof props.options.payFees !== "boolean" || props.options.intentId !== "random" && typeof props.options.intentId !== "number") throw new Error("Invalid Midnight intent options");
1344
+ validateTokens(props.desiredInputs);
1345
+ validateTokens(props.desiredOutputs);
1346
+ const inputs = groupMidnightConnectorInputs(props.desiredInputs);
1347
+ const outputs = groupMidnightConnectorOutputs(props.desiredOutputs, engine.networkId);
1348
+ assertOutputKindsHaveInputs(inputs, outputs);
1349
+ const ttl = new Date(Date.now() + require_const$1.defaultTxTtlLength);
1350
+ return finalize(engine, await (0, rxjs.firstValueFrom)(engine.initSwap(inputs, outputs, {
1351
+ ttl,
1352
+ payFees: false
1353
+ }).pipe((0, rxjs.switchMap)((built) => props.options.payFees ? balanceMidnightRecipe(engine, built, ttl) : (0, rxjs.of)(built)))), {
1354
+ sign: !!inputs.unshielded || outputs.some((output) => output.type === "unshielded"),
1355
+ proveTimeout
1356
+ });
1357
+ }));
1358
+ //#endregion
1359
+ exports.AccountId = require_account_id_vo.AccountId;
1360
+ exports.Err = require_asyncoption.Err;
1361
+ exports.FEATURE_FLAG_MIDNIGHT = require_watch.FEATURE_FLAG_MIDNIGHT;
1362
+ exports.FEATURE_FLAG_MIDNIGHT_UNSHIELDED = require_watch.FEATURE_FLAG_MIDNIGHT_UNSHIELDED;
1363
+ exports.FEATURE_FLAG_NETWORK_TYPE = require_const.FEATURE_FLAG_NETWORK_TYPE;
1364
+ exports.MIDNIGHT_LOCAL_PROOF_SERVER_URL = MIDNIGHT_LOCAL_PROOF_SERVER_URL;
1365
+ exports.MIDNIGHT_PREVIEW_INDEXER_URL = MIDNIGHT_PREVIEW_INDEXER_URL;
1366
+ exports.MIDNIGHT_PREVIEW_NODE_URL = MIDNIGHT_PREVIEW_NODE_URL;
1367
+ exports.MIDNIGHT_PUBLIC_ENDPOINTS = MIDNIGHT_PUBLIC_ENDPOINTS;
1368
+ exports.MidnightAccountId = require_midnight_account_id_vo.MidnightAccountId;
1369
+ exports.MidnightAccountNotFoundError = MidnightAccountNotFoundError;
1370
+ exports.MidnightNetworkId = require_const$1.MidnightNetworkId;
1371
+ exports.MidnightNetworkNotConfiguredError = MidnightNetworkNotConfiguredError;
1372
+ exports.MidnightNothingToRegisterError = MidnightNothingToRegisterError;
1373
+ exports.MidnightSDKNetworkIds = require_const$1.MidnightSDKNetworkIds;
1374
+ exports.MidnightSubmitTimeoutError = MidnightSubmitTimeoutError;
1375
+ exports.MidnightWalletNotReadyError = MidnightWalletNotReadyError;
1376
+ exports.NIGHT_TOKEN_ID = require_const$1.NIGHT_TOKEN_ID;
1377
+ exports.Ok = require_asyncoption.Ok;
1378
+ exports.WalletId = require_sdk.WalletId;
1379
+ exports.WalletType = require_sdk.WalletType;
1380
+ exports.balanceMidnightSealedTransaction = balanceMidnightSealedTransaction;
1381
+ exports.balanceMidnightUnsealedTransaction = balanceMidnightUnsealedTransaction;
1382
+ exports.buildMidnightTransfer = buildMidnightTransfer;
1383
+ exports.buildMidnightTransfers = buildMidnightTransfers;
1384
+ exports.createInMemoryWalletEntity = require_sdk.createInMemoryWalletEntity;
1385
+ exports.createLaceWallet = require_sdk.createLaceWallet;
1386
+ exports.createMidnightAccounts = createMidnightAccounts;
1387
+ exports.createMidnightModule = createMidnightModule;
1388
+ exports.createMidnightPasskeyWalletEntity = createMidnightPasskeyWalletEntity;
1389
+ exports.createPasskeyKeySource = require_key_source.createPasskeyKeySource;
1390
+ exports.createTemenosAttestedProver = createTemenosAttestedProver;
1391
+ exports.discardMidnightTx = discardMidnightTx;
1392
+ exports.estimateMidnightFee = estimateMidnightFee;
1393
+ exports.getMidnightProvingProvider = getMidnightProvingProvider;
1394
+ exports.isForbiddenTokenName = isForbiddenTokenName;
1395
+ exports.isTakenTokenName = isTakenTokenName;
1396
+ exports.isTokenFullNameValid = isTokenFullNameValid;
1397
+ exports.isTokenShortNameValid = isTokenShortNameValid;
1398
+ Object.defineProperty(exports, "m", {
1399
+ enumerable: true,
1400
+ get: function() {
1401
+ return modules_midnight_exports;
1402
+ }
1403
+ });
1404
+ exports.makeMidnightIntent = makeMidnightIntent;
1405
+ exports.makeMidnightTransfer = makeMidnightTransfer;
1406
+ exports.observeMidnightBalances = observeMidnightBalances;
1407
+ exports.proveMidnightTx = proveMidnightTx;
1408
+ exports.registerMidnightDust = registerMidnightDust;
1409
+ exports.selectMidnightNetwork = selectMidnightNetwork;
1410
+ exports.signMidnightData = signMidnightData;
1411
+ exports.signMidnightTx = signMidnightTx;
1412
+ exports.submitMidnightTx = submitMidnightTx;