@bsv/wallet-toolbox-client 2.1.24 → 3.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (588) hide show
  1. package/out/src/CWIStyleWalletManager.d.ts +33 -7
  2. package/out/src/CWIStyleWalletManager.d.ts.map +1 -1
  3. package/out/src/CWIStyleWalletManager.js +281 -313
  4. package/out/src/CWIStyleWalletManager.js.map +1 -1
  5. package/out/src/SetupClient.d.ts +6 -6
  6. package/out/src/SetupClient.d.ts.map +1 -1
  7. package/out/src/SetupClient.js +5 -5
  8. package/out/src/SetupClient.js.map +1 -1
  9. package/out/src/SetupWallet.d.ts.map +1 -1
  10. package/out/src/SimpleWalletManager.d.ts +12 -2
  11. package/out/src/SimpleWalletManager.d.ts.map +1 -1
  12. package/out/src/SimpleWalletManager.js +46 -30
  13. package/out/src/SimpleWalletManager.js.map +1 -1
  14. package/out/src/Wallet.d.ts +1 -1
  15. package/out/src/Wallet.d.ts.map +1 -1
  16. package/out/src/Wallet.js +102 -100
  17. package/out/src/Wallet.js.map +1 -1
  18. package/out/src/WalletAuthenticationManager.d.ts +1 -1
  19. package/out/src/WalletAuthenticationManager.d.ts.map +1 -1
  20. package/out/src/WalletAuthenticationManager.js +3 -3
  21. package/out/src/WalletAuthenticationManager.js.map +1 -1
  22. package/out/src/WalletLogger.d.ts.map +1 -1
  23. package/out/src/WalletLogger.js +16 -8
  24. package/out/src/WalletLogger.js.map +1 -1
  25. package/out/src/WalletPermissionsManager.d.ts +89 -18
  26. package/out/src/WalletPermissionsManager.d.ts.map +1 -1
  27. package/out/src/WalletPermissionsManager.js +656 -870
  28. package/out/src/WalletPermissionsManager.js.map +1 -1
  29. package/out/src/WalletSettingsManager.d.ts +2 -2
  30. package/out/src/WalletSettingsManager.d.ts.map +1 -1
  31. package/out/src/WalletSettingsManager.js.map +1 -1
  32. package/out/src/fundWalletP2PKH.d.ts +2 -2
  33. package/out/src/fundWalletP2PKH.d.ts.map +1 -1
  34. package/out/src/fundWalletP2PKH.js +11 -10
  35. package/out/src/fundWalletP2PKH.js.map +1 -1
  36. package/out/src/mockchain/MockChainMigrations.d.ts +3 -3
  37. package/out/src/mockchain/MockChainMigrations.d.ts.map +1 -1
  38. package/out/src/mockchain/MockChainMigrations.js.map +1 -1
  39. package/out/src/mockchain/MockChainStorage.d.ts.map +1 -1
  40. package/out/src/mockchain/MockChainStorage.js +5 -5
  41. package/out/src/mockchain/MockChainStorage.js.map +1 -1
  42. package/out/src/mockchain/MockChainTracker.d.ts.map +1 -1
  43. package/out/src/mockchain/MockChainTracker.js +10 -10
  44. package/out/src/mockchain/MockChainTracker.js.map +1 -1
  45. package/out/src/mockchain/MockMiner.d.ts.map +1 -1
  46. package/out/src/mockchain/MockMiner.js +3 -3
  47. package/out/src/mockchain/MockMiner.js.map +1 -1
  48. package/out/src/mockchain/MockServices.d.ts +9 -0
  49. package/out/src/mockchain/MockServices.d.ts.map +1 -1
  50. package/out/src/mockchain/MockServices.js +195 -238
  51. package/out/src/mockchain/MockServices.js.map +1 -1
  52. package/out/src/mockchain/merkleTree.d.ts.map +1 -1
  53. package/out/src/mockchain/merkleTree.js +21 -12
  54. package/out/src/mockchain/merkleTree.js.map +1 -1
  55. package/out/src/monitor/LeasedMonitorTask.d.ts +43 -0
  56. package/out/src/monitor/LeasedMonitorTask.d.ts.map +1 -0
  57. package/out/src/monitor/LeasedMonitorTask.js +89 -0
  58. package/out/src/monitor/LeasedMonitorTask.js.map +1 -0
  59. package/out/src/monitor/Monitor.d.ts +24 -0
  60. package/out/src/monitor/Monitor.d.ts.map +1 -1
  61. package/out/src/monitor/Monitor.js +63 -75
  62. package/out/src/monitor/Monitor.js.map +1 -1
  63. package/out/src/monitor/V7LeasedTask.d.ts +43 -0
  64. package/out/src/monitor/V7LeasedTask.d.ts.map +1 -0
  65. package/out/src/monitor/V7LeasedTask.js +89 -0
  66. package/out/src/monitor/V7LeasedTask.js.map +1 -0
  67. package/out/src/monitor/tasks/TaskArcSSE.d.ts +2 -2
  68. package/out/src/monitor/tasks/TaskArcSSE.d.ts.map +1 -1
  69. package/out/src/monitor/tasks/TaskArcSSE.js +10 -23
  70. package/out/src/monitor/tasks/TaskArcSSE.js.map +1 -1
  71. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts +4 -2
  72. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
  73. package/out/src/monitor/tasks/TaskCheckForProofs.js +83 -16
  74. package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -1
  75. package/out/src/monitor/tasks/TaskCheckNoSends.d.ts +1 -1
  76. package/out/src/monitor/tasks/TaskCheckNoSends.d.ts.map +1 -1
  77. package/out/src/monitor/tasks/TaskCheckNoSends.js +1 -2
  78. package/out/src/monitor/tasks/TaskCheckNoSends.js.map +1 -1
  79. package/out/src/monitor/tasks/TaskClock.d.ts +1 -1
  80. package/out/src/monitor/tasks/TaskClock.d.ts.map +1 -1
  81. package/out/src/monitor/tasks/TaskClock.js +0 -1
  82. package/out/src/monitor/tasks/TaskClock.js.map +1 -1
  83. package/out/src/monitor/tasks/TaskFailAbandoned.d.ts +1 -1
  84. package/out/src/monitor/tasks/TaskFailAbandoned.d.ts.map +1 -1
  85. package/out/src/monitor/tasks/TaskFailAbandoned.js.map +1 -1
  86. package/out/src/monitor/tasks/TaskMineBlock.d.ts +1 -1
  87. package/out/src/monitor/tasks/TaskMineBlock.d.ts.map +1 -1
  88. package/out/src/monitor/tasks/TaskMineBlock.js.map +1 -1
  89. package/out/src/monitor/tasks/TaskMonitorCallHistory.d.ts +1 -1
  90. package/out/src/monitor/tasks/TaskMonitorCallHistory.d.ts.map +1 -1
  91. package/out/src/monitor/tasks/TaskMonitorCallHistory.js +1 -1
  92. package/out/src/monitor/tasks/TaskMonitorCallHistory.js.map +1 -1
  93. package/out/src/monitor/tasks/TaskNewHeader.d.ts +2 -2
  94. package/out/src/monitor/tasks/TaskNewHeader.d.ts.map +1 -1
  95. package/out/src/monitor/tasks/TaskNewHeader.js +7 -5
  96. package/out/src/monitor/tasks/TaskNewHeader.js.map +1 -1
  97. package/out/src/monitor/tasks/TaskPurge.d.ts +1 -1
  98. package/out/src/monitor/tasks/TaskPurge.d.ts.map +1 -1
  99. package/out/src/monitor/tasks/TaskPurge.js.map +1 -1
  100. package/out/src/monitor/tasks/TaskReorg.d.ts +1 -1
  101. package/out/src/monitor/tasks/TaskReorg.d.ts.map +1 -1
  102. package/out/src/monitor/tasks/TaskReorg.js +2 -2
  103. package/out/src/monitor/tasks/TaskReorg.js.map +1 -1
  104. package/out/src/monitor/tasks/TaskReviewDoubleSpends.d.ts +1 -1
  105. package/out/src/monitor/tasks/TaskReviewDoubleSpends.d.ts.map +1 -1
  106. package/out/src/monitor/tasks/TaskReviewDoubleSpends.js +10 -10
  107. package/out/src/monitor/tasks/TaskReviewDoubleSpends.js.map +1 -1
  108. package/out/src/monitor/tasks/TaskReviewProvenTxs.d.ts +1 -1
  109. package/out/src/monitor/tasks/TaskReviewProvenTxs.d.ts.map +1 -1
  110. package/out/src/monitor/tasks/TaskReviewProvenTxs.js +2 -2
  111. package/out/src/monitor/tasks/TaskReviewProvenTxs.js.map +1 -1
  112. package/out/src/monitor/tasks/TaskReviewStatus.d.ts +1 -1
  113. package/out/src/monitor/tasks/TaskReviewStatus.d.ts.map +1 -1
  114. package/out/src/monitor/tasks/TaskReviewStatus.js.map +1 -1
  115. package/out/src/monitor/tasks/TaskReviewUtxos.d.ts +1 -1
  116. package/out/src/monitor/tasks/TaskReviewUtxos.d.ts.map +1 -1
  117. package/out/src/monitor/tasks/TaskReviewUtxos.js.map +1 -1
  118. package/out/src/monitor/tasks/TaskSendWaiting.d.ts +1 -1
  119. package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -1
  120. package/out/src/monitor/tasks/TaskSendWaiting.js +4 -5
  121. package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -1
  122. package/out/src/monitor/tasks/TaskUnFail.d.ts +1 -1
  123. package/out/src/monitor/tasks/TaskUnFail.d.ts.map +1 -1
  124. package/out/src/monitor/tasks/TaskUnFail.js +13 -15
  125. package/out/src/monitor/tasks/TaskUnFail.js.map +1 -1
  126. package/out/src/monitor/tasks/WalletMonitorTask.d.ts.map +1 -1
  127. package/out/src/monitor/tasks/WalletMonitorTask.js +3 -1
  128. package/out/src/monitor/tasks/WalletMonitorTask.js.map +1 -1
  129. package/out/src/sdk/CertOpsWallet.d.ts +3 -3
  130. package/out/src/sdk/CertOpsWallet.d.ts.map +1 -1
  131. package/out/src/sdk/PrivilegedKeyManager.d.ts +3 -3
  132. package/out/src/sdk/PrivilegedKeyManager.d.ts.map +1 -1
  133. package/out/src/sdk/PrivilegedKeyManager.js +26 -21
  134. package/out/src/sdk/PrivilegedKeyManager.js.map +1 -1
  135. package/out/src/sdk/WERR_errors.d.ts.map +1 -1
  136. package/out/src/sdk/WERR_errors.js +5 -5
  137. package/out/src/sdk/WERR_errors.js.map +1 -1
  138. package/out/src/sdk/WalletError.d.ts +1 -1
  139. package/out/src/sdk/WalletError.d.ts.map +1 -1
  140. package/out/src/sdk/WalletError.js +10 -3
  141. package/out/src/sdk/WalletError.js.map +1 -1
  142. package/out/src/sdk/WalletErrorFromJson.d.ts.map +1 -1
  143. package/out/src/sdk/WalletErrorFromJson.js +1 -3
  144. package/out/src/sdk/WalletErrorFromJson.js.map +1 -1
  145. package/out/src/sdk/WalletServices.interfaces.d.ts +19 -19
  146. package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -1
  147. package/out/src/sdk/WalletStorage.interfaces.d.ts +59 -59
  148. package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
  149. package/out/src/sdk/types.d.ts +36 -4
  150. package/out/src/sdk/types.d.ts.map +1 -1
  151. package/out/src/sdk/types.js +53 -4
  152. package/out/src/sdk/types.js.map +1 -1
  153. package/out/src/services/ServiceCollection.d.ts +6 -6
  154. package/out/src/services/ServiceCollection.d.ts.map +1 -1
  155. package/out/src/services/ServiceCollection.js +3 -4
  156. package/out/src/services/ServiceCollection.js.map +1 -1
  157. package/out/src/services/Services.d.ts +5 -0
  158. package/out/src/services/Services.d.ts.map +1 -1
  159. package/out/src/services/Services.js +174 -182
  160. package/out/src/services/Services.js.map +1 -1
  161. package/out/src/services/chaintracker/BHServiceClient.d.ts.map +1 -1
  162. package/out/src/services/chaintracker/BHServiceClient.js +7 -7
  163. package/out/src/services/chaintracker/BHServiceClient.js.map +1 -1
  164. package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts.map +1 -1
  165. package/out/src/services/chaintracker/ChaintracksChainTracker.js +5 -5
  166. package/out/src/services/chaintracker/ChaintracksChainTracker.js.map +1 -1
  167. package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.d.ts +5 -3
  168. package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.d.ts.map +1 -1
  169. package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.js.map +1 -1
  170. package/out/src/services/chaintracker/chaintracks/Api/BulkStorageApi.d.ts.map +1 -1
  171. package/out/src/services/chaintracker/chaintracks/Chaintracks.d.ts +20 -10
  172. package/out/src/services/chaintracker/chaintracks/Chaintracks.d.ts.map +1 -1
  173. package/out/src/services/chaintracker/chaintracks/Chaintracks.js +228 -221
  174. package/out/src/services/chaintracker/chaintracks/Chaintracks.js.map +1 -1
  175. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +1 -1
  176. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js +9 -10
  177. package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js.map +1 -1
  178. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.d.ts.map +1 -1
  179. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.js +1 -1
  180. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.js.map +1 -1
  181. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.d.ts +1 -2
  182. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.d.ts.map +1 -1
  183. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js +3 -3
  184. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js.map +1 -1
  185. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.d.ts.map +1 -1
  186. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.js.map +1 -1
  187. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.d.ts.map +1 -1
  188. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.js +3 -3
  189. package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.js.map +1 -1
  190. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.d.ts.map +1 -1
  191. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.js +1 -1
  192. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.js.map +1 -1
  193. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.d.ts.map +1 -1
  194. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js +2 -2
  195. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js.map +1 -1
  196. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.d.ts +2 -2
  197. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.d.ts.map +1 -1
  198. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js +6 -39
  199. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js.map +1 -1
  200. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.d.ts +3 -3
  201. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.d.ts.map +1 -1
  202. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.js +8 -6
  203. package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.js.map +1 -1
  204. package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.d.ts.map +1 -1
  205. package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.js +9 -16
  206. package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.js.map +1 -1
  207. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.d.ts.map +1 -1
  208. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js +34 -22
  209. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js.map +1 -1
  210. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.d.ts.map +1 -1
  211. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.js +31 -30
  212. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.js.map +1 -1
  213. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.d.ts +2 -2
  214. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.d.ts.map +1 -1
  215. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js +11 -10
  216. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js.map +1 -1
  217. package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.d.ts.map +1 -1
  218. package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.js.map +1 -1
  219. package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.d.ts.map +1 -1
  220. package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.js.map +1 -1
  221. package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.d.ts.map +1 -1
  222. package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.js.map +1 -1
  223. package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.d.ts.map +1 -1
  224. package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.js.map +1 -1
  225. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts +6 -1
  226. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts.map +1 -1
  227. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js +247 -227
  228. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js.map +1 -1
  229. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataReader.d.ts.map +1 -1
  230. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataReader.js +8 -7
  231. package/out/src/services/chaintracker/chaintracks/util/BulkFileDataReader.js.map +1 -1
  232. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.d.ts.map +1 -1
  233. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js +35 -25
  234. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js.map +1 -1
  235. package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.d.ts +5 -5
  236. package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.d.ts.map +1 -1
  237. package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.js +13 -11
  238. package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.js.map +1 -1
  239. package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts +0 -1
  240. package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts.map +1 -1
  241. package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.js.map +1 -1
  242. package/out/src/services/chaintracker/chaintracks/util/HeightRange.d.ts.map +1 -1
  243. package/out/src/services/chaintracker/chaintracks/util/HeightRange.js +21 -13
  244. package/out/src/services/chaintracker/chaintracks/util/HeightRange.js.map +1 -1
  245. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts +2 -2
  246. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts.map +1 -1
  247. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.js.map +1 -1
  248. package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts +1 -1
  249. package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts.map +1 -1
  250. package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js +28 -24
  251. package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js.map +1 -1
  252. package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.d.ts.map +1 -1
  253. package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.js.map +1 -1
  254. package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.d.ts.map +1 -1
  255. package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.js +9 -10
  256. package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.js.map +1 -1
  257. package/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -1
  258. package/out/src/services/createDefaultWalletServicesOptions.js +3 -3
  259. package/out/src/services/createDefaultWalletServicesOptions.js.map +1 -1
  260. package/out/src/services/providers/ARC.d.ts.map +1 -1
  261. package/out/src/services/providers/ARC.js +7 -14
  262. package/out/src/services/providers/ARC.js.map +1 -1
  263. package/out/src/services/providers/ArcSSEClient.d.ts.map +1 -1
  264. package/out/src/services/providers/ArcSSEClient.js +1 -1
  265. package/out/src/services/providers/ArcSSEClient.js.map +1 -1
  266. package/out/src/services/providers/Bitails.d.ts.map +1 -1
  267. package/out/src/services/providers/Bitails.js +17 -17
  268. package/out/src/services/providers/Bitails.js.map +1 -1
  269. package/out/src/services/providers/SdkWhatsOnChain.d.ts.map +1 -1
  270. package/out/src/services/providers/SdkWhatsOnChain.js.map +1 -1
  271. package/out/src/services/providers/WhatsOnChain.d.ts +2 -0
  272. package/out/src/services/providers/WhatsOnChain.d.ts.map +1 -1
  273. package/out/src/services/providers/WhatsOnChain.js +109 -233
  274. package/out/src/services/providers/WhatsOnChain.js.map +1 -1
  275. package/out/src/services/providers/exchangeRates.d.ts.map +1 -1
  276. package/out/src/services/providers/exchangeRates.js +3 -3
  277. package/out/src/services/providers/exchangeRates.js.map +1 -1
  278. package/out/src/services/providers/getBeefForTxid.d.ts +1 -1
  279. package/out/src/services/providers/getBeefForTxid.d.ts.map +1 -1
  280. package/out/src/services/providers/getBeefForTxid.js.map +1 -1
  281. package/out/src/services/providers/whatsOnChainHelpers.d.ts +68 -0
  282. package/out/src/services/providers/whatsOnChainHelpers.d.ts.map +1 -0
  283. package/out/src/services/providers/whatsOnChainHelpers.js +147 -0
  284. package/out/src/services/providers/whatsOnChainHelpers.js.map +1 -0
  285. package/out/src/signer/WalletSigner.d.ts.map +1 -1
  286. package/out/src/signer/WalletSigner.js.map +1 -1
  287. package/out/src/signer/methods/acquireDirectCertificate.js +1 -1
  288. package/out/src/signer/methods/acquireDirectCertificate.js.map +1 -1
  289. package/out/src/signer/methods/buildSignableTransaction.d.ts.map +1 -1
  290. package/out/src/signer/methods/buildSignableTransaction.js +21 -13
  291. package/out/src/signer/methods/buildSignableTransaction.js.map +1 -1
  292. package/out/src/signer/methods/completeSignedTransaction.d.ts.map +1 -1
  293. package/out/src/signer/methods/completeSignedTransaction.js +20 -21
  294. package/out/src/signer/methods/completeSignedTransaction.js.map +1 -1
  295. package/out/src/signer/methods/createAction.d.ts.map +1 -1
  296. package/out/src/signer/methods/createAction.js +8 -7
  297. package/out/src/signer/methods/createAction.js.map +1 -1
  298. package/out/src/signer/methods/internalizeAction.d.ts.map +1 -1
  299. package/out/src/signer/methods/internalizeAction.js +8 -6
  300. package/out/src/signer/methods/internalizeAction.js.map +1 -1
  301. package/out/src/signer/methods/proveCertificate.js +1 -1
  302. package/out/src/signer/methods/signAction.d.ts.map +1 -1
  303. package/out/src/signer/methods/signAction.js +8 -10
  304. package/out/src/signer/methods/signAction.js.map +1 -1
  305. package/out/src/storage/StorageIdb.d.ts +16 -1
  306. package/out/src/storage/StorageIdb.d.ts.map +1 -1
  307. package/out/src/storage/StorageIdb.js +544 -1224
  308. package/out/src/storage/StorageIdb.js.map +1 -1
  309. package/out/src/storage/StorageProvider.d.ts +124 -1
  310. package/out/src/storage/StorageProvider.d.ts.map +1 -1
  311. package/out/src/storage/StorageProvider.js +316 -186
  312. package/out/src/storage/StorageProvider.js.map +1 -1
  313. package/out/src/storage/StorageReader.d.ts.map +1 -1
  314. package/out/src/storage/StorageReader.js +8 -7
  315. package/out/src/storage/StorageReader.js.map +1 -1
  316. package/out/src/storage/StorageReaderWriter.d.ts.map +1 -1
  317. package/out/src/storage/StorageReaderWriter.js +32 -32
  318. package/out/src/storage/StorageReaderWriter.js.map +1 -1
  319. package/out/src/storage/StorageSyncReader.d.ts.map +1 -1
  320. package/out/src/storage/StorageSyncReader.js +3 -3
  321. package/out/src/storage/StorageSyncReader.js.map +1 -1
  322. package/out/src/storage/WalletStorageManager.d.ts +3 -0
  323. package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
  324. package/out/src/storage/WalletStorageManager.js +83 -73
  325. package/out/src/storage/WalletStorageManager.js.map +1 -1
  326. package/out/src/storage/idbHelpers.d.ts +47 -0
  327. package/out/src/storage/idbHelpers.d.ts.map +1 -0
  328. package/out/src/storage/idbHelpers.js +417 -0
  329. package/out/src/storage/idbHelpers.js.map +1 -0
  330. package/out/src/storage/methods/ListActionsSpecOp.d.ts +6 -1
  331. package/out/src/storage/methods/ListActionsSpecOp.d.ts.map +1 -1
  332. package/out/src/storage/methods/ListActionsSpecOp.js +28 -2
  333. package/out/src/storage/methods/ListActionsSpecOp.js.map +1 -1
  334. package/out/src/storage/methods/ListOutputsSpecOp.d.ts.map +1 -1
  335. package/out/src/storage/methods/ListOutputsSpecOp.js +8 -11
  336. package/out/src/storage/methods/ListOutputsSpecOp.js.map +1 -1
  337. package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +83 -0
  338. package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
  339. package/out/src/storage/methods/attemptToPostReqsToNetwork.js +338 -63
  340. package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
  341. package/out/src/storage/methods/createAction.d.ts.map +1 -1
  342. package/out/src/storage/methods/createAction.js +251 -274
  343. package/out/src/storage/methods/createAction.js.map +1 -1
  344. package/out/src/storage/methods/generateChange.d.ts.map +1 -1
  345. package/out/src/storage/methods/generateChange.js +99 -80
  346. package/out/src/storage/methods/generateChange.js.map +1 -1
  347. package/out/src/storage/methods/getBeefForTransaction.js +15 -13
  348. package/out/src/storage/methods/getBeefForTransaction.js.map +1 -1
  349. package/out/src/storage/methods/getSyncChunk.d.ts.map +1 -1
  350. package/out/src/storage/methods/getSyncChunk.js +4 -3
  351. package/out/src/storage/methods/getSyncChunk.js.map +1 -1
  352. package/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
  353. package/out/src/storage/methods/internalizeAction.js +213 -56
  354. package/out/src/storage/methods/internalizeAction.js.map +1 -1
  355. package/out/src/storage/methods/listActionsIdb.d.ts.map +1 -1
  356. package/out/src/storage/methods/listActionsIdb.js +85 -110
  357. package/out/src/storage/methods/listActionsIdb.js.map +1 -1
  358. package/out/src/storage/methods/listCertificates.d.ts +1 -1
  359. package/out/src/storage/methods/listCertificates.d.ts.map +1 -1
  360. package/out/src/storage/methods/listCertificates.js +7 -7
  361. package/out/src/storage/methods/listCertificates.js.map +1 -1
  362. package/out/src/storage/methods/listOutputsIdb.d.ts.map +1 -1
  363. package/out/src/storage/methods/listOutputsIdb.js +24 -27
  364. package/out/src/storage/methods/listOutputsIdb.js.map +1 -1
  365. package/out/src/storage/methods/offsetKey.d.ts +1 -1
  366. package/out/src/storage/methods/offsetKey.d.ts.map +1 -1
  367. package/out/src/storage/methods/offsetKey.js +3 -5
  368. package/out/src/storage/methods/offsetKey.js.map +1 -1
  369. package/out/src/storage/methods/processAction.d.ts +0 -11
  370. package/out/src/storage/methods/processAction.d.ts.map +1 -1
  371. package/out/src/storage/methods/processAction.js +168 -93
  372. package/out/src/storage/methods/processAction.js.map +1 -1
  373. package/out/src/storage/methods/purgeDataIdb.d.ts.map +1 -1
  374. package/out/src/storage/methods/purgeDataIdb.js +1 -1
  375. package/out/src/storage/methods/purgeDataIdb.js.map +1 -1
  376. package/out/src/storage/methods/reviewStatusIdb.d.ts +1 -1
  377. package/out/src/storage/methods/reviewStatusIdb.d.ts.map +1 -1
  378. package/out/src/storage/methods/reviewStatusIdb.js.map +1 -1
  379. package/out/src/storage/methods/utils.d.ts.map +1 -1
  380. package/out/src/storage/methods/utils.js +7 -1
  381. package/out/src/storage/methods/utils.js.map +1 -1
  382. package/out/src/storage/remoting/StorageClient.d.ts +4 -270
  383. package/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
  384. package/out/src/storage/remoting/StorageClient.js +16 -423
  385. package/out/src/storage/remoting/StorageClient.js.map +1 -1
  386. package/out/src/storage/remoting/StorageClientBase.d.ts +289 -0
  387. package/out/src/storage/remoting/StorageClientBase.d.ts.map +1 -0
  388. package/out/src/storage/remoting/StorageClientBase.js +375 -0
  389. package/out/src/storage/remoting/StorageClientBase.js.map +1 -0
  390. package/out/src/storage/remoting/entityValidationHelpers.d.ts +29 -0
  391. package/out/src/storage/remoting/entityValidationHelpers.d.ts.map +1 -0
  392. package/out/src/storage/remoting/entityValidationHelpers.js +91 -0
  393. package/out/src/storage/remoting/entityValidationHelpers.js.map +1 -0
  394. package/out/src/storage/schema/StorageIdbSchema.d.ts +43 -2
  395. package/out/src/storage/schema/StorageIdbSchema.d.ts.map +1 -1
  396. package/out/src/storage/schema/entities/EntityBase.d.ts.map +1 -1
  397. package/out/src/storage/schema/entities/EntityBase.js.map +1 -1
  398. package/out/src/storage/schema/entities/EntityCertificate.d.ts.map +1 -1
  399. package/out/src/storage/schema/entities/EntityCertificate.js +5 -4
  400. package/out/src/storage/schema/entities/EntityCertificate.js.map +1 -1
  401. package/out/src/storage/schema/entities/EntityCertificateField.d.ts.map +1 -1
  402. package/out/src/storage/schema/entities/EntityCertificateField.js +5 -7
  403. package/out/src/storage/schema/entities/EntityCertificateField.js.map +1 -1
  404. package/out/src/storage/schema/entities/EntityCommission.d.ts.map +1 -1
  405. package/out/src/storage/schema/entities/EntityCommission.js +6 -8
  406. package/out/src/storage/schema/entities/EntityCommission.js.map +1 -1
  407. package/out/src/storage/schema/entities/EntityOutput.d.ts.map +1 -1
  408. package/out/src/storage/schema/entities/EntityOutput.js +21 -24
  409. package/out/src/storage/schema/entities/EntityOutput.js.map +1 -1
  410. package/out/src/storage/schema/entities/EntityOutputBasket.d.ts.map +1 -1
  411. package/out/src/storage/schema/entities/EntityOutputBasket.js +6 -6
  412. package/out/src/storage/schema/entities/EntityOutputBasket.js.map +1 -1
  413. package/out/src/storage/schema/entities/EntityOutputTag.d.ts.map +1 -1
  414. package/out/src/storage/schema/entities/EntityOutputTag.js +2 -2
  415. package/out/src/storage/schema/entities/EntityOutputTag.js.map +1 -1
  416. package/out/src/storage/schema/entities/EntityOutputTagMap.d.ts.map +1 -1
  417. package/out/src/storage/schema/entities/EntityOutputTagMap.js +4 -6
  418. package/out/src/storage/schema/entities/EntityOutputTagMap.js.map +1 -1
  419. package/out/src/storage/schema/entities/EntityProvenTx.d.ts +3 -3
  420. package/out/src/storage/schema/entities/EntityProvenTx.d.ts.map +1 -1
  421. package/out/src/storage/schema/entities/EntityProvenTx.js +22 -23
  422. package/out/src/storage/schema/entities/EntityProvenTx.js.map +1 -1
  423. package/out/src/storage/schema/entities/EntityProvenTxReq.d.ts +9 -0
  424. package/out/src/storage/schema/entities/EntityProvenTxReq.d.ts.map +1 -1
  425. package/out/src/storage/schema/entities/EntityProvenTxReq.js +116 -68
  426. package/out/src/storage/schema/entities/EntityProvenTxReq.js.map +1 -1
  427. package/out/src/storage/schema/entities/EntitySyncState.d.ts.map +1 -1
  428. package/out/src/storage/schema/entities/EntitySyncState.js +19 -18
  429. package/out/src/storage/schema/entities/EntitySyncState.js.map +1 -1
  430. package/out/src/storage/schema/entities/EntityTransaction.d.ts.map +1 -1
  431. package/out/src/storage/schema/entities/EntityTransaction.js +25 -26
  432. package/out/src/storage/schema/entities/EntityTransaction.js.map +1 -1
  433. package/out/src/storage/schema/entities/EntityTxLabel.d.ts.map +1 -1
  434. package/out/src/storage/schema/entities/EntityTxLabel.js +2 -2
  435. package/out/src/storage/schema/entities/EntityTxLabel.js.map +1 -1
  436. package/out/src/storage/schema/entities/EntityTxLabelMap.d.ts.map +1 -1
  437. package/out/src/storage/schema/entities/EntityTxLabelMap.js +4 -6
  438. package/out/src/storage/schema/entities/EntityTxLabelMap.js.map +1 -1
  439. package/out/src/storage/schema/entities/EntityUser.d.ts.map +1 -1
  440. package/out/src/storage/schema/entities/EntityUser.js +3 -3
  441. package/out/src/storage/schema/entities/EntityUser.js.map +1 -1
  442. package/out/src/storage/schema/entities/MergeEntity.d.ts.map +1 -1
  443. package/out/src/storage/schema/entities/MergeEntity.js +6 -6
  444. package/out/src/storage/schema/entities/MergeEntity.js.map +1 -1
  445. package/out/src/storage/schema/monitorLease.d.ts +57 -0
  446. package/out/src/storage/schema/monitorLease.d.ts.map +1 -0
  447. package/out/src/storage/schema/monitorLease.js +101 -0
  448. package/out/src/storage/schema/monitorLease.js.map +1 -0
  449. package/out/src/storage/schema/processingFsm.d.ts +27 -0
  450. package/out/src/storage/schema/processingFsm.d.ts.map +1 -0
  451. package/out/src/storage/schema/processingFsm.js +132 -0
  452. package/out/src/storage/schema/processingFsm.js.map +1 -0
  453. package/out/src/storage/schema/tables/TableAction.d.ts +38 -0
  454. package/out/src/storage/schema/tables/TableAction.d.ts.map +1 -0
  455. package/out/src/storage/schema/tables/TableAction.js +3 -0
  456. package/out/src/storage/schema/tables/TableAction.js.map +1 -0
  457. package/out/src/storage/schema/tables/TableCertificate.d.ts +2 -1
  458. package/out/src/storage/schema/tables/TableCertificate.d.ts.map +1 -1
  459. package/out/src/storage/schema/tables/TableCertificateField.d.ts +1 -1
  460. package/out/src/storage/schema/tables/TableCertificateField.d.ts.map +1 -1
  461. package/out/src/storage/schema/tables/TableChainTip.d.ts +17 -0
  462. package/out/src/storage/schema/tables/TableChainTip.d.ts.map +1 -0
  463. package/out/src/storage/schema/tables/TableChainTip.js +3 -0
  464. package/out/src/storage/schema/tables/TableChainTip.js.map +1 -0
  465. package/out/src/storage/schema/tables/TableCommission.d.ts +1 -1
  466. package/out/src/storage/schema/tables/TableCommission.d.ts.map +1 -1
  467. package/out/src/storage/schema/tables/TableMonitorEvent.d.ts +1 -1
  468. package/out/src/storage/schema/tables/TableMonitorEvent.d.ts.map +1 -1
  469. package/out/src/storage/schema/tables/TableMonitorLease.d.ts +23 -0
  470. package/out/src/storage/schema/tables/TableMonitorLease.d.ts.map +1 -0
  471. package/out/src/storage/schema/tables/TableMonitorLease.js +3 -0
  472. package/out/src/storage/schema/tables/TableMonitorLease.js.map +1 -0
  473. package/out/src/storage/schema/tables/TableOutput.d.ts +10 -2
  474. package/out/src/storage/schema/tables/TableOutput.d.ts.map +1 -1
  475. package/out/src/storage/schema/tables/TableOutput.js +1 -1
  476. package/out/src/storage/schema/tables/TableOutput.js.map +1 -1
  477. package/out/src/storage/schema/tables/TableOutputBasket.d.ts +1 -1
  478. package/out/src/storage/schema/tables/TableOutputBasket.d.ts.map +1 -1
  479. package/out/src/storage/schema/tables/TableOutputTag.d.ts +1 -1
  480. package/out/src/storage/schema/tables/TableOutputTag.d.ts.map +1 -1
  481. package/out/src/storage/schema/tables/TableOutputTagMap.d.ts +1 -1
  482. package/out/src/storage/schema/tables/TableOutputTagMap.d.ts.map +1 -1
  483. package/out/src/storage/schema/tables/TableProvenTx.d.ts +1 -1
  484. package/out/src/storage/schema/tables/TableProvenTx.d.ts.map +1 -1
  485. package/out/src/storage/schema/tables/TableProvenTxReq.d.ts +24 -1
  486. package/out/src/storage/schema/tables/TableProvenTxReq.d.ts.map +1 -1
  487. package/out/src/storage/schema/tables/TableSettings.d.ts +1 -1
  488. package/out/src/storage/schema/tables/TableSettings.d.ts.map +1 -1
  489. package/out/src/storage/schema/tables/TableSyncState.d.ts +1 -1
  490. package/out/src/storage/schema/tables/TableSyncState.d.ts.map +1 -1
  491. package/out/src/storage/schema/tables/TableTransaction.d.ts +1 -1
  492. package/out/src/storage/schema/tables/TableTransaction.d.ts.map +1 -1
  493. package/out/src/storage/schema/tables/TableTransactionNew.d.ts +50 -0
  494. package/out/src/storage/schema/tables/TableTransactionNew.d.ts.map +1 -0
  495. package/out/src/storage/schema/tables/TableTransactionNew.js +3 -0
  496. package/out/src/storage/schema/tables/TableTransactionNew.js.map +1 -0
  497. package/out/src/storage/schema/tables/TableTransactionV7.d.ts +50 -0
  498. package/out/src/storage/schema/tables/TableTransactionV7.d.ts.map +1 -0
  499. package/out/src/storage/schema/tables/TableTransactionV7.js +3 -0
  500. package/out/src/storage/schema/tables/TableTransactionV7.js.map +1 -0
  501. package/out/src/storage/schema/tables/TableTxAudit.d.ts +26 -0
  502. package/out/src/storage/schema/tables/TableTxAudit.d.ts.map +1 -0
  503. package/out/src/storage/schema/tables/TableTxAudit.js +3 -0
  504. package/out/src/storage/schema/tables/TableTxAudit.js.map +1 -0
  505. package/out/src/storage/schema/tables/TableTxLabel.d.ts +1 -1
  506. package/out/src/storage/schema/tables/TableTxLabel.d.ts.map +1 -1
  507. package/out/src/storage/schema/tables/TableTxLabelMap.d.ts +1 -1
  508. package/out/src/storage/schema/tables/TableTxLabelMap.d.ts.map +1 -1
  509. package/out/src/storage/schema/tables/TableUser.d.ts +1 -1
  510. package/out/src/storage/schema/tables/TableUser.d.ts.map +1 -1
  511. package/out/src/storage/schema/tables/index.d.ts +5 -0
  512. package/out/src/storage/schema/tables/index.d.ts.map +1 -1
  513. package/out/src/storage/schema/tables/index.js +5 -0
  514. package/out/src/storage/schema/tables/index.js.map +1 -1
  515. package/out/src/storage/schema/transactionCrud.d.ts +41 -0
  516. package/out/src/storage/schema/transactionCrud.d.ts.map +1 -0
  517. package/out/src/storage/schema/transactionCrud.js +205 -0
  518. package/out/src/storage/schema/transactionCrud.js.map +1 -0
  519. package/out/src/storage/schema/transactionService.d.ts +315 -0
  520. package/out/src/storage/schema/transactionService.d.ts.map +1 -0
  521. package/out/src/storage/schema/transactionService.js +783 -0
  522. package/out/src/storage/schema/transactionService.js.map +1 -0
  523. package/out/src/storage/schema/txAudit.d.ts +33 -0
  524. package/out/src/storage/schema/txAudit.d.ts.map +1 -0
  525. package/out/src/storage/schema/txAudit.js +64 -0
  526. package/out/src/storage/schema/txAudit.js.map +1 -0
  527. package/out/src/storage/schema/v7Crud.d.ts +41 -0
  528. package/out/src/storage/schema/v7Crud.d.ts.map +1 -0
  529. package/out/src/storage/schema/v7Crud.js +205 -0
  530. package/out/src/storage/schema/v7Crud.js.map +1 -0
  531. package/out/src/storage/schema/v7Fsm.d.ts +27 -0
  532. package/out/src/storage/schema/v7Fsm.d.ts.map +1 -0
  533. package/out/src/storage/schema/v7Fsm.js +124 -0
  534. package/out/src/storage/schema/v7Fsm.js.map +1 -0
  535. package/out/src/storage/schema/v7MonitorLease.d.ts +57 -0
  536. package/out/src/storage/schema/v7MonitorLease.d.ts.map +1 -0
  537. package/out/src/storage/schema/v7MonitorLease.js +101 -0
  538. package/out/src/storage/schema/v7MonitorLease.js.map +1 -0
  539. package/out/src/storage/schema/v7Service.d.ts +305 -0
  540. package/out/src/storage/schema/v7Service.d.ts.map +1 -0
  541. package/out/src/storage/schema/v7Service.js +757 -0
  542. package/out/src/storage/schema/v7Service.js.map +1 -0
  543. package/out/src/storage/schema/v7TxAudit.d.ts +33 -0
  544. package/out/src/storage/schema/v7TxAudit.d.ts.map +1 -0
  545. package/out/src/storage/schema/v7TxAudit.js +64 -0
  546. package/out/src/storage/schema/v7TxAudit.js.map +1 -0
  547. package/out/src/storage/storageProviderHelpers.d.ts +34 -0
  548. package/out/src/storage/storageProviderHelpers.d.ts.map +1 -0
  549. package/out/src/storage/storageProviderHelpers.js +100 -0
  550. package/out/src/storage/storageProviderHelpers.js.map +1 -0
  551. package/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -1
  552. package/out/src/utility/ScriptTemplateBRC29.js +2 -1
  553. package/out/src/utility/ScriptTemplateBRC29.js.map +1 -1
  554. package/out/src/utility/aggregateResults.d.ts +1 -1
  555. package/out/src/utility/aggregateResults.d.ts.map +1 -1
  556. package/out/src/utility/aggregateResults.js +2 -2
  557. package/out/src/utility/aggregateResults.js.map +1 -1
  558. package/out/src/utility/brc114ActionTimeLabels.d.ts +2 -2
  559. package/out/src/utility/brc114ActionTimeLabels.d.ts.map +1 -1
  560. package/out/src/utility/brc114ActionTimeLabels.js +16 -9
  561. package/out/src/utility/brc114ActionTimeLabels.js.map +1 -1
  562. package/out/src/utility/identityUtils.js +1 -1
  563. package/out/src/utility/identityUtils.js.map +1 -1
  564. package/out/src/utility/parseTxScriptOffsets.d.ts +4 -4
  565. package/out/src/utility/parseTxScriptOffsets.d.ts.map +1 -1
  566. package/out/src/utility/parseTxScriptOffsets.js.map +1 -1
  567. package/out/src/utility/stampLog.d.ts.map +1 -1
  568. package/out/src/utility/stampLog.js +7 -5
  569. package/out/src/utility/stampLog.js.map +1 -1
  570. package/out/src/utility/tscProofToMerklePath.d.ts.map +1 -1
  571. package/out/src/utility/tscProofToMerklePath.js +1 -1
  572. package/out/src/utility/tscProofToMerklePath.js.map +1 -1
  573. package/out/src/utility/utilityHelpers.d.ts +1 -2
  574. package/out/src/utility/utilityHelpers.d.ts.map +1 -1
  575. package/out/src/utility/utilityHelpers.js +10 -10
  576. package/out/src/utility/utilityHelpers.js.map +1 -1
  577. package/out/src/utility/utilityHelpers.noBuffer.d.ts +7 -3
  578. package/out/src/utility/utilityHelpers.noBuffer.d.ts.map +1 -1
  579. package/out/src/utility/utilityHelpers.noBuffer.js +3 -3
  580. package/out/src/utility/utilityHelpers.noBuffer.js.map +1 -1
  581. package/out/src/wab-client/WABClient.d.ts +1 -1
  582. package/out/src/wab-client/WABClient.d.ts.map +1 -1
  583. package/out/src/wab-client/WABClient.js +12 -12
  584. package/out/src/wab-client/WABClient.js.map +1 -1
  585. package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts.map +1 -1
  586. package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js +3 -3
  587. package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js.map +1 -1
  588. package/package.json +7 -6
