@bsv/wallet-toolbox 1.1.6 → 1.1.8

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 (319) hide show
  1. package/docs/client.md +499 -900
  2. package/docs/monitor.md +29 -69
  3. package/docs/services.md +22 -40
  4. package/docs/setup.md +23 -65
  5. package/docs/storage.md +2163 -489
  6. package/docs/wallet.md +499 -900
  7. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts +4 -4
  8. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
  9. package/out/src/monitor/tasks/TaskCheckForProofs.js +2 -2
  10. package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -1
  11. package/out/src/monitor/tasks/TaskSendWaiting.d.ts +2 -2
  12. package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -1
  13. package/out/src/monitor/tasks/TaskSendWaiting.js +2 -2
  14. package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -1
  15. package/out/src/sdk/StorageSyncReader.d.ts +30 -30
  16. package/out/src/sdk/StorageSyncReader.d.ts.map +1 -1
  17. package/out/src/sdk/StorageSyncReaderWriter.d.ts +60 -60
  18. package/out/src/sdk/StorageSyncReaderWriter.d.ts.map +1 -1
  19. package/out/src/sdk/WalletStorage.interfaces.d.ts +36 -36
  20. package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
  21. package/out/src/signer/methods/acquireDirectCertificate.d.ts.map +1 -1
  22. package/out/src/signer/methods/acquireDirectCertificate.js.map +1 -1
  23. package/out/src/storage/StorageKnex.d.ts +61 -61
  24. package/out/src/storage/StorageKnex.d.ts.map +1 -1
  25. package/out/src/storage/StorageKnex.js +2 -2
  26. package/out/src/storage/StorageKnex.js.map +1 -1
  27. package/out/src/storage/StorageProvider.d.ts +16 -15
  28. package/out/src/storage/StorageProvider.d.ts.map +1 -1
  29. package/out/src/storage/StorageProvider.js +8 -8
  30. package/out/src/storage/StorageProvider.js.map +1 -1
  31. package/out/src/storage/StorageReader.d.ts +21 -21
  32. package/out/src/storage/StorageReader.d.ts.map +1 -1
  33. package/out/src/storage/StorageReader.js.map +1 -1
  34. package/out/src/storage/StorageReaderWriter.d.ts +60 -60
  35. package/out/src/storage/StorageReaderWriter.d.ts.map +1 -1
  36. package/out/src/storage/StorageReaderWriter.js.map +1 -1
  37. package/out/src/storage/StorageSyncReader.d.ts +17 -17
  38. package/out/src/storage/StorageSyncReader.d.ts.map +1 -1
  39. package/out/src/storage/StorageSyncReader.js.map +1 -1
  40. package/out/src/storage/WalletStorageManager.d.ts +9 -9
  41. package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
  42. package/out/src/storage/WalletStorageManager.js +2 -2
  43. package/out/src/storage/WalletStorageManager.js.map +1 -1
  44. package/out/src/storage/index.all.d.ts +2 -2
  45. package/out/src/storage/index.all.d.ts.map +1 -1
  46. package/out/src/storage/index.all.js +3 -3
  47. package/out/src/storage/index.all.js.map +1 -1
  48. package/out/src/storage/index.client.d.ts +2 -2
  49. package/out/src/storage/index.client.d.ts.map +1 -1
  50. package/out/src/storage/index.client.js +2 -25
  51. package/out/src/storage/index.client.js.map +1 -1
  52. package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +3 -3
  53. package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
  54. package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
  55. package/out/src/storage/methods/createAction.d.ts.map +1 -1
  56. package/out/src/storage/methods/createAction.js +1 -1
  57. package/out/src/storage/methods/createAction.js.map +1 -1
  58. package/out/src/storage/methods/getBeefForTransaction.js +2 -2
  59. package/out/src/storage/methods/getBeefForTransaction.js.map +1 -1
  60. package/out/src/storage/methods/getSyncChunk.d.ts.map +1 -1
  61. package/out/src/storage/methods/getSyncChunk.js.map +1 -1
  62. package/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
  63. package/out/src/storage/methods/internalizeAction.js +1 -1
  64. package/out/src/storage/methods/internalizeAction.js.map +1 -1
  65. package/out/src/storage/methods/listActions.js.map +1 -1
  66. package/out/src/storage/methods/listCertificates.d.ts.map +1 -1
  67. package/out/src/storage/methods/listCertificates.js.map +1 -1
  68. package/out/src/storage/methods/listOutputs.js.map +1 -1
  69. package/out/src/storage/methods/processAction.d.ts +4 -4
  70. package/out/src/storage/methods/processAction.d.ts.map +1 -1
  71. package/out/src/storage/methods/processAction.js +2 -2
  72. package/out/src/storage/methods/processAction.js.map +1 -1
  73. package/out/src/storage/methods/purgeData.d.ts.map +1 -1
  74. package/out/src/storage/methods/purgeData.js +4 -2
  75. package/out/src/storage/methods/purgeData.js.map +1 -1
  76. package/out/src/storage/methods/reviewStatus.js +1 -1
  77. package/out/src/storage/methods/reviewStatus.js.map +1 -1
  78. package/out/src/storage/remoting/StorageClient.d.ts +11 -11
  79. package/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
  80. package/out/src/storage/remoting/StorageClient.js.map +1 -1
  81. package/out/src/storage/schema/entities/Certificate.d.ts +9 -9
  82. package/out/src/storage/schema/entities/Certificate.d.ts.map +1 -1
  83. package/out/src/storage/schema/entities/Certificate.js +5 -5
  84. package/out/src/storage/schema/entities/Certificate.js.map +1 -1
  85. package/out/src/storage/schema/entities/CertificateField.d.ts +9 -9
  86. package/out/src/storage/schema/entities/CertificateField.d.ts.map +1 -1
  87. package/out/src/storage/schema/entities/CertificateField.js +5 -5
  88. package/out/src/storage/schema/entities/CertificateField.js.map +1 -1
  89. package/out/src/storage/schema/entities/Commission.d.ts +9 -9
  90. package/out/src/storage/schema/entities/Commission.d.ts.map +1 -1
  91. package/out/src/storage/schema/entities/Commission.js +5 -5
  92. package/out/src/storage/schema/entities/Commission.js.map +1 -1
  93. package/out/src/storage/schema/entities/EntityBase.d.ts +1 -1
  94. package/out/src/storage/schema/entities/MergeEntity.d.ts +6 -7
  95. package/out/src/storage/schema/entities/MergeEntity.d.ts.map +1 -1
  96. package/out/src/storage/schema/entities/MergeEntity.js.map +1 -1
  97. package/out/src/storage/schema/entities/Output.d.ts +9 -9
  98. package/out/src/storage/schema/entities/Output.d.ts.map +1 -1
  99. package/out/src/storage/schema/entities/Output.js +5 -5
  100. package/out/src/storage/schema/entities/Output.js.map +1 -1
  101. package/out/src/storage/schema/entities/OutputBasket.d.ts +9 -9
  102. package/out/src/storage/schema/entities/OutputBasket.d.ts.map +1 -1
  103. package/out/src/storage/schema/entities/OutputBasket.js +5 -5
  104. package/out/src/storage/schema/entities/OutputBasket.js.map +1 -1
  105. package/out/src/storage/schema/entities/OutputTag.d.ts +9 -9
  106. package/out/src/storage/schema/entities/OutputTag.d.ts.map +1 -1
  107. package/out/src/storage/schema/entities/OutputTag.js +5 -5
  108. package/out/src/storage/schema/entities/OutputTag.js.map +1 -1
  109. package/out/src/storage/schema/entities/OutputTagMap.d.ts +9 -9
  110. package/out/src/storage/schema/entities/OutputTagMap.d.ts.map +1 -1
  111. package/out/src/storage/schema/entities/OutputTagMap.js +5 -5
  112. package/out/src/storage/schema/entities/OutputTagMap.js.map +1 -1
  113. package/out/src/storage/schema/entities/ProvenTx.d.ts +11 -11
  114. package/out/src/storage/schema/entities/ProvenTx.d.ts.map +1 -1
  115. package/out/src/storage/schema/entities/ProvenTx.js +11 -11
  116. package/out/src/storage/schema/entities/ProvenTx.js.map +1 -1
  117. package/out/src/storage/schema/entities/ProvenTxReq.d.ts +19 -19
  118. package/out/src/storage/schema/entities/ProvenTxReq.d.ts.map +1 -1
  119. package/out/src/storage/schema/entities/ProvenTxReq.js +13 -13
  120. package/out/src/storage/schema/entities/ProvenTxReq.js.map +1 -1
  121. package/out/src/storage/schema/entities/SyncState.d.ts +11 -11
  122. package/out/src/storage/schema/entities/SyncState.d.ts.map +1 -1
  123. package/out/src/storage/schema/entities/SyncState.js +27 -27
  124. package/out/src/storage/schema/entities/SyncState.js.map +1 -1
  125. package/out/src/storage/schema/entities/Transaction.d.ts +11 -11
  126. package/out/src/storage/schema/entities/Transaction.d.ts.map +1 -1
  127. package/out/src/storage/schema/entities/Transaction.js +6 -6
  128. package/out/src/storage/schema/entities/Transaction.js.map +1 -1
  129. package/out/src/storage/schema/entities/TxLabel.d.ts +9 -9
  130. package/out/src/storage/schema/entities/TxLabel.d.ts.map +1 -1
  131. package/out/src/storage/schema/entities/TxLabel.js +5 -5
  132. package/out/src/storage/schema/entities/TxLabel.js.map +1 -1
  133. package/out/src/storage/schema/entities/TxLabelMap.d.ts +9 -9
  134. package/out/src/storage/schema/entities/TxLabelMap.d.ts.map +1 -1
  135. package/out/src/storage/schema/entities/TxLabelMap.js +5 -5
  136. package/out/src/storage/schema/entities/TxLabelMap.js.map +1 -1
  137. package/out/src/storage/schema/entities/User.d.ts +9 -9
  138. package/out/src/storage/schema/entities/User.d.ts.map +1 -1
  139. package/out/src/storage/schema/entities/User.js +5 -5
  140. package/out/src/storage/schema/entities/User.js.map +1 -1
  141. package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.js +20 -307
  142. package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.js.map +1 -1
  143. package/out/src/storage/schema/entities/__tests/CertificateTests.test.js +17 -158
  144. package/out/src/storage/schema/entities/__tests/CertificateTests.test.js.map +1 -1
  145. package/out/src/storage/schema/entities/__tests/CommissionTests.test.js +23 -309
  146. package/out/src/storage/schema/entities/__tests/CommissionTests.test.js.map +1 -1
  147. package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.js +19 -306
  148. package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.js.map +1 -1
  149. package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.js +19 -306
  150. package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.js.map +1 -1
  151. package/out/src/storage/schema/entities/__tests/OutputTagTests.test.js +23 -237
  152. package/out/src/storage/schema/entities/__tests/OutputTagTests.test.js.map +1 -1
  153. package/out/src/storage/schema/entities/__tests/OutputTests.test.js +20 -233
  154. package/out/src/storage/schema/entities/__tests/OutputTests.test.js.map +1 -1
  155. package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.js +27 -98
  156. package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.js.map +1 -1
  157. package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js +25 -241
  158. package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js.map +1 -1
  159. package/out/src/storage/schema/entities/__tests/SyncStateTests.test.js +38 -112
  160. package/out/src/storage/schema/entities/__tests/SyncStateTests.test.js.map +1 -1
  161. package/out/src/storage/schema/entities/__tests/TransactionTests.test.js +39 -323
  162. package/out/src/storage/schema/entities/__tests/TransactionTests.test.js.map +1 -1
  163. package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.js +31 -169
  164. package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.js.map +1 -1
  165. package/out/src/storage/schema/entities/__tests/TxLabelTests.test.js +16 -159
  166. package/out/src/storage/schema/entities/__tests/TxLabelTests.test.js.map +1 -1
  167. package/out/src/storage/schema/entities/__tests/usersTests.test.js +21 -168
  168. package/out/src/storage/schema/entities/__tests/usersTests.test.js.map +1 -1
  169. package/out/src/storage/schema/tables/Certificate.d.ts +4 -4
  170. package/out/src/storage/schema/tables/Certificate.d.ts.map +1 -1
  171. package/out/src/storage/schema/tables/CertificateField.d.ts +1 -1
  172. package/out/src/storage/schema/tables/CertificateField.d.ts.map +1 -1
  173. package/out/src/storage/schema/tables/Commission.d.ts +1 -1
  174. package/out/src/storage/schema/tables/Commission.d.ts.map +1 -1
  175. package/out/src/storage/schema/tables/MonitorEvent.d.ts +1 -1
  176. package/out/src/storage/schema/tables/MonitorEvent.d.ts.map +1 -1
  177. package/out/src/storage/schema/tables/Output.d.ts +5 -5
  178. package/out/src/storage/schema/tables/Output.d.ts.map +1 -1
  179. package/out/src/storage/schema/tables/OutputBasket.d.ts +1 -1
  180. package/out/src/storage/schema/tables/OutputBasket.d.ts.map +1 -1
  181. package/out/src/storage/schema/tables/OutputTag.d.ts +1 -1
  182. package/out/src/storage/schema/tables/OutputTag.d.ts.map +1 -1
  183. package/out/src/storage/schema/tables/OutputTagMap.d.ts +1 -1
  184. package/out/src/storage/schema/tables/OutputTagMap.d.ts.map +1 -1
  185. package/out/src/storage/schema/tables/ProvenTx.d.ts +1 -1
  186. package/out/src/storage/schema/tables/ProvenTx.d.ts.map +1 -1
  187. package/out/src/storage/schema/tables/ProvenTxReq.d.ts +2 -2
  188. package/out/src/storage/schema/tables/ProvenTxReq.d.ts.map +1 -1
  189. package/out/src/storage/schema/tables/SyncState.d.ts +1 -1
  190. package/out/src/storage/schema/tables/SyncState.d.ts.map +1 -1
  191. package/out/src/storage/schema/tables/{Settings.d.ts → TableSettings.d.ts} +2 -2
  192. package/out/src/storage/schema/tables/TableSettings.d.ts.map +1 -0
  193. package/out/src/storage/schema/tables/{Settings.js → TableSettings.js} +1 -1
  194. package/out/src/storage/schema/tables/TableSettings.js.map +1 -0
  195. package/out/src/storage/schema/tables/Transaction.d.ts +1 -1
  196. package/out/src/storage/schema/tables/Transaction.d.ts.map +1 -1
  197. package/out/src/storage/schema/tables/TxLabel.d.ts +1 -1
  198. package/out/src/storage/schema/tables/TxLabel.d.ts.map +1 -1
  199. package/out/src/storage/schema/tables/TxLabelMap.d.ts +1 -1
  200. package/out/src/storage/schema/tables/TxLabelMap.d.ts.map +1 -1
  201. package/out/src/storage/schema/tables/User.d.ts +1 -1
  202. package/out/src/storage/schema/tables/User.d.ts.map +1 -1
  203. package/out/src/storage/schema/tables/index.d.ts +1 -1
  204. package/out/src/storage/schema/tables/index.d.ts.map +1 -1
  205. package/out/src/storage/schema/tables/index.js +1 -1
  206. package/out/src/storage/schema/tables/index.js.map +1 -1
  207. package/out/src/storage/sync/StorageMySQLDojoReader.d.ts +17 -17
  208. package/out/src/storage/sync/StorageMySQLDojoReader.d.ts.map +1 -1
  209. package/out/src/storage/sync/StorageMySQLDojoReader.js +2 -2
  210. package/out/src/storage/sync/StorageMySQLDojoReader.js.map +1 -1
  211. package/out/test/Wallet/certificate/listCertificates.test.js.map +1 -1
  212. package/out/test/Wallet/live/walletLive.man.test.d.ts.map +1 -1
  213. package/out/test/Wallet/live/walletLive.man.test.js +35 -1
  214. package/out/test/Wallet/live/walletLive.man.test.js.map +1 -1
  215. package/out/test/monitor/Monitor.test.js +7 -7
  216. package/out/test/monitor/Monitor.test.js.map +1 -1
  217. package/out/test/storage/StorageMySQLDojoReader.man.test.js +1 -1
  218. package/out/test/storage/StorageMySQLDojoReader.man.test.js.map +1 -1
  219. package/out/test/storage/insert.test.js.map +1 -1
  220. package/out/test/storage/update.test.js.map +1 -1
  221. package/out/test/storage/update2.test.js.map +1 -1
  222. package/out/test/utils/TestUtilsWalletStorage.d.ts +56 -56
  223. package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
  224. package/out/test/utils/TestUtilsWalletStorage.js +11 -4
  225. package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
  226. package/out/test/wallet/action/createActionToGenerateBeefs.man.test.js.map +1 -1
  227. package/out/tsconfig.all.tsbuildinfo +1 -1
  228. package/package.json +2 -2
  229. package/src/monitor/tasks/TaskCheckForProofs.ts +11 -10
  230. package/src/monitor/tasks/TaskSendWaiting.ts +5 -5
  231. package/src/sdk/StorageSyncReader.ts +47 -30
  232. package/src/sdk/StorageSyncReaderWriter.ts +77 -63
  233. package/src/sdk/WalletStorage.interfaces.ts +55 -36
  234. package/src/signer/methods/acquireDirectCertificate.ts +2 -2
  235. package/src/storage/StorageKnex.ts +124 -104
  236. package/src/storage/StorageProvider.ts +43 -30
  237. package/src/storage/StorageReader.ts +36 -21
  238. package/src/storage/StorageReaderWriter.ts +78 -65
  239. package/src/storage/StorageSyncReader.ts +34 -17
  240. package/src/storage/WalletStorageManager.ts +17 -12
  241. package/src/storage/index.all.ts +2 -2
  242. package/src/storage/index.client.ts +2 -2
  243. package/src/storage/methods/attemptToPostReqsToNetwork.ts +3 -3
  244. package/src/storage/methods/createAction.ts +29 -26
  245. package/src/storage/methods/getBeefForTransaction.ts +3 -3
  246. package/src/storage/methods/getSyncChunk.ts +28 -13
  247. package/src/storage/methods/internalizeAction.ts +19 -17
  248. package/src/storage/methods/listActions.ts +5 -5
  249. package/src/storage/methods/listCertificates.ts +2 -2
  250. package/src/storage/methods/listOutputs.ts +5 -5
  251. package/src/storage/methods/processAction.ts +21 -17
  252. package/src/storage/methods/purgeData.ts +20 -12
  253. package/src/storage/methods/reviewStatus.ts +5 -5
  254. package/src/storage/remoting/StorageClient.ts +28 -18
  255. package/src/storage/schema/entities/Certificate.ts +16 -17
  256. package/src/storage/schema/entities/CertificateField.ts +17 -18
  257. package/src/storage/schema/entities/Commission.ts +16 -20
  258. package/src/storage/schema/entities/EntityBase.ts +1 -1
  259. package/src/storage/schema/entities/MergeEntity.ts +7 -7
  260. package/src/storage/schema/entities/Output.ts +16 -20
  261. package/src/storage/schema/entities/OutputBasket.ts +16 -17
  262. package/src/storage/schema/entities/OutputTag.ts +16 -20
  263. package/src/storage/schema/entities/OutputTagMap.ts +17 -18
  264. package/src/storage/schema/entities/ProvenTx.ts +24 -28
  265. package/src/storage/schema/entities/ProvenTxReq.ts +42 -45
  266. package/src/storage/schema/entities/SyncState.ts +61 -38
  267. package/src/storage/schema/entities/Transaction.ts +23 -23
  268. package/src/storage/schema/entities/TxLabel.ts +16 -17
  269. package/src/storage/schema/entities/TxLabelMap.ts +16 -20
  270. package/src/storage/schema/entities/User.ts +15 -19
  271. package/src/storage/schema/entities/__tests/CertificateFieldTests.test.ts +39 -318
  272. package/src/storage/schema/entities/__tests/CertificateTests.test.ts +29 -169
  273. package/src/storage/schema/entities/__tests/CommissionTests.test.ts +47 -325
  274. package/src/storage/schema/entities/__tests/OutputBasketTests.test.ts +35 -316
  275. package/src/storage/schema/entities/__tests/OutputTagMapTests.test.ts +38 -318
  276. package/src/storage/schema/entities/__tests/OutputTagTests.test.ts +36 -249
  277. package/src/storage/schema/entities/__tests/OutputTests.test.ts +30 -244
  278. package/src/storage/schema/entities/__tests/ProvenTxReqTests.test.ts +35 -101
  279. package/src/storage/schema/entities/__tests/ProvenTxTests.test.ts +27 -243
  280. package/src/storage/schema/entities/__tests/SyncStateTests.test.ts +54 -122
  281. package/src/storage/schema/entities/__tests/TransactionTests.test.ts +53 -333
  282. package/src/storage/schema/entities/__tests/TxLabelMapTests.test.ts +44 -177
  283. package/src/storage/schema/entities/__tests/TxLabelTests.test.ts +19 -163
  284. package/src/storage/schema/entities/__tests/usersTests.test.ts +31 -179
  285. package/src/storage/schema/tables/Certificate.ts +4 -4
  286. package/src/storage/schema/tables/CertificateField.ts +1 -1
  287. package/src/storage/schema/tables/Commission.ts +1 -1
  288. package/src/storage/schema/tables/MonitorEvent.ts +1 -1
  289. package/src/storage/schema/tables/Output.ts +5 -5
  290. package/src/storage/schema/tables/OutputBasket.ts +1 -1
  291. package/src/storage/schema/tables/OutputTag.ts +1 -1
  292. package/src/storage/schema/tables/OutputTagMap.ts +1 -1
  293. package/src/storage/schema/tables/ProvenTx.ts +1 -1
  294. package/src/storage/schema/tables/ProvenTxReq.ts +2 -2
  295. package/src/storage/schema/tables/SyncState.ts +1 -1
  296. package/src/storage/schema/tables/{Settings.ts → TableSettings.ts} +3 -1
  297. package/src/storage/schema/tables/Transaction.ts +1 -1
  298. package/src/storage/schema/tables/TxLabel.ts +1 -1
  299. package/src/storage/schema/tables/TxLabelMap.ts +1 -1
  300. package/src/storage/schema/tables/User.ts +1 -1
  301. package/src/storage/schema/tables/index.ts +1 -1
  302. package/src/storage/sync/StorageMySQLDojoReader.ts +67 -50
  303. package/test/Wallet/certificate/listCertificates.test.ts +12 -8
  304. package/test/Wallet/live/walletLive.man.test.ts +46 -6
  305. package/test/monitor/Monitor.test.ts +8 -8
  306. package/test/storage/StorageMySQLDojoReader.man.test.ts +1 -1
  307. package/test/storage/insert.test.ts +2 -2
  308. package/test/storage/update.test.ts +30 -30
  309. package/test/storage/update2.test.ts +23 -24
  310. package/test/utils/TestUtilsWalletStorage.ts +103 -82
  311. package/test/wallet/action/createActionToGenerateBeefs.man.test.ts +1 -2
  312. package/ts2md.json +12 -6
  313. package/out/src/storage/index.db.d.ts +0 -1
  314. package/out/src/storage/index.db.d.ts.map +0 -1
  315. package/out/src/storage/index.db.js +0 -2
  316. package/out/src/storage/index.db.js.map +0 -1
  317. package/out/src/storage/schema/tables/Settings.d.ts.map +0 -1
  318. package/out/src/storage/schema/tables/Settings.js.map +0 -1
  319. package/src/storage/index.db.ts +0 -0
@@ -1,11 +1,16 @@
1
1
  import { Knex } from 'knex'
2
2
  import * as bsv from '@bsv/sdk'
3
- import { entity, table, sdk } from '../../../../../src'
3
+ import {
4
+ createSyncMap,
5
+ sdk,
6
+ SyncMap,
7
+ TableTransaction
8
+ } from '../../../../../src'
4
9
  import {
5
10
  TestUtilsWalletStorage as _tu,
6
11
  TestWalletNoSetup
7
12
  } from '../../../../../test/utils/TestUtilsWalletStorage'
8
- import { Transaction } from '../../../../../src/storage/schema/entities/Transaction'
13
+ import { EntityTransaction } from '../../../../../src/storage/schema/entities/Transaction'
9
14
 
10
15
  describe('Transaction class method tests', () => {
11
16
  jest.setTimeout(99999999)
@@ -35,7 +40,7 @@ describe('Transaction class method tests', () => {
35
40
 
36
41
  // Test: Constructor with default values
37
42
  test('0_creates_instance_with_default_values', () => {
38
- const tx = new Transaction()
43
+ const tx = new EntityTransaction()
39
44
 
40
45
  const now = new Date()
41
46
  expect(tx.transactionId).toBe(0)
@@ -57,7 +62,7 @@ describe('Transaction class method tests', () => {
57
62
  // Test: Constructor with provided API object
58
63
  test('1_creates_instance_with_provided_api_object', () => {
59
64
  const now = new Date()
60
- const apiObject: table.Transaction = {
65
+ const apiObject: TableTransaction = {
61
66
  transactionId: 123,
62
67
  userId: 456,
63
68
  txid: 'testTxid',
@@ -72,7 +77,7 @@ describe('Transaction class method tests', () => {
72
77
  updated_at: now
73
78
  }
74
79
 
75
- const tx = new Transaction(apiObject)
80
+ const tx = new EntityTransaction(apiObject)
76
81
 
77
82
  expect(tx.transactionId).toBe(123)
78
83
  expect(tx.userId).toBe(456)
@@ -90,7 +95,7 @@ describe('Transaction class method tests', () => {
90
95
 
91
96
  // Test: Getters and setters
92
97
  test('2_getters_and_setters_work_correctly', () => {
93
- const tx = new Transaction()
98
+ const tx = new EntityTransaction()
94
99
 
95
100
  const now = new Date()
96
101
  tx.transactionId = 123
@@ -131,9 +136,9 @@ describe('Transaction class method tests', () => {
131
136
  // Test: `getBsvTx` returns parsed transaction
132
137
  test('3_getBsvTx_returns_parsed_transaction', () => {
133
138
  const rawTx = Uint8Array.from([1, 2, 3])
134
- const tx = new Transaction({
139
+ const tx = new EntityTransaction({
135
140
  rawTx: Array.from(rawTx)
136
- } as table.Transaction)
141
+ } as TableTransaction)
137
142
 
138
143
  const bsvTx = tx.getBsvTx()
139
144
  expect(bsvTx).toBeInstanceOf(bsv.Transaction)
@@ -141,7 +146,7 @@ describe('Transaction class method tests', () => {
141
146
 
142
147
  // Test: `getBsvTx` returns undefined if rawTx is not set
143
148
  test('4_getBsvTx_returns_undefined_if_no_rawTx', () => {
144
- const tx = new Transaction()
149
+ const tx = new EntityTransaction()
145
150
  const bsvTx = tx.getBsvTx()
146
151
  expect(bsvTx).toBeUndefined()
147
152
  })
@@ -149,9 +154,9 @@ describe('Transaction class method tests', () => {
149
154
  // Test: `getBsvTxIns` returns parsed inputs
150
155
  test('5_getBsvTxIns_returns_inputs', () => {
151
156
  const rawTx = Uint8Array.from([1, 2, 3])
152
- const tx = new Transaction({
157
+ const tx = new EntityTransaction({
153
158
  rawTx: Array.from(rawTx)
154
- } as table.Transaction)
159
+ } as TableTransaction)
155
160
 
156
161
  const inputs = tx.getBsvTxIns()
157
162
  expect(inputs).toBeInstanceOf(Array)
@@ -166,7 +171,7 @@ describe('Transaction class method tests', () => {
166
171
  undefined,
167
172
  true
168
173
  )
169
- const tx = new Transaction(txData.tx)
174
+ const tx = new EntityTransaction(txData.tx)
170
175
 
171
176
  // Assign rawTx to simulate transaction inputs
172
177
  const rawTx = Uint8Array.from([1, 2, 3])
@@ -219,93 +224,21 @@ describe('Transaction class method tests', () => {
219
224
  )
220
225
 
221
226
  // Create the `Transaction` instance with an earlier updated_at timestamp
222
- const tx = new Transaction({
227
+ const tx = new EntityTransaction({
223
228
  ...txData.tx,
224
229
  updated_at: new Date(2022, 1, 1)
225
230
  })
226
231
 
227
232
  // Create an incoming entity object (`ei`) with a newer updated_at timestamp
228
- const ei: table.Transaction = {
233
+ const ei: TableTransaction = {
229
234
  ...txData.tx,
230
235
  updated_at: new Date(2023, 1, 1),
231
236
  txid: 'newTxId'
232
237
  }
233
238
 
234
- // Prepare a syncMap
235
- const syncMap: entity.SyncMap = {
236
- transaction: {
237
- idMap: { 456: 123 },
238
- entityName: 'Transaction',
239
- maxUpdated_at: undefined,
240
- count: 1
241
- },
242
- provenTx: {
243
- idMap: {},
244
- entityName: 'ProvenTx',
245
- maxUpdated_at: undefined,
246
- count: 0
247
- },
248
- outputBasket: {
249
- idMap: {},
250
- entityName: 'OutputBasket',
251
- maxUpdated_at: undefined,
252
- count: 0
253
- },
254
- provenTxReq: {
255
- idMap: {},
256
- entityName: 'ProvenTxReq',
257
- maxUpdated_at: undefined,
258
- count: 0
259
- },
260
- txLabel: {
261
- idMap: {},
262
- entityName: 'TxLabel',
263
- maxUpdated_at: undefined,
264
- count: 0
265
- },
266
- txLabelMap: {
267
- idMap: {},
268
- entityName: 'TxLabelMap',
269
- maxUpdated_at: undefined,
270
- count: 0
271
- },
272
- output: {
273
- idMap: {},
274
- entityName: 'Output',
275
- maxUpdated_at: undefined,
276
- count: 0
277
- },
278
- outputTag: {
279
- idMap: {},
280
- entityName: 'OutputTag',
281
- maxUpdated_at: undefined,
282
- count: 0
283
- },
284
- outputTagMap: {
285
- idMap: {},
286
- entityName: 'OutputTagMap',
287
- maxUpdated_at: undefined,
288
- count: 0
289
- },
290
- certificate: {
291
- idMap: {},
292
- entityName: 'Certificate',
293
- maxUpdated_at: undefined,
294
- count: 0
295
- },
296
- certificateField: {
297
- idMap: {},
298
- entityName: 'CertificateField',
299
- maxUpdated_at: undefined,
300
- count: 0
301
- },
302
- commission: {
303
- idMap: {},
304
- entityName: 'Commission',
305
- maxUpdated_at: undefined,
306
- count: 0
307
- }
308
- }
239
+ const syncMap = createSyncMap()
240
+ syncMap.transaction.idMap = { 456: 123 }
241
+ syncMap.transaction.count = 1
309
242
 
310
243
  // Execute `mergeExisting`
311
244
  const result = await tx.mergeExisting(
@@ -332,7 +265,7 @@ describe('Transaction class method tests', () => {
332
265
 
333
266
  // Test: getBsvTx handles undefined rawTx
334
267
  test('10_getBsvTx_handles_undefined_rawTx', () => {
335
- const tx = new Transaction() // No rawTx provided
268
+ const tx = new EntityTransaction() // No rawTx provided
336
269
  const bsvTx = tx.getBsvTx()
337
270
  expect(bsvTx).toBeUndefined()
338
271
  })
@@ -348,7 +281,7 @@ describe('Transaction class method tests', () => {
348
281
  )
349
282
 
350
283
  // Create a Transaction instance with the inserted transaction's data
351
- const transaction = new Transaction(tx)
284
+ const transaction = new EntityTransaction(tx)
352
285
 
353
286
  // Insert known inputs into the database and set the `spentBy` column to the transaction ID
354
287
  const input1 = await _tu.insertTestOutput(activeStorage, tx, 0, 100) // vout = 0
@@ -399,9 +332,9 @@ describe('Transaction class method tests', () => {
399
332
  const provenTx = await _tu.insertTestProvenTx(activeStorage)
400
333
 
401
334
  // Create a Transaction instance with a valid provenTxId
402
- const tx = new Transaction({
335
+ const tx = new EntityTransaction({
403
336
  provenTxId: provenTx.provenTxId
404
- } as table.Transaction)
337
+ } as TableTransaction)
405
338
 
406
339
  // Retrieve the ProvenTx using the getProvenTx method
407
340
  const retrievedProvenTx = await tx.getProvenTx(activeStorage)
@@ -416,7 +349,7 @@ describe('Transaction class method tests', () => {
416
349
  test('16_getProvenTx_returns_undefined_when_provenTxId_is_not_set', async () => {
417
350
  for (const { activeStorage } of ctxs) {
418
351
  // Create a Transaction instance with no provenTxId
419
- const tx = new Transaction()
352
+ const tx = new EntityTransaction()
420
353
 
421
354
  // Attempt to retrieve a ProvenTx
422
355
  const retrievedProvenTx = await tx.getProvenTx(activeStorage)
@@ -430,7 +363,7 @@ describe('Transaction class method tests', () => {
430
363
  test('17_getProvenTx_returns_undefined_when_no_matching_ProvenTx_is_found', async () => {
431
364
  for (const { activeStorage } of ctxs) {
432
365
  // Create a Transaction instance with a provenTxId that doesn't exist in storage
433
- const tx = new Transaction({ provenTxId: 9999 } as table.Transaction) // Use an ID unlikely to exist
366
+ const tx = new EntityTransaction({ provenTxId: 9999 } as TableTransaction) // Use an ID unlikely to exist
434
367
 
435
368
  // Attempt to retrieve a ProvenTx
436
369
  const retrievedProvenTx = await tx.getProvenTx(activeStorage)
@@ -456,10 +389,10 @@ describe('Transaction class method tests', () => {
456
389
 
457
390
  // Step 3: Create a Transaction instance with rawTx
458
391
  const rawTx = Uint8Array.from([1, 2, 3]) // Example raw transaction
459
- const transaction = new Transaction({
392
+ const transaction = new EntityTransaction({
460
393
  ...tx,
461
394
  rawTx: Array.from(rawTx)
462
- } as table.Transaction)
395
+ } as TableTransaction)
463
396
 
464
397
  // Step 4: Simulate rawTx inputs
465
398
  transaction.getBsvTxIns = () => [
@@ -489,32 +422,32 @@ describe('Transaction class method tests', () => {
489
422
 
490
423
  // Test: getVersion returns API version
491
424
  test('19_get_version_returns_api_version', () => {
492
- const tx = new Transaction({ version: 2 } as table.Transaction)
425
+ const tx = new EntityTransaction({ version: 2 } as TableTransaction)
493
426
  expect(tx.version).toBe(2)
494
427
  })
495
428
 
496
429
  // Test: getLockTime returns API lockTime
497
430
  test('20_get_lockTime_returns_api_lockTime', () => {
498
- const tx = new Transaction({ lockTime: 500 } as table.Transaction)
431
+ const tx = new EntityTransaction({ lockTime: 500 } as TableTransaction)
499
432
  expect(tx.lockTime).toBe(500)
500
433
  })
501
434
 
502
435
  // Test: set id updates transactionId
503
436
  test('21_set_id_updates_transactionId', () => {
504
- const tx = new Transaction()
437
+ const tx = new EntityTransaction()
505
438
  tx.id = 123
506
439
  expect(tx.transactionId).toBe(123)
507
440
  })
508
441
 
509
442
  // Test: get entityName returns correct value
510
443
  test('22_get_entityName_returns_correct_value', () => {
511
- const tx = new Transaction()
512
- expect(tx.entityName).toBe('ojoTransaction')
444
+ const tx = new EntityTransaction()
445
+ expect(tx.entityName).toBe('transaction')
513
446
  })
514
447
 
515
448
  // Test: get entityTable returns correct value
516
449
  test('23_get_entityTable_returns_correct_value', () => {
517
- const tx = new Transaction()
450
+ const tx = new EntityTransaction()
518
451
  expect(tx.entityTable).toBe('transactions')
519
452
  })
520
453
 
@@ -528,82 +461,13 @@ describe('Transaction class method tests', () => {
528
461
  true
529
462
  )
530
463
 
531
- const syncMap: entity.SyncMap = {
532
- transaction: {
533
- idMap: { [txData.tx.transactionId]: txData.tx.transactionId },
534
- entityName: 'Transaction',
535
- maxUpdated_at: undefined,
536
- count: 1
537
- },
538
- provenTx: {
539
- idMap: {},
540
- entityName: 'ProvenTx',
541
- maxUpdated_at: undefined,
542
- count: 0
543
- },
544
- outputBasket: {
545
- idMap: {},
546
- entityName: 'OutputBasket',
547
- maxUpdated_at: undefined,
548
- count: 0
549
- },
550
- provenTxReq: {
551
- idMap: {},
552
- entityName: 'ProvenTxReq',
553
- maxUpdated_at: undefined,
554
- count: 0
555
- },
556
- txLabel: {
557
- idMap: {},
558
- entityName: 'TxLabel',
559
- maxUpdated_at: undefined,
560
- count: 0
561
- },
562
- txLabelMap: {
563
- idMap: {},
564
- entityName: 'TxLabelMap',
565
- maxUpdated_at: undefined,
566
- count: 0
567
- },
568
- output: {
569
- idMap: {},
570
- entityName: 'Output',
571
- maxUpdated_at: undefined,
572
- count: 0
573
- },
574
- outputTag: {
575
- idMap: {},
576
- entityName: 'OutputTag',
577
- maxUpdated_at: undefined,
578
- count: 0
579
- },
580
- outputTagMap: {
581
- idMap: {},
582
- entityName: 'OutputTagMap',
583
- maxUpdated_at: undefined,
584
- count: 0
585
- },
586
- certificate: {
587
- idMap: {},
588
- entityName: 'Certificate',
589
- maxUpdated_at: undefined,
590
- count: 0
591
- },
592
- certificateField: {
593
- idMap: {},
594
- entityName: 'CertificateField',
595
- maxUpdated_at: undefined,
596
- count: 0
597
- },
598
- commission: {
599
- idMap: {},
600
- entityName: 'Commission',
601
- maxUpdated_at: undefined,
602
- count: 0
603
- }
464
+ const syncMap = createSyncMap()
465
+ syncMap.transaction.idMap = {
466
+ [txData.tx.transactionId]: txData.tx.transactionId
604
467
  }
468
+ syncMap.transaction.count = 1
605
469
 
606
- const tx = new Transaction({
470
+ const tx = new EntityTransaction({
607
471
  ...txData.tx, // Base transaction
608
472
  version: 2,
609
473
  lockTime: 500,
@@ -614,7 +478,7 @@ describe('Transaction class method tests', () => {
614
478
  description: 'desc1',
615
479
  status: 'completed',
616
480
  reference: 'ref1'
617
- } as table.Transaction)
481
+ } as TableTransaction)
618
482
 
619
483
  const other = {
620
484
  transactionId: txData.tx.transactionId, // Matching transactionId
@@ -627,7 +491,7 @@ describe('Transaction class method tests', () => {
627
491
  txid: 'txid2', // Different txid
628
492
  rawTx: [7, 8, 9], // Different rawTx
629
493
  inputBEEF: [10, 11, 12] // Different inputBEEF
630
- } as table.Transaction
494
+ } as TableTransaction
631
495
 
632
496
  expect(tx.equals(other, syncMap)).toBe(false) // Should return false due to mismatched properties
633
497
  }
@@ -685,7 +549,7 @@ describe('Transaction class method tests', () => {
685
549
  const ctx2 = ctxs2[0]
686
550
 
687
551
  // Insert a transaction into the first database
688
- const tx1 = new Transaction({
552
+ const tx1 = new EntityTransaction({
689
553
  transactionId: 405,
690
554
  userId: 1,
691
555
  txid: 'txid1',
@@ -705,7 +569,7 @@ describe('Transaction class method tests', () => {
705
569
  await ctx1.activeStorage.insertTransaction(tx1.toApi())
706
570
 
707
571
  // Insert a matching transaction into the second database
708
- const tx2 = new Transaction({
572
+ const tx2 = new EntityTransaction({
709
573
  transactionId: 405,
710
574
  userId: 1, // Matching userId
711
575
  txid: 'txid1', // Matching txid
@@ -723,81 +587,9 @@ describe('Transaction class method tests', () => {
723
587
  })
724
588
  await ctx2.activeStorage.insertTransaction(tx2.toApi())
725
589
 
726
- // Create a valid SyncMap
727
- const syncMap: entity.SyncMap = {
728
- transaction: {
729
- idMap: { [tx1.transactionId]: tx2.transactionId },
730
- entityName: 'Transaction',
731
- maxUpdated_at: undefined,
732
- count: 1
733
- },
734
- provenTx: {
735
- idMap: {},
736
- entityName: 'ProvenTx',
737
- maxUpdated_at: undefined,
738
- count: 0
739
- },
740
- outputBasket: {
741
- idMap: {},
742
- entityName: 'OutputBasket',
743
- maxUpdated_at: undefined,
744
- count: 0
745
- },
746
- provenTxReq: {
747
- idMap: {},
748
- entityName: 'ProvenTxReq',
749
- maxUpdated_at: undefined,
750
- count: 0
751
- },
752
- txLabel: {
753
- idMap: {},
754
- entityName: 'TxLabel',
755
- maxUpdated_at: undefined,
756
- count: 0
757
- },
758
- txLabelMap: {
759
- idMap: {},
760
- entityName: 'TxLabelMap',
761
- maxUpdated_at: undefined,
762
- count: 0
763
- },
764
- output: {
765
- idMap: {},
766
- entityName: 'Output',
767
- maxUpdated_at: undefined,
768
- count: 0
769
- },
770
- outputTag: {
771
- idMap: {},
772
- entityName: 'OutputTag',
773
- maxUpdated_at: undefined,
774
- count: 0
775
- },
776
- outputTagMap: {
777
- idMap: {},
778
- entityName: 'OutputTagMap',
779
- maxUpdated_at: undefined,
780
- count: 0
781
- },
782
- certificate: {
783
- idMap: {},
784
- entityName: 'Certificate',
785
- maxUpdated_at: undefined,
786
- count: 0
787
- },
788
- certificateField: {
789
- idMap: {},
790
- entityName: 'CertificateField',
791
- maxUpdated_at: undefined,
792
- count: 0
793
- },
794
- commission: {
795
- idMap: {},
796
- entityName: 'Commission',
797
- maxUpdated_at: undefined,
798
- count: 0
799
- }
800
- }
590
+ const syncMap = createSyncMap()
591
+ syncMap.transaction.idMap = { [tx1.transactionId]: tx2.transactionId }
592
+ syncMap.transaction.count = 1
801
593
 
802
594
  // Verify the transactions match
803
595
  expect(tx1.equals(tx2.toApi(), syncMap)).toBe(true)
@@ -809,7 +601,7 @@ describe('Transaction class method tests', () => {
809
601
  const ctx2 = ctxs2[0]
810
602
 
811
603
  // Insert a transaction into the first database
812
- const tx1 = new Transaction({
604
+ const tx1 = new EntityTransaction({
813
605
  transactionId: 303,
814
606
  userId: 1,
815
607
  txid: 'tx456',
@@ -824,7 +616,7 @@ describe('Transaction class method tests', () => {
824
616
  await ctx1.activeStorage.insertTransaction(tx1.toApi())
825
617
 
826
618
  // Insert a non-matching transaction into the second database
827
- const tx2 = new Transaction({
619
+ const tx2 = new EntityTransaction({
828
620
  transactionId: 304,
829
621
  userId: 1,
830
622
  txid: 'tx789',
@@ -838,81 +630,9 @@ describe('Transaction class method tests', () => {
838
630
  })
839
631
  await ctx2.activeStorage.insertTransaction(tx2.toApi())
840
632
 
841
- // Create a valid SyncMap
842
- const syncMap: entity.SyncMap = {
843
- transaction: {
844
- idMap: { [tx1.transactionId]: tx2.transactionId },
845
- entityName: 'Transaction',
846
- maxUpdated_at: undefined,
847
- count: 1
848
- },
849
- provenTx: {
850
- idMap: {},
851
- entityName: 'ProvenTx',
852
- maxUpdated_at: undefined,
853
- count: 0
854
- },
855
- outputBasket: {
856
- idMap: {},
857
- entityName: 'OutputBasket',
858
- maxUpdated_at: undefined,
859
- count: 0
860
- },
861
- provenTxReq: {
862
- idMap: {},
863
- entityName: 'ProvenTxReq',
864
- maxUpdated_at: undefined,
865
- count: 0
866
- },
867
- txLabel: {
868
- idMap: {},
869
- entityName: 'TxLabel',
870
- maxUpdated_at: undefined,
871
- count: 0
872
- },
873
- txLabelMap: {
874
- idMap: {},
875
- entityName: 'TxLabelMap',
876
- maxUpdated_at: undefined,
877
- count: 0
878
- },
879
- output: {
880
- idMap: {},
881
- entityName: 'Output',
882
- maxUpdated_at: undefined,
883
- count: 0
884
- },
885
- outputTag: {
886
- idMap: {},
887
- entityName: 'OutputTag',
888
- maxUpdated_at: undefined,
889
- count: 0
890
- },
891
- outputTagMap: {
892
- idMap: {},
893
- entityName: 'OutputTagMap',
894
- maxUpdated_at: undefined,
895
- count: 0
896
- },
897
- certificate: {
898
- idMap: {},
899
- entityName: 'Certificate',
900
- maxUpdated_at: undefined,
901
- count: 0
902
- },
903
- certificateField: {
904
- idMap: {},
905
- entityName: 'CertificateField',
906
- maxUpdated_at: undefined,
907
- count: 0
908
- },
909
- commission: {
910
- idMap: {},
911
- entityName: 'Commission',
912
- maxUpdated_at: undefined,
913
- count: 0
914
- }
915
- }
633
+ const syncMap = createSyncMap()
634
+ syncMap.transaction.idMap = { [tx1.transactionId]: tx2.transactionId }
635
+ syncMap.transaction.count = 1
916
636
 
917
637
  // Verify the transactions do not match
918
638
  expect(tx1.equals(tx2.toApi(), syncMap)).toBe(false)