@@ -35,19 +35,16 @@ class BulkFileDataManager {
35
35
  this.bfds = [];
36
36
  this.fileHashToIndex = {};
37
37
  this.lock = new SingleWriterMultiReaderLock_1.SingleWriterMultiReaderLock();
38
- if (typeof options === 'object')
39
- options = options;
40
- else
41
- options = BulkFileDataManager.createDefaultOptions(options);
42
- this.chain = options.chain;
43
- this.maxPerFile = options.maxPerFile;
44
- this.maxRetained = options.maxRetained;
45
- this.fromKnownSourceUrl = options.fromKnownSourceUrl;
46
- this.fetch = options.fetch;
38
+ const resolvedOptions = typeof options === 'object' ? options : BulkFileDataManager.createDefaultOptions(options);
39
+ this.chain = resolvedOptions.chain;
40
+ this.maxPerFile = resolvedOptions.maxPerFile;
41
+ this.maxRetained = resolvedOptions.maxRetained;
42
+ this.fromKnownSourceUrl = resolvedOptions.fromKnownSourceUrl;
43
+ this.fetch = resolvedOptions.fetch;
47
44
  this.deleteBulkFilesNoLock();
48
45
  }
49
46
  async deleteBulkFiles() {
50
- return this.lock.withWriteLock(async () => this.deleteBulkFilesNoLock());
47
+ return await this.lock.withWriteLock(async () => this.deleteBulkFilesNoLock());
51
48
  }
52
49
  deleteBulkFilesNoLock() {
53
50
  this.bfds = [];
@@ -69,13 +66,13 @@ class BulkFileDataManager {
69
66
  * There should be no changes to bulk files by direct access to storage bulk file methods.
70
67
  */
71
68
  async setStorage(storage, log) {
72
- return this.lock.withWriteLock(async () => this.setStorageNoLock(storage, log));
69
+ return await this.lock.withWriteLock(async () => await this.setStorageNoLock(storage, log));
73
70
  }
74
71
  async setStorageNoLock(storage, log) {
75
72
  this.storage = storage;
76
73
  this.log = log;
77
74
  // Get files currently in persistent storage.
78
- let sfs = await this.storage.getBulkFiles();
75
+ const sfs = await this.storage.getBulkFiles();
79
76
  // Sync bfds with storage. Two scenarios supported:
80
77
  const bfdsRanges = this.heightRangesFromBulkFiles(this.bfds);
81
78
  const sfsRanges = this.heightRangesFromBulkFiles(sfs);
@@ -91,7 +88,9 @@ class BulkFileDataManager {
91
88
  else {
92
89
  // Bfds win if they have greater CDN coverage
93
90
  // Replace all sfs with bfds
94
- for (const s of sfs.reverse())
91
+ const reversedFiles = [...sfs];
92
+ reversedFiles.reverse();
93
+ for (const s of reversedFiles)
95
94
  await this.storage.deleteBulkFile(s.fileId);
96
95
  for (const bfd of this.bfds) {
97
96
  await this.ensureData(bfd);
@@ -117,26 +116,27 @@ class BulkFileDataManager {
117
116
  return new BulkFileDataReader_1.BulkFileDataReader(this, range, maxBufferSize);
118
117
  }
119
118
  async updateFromUrl(cdnUrl) {
120
- if (!this.fetch)
119
+ if (this.fetch == null)
121
120
  throw new sdk_1.WERR_INVALID_OPERATION('fetch is not defined in the BulkFileDataManager.');
122
121
  const toUrl = (file) => this.fetch.pathJoin(cdnUrl, file);
123
122
  const url = toUrl(`${this.chain}NetBlockHeaders.json`);
124
- const availableBulkFiles = (await this.fetch.fetchJson(url));
125
- if (!availableBulkFiles)
126
- throw new sdk_1.WERR_INVALID_PARAMETER(`cdnUrl`, `a valid BulkHeaderFilesInfo JSON resource available from ${url}`);
123
+ const availableBulkFiles = await this.fetch.fetchJson(url);
124
+ if (!availableBulkFiles) {
125
+ throw new sdk_1.WERR_INVALID_PARAMETER('cdnUrl', `a valid BulkHeaderFilesInfo JSON resource available from ${url}`);
126
+ }
127
127
  const selectedFiles = selectBulkHeaderFiles(availableBulkFiles.files, this.chain, this.maxPerFile || availableBulkFiles.headersPerFile);
128
128
  for (const bf of selectedFiles) {
129
129
  if (!bf.fileHash) {
130
- throw new sdk_1.WERR_INVALID_PARAMETER(`fileHash`, `valid for all files in json downloaded from ${url}`);
130
+ throw new sdk_1.WERR_INVALID_PARAMETER('fileHash', `valid for all files in json downloaded from ${url}`);
131
131
  }
132
132
  if (!bf.chain || bf.chain !== this.chain) {
133
- throw new sdk_1.WERR_INVALID_PARAMETER(`chain`, `"${this.chain}" for all files in json downloaded from ${url}`);
133
+ throw new sdk_1.WERR_INVALID_PARAMETER('chain', `"${this.chain}" for all files in json downloaded from ${url}`);
134
134
  }
135
135
  if (!bf.sourceUrl || bf.sourceUrl !== cdnUrl)
136
136
  bf.sourceUrl = cdnUrl;
137
137
  }
138
138
  const rangeBefore = await this.getHeightRange();
139
- const r = await this.merge(selectedFiles);
139
+ await this.merge(selectedFiles);
140
140
  const rangeAfter = await this.getHeightRange();
141
141
  let log = 'BulkDataFileManager.updateFromUrl\n';
142
142
  log += ` url: ${url}\n`;
@@ -145,17 +145,16 @@ class BulkFileDataManager {
145
145
  this.log(log);
146
146
  }
147
147
  async merge(files) {
148
- return this.lock.withWriteLock(async () => this.mergeNoLock(files));
148
+ return await this.lock.withWriteLock(async () => await this.mergeNoLock(files));
149
149
  }
150
150
  async mergeNoLock(files) {
151
151
  const r = { inserted: [], updated: [], unchanged: [], dropped: [] };
152
152
  for (const file of files) {
153
153
  const hbf = this.getBfdForHeight(file.firstHeight);
154
- if (hbf && file.fileId)
154
+ if ((hbf != null) && file.fileId)
155
155
  hbf.fileId = file.fileId; // Always update fileId if provided
156
156
  const lbf = this.getLastBfd();
157
- if (hbf &&
158
- hbf.fileHash === file.fileHash &&
157
+ if ((hbf === null || hbf === void 0 ? void 0 : hbf.fileHash) === file.fileHash &&
159
158
  hbf.count === file.count &&
160
159
  hbf.lastHash === file.lastHash &&
161
160
  hbf.lastChainWork === file.lastChainWork) {
@@ -164,11 +163,11 @@ class BulkFileDataManager {
164
163
  continue;
165
164
  }
166
165
  const vbf = await this.validateFileInfo(file);
167
- if (hbf) {
166
+ if (hbf != null) {
168
167
  // We have a matching file by firstHeight but count and fileHash differ
169
168
  await this.update(vbf, hbf, r);
170
169
  }
171
- else if (isBdfIncremental(vbf) && lbf && isBdfIncremental(lbf)) {
170
+ else if (isBdfIncremental(vbf) && (lbf != null) && isBdfIncremental(lbf)) {
172
171
  await this.mergeIncremental(lbf, vbf, r);
173
172
  }
174
173
  else {
@@ -194,13 +193,13 @@ class BulkFileDataManager {
194
193
  lbf.mru = Date.now();
195
194
  const lbfInfo = bfdToInfo(lbf, true);
196
195
  r.updated.push(lbfInfo);
197
- if (this.storage && lbf.fileId) {
196
+ if ((this.storage != null) && lbf.fileId) {
198
197
  await this.storage.updateBulkFile(lbf.fileId, lbfInfo);
199
198
  }
200
199
  }
201
200
  toLogString(what) {
202
201
  let log = '';
203
- if (!what) {
202
+ if (what == null) {
204
203
  log += this.toLogString(this.bfds);
205
204
  }
206
205
  else if (what['updated']) {
@@ -230,45 +229,20 @@ class BulkFileDataManager {
230
229
  async mergeIncrementalBlockHeaders(newBulkHeaders, incrementalChainWork) {
231
230
  if (newBulkHeaders.length === 0)
232
231
  return;
233
- return this.lock.withWriteLock(async () => {
232
+ return await this.lock.withWriteLock(async () => {
234
233
  const lbf = this.getLastFileNoLock();
235
- const nextHeight = lbf ? lbf.firstHeight + lbf.count : 0;
236
- if (nextHeight > 0 && newBulkHeaders.length > 0 && newBulkHeaders[0].height < nextHeight) {
237
- // Don't modify the incoming array...
238
- newBulkHeaders = [...newBulkHeaders];
239
- // If we have more headers than we need, drop the incoming headers.
240
- while (newBulkHeaders.length > 0 && newBulkHeaders[0].height < nextHeight) {
241
- const h = newBulkHeaders.shift();
242
- if (h && incrementalChainWork) {
243
- incrementalChainWork = (0, blockHeaderUtilities_1.subWork)(incrementalChainWork, (0, blockHeaderUtilities_1.convertBitsToWork)(h.bits));
244
- }
245
- }
246
- }
234
+ const nextHeight = lbf != null ? lbf.firstHeight + lbf.count : 0;
235
+ ({ headers: newBulkHeaders, incrementalChainWork } = trimAlreadyStoredHeaders(newBulkHeaders, nextHeight, incrementalChainWork));
247
236
  if (newBulkHeaders.length === 0)
248
237
  return;
249
- if (!lbf || nextHeight !== newBulkHeaders[0].height)
238
+ if ((lbf == null) || nextHeight !== newBulkHeaders[0].height) {
250
239
  throw new sdk_1.WERR_INVALID_PARAMETER('newBulkHeaders', 'an extension of existing bulk headers');
240
+ }
251
241
  if (!lbf.lastHash)
252
242
  throw new sdk_1.WERR_INTERNAL(`lastHash is not defined for the last bulk file ${lbf.fileName}`);
253
- const fbh = newBulkHeaders[0];
254
- const lbh = newBulkHeaders.slice(-1)[0];
255
- let lastChainWork = lbf.lastChainWork;
256
- if (incrementalChainWork) {
257
- lastChainWork = (0, blockHeaderUtilities_1.addWork)(incrementalChainWork, lastChainWork);
258
- }
259
- else {
260
- // If lastChainWork is not provided, calculate it from the last file with basic validation.
261
- let lastHeight = lbf.firstHeight + lbf.count - 1;
262
- let lastHash = lbf.lastHash;
263
- for (const h of newBulkHeaders) {
264
- if (h.height !== lastHeight + 1 || h.previousHash !== lastHash) {
265
- throw new sdk_1.WERR_INVALID_PARAMETER('headers', `an extension of existing bulk headers, header with height ${h.height} is non-sequential`);
266
- }
267
- lastChainWork = (0, blockHeaderUtilities_1.addWork)(lastChainWork, (0, blockHeaderUtilities_1.convertBitsToWork)(h.bits));
268
- lastHeight = h.height;
269
- lastHash = h.hash;
270
- }
271
- }
243
+ const lastChainWork = incrementalChainWork
244
+ ? (0, blockHeaderUtilities_1.addWork)(incrementalChainWork, lbf.lastChainWork)
245
+ : computeChainWorkFromHeaders(newBulkHeaders, lbf);
272
246
  const data = (0, blockHeaderUtilities_1.serializeBaseBlockHeaders)(newBulkHeaders);
273
247
  const fileHash = (0, utilityHelpers_noBuffer_1.asString)(sdk_2.Hash.sha256((0, utilityHelpers_noBuffer_1.asArray)(data)), 'base64');
274
248
  const bf = {
@@ -276,12 +250,12 @@ class BulkFileDataManager {
276
250
  chain: this.chain,
277
251
  sourceUrl: undefined,
278
252
  fileName: 'incremental',
279
- firstHeight: fbh.height,
253
+ firstHeight: newBulkHeaders[0].height,
280
254
  count: newBulkHeaders.length,
281
255
  prevChainWork: lbf.lastChainWork,
282
256
  lastChainWork,
283
257
  prevHash: lbf.lastHash,
284
- lastHash: lbh.hash,
258
+ lastHash: newBulkHeaders.at(-1).hash,
285
259
  fileHash,
286
260
  data
287
261
  };
@@ -289,24 +263,25 @@ class BulkFileDataManager {
289
263
  });
290
264
  }
291
265
  async getBulkFiles(keepData) {
292
- return this.lock.withReadLock(async () => {
266
+ return await this.lock.withReadLock(async () => {
293
267
  return this.bfds.map(bfd => bfdToInfo(bfd, keepData));
294
268
  });
295
269
  }
296
270
  async getHeightRange() {
297
- return this.lock.withReadLock(async () => {
271
+ return await this.lock.withReadLock(async () => {
298
272
  if (this.bfds.length === 0)
299
273
  return HeightRange_1.HeightRange.empty;
300
274
  const first = this.bfds[0];
301
- const last = this.bfds[this.bfds.length - 1];
275
+ const last = this.bfds.at(-1);
302
276
  return new HeightRange_1.HeightRange(first.firstHeight, last.firstHeight + last.count - 1);
303
277
  });
304
278
  }
305
279
  async getDataFromFile(file, offset, length) {
306
- const bfd = await this.getBfdForHeight(file.firstHeight);
307
- if (!bfd || bfd.count < file.count)
280
+ const bfd = this.getBfdForHeight(file.firstHeight);
281
+ if ((bfd == null) || bfd.count < file.count) {
308
282
  throw new sdk_1.WERR_INVALID_PARAMETER('file', `a match for ${file.firstHeight}, ${file.count} in the BulkFileDataManager.`);
309
- return this.lock.withReadLock(async () => this.getDataFromFileNoLock(bfd, offset, length));
283
+ }
284
+ return await this.lock.withReadLock(async () => await this.getDataFromFileNoLock(bfd, offset, length));
310
285
  }
311
286
  async getDataFromFileNoLock(bfd, offset, length) {
312
287
  const fileLength = bfd.count * 80;
@@ -316,47 +291,49 @@ class BulkFileDataManager {
316
291
  length = length || bfd.count * 80 - offset;
317
292
  length = Math.min(length, fileLength - offset);
318
293
  let data;
319
- if (bfd.data) {
294
+ if (bfd.data != null) {
320
295
  data = bfd.data.slice(offset, offset + length);
321
296
  }
322
- else if (bfd.fileId && this.storage) {
297
+ else if (bfd.fileId && (this.storage != null)) {
323
298
  data = await this.storage.getBulkFileData(bfd.fileId, offset, length);
324
299
  }
325
- if (!data) {
300
+ if (data == null) {
326
301
  await this.ensureData(bfd);
327
- if (bfd.data)
302
+ if (bfd.data != null)
328
303
  data = bfd.data.slice(offset, offset + length);
329
304
  }
330
- if (!data)
305
+ if (data == null)
331
306
  return undefined;
332
307
  return data;
333
308
  }
334
309
  async findHeaderForHeightOrUndefined(height) {
335
- return this.lock.withReadLock(async () => {
336
- if (!Number.isInteger(height) || height < 0)
310
+ return await this.lock.withReadLock(async () => {
311
+ if (!Number.isInteger(height) || height < 0) {
337
312
  throw new sdk_1.WERR_INVALID_PARAMETER('height', `a non-negative integer (${height}).`);
313
+ }
338
314
  const file = this.bfds.find(f => f.firstHeight <= height && f.firstHeight + f.count > height);
339
- if (!file)
315
+ if (file == null)
340
316
  return undefined;
341
317
  const offset = (height - file.firstHeight) * 80;
342
318
  const data = await this.getDataFromFileNoLock(file, offset, 80);
343
- if (!data)
319
+ if (data == null)
344
320
  return undefined;
345
- const header = (0, blockHeaderUtilities_1.deserializeBlockHeader)(data, 0, height);
321
+ const header = (0, blockHeaderUtilities_1.deserializeBlockHeader)(data, height, 0);
346
322
  return header;
347
323
  });
348
324
  }
349
325
  async getFileForHeight(height) {
350
- return this.lock.withReadLock(async () => {
326
+ return await this.lock.withReadLock(async () => {
351
327
  const bfd = this.getBfdForHeight(height);
352
- if (!bfd)
328
+ if (bfd == null)
353
329
  return undefined;
354
330
  return bfdToInfo(bfd);
355
331
  });
356
332
  }
357
333
  getBfdForHeight(height) {
358
- if (!Number.isInteger(height) || height < 0)
334
+ if (!Number.isInteger(height) || height < 0) {
359
335
  throw new sdk_1.WERR_INVALID_PARAMETER('height', `a non-negative integer (${height}).`);
336
+ }
360
337
  const file = this.bfds.find(f => f.firstHeight <= height && f.firstHeight + f.count > height);
361
338
  return file;
362
339
  }
@@ -367,74 +344,85 @@ class BulkFileDataManager {
367
344
  return bfd;
368
345
  }
369
346
  async getLastFile(fromEnd = 1) {
370
- return this.lock.withReadLock(async () => this.getLastFileNoLock(fromEnd));
347
+ return await this.lock.withReadLock(async () => this.getLastFileNoLock(fromEnd));
371
348
  }
372
349
  getLastFileNoLock(fromEnd = 1) {
373
350
  const bfd = this.getLastBfd(fromEnd);
374
- if (!bfd)
351
+ if (bfd == null)
375
352
  return undefined;
376
353
  return bfdToInfo(bfd);
377
354
  }
378
355
  async getDataByFileHash(fileHash) {
379
356
  const index = this.fileHashToIndex[fileHash];
380
- if (index === undefined)
357
+ if (index === undefined) {
381
358
  throw new sdk_1.WERR_INVALID_PARAMETER('fileHash', `known to the BulkFileDataManager. ${fileHash} is unknown.`);
359
+ }
382
360
  const bfd = this.bfds[index];
383
361
  const data = await this.ensureData(bfd);
384
362
  return data;
385
363
  }
386
364
  async getDataByFileId(fileId) {
387
365
  const bfd = this.bfds.find(f => f.fileId === fileId);
388
- if (bfd === undefined)
366
+ if (bfd === undefined) {
389
367
  throw new sdk_1.WERR_INVALID_PARAMETER('fileId', `known to the BulkFileDataManager. ${fileId} is unknown.`);
368
+ }
390
369
  const data = await this.ensureData(bfd);
391
370
  return data;
392
371
  }
393
372
  async validateFileInfo(file) {
394
- var _a;
395
373
  if (file.chain !== this.chain)
396
374
  throw new sdk_1.WERR_INVALID_PARAMETER('chain', `${this.chain}`);
397
- if (file.count <= 0)
375
+ if (file.count <= 0) {
398
376
  throw new sdk_1.WERR_INVALID_PARAMETER('bf.count', `expected count to be greater than 0, but got ${file.count}`);
399
- if (file.count > this.maxPerFile && file.fileName !== 'incremental')
377
+ }
378
+ if (file.count > this.maxPerFile && file.fileName !== 'incremental') {
400
379
  throw new sdk_1.WERR_INVALID_PARAMETER('count', `less than or equal to maxPerFile ${this.maxPerFile}`);
380
+ }
401
381
  if (!file.fileHash)
402
- throw new sdk_1.WERR_INVALID_PARAMETER('fileHash', `defined`);
403
- if (!file.sourceUrl && !file.fileId && !file.data)
404
- throw new sdk_1.WERR_INVALID_PARAMETER('data', `defined when sourceUrl and fileId are undefined`);
405
- let bfd = {
406
- ...file,
407
- fileHash: file.fileHash,
408
- mru: Date.now()
409
- };
382
+ throw new sdk_1.WERR_INVALID_PARAMETER('fileHash', 'defined');
383
+ if (!file.sourceUrl && !file.fileId && (file.data == null)) {
384
+ throw new sdk_1.WERR_INVALID_PARAMETER('data', 'defined when sourceUrl and fileId are undefined');
385
+ }
386
+ const bfd = { ...file, fileHash: file.fileHash, mru: Date.now() };
410
387
  if (!bfd.validated) {
411
- await this.ensureData(bfd);
412
- if (!bfd.data || bfd.data.length !== bfd.count * 80)
413
- throw new sdk_1.WERR_INVALID_PARAMETER('file.data', `bulk file ${bfd.fileName} data length ${(_a = bfd.data) === null || _a === void 0 ? void 0 : _a.length} does not match expected count ${bfd.count}`);
414
- bfd.fileHash = (0, utilityHelpers_noBuffer_1.asString)(sdk_2.Hash.sha256((0, utilityHelpers_noBuffer_1.asArray)(bfd.data)), 'base64');
415
- if (file.fileHash && file.fileHash !== bfd.fileHash)
416
- throw new sdk_1.WERR_INVALID_PARAMETER('file.fileHash', `expected ${file.fileHash} but got ${bfd.fileHash}`);
417
- if (!(0, validBulkHeaderFilesByFileHash_1.isKnownValidBulkHeaderFile)(bfd)) {
418
- const pbf = bfd.firstHeight > 0 ? this.getBfdForHeight(bfd.firstHeight - 1) : undefined;
419
- const prevHash = pbf ? pbf.lastHash : '00'.repeat(32);
420
- const prevChainWork = pbf ? pbf.lastChainWork : '00'.repeat(32);
421
- const { lastHeaderHash, lastChainWork } = (0, blockHeaderUtilities_1.validateBufferOfHeaders)(bfd.data, prevHash, 0, undefined, prevChainWork);
422
- if (bfd.lastHash && bfd.lastHash !== lastHeaderHash)
423
- throw new sdk_1.WERR_INVALID_PARAMETER('file.lastHash', `expected ${bfd.lastHash} but got ${lastHeaderHash}`);
424
- if (bfd.lastChainWork && bfd.lastChainWork !== lastChainWork)
425
- throw new sdk_1.WERR_INVALID_PARAMETER('file.lastChainWork', `expected ${bfd.lastChainWork} but got ${lastChainWork}`);
426
- bfd.lastHash = lastHeaderHash;
427
- bfd.lastChainWork = lastChainWork;
428
- if (bfd.firstHeight === 0) {
429
- (0, blockHeaderUtilities_1.validateGenesisHeader)(bfd.data, bfd.chain);
430
- }
431
- }
388
+ await this.validateBfdData(bfd, file.fileHash);
432
389
  bfd.validated = true;
433
390
  }
434
391
  return bfd;
435
392
  }
393
+ async validateBfdData(bfd, expectedFileHash) {
394
+ var _a;
395
+ await this.ensureData(bfd);
396
+ if ((bfd.data == null) || bfd.data.length !== bfd.count * 80) {
397
+ throw new sdk_1.WERR_INVALID_PARAMETER('file.data', `bulk file ${bfd.fileName} data length ${(_a = bfd.data) === null || _a === void 0 ? void 0 : _a.length} does not match expected count ${bfd.count}`);
398
+ }
399
+ bfd.fileHash = (0, utilityHelpers_noBuffer_1.asString)(sdk_2.Hash.sha256((0, utilityHelpers_noBuffer_1.asArray)(bfd.data)), 'base64');
400
+ if (expectedFileHash && expectedFileHash !== bfd.fileHash) {
401
+ throw new sdk_1.WERR_INVALID_PARAMETER('file.fileHash', `expected ${expectedFileHash} but got ${bfd.fileHash}`);
402
+ }
403
+ if (!(0, validBulkHeaderFilesByFileHash_1.isKnownValidBulkHeaderFile)(bfd)) {
404
+ this.validateBfdHeaders(bfd);
405
+ }
406
+ }
407
+ validateBfdHeaders(bfd) {
408
+ var _a, _b;
409
+ const pbf = bfd.firstHeight > 0 ? this.getBfdForHeight(bfd.firstHeight - 1) : undefined;
410
+ const prevHash = (_a = pbf === null || pbf === void 0 ? void 0 : pbf.lastHash) !== null && _a !== void 0 ? _a : '00'.repeat(32);
411
+ const prevChainWork = (_b = pbf === null || pbf === void 0 ? void 0 : pbf.lastChainWork) !== null && _b !== void 0 ? _b : '00'.repeat(32);
412
+ const { lastHeaderHash, lastChainWork } = (0, blockHeaderUtilities_1.validateBufferOfHeaders)(bfd.data, prevHash, 0, undefined, prevChainWork);
413
+ if (bfd.lastHash && bfd.lastHash !== lastHeaderHash) {
414
+ throw new sdk_1.WERR_INVALID_PARAMETER('file.lastHash', `expected ${bfd.lastHash} but got ${lastHeaderHash}`);
415
+ }
416
+ if (bfd.lastChainWork && bfd.lastChainWork !== lastChainWork) {
417
+ throw new sdk_1.WERR_INVALID_PARAMETER('file.lastChainWork', `expected ${bfd.lastChainWork} but got ${lastChainWork}`);
418
+ }
419
+ bfd.lastHash = lastHeaderHash;
420
+ bfd.lastChainWork = lastChainWork;
421
+ if (bfd.firstHeight === 0)
422
+ (0, blockHeaderUtilities_1.validateGenesisHeader)(bfd.data, bfd.chain);
423
+ }
436
424
  async ReValidate() {
437
- return this.lock.withReadLock(async () => this.ReValidateNoLock());
425
+ return await this.lock.withReadLock(async () => await this.ReValidateNoLock());
438
426
  }
439
427
  async ReValidateNoLock() {
440
428
  for (const file of this.bfds) {
@@ -447,14 +435,17 @@ class BulkFileDataManager {
447
435
  }
448
436
  }
449
437
  validateBfdForAdd(bfd) {
450
- if (this.bfds.length === 0 && bfd.firstHeight !== 0)
451
- throw new sdk_1.WERR_INVALID_PARAMETER('firstHeight', `0 for the first file`);
438
+ if (this.bfds.length === 0 && bfd.firstHeight !== 0) {
439
+ throw new sdk_1.WERR_INVALID_PARAMETER('firstHeight', '0 for the first file');
440
+ }
452
441
  if (this.bfds.length > 0) {
453
- const last = this.bfds[this.bfds.length - 1];
454
- if (bfd.firstHeight !== last.firstHeight + last.count)
455
- throw new sdk_1.WERR_INVALID_PARAMETER('firstHeight', `the last file's firstHeight + count`);
456
- if (bfd.prevHash !== last.lastHash || bfd.prevChainWork !== last.lastChainWork)
457
- throw new sdk_1.WERR_INVALID_PARAMETER('prevHash/prevChainWork', `the last file's lastHash/lastChainWork`);
442
+ const last = this.bfds.at(-1);
443
+ if (bfd.firstHeight !== last.firstHeight + last.count) {
444
+ throw new sdk_1.WERR_INVALID_PARAMETER('firstHeight', 'the last file\'s firstHeight + count');
445
+ }
446
+ if (bfd.prevHash !== last.lastHash || bfd.prevChainWork !== last.lastChainWork) {
447
+ throw new sdk_1.WERR_INVALID_PARAMETER('prevHash/prevChainWork', 'the last file\'s lastHash/lastChainWork');
448
+ }
458
449
  }
459
450
  }
460
451
  async add(bfd) {
@@ -464,7 +455,7 @@ class BulkFileDataManager {
464
455
  this.fileHashToIndex[bfd.fileHash] = index;
465
456
  this.ensureMaxRetained();
466
457
  const info = bfdToInfo(bfd, true);
467
- if (this.storage) {
458
+ if (this.storage != null) {
468
459
  info.fileId = bfd.fileId = await this.storage.insertBulkFile(info);
469
460
  }
470
461
  return info;
@@ -502,120 +493,109 @@ class BulkFileDataManager {
502
493
  * @param hbf corresponding existing BulkFileData to update.
503
494
  */
504
495
  async update(update, hbf, r) {
505
- if (!hbf ||
506
- hbf.firstHeight !== update.firstHeight ||
507
- hbf.prevChainWork !== update.prevChainWork ||
508
- hbf.prevHash !== update.prevHash)
509
- throw new sdk_1.WERR_INVALID_PARAMETER('file', `an existing file by height, prevChainWork and prevHash`);
510
- if (isBdfCdn(update) === isBdfCdn(hbf) && update.count <= hbf.count)
496
+ if ((hbf === null || hbf === void 0 ? void 0 : hbf.firstHeight) !== update.firstHeight ||
497
+ (hbf === null || hbf === void 0 ? void 0 : hbf.prevChainWork) !== update.prevChainWork ||
498
+ (hbf === null || hbf === void 0 ? void 0 : hbf.prevHash) !== update.prevHash) {
499
+ throw new sdk_1.WERR_INVALID_PARAMETER('file', 'an existing file by height, prevChainWork and prevHash');
500
+ }
501
+ if (isBdfCdn(update) === isBdfCdn(hbf) && update.count <= hbf.count) {
511
502
  throw new sdk_1.WERR_INVALID_PARAMETER('file.count', `greater than the current count ${hbf.count}`);
503
+ }
504
+ const { index, truncate, replaced, drop } = await this.resolveUpdatePlan(update, hbf);
505
+ this.replaceBfdAtIndex(index, update);
506
+ if (truncate != null)
507
+ await this.shiftWork(update, truncate, replaced);
508
+ if (drop != null)
509
+ this.dropLastBulkFile(drop);
510
+ await this.persistUpdate(update, truncate, replaced, drop);
511
+ this.recordUpdateResults(r, update, truncate, replaced, drop);
512
+ this.ensureMaxRetained();
513
+ }
514
+ async resolveUpdatePlan(update, hbf) {
512
515
  const lbf = this.getLastBfd();
513
516
  let index = this.bfds.length - 1;
514
- let truncate = undefined;
515
- let replaced = undefined;
516
- let drop = undefined;
517
+ let truncate;
518
+ let replaced;
519
+ let drop;
517
520
  if (hbf.firstHeight === lbf.firstHeight) {
518
- // If the update is for the last file, there are three cases:
521
+ // Update targets the last file three cases:
519
522
  if (isBdfIncremental(update)) {
520
- // 1. Incremental file may only be extended with more incremental headers.
523
+ // 1. Incremental incremental extension.
521
524
  if (!isBdfIncremental(lbf))
522
- throw new sdk_1.WERR_INVALID_PARAMETER('file', `an incremental file to update an existing incremental file`);
525
+ throw new sdk_1.WERR_INVALID_PARAMETER('file', 'an incremental file to update an existing incremental file');
523
526
  }
524
- else {
525
- // The update is a CDN bulk file.
526
- if (isBdfCdn(lbf)) {
527
- // 2. An updated CDN file replaces a partial CDN file.
528
- if (update.count <= lbf.count)
529
- throw new sdk_1.WERR_INVALID_PARAMETER('update.count', `CDN update must have more headers. ${update.count} <= ${lbf.count}`);
530
- }
531
- else {
532
- // 3. A new CDN file replaces some or all of current incremental file.
533
- // Retain extra incremental headers if any.
534
- if (update.count < lbf.count) {
535
- // The new CDN partially replaces the last incremental file, prepare to shift work and re-add it.
536
- await this.ensureData(lbf);
537
- truncate = lbf;
538
- }
539
- }
527
+ else if (isBdfCdn(lbf)) {
528
+ // 2. CDN CDN replacement (must grow).
529
+ if (update.count <= lbf.count)
530
+ throw new sdk_1.WERR_INVALID_PARAMETER('update.count', `CDN update must have more headers. ${update.count} <= ${lbf.count}`);
531
+ }
532
+ else if (update.count < lbf.count) {
533
+ // 3. New CDN partially replaces incremental tail — retain excess incremental headers.
534
+ await this.ensureData(lbf);
535
+ truncate = lbf;
540
536
  }
541
537
  }
542
538
  else {
543
- // If the update is NOT for the last file, then it MUST be for the second to last file which MUST be a CDN file:
544
- // - it must be a CDN file update with more headers than the current CDN file.
545
- // - the last file must be an incremental file which is updated or deleted. The updated (or deleted) last file is returned.
539
+ // Update targets the second-to-last file must be CDN replacing CDN, last must be incremental.
546
540
  const lbf2 = this.getLastBfd(2);
547
- if (!lbf2 || hbf.firstHeight !== lbf2.firstHeight)
548
- throw new sdk_1.WERR_INVALID_PARAMETER('file', `an update to last or second to last file`);
541
+ if ((lbf2 == null) || hbf.firstHeight !== lbf2.firstHeight)
542
+ throw new sdk_1.WERR_INVALID_PARAMETER('file', 'an update to last or second to last file');
549
543
  if (!isBdfCdn(update) || !isBdfCdn(lbf2) || update.count <= lbf2.count)
550
- throw new sdk_1.WERR_INVALID_PARAMETER('file', `a CDN file update with more headers than the current CDN file`);
544
+ throw new sdk_1.WERR_INVALID_PARAMETER('file', 'a CDN file update with more headers than the current CDN file');
551
545
  if (!isBdfIncremental(lbf))
552
- throw new sdk_1.WERR_INVALID_PARAMETER('file', `a CDN file update followed by an incremental file`);
546
+ throw new sdk_1.WERR_INVALID_PARAMETER('file', 'a CDN file update followed by an incremental file');
553
547
  if (!update.fileId)
554
- update.fileId = lbf2.fileId; // Update fileId if not provided
548
+ update.fileId = lbf2.fileId;
555
549
  if (update.count >= lbf2.count + lbf.count) {
556
- // The current last file is fully replaced by the CDN update.
557
550
  drop = lbf;
558
551
  }
559
552
  else {
560
- // If the update doesn't fully replace the last incremental file, make sure data is available to be truncated.
561
553
  await this.ensureData(lbf);
562
554
  truncate = lbf;
563
- // The existing second to last file is fully replaced by the update.
564
555
  replaced = lbf2;
565
556
  }
566
- index = index - 1; // The update replaces the second to last file.
567
- }
568
- // In all cases the bulk file at the current fileId if any is updated.
569
- this.replaceBfdAtIndex(index, update);
570
- if (truncate) {
571
- // If there is a bulk file to be truncated, it becomes the new (reduced) last file.
572
- await this.shiftWork(update, truncate, replaced);
573
- }
574
- if (drop) {
575
- this.dropLastBulkFile(drop);
557
+ index = index - 1;
576
558
  }
577
- const updateInfo = bfdToInfo(update, true);
578
- const truncateInfo = truncate ? bfdToInfo(truncate, true) : undefined;
579
- if (this.storage) {
580
- // Keep storage in sync.
581
- if (update.fileId) {
582
- await this.storage.updateBulkFile(update.fileId, updateInfo);
583
- }
584
- if (truncate && truncateInfo) {
585
- if (replaced) {
586
- await this.storage.updateBulkFile(truncate.fileId, truncateInfo);
587
- }
588
- else {
589
- truncateInfo.fileId = undefined; // Make sure truncate is a new file.
590
- truncate.fileId = await this.storage.insertBulkFile(truncateInfo);
591
- }
559
+ return { index, truncate, replaced, drop };
560
+ }
561
+ async persistUpdate(update, truncate, replaced, drop) {
562
+ if (this.storage == null)
563
+ return;
564
+ if (update.fileId)
565
+ await this.storage.updateBulkFile(update.fileId, bfdToInfo(update, true));
566
+ if ((truncate != null)) {
567
+ const truncateInfo = bfdToInfo(truncate, true);
568
+ if (replaced != null) {
569
+ await this.storage.updateBulkFile(truncate.fileId, truncateInfo);
592
570
  }
593
- if (drop && drop.fileId) {
594
- await this.storage.deleteBulkFile(drop.fileId);
571
+ else {
572
+ truncateInfo.fileId = undefined;
573
+ truncate.fileId = await this.storage.insertBulkFile(truncateInfo);
595
574
  }
596
575
  }
597
- if (r) {
598
- // Update results for logging...
599
- r.updated.push(updateInfo);
600
- if (truncateInfo) {
601
- if (replaced) {
602
- r.updated.push(truncateInfo);
603
- }
604
- else {
605
- r.inserted.push(truncateInfo);
606
- }
607
- }
608
- if (drop) {
609
- r.dropped.push(bfdToInfo(drop));
610
- }
576
+ if (drop === null || drop === void 0 ? void 0 : drop.fileId)
577
+ await this.storage.deleteBulkFile(drop.fileId);
578
+ }
579
+ recordUpdateResults(r, update, truncate, replaced, drop) {
580
+ if (!r)
581
+ return;
582
+ r.updated.push(bfdToInfo(update, true));
583
+ if (truncate != null) {
584
+ const truncateInfo = bfdToInfo(truncate, true);
585
+ if (replaced != null)
586
+ r.updated.push(truncateInfo);
587
+ else
588
+ r.inserted.push(truncateInfo);
611
589
  }
612
- this.ensureMaxRetained();
590
+ if (drop != null)
591
+ r.dropped.push(bfdToInfo(drop));
613
592
  }
614
593
  dropLastBulkFile(lbf) {
615
594
  delete this.fileHashToIndex[lbf.fileHash];
616
595
  const index = this.bfds.indexOf(lbf);
617
- if (index !== this.bfds.length - 1)
618
- throw new sdk_1.WERR_INTERNAL(`dropLastBulkFile requires lbf is the current last file.`);
596
+ if (index !== this.bfds.length - 1) {
597
+ throw new sdk_1.WERR_INTERNAL('dropLastBulkFile requires lbf is the current last file.');
598
+ }
619
599
  this.bfds.pop();
620
600
  }
621
601
  /**
@@ -633,15 +613,17 @@ class BulkFileDataManager {
633
613
  // replaced will be valid if the update replaced it and it must become the new last file.
634
614
  // truncateIndex will be updateIndex + 1 if the existing last file is being truncated and update is second to last.
635
615
  const truncateIndex = this.fileHashToIndex[truncate.fileHash];
636
- if (truncateIndex !== undefined && truncateIndex !== updateIndex + 1)
637
- throw new sdk_1.WERR_INTERNAL(`shiftWork requires update to have replaced truncate or truncate to follow update`);
638
- if (truncateIndex !== undefined && !replaced)
639
- throw new sdk_1.WERR_INTERNAL(`shiftWork requires valid replaced when update hasn't replaced truncate`);
616
+ if (truncateIndex !== undefined && truncateIndex !== updateIndex + 1) {
617
+ throw new sdk_1.WERR_INTERNAL('shiftWork requires update to have replaced truncate or truncate to follow update');
618
+ }
619
+ if (truncateIndex !== undefined && (replaced == null)) {
620
+ throw new sdk_1.WERR_INTERNAL('shiftWork requires valid replaced when update hasn\'t replaced truncate');
621
+ }
640
622
  truncate.prevHash = update.lastHash;
641
623
  truncate.prevChainWork = update.lastChainWork;
642
624
  // truncate.lastChainWork, truncate.lastHash remain unchanged
643
625
  let count = update.count;
644
- if (replaced) {
626
+ if (replaced != null) {
645
627
  count -= replaced.count;
646
628
  }
647
629
  else {
@@ -662,44 +644,46 @@ class BulkFileDataManager {
662
644
  * @returns
663
645
  */
664
646
  async ensureData(bfd) {
665
- if (bfd.data)
647
+ if (bfd.data != null)
666
648
  return bfd.data;
667
- if (this.storage && bfd.fileId) {
649
+ if ((this.storage != null) && bfd.fileId) {
668
650
  bfd.data = await this.storage.getBulkFileData(bfd.fileId);
669
- if (!bfd.data)
651
+ if (bfd.data == null)
670
652
  throw new sdk_1.WERR_INVALID_PARAMETER('fileId', `valid, data not found for fileId ${bfd.fileId}`);
671
653
  }
672
- if (!bfd.data && this.fetch && bfd.sourceUrl) {
673
- // TODO - restore this change
654
+ if ((bfd.data == null) && (this.fetch != null) && bfd.sourceUrl) {
674
655
  const url = this.fetch.pathJoin(bfd.sourceUrl, bfd.fileName);
675
- //const url = this.fetch.pathJoin('http://localhost:8842/blockheaders', bfd.fileName)
676
656
  try {
677
657
  bfd.data = await this.fetch.download(url);
678
658
  }
679
- catch (err) {
659
+ catch (firstAttemptErr) {
660
+ // First download attempt failed (e.g. transient network error); retry once.
661
+ console.debug(`BulkFileDataManager: first download attempt failed for ${url}, retrying`, firstAttemptErr);
680
662
  bfd.data = await this.fetch.download(url);
681
663
  }
682
664
  if (!bfd.data)
683
665
  throw new sdk_1.WERR_INVALID_PARAMETER('sourceUrl', `data not found for sourceUrl ${url}`);
684
666
  }
685
- if (!bfd.data)
667
+ if (bfd.data == null)
686
668
  throw new sdk_1.WERR_INVALID_PARAMETER('data', `defined. Unable to retrieve data for ${bfd.fileName}`);
687
669
  bfd.mru = Date.now();
688
670
  // Validate retrieved data.
689
671
  const fileHash = (0, utilityHelpers_noBuffer_1.asString)(sdk_2.Hash.sha256((0, utilityHelpers_noBuffer_1.asArray)(bfd.data)), 'base64');
690
- if (fileHash !== bfd.fileHash)
672
+ if (fileHash !== bfd.fileHash) {
691
673
  throw new sdk_1.WERR_INVALID_PARAMETER('fileHash', `a match for retrieved data for ${bfd.fileName}`);
674
+ }
692
675
  this.ensureMaxRetained();
693
676
  return bfd.data;
694
677
  }
695
678
  ensureMaxRetained() {
696
679
  if (this.maxRetained === undefined)
697
680
  return;
698
- let withData = this.bfds.filter(bfd => bfd.data && (bfd.fileId || bfd.sourceUrl));
681
+ const withData = this.bfds.filter(bfd => (bfd.data != null) && (bfd.fileId || bfd.sourceUrl));
699
682
  let countToRelease = withData.length - this.maxRetained;
700
683
  if (countToRelease <= 0)
701
684
  return;
702
- const sorted = withData.sort((a, b) => a.mru - b.mru);
685
+ const sorted = [...withData];
686
+ sorted.sort((a, b) => a.mru - b.mru);
703
687
  while (countToRelease-- > 0 && sorted.length > 0) {
704
688
  const oldest = sorted.shift();
705
689
  // Release the least recently used data
@@ -728,7 +712,7 @@ class BulkFileDataManager {
728
712
  for (;;) {
729
713
  i++;
730
714
  const data = await reader.read();
731
- if (!data || data.length === 0) {
715
+ if ((data == null) || data.length === 0) {
732
716
  break;
733
717
  }
734
718
  const last = (0, blockHeaderUtilities_1.validateBufferOfHeaders)(data, lastHeaderHash, 0, undefined, lastChainWork);
@@ -792,6 +776,42 @@ function bfdToInfo(bfd, keepData) {
792
776
  data: keepData ? bfd.data : undefined
793
777
  };
794
778
  }
779
+ /**
780
+ * Drops any headers whose height is already covered by bulk storage,
781
+ * reducing `incrementalChainWork` accordingly (when provided).
782
+ */
783
+ function trimAlreadyStoredHeaders(headers, nextHeight, incrementalChainWork) {
784
+ if (nextHeight <= 0 || headers.length === 0 || headers[0].height >= nextHeight) {
785
+ return { headers, incrementalChainWork };
786
+ }
787
+ // Avoid mutating the caller's array.
788
+ headers = [...headers];
789
+ while (headers.length > 0 && headers[0].height < nextHeight) {
790
+ const h = headers.shift();
791
+ if ((h != null) && incrementalChainWork) {
792
+ incrementalChainWork = (0, blockHeaderUtilities_1.subWork)(incrementalChainWork, (0, blockHeaderUtilities_1.convertBitsToWork)(h.bits));
793
+ }
794
+ }
795
+ return { headers, incrementalChainWork };
796
+ }
797
+ /**
798
+ * Computes `lastChainWork` for a sequence of new bulk headers extending `lbf`,
799
+ * validating that the sequence is contiguous.
800
+ */
801
+ function computeChainWorkFromHeaders(headers, lbf) {
802
+ let lastHeight = lbf.firstHeight + lbf.count - 1;
803
+ let lastHash = lbf.lastHash;
804
+ let lastChainWork = lbf.lastChainWork;
805
+ for (const h of headers) {
806
+ if (h.height !== lastHeight + 1 || h.previousHash !== lastHash) {
807
+ throw new sdk_1.WERR_INVALID_PARAMETER('headers', `an extension of existing bulk headers, header with height ${h.height} is non-sequential`);
808
+ }
809
+ lastChainWork = (0, blockHeaderUtilities_1.addWork)(lastChainWork, (0, blockHeaderUtilities_1.convertBitsToWork)(h.bits));
810
+ lastHeight = h.height;
811
+ lastHash = h.hash;
812
+ }
813
+ return lastChainWork;
814
+ }
795
815
  // Re-export BulkFileDataReader for backward compatibility
796
816
  var BulkFileDataReader_2 = require("./BulkFileDataReader");
797
817
  Object.defineProperty(exports, "BulkFileDataReader", { enumerable: true, get: function () { return BulkFileDataReader_2.BulkFileDataReader; } });