@bsv/wallet-toolbox 1.3.2 → 1.3.4

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 (329) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/docs/client.md +97 -28
  3. package/docs/services.md +2 -1
  4. package/docs/setup.md +404 -14
  5. package/docs/storage.md +720 -42
  6. package/docs/wallet.md +97 -28
  7. package/out/src/CWIStyleWalletManager.d.ts.map +1 -1
  8. package/out/src/CWIStyleWalletManager.js +12 -5
  9. package/out/src/CWIStyleWalletManager.js.map +1 -1
  10. package/out/src/Setup.d.ts +2 -69
  11. package/out/src/Setup.d.ts.map +1 -1
  12. package/out/src/Setup.js.map +1 -1
  13. package/out/src/SetupClient.d.ts +126 -0
  14. package/out/src/SetupClient.d.ts.map +1 -0
  15. package/out/src/SetupClient.js +220 -0
  16. package/out/src/SetupClient.js.map +1 -0
  17. package/out/src/SetupWallet.d.ts +100 -0
  18. package/out/src/SetupWallet.d.ts.map +1 -0
  19. package/out/src/{storage/schema/tables/Certificate.js → SetupWallet.js} +1 -1
  20. package/out/src/SetupWallet.js.map +1 -0
  21. package/out/src/index.all.d.ts +2 -0
  22. package/out/src/index.all.d.ts.map +1 -1
  23. package/out/src/index.all.js +2 -0
  24. package/out/src/index.all.js.map +1 -1
  25. package/out/src/index.client.d.ts +1 -0
  26. package/out/src/index.client.d.ts.map +1 -1
  27. package/out/src/index.client.js +1 -0
  28. package/out/src/index.client.js.map +1 -1
  29. package/out/src/monitor/Monitor.d.ts.map +1 -1
  30. package/out/src/monitor/Monitor.js +4 -0
  31. package/out/src/monitor/Monitor.js.map +1 -1
  32. package/out/src/monitor/MonitorDaemon.d.ts.map +1 -1
  33. package/out/src/monitor/MonitorDaemon.js +0 -3
  34. package/out/src/monitor/MonitorDaemon.js.map +1 -1
  35. package/out/src/monitor/tasks/TaskUnFail.d.ts.map +1 -1
  36. package/out/src/monitor/tasks/TaskUnFail.js +1 -2
  37. package/out/src/monitor/tasks/TaskUnFail.js.map +1 -1
  38. package/out/src/sdk/WalletServices.interfaces.d.ts +9 -0
  39. package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -1
  40. package/out/src/services/Services.d.ts +2 -1
  41. package/out/src/services/Services.d.ts.map +1 -1
  42. package/out/src/services/Services.js +8 -0
  43. package/out/src/services/Services.js.map +1 -1
  44. package/out/src/services/__tests/postBeef.test.js +1 -1
  45. package/out/src/services/__tests/postBeef.test.js.map +1 -1
  46. package/out/src/storage/StorageIdb.d.ts +203 -0
  47. package/out/src/storage/StorageIdb.d.ts.map +1 -0
  48. package/out/src/storage/StorageIdb.js +2289 -0
  49. package/out/src/storage/StorageIdb.js.map +1 -0
  50. package/out/src/storage/StorageKnex.d.ts +6 -6
  51. package/out/src/storage/StorageKnex.d.ts.map +1 -1
  52. package/out/src/storage/StorageKnex.js +9 -29
  53. package/out/src/storage/StorageKnex.js.map +1 -1
  54. package/out/src/storage/StorageProvider.d.ts +3 -1
  55. package/out/src/storage/StorageProvider.d.ts.map +1 -1
  56. package/out/src/storage/StorageProvider.js +22 -0
  57. package/out/src/storage/StorageProvider.js.map +1 -1
  58. package/out/src/storage/StorageReader.d.ts +1 -1
  59. package/out/src/storage/StorageReader.d.ts.map +1 -1
  60. package/out/src/storage/StorageReader.js +5 -0
  61. package/out/src/storage/StorageReader.js.map +1 -1
  62. package/out/src/storage/__test/StorageIdb.test.d.ts +2 -0
  63. package/out/src/storage/__test/StorageIdb.test.d.ts.map +1 -0
  64. package/out/src/storage/__test/StorageIdb.test.js +16 -0
  65. package/out/src/storage/__test/StorageIdb.test.js.map +1 -0
  66. package/out/src/storage/methods/ListActionsSpecOp.d.ts +16 -0
  67. package/out/src/storage/methods/ListActionsSpecOp.d.ts.map +1 -0
  68. package/out/src/storage/methods/ListActionsSpecOp.js +40 -0
  69. package/out/src/storage/methods/ListActionsSpecOp.js.map +1 -0
  70. package/out/src/storage/methods/ListOutputsSpecOp.d.ts +26 -0
  71. package/out/src/storage/methods/ListOutputsSpecOp.d.ts.map +1 -0
  72. package/out/src/storage/methods/ListOutputsSpecOp.js +71 -0
  73. package/out/src/storage/methods/ListOutputsSpecOp.js.map +1 -0
  74. package/out/src/storage/methods/listActionsIdb.d.ts +5 -0
  75. package/out/src/storage/methods/listActionsIdb.d.ts.map +1 -0
  76. package/out/src/storage/methods/listActionsIdb.js +155 -0
  77. package/out/src/storage/methods/listActionsIdb.js.map +1 -0
  78. package/out/src/storage/methods/{listActions.d.ts → listActionsKnex.d.ts} +1 -1
  79. package/out/src/storage/methods/listActionsKnex.d.ts.map +1 -0
  80. package/out/src/storage/methods/{listActions.js → listActionsKnex.js} +3 -34
  81. package/out/src/storage/methods/listActionsKnex.js.map +1 -0
  82. package/out/src/storage/methods/listOutputsIdb.d.ts +5 -0
  83. package/out/src/storage/methods/listOutputsIdb.d.ts.map +1 -0
  84. package/out/src/storage/methods/listOutputsIdb.js +181 -0
  85. package/out/src/storage/methods/listOutputsIdb.js.map +1 -0
  86. package/out/src/storage/methods/{listOutputs.d.ts → listOutputsKnex.d.ts} +1 -1
  87. package/out/src/storage/methods/listOutputsKnex.d.ts.map +1 -0
  88. package/out/src/storage/methods/{listOutputs.js → listOutputsKnex.js} +7 -76
  89. package/out/src/storage/methods/listOutputsKnex.js.map +1 -0
  90. package/out/src/storage/methods/purgeDataIdb.d.ts +4 -0
  91. package/out/src/storage/methods/purgeDataIdb.d.ts.map +1 -0
  92. package/out/src/storage/methods/purgeDataIdb.js +9 -0
  93. package/out/src/storage/methods/purgeDataIdb.js.map +1 -0
  94. package/out/src/storage/methods/reviewStatus.d.ts +11 -0
  95. package/out/src/storage/methods/reviewStatus.d.ts.map +1 -1
  96. package/out/src/storage/methods/reviewStatus.js +11 -0
  97. package/out/src/storage/methods/reviewStatus.js.map +1 -1
  98. package/out/src/storage/methods/reviewStatusIdb.d.ts +20 -0
  99. package/out/src/storage/methods/reviewStatusIdb.d.ts.map +1 -0
  100. package/out/src/storage/methods/reviewStatusIdb.js +35 -0
  101. package/out/src/storage/methods/reviewStatusIdb.js.map +1 -0
  102. package/out/src/storage/schema/StorageIdbSchema.d.ts +133 -0
  103. package/out/src/storage/schema/StorageIdbSchema.d.ts.map +1 -0
  104. package/out/src/storage/schema/{tables/CertificateField.js → StorageIdbSchema.js} +1 -1
  105. package/out/src/storage/schema/StorageIdbSchema.js.map +1 -0
  106. package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js +1 -0
  107. package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js.map +1 -1
  108. package/out/src/storage/schema/tables/{Certificate.d.ts → TableCertificate.d.ts} +1 -1
  109. package/out/src/storage/schema/tables/TableCertificate.d.ts.map +1 -0
  110. package/out/src/storage/schema/tables/TableCertificate.js +3 -0
  111. package/out/src/storage/schema/tables/TableCertificate.js.map +1 -0
  112. package/out/src/storage/schema/tables/{CertificateField.d.ts → TableCertificateField.d.ts} +1 -1
  113. package/out/src/storage/schema/tables/TableCertificateField.d.ts.map +1 -0
  114. package/out/src/storage/schema/tables/TableCertificateField.js +3 -0
  115. package/out/src/storage/schema/tables/TableCertificateField.js.map +1 -0
  116. package/out/src/storage/schema/tables/{Commission.d.ts → TableCommission.d.ts} +1 -1
  117. package/out/src/storage/schema/tables/TableCommission.d.ts.map +1 -0
  118. package/out/src/storage/schema/tables/TableCommission.js +3 -0
  119. package/out/src/storage/schema/tables/TableCommission.js.map +1 -0
  120. package/out/src/storage/schema/tables/{MonitorEvent.d.ts → TableMonitorEvent.d.ts} +1 -1
  121. package/out/src/storage/schema/tables/TableMonitorEvent.d.ts.map +1 -0
  122. package/out/src/storage/schema/tables/TableMonitorEvent.js +3 -0
  123. package/out/src/storage/schema/tables/TableMonitorEvent.js.map +1 -0
  124. package/out/src/storage/schema/tables/{Output.d.ts → TableOutput.d.ts} +1 -1
  125. package/out/src/storage/schema/tables/TableOutput.d.ts.map +1 -0
  126. package/out/src/storage/schema/tables/{Output.js → TableOutput.js} +1 -1
  127. package/out/src/storage/schema/tables/TableOutput.js.map +1 -0
  128. package/out/src/storage/schema/tables/{OutputBasket.d.ts → TableOutputBasket.d.ts} +1 -1
  129. package/out/src/storage/schema/tables/TableOutputBasket.d.ts.map +1 -0
  130. package/out/src/storage/schema/tables/TableOutputBasket.js +3 -0
  131. package/out/src/storage/schema/tables/TableOutputBasket.js.map +1 -0
  132. package/out/src/storage/schema/tables/{OutputTag.d.ts → TableOutputTag.d.ts} +1 -1
  133. package/out/src/storage/schema/tables/TableOutputTag.d.ts.map +1 -0
  134. package/out/src/storage/schema/tables/{MonitorEvent.js → TableOutputTag.js} +1 -1
  135. package/out/src/storage/schema/tables/TableOutputTag.js.map +1 -0
  136. package/out/src/storage/schema/tables/{OutputTagMap.d.ts → TableOutputTagMap.d.ts} +1 -1
  137. package/out/src/storage/schema/tables/TableOutputTagMap.d.ts.map +1 -0
  138. package/out/src/storage/schema/tables/TableOutputTagMap.js +3 -0
  139. package/out/src/storage/schema/tables/TableOutputTagMap.js.map +1 -0
  140. package/out/src/storage/schema/tables/{ProvenTx.d.ts → TableProvenTx.d.ts} +1 -1
  141. package/out/src/storage/schema/tables/TableProvenTx.d.ts.map +1 -0
  142. package/out/src/storage/schema/tables/{Commission.js → TableProvenTx.js} +1 -1
  143. package/out/src/storage/schema/tables/TableProvenTx.js.map +1 -0
  144. package/out/src/storage/schema/tables/{ProvenTxReq.d.ts → TableProvenTxReq.d.ts} +1 -1
  145. package/out/src/storage/schema/tables/TableProvenTxReq.d.ts.map +1 -0
  146. package/out/src/storage/schema/tables/TableProvenTxReq.js +3 -0
  147. package/out/src/storage/schema/tables/TableProvenTxReq.js.map +1 -0
  148. package/out/src/storage/schema/tables/TableSettings.d.ts +1 -1
  149. package/out/src/storage/schema/tables/TableSettings.d.ts.map +1 -1
  150. package/out/src/storage/schema/tables/{SyncState.d.ts → TableSyncState.d.ts} +1 -1
  151. package/out/src/storage/schema/tables/TableSyncState.d.ts.map +1 -0
  152. package/out/src/storage/schema/tables/TableSyncState.js +3 -0
  153. package/out/src/storage/schema/tables/TableSyncState.js.map +1 -0
  154. package/out/src/storage/schema/tables/{Transaction.d.ts → TableTransaction.d.ts} +1 -1
  155. package/out/src/storage/schema/tables/TableTransaction.d.ts.map +1 -0
  156. package/out/src/storage/schema/tables/{Transaction.js → TableTransaction.js} +1 -1
  157. package/out/src/storage/schema/tables/TableTransaction.js.map +1 -0
  158. package/out/src/storage/schema/tables/{TxLabel.d.ts → TableTxLabel.d.ts} +1 -1
  159. package/out/src/storage/schema/tables/TableTxLabel.d.ts.map +1 -0
  160. package/out/src/storage/schema/tables/{OutputBasket.js → TableTxLabel.js} +1 -1
  161. package/out/src/storage/schema/tables/TableTxLabel.js.map +1 -0
  162. package/out/src/storage/schema/tables/{TxLabelMap.d.ts → TableTxLabelMap.d.ts} +1 -1
  163. package/out/src/storage/schema/tables/TableTxLabelMap.d.ts.map +1 -0
  164. package/out/src/storage/schema/tables/TableTxLabelMap.js +3 -0
  165. package/out/src/storage/schema/tables/TableTxLabelMap.js.map +1 -0
  166. package/out/src/storage/schema/tables/{User.d.ts → TableUser.d.ts} +1 -1
  167. package/out/src/storage/schema/tables/TableUser.d.ts.map +1 -0
  168. package/out/src/storage/schema/tables/{SyncState.js → TableUser.js} +1 -1
  169. package/out/src/storage/schema/tables/TableUser.js.map +1 -0
  170. package/out/src/storage/schema/tables/index.d.ts +15 -15
  171. package/out/src/storage/schema/tables/index.d.ts.map +1 -1
  172. package/out/src/storage/schema/tables/index.js +15 -15
  173. package/out/src/storage/schema/tables/index.js.map +1 -1
  174. package/out/test/Wallet/local/localWallet2.man.test.js +4 -0
  175. package/out/test/Wallet/local/localWallet2.man.test.js.map +1 -1
  176. package/out/test/Wallet/support/operations.man.test.d.ts +2 -0
  177. package/out/test/Wallet/support/operations.man.test.d.ts.map +1 -0
  178. package/out/test/Wallet/support/{opers1.man.test.js → operations.man.test.js} +41 -6
  179. package/out/test/Wallet/support/operations.man.test.js.map +1 -0
  180. package/out/test/storage/find.test.js +1 -1
  181. package/out/test/storage/find.test.js.map +1 -1
  182. package/out/test/storage/idb/allocateChange.test.d.ts +2 -0
  183. package/out/test/storage/idb/allocateChange.test.d.ts.map +1 -0
  184. package/out/test/storage/idb/allocateChange.test.js +110 -0
  185. package/out/test/storage/idb/allocateChange.test.js.map +1 -0
  186. package/out/test/storage/idb/count.test.d.ts +2 -0
  187. package/out/test/storage/idb/count.test.d.ts.map +1 -0
  188. package/out/test/storage/idb/count.test.js +129 -0
  189. package/out/test/storage/idb/count.test.js.map +1 -0
  190. package/out/test/storage/idb/find.test.d.ts +2 -0
  191. package/out/test/storage/idb/find.test.d.ts.map +1 -0
  192. package/out/test/storage/idb/find.test.js +131 -0
  193. package/out/test/storage/idb/find.test.js.map +1 -0
  194. package/out/test/storage/idb/idbSpeed.test.d.ts +2 -0
  195. package/out/test/storage/idb/idbSpeed.test.d.ts.map +1 -0
  196. package/out/test/storage/idb/idbSpeed.test.js +29 -0
  197. package/out/test/storage/idb/idbSpeed.test.js.map +1 -0
  198. package/out/test/storage/idb/insert.test.d.ts +2 -0
  199. package/out/test/storage/idb/insert.test.d.ts.map +1 -0
  200. package/out/test/storage/idb/insert.test.js +242 -0
  201. package/out/test/storage/idb/insert.test.js.map +1 -0
  202. package/out/test/storage/idb/transactionAbort.test.d.ts +2 -0
  203. package/out/test/storage/idb/transactionAbort.test.d.ts.map +1 -0
  204. package/out/test/storage/idb/transactionAbort.test.js +97 -0
  205. package/out/test/storage/idb/transactionAbort.test.js.map +1 -0
  206. package/out/test/storage/idb/update.test.d.ts +2 -0
  207. package/out/test/storage/idb/update.test.d.ts.map +1 -0
  208. package/out/test/storage/idb/update.test.js +902 -0
  209. package/out/test/storage/idb/update.test.js.map +1 -0
  210. package/out/test/storage/update.test.js +2 -2
  211. package/out/test/storage/update.test.js.map +1 -1
  212. package/out/test/utils/TestUtilsWalletStorage.d.ts +24 -1
  213. package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
  214. package/out/test/utils/TestUtilsWalletStorage.js +147 -3
  215. package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
  216. package/out/test/wallet/list/listActions.test.d.ts +1 -1
  217. package/out/test/wallet/list/listActions.test.d.ts.map +1 -1
  218. package/out/test/wallet/list/listActions.test.js +9 -3
  219. package/out/test/wallet/list/listActions.test.js.map +1 -1
  220. package/out/test/wallet/list/listOutputs.test.d.ts +1 -1
  221. package/out/test/wallet/list/listOutputs.test.d.ts.map +1 -1
  222. package/out/test/wallet/list/listOutputs.test.js +34 -219
  223. package/out/test/wallet/list/listOutputs.test.js.map +1 -1
  224. package/out/tsconfig.all.tsbuildinfo +1 -1
  225. package/package.json +3 -1
  226. package/src/CWIStyleWalletManager.ts +12 -5
  227. package/src/Setup.ts +1 -71
  228. package/src/SetupClient.ts +312 -0
  229. package/src/SetupWallet.ts +105 -0
  230. package/src/index.all.ts +2 -0
  231. package/src/index.client.ts +1 -0
  232. package/src/monitor/Monitor.ts +4 -0
  233. package/src/monitor/MonitorDaemon.ts +0 -1
  234. package/src/monitor/tasks/TaskUnFail.ts +3 -4
  235. package/src/sdk/WalletServices.interfaces.ts +10 -0
  236. package/src/services/Services.ts +13 -1
  237. package/src/services/__tests/postBeef.test.ts +1 -1
  238. package/src/storage/StorageIdb.ts +2298 -0
  239. package/src/storage/StorageKnex.ts +7 -32
  240. package/src/storage/StorageProvider.ts +28 -0
  241. package/src/storage/StorageReader.ts +5 -1
  242. package/src/storage/__test/StorageIdb.test.ts +15 -0
  243. package/src/storage/methods/ListActionsSpecOp.ts +68 -0
  244. package/src/storage/methods/ListOutputsSpecOp.ts +125 -0
  245. package/src/storage/methods/listActionsIdb.ts +181 -0
  246. package/src/storage/methods/{listActions.ts → listActionsKnex.ts} +2 -64
  247. package/src/storage/methods/listOutputsIdb.ts +199 -0
  248. package/src/storage/methods/{listOutputs.ts → listOutputsKnex.ts} +9 -133
  249. package/src/storage/methods/purgeDataIdb.ts +15 -0
  250. package/src/storage/methods/reviewStatus.ts +11 -0
  251. package/src/storage/methods/reviewStatusIdb.ts +43 -0
  252. package/src/storage/schema/StorageIdbSchema.ts +150 -0
  253. package/src/storage/schema/entities/__tests/ProvenTxTests.test.ts +2 -0
  254. package/src/storage/schema/tables/TableSettings.ts +1 -1
  255. package/src/storage/schema/tables/index.ts +15 -15
  256. package/test/Wallet/local/localWallet2.man.test.ts +5 -0
  257. package/test/Wallet/support/{opers1.man.test.ts → operations.man.test.ts} +43 -14
  258. package/test/storage/find.test.ts +1 -1
  259. package/test/storage/idb/allocateChange.test.ts +251 -0
  260. package/test/storage/idb/count.test.ts +158 -0
  261. package/test/storage/idb/find.test.ts +177 -0
  262. package/test/storage/idb/idbSpeed.test.ts +34 -0
  263. package/test/storage/idb/insert.test.ts +268 -0
  264. package/test/storage/idb/transactionAbort.test.ts +108 -0
  265. package/test/storage/idb/update.test.ts +1000 -0
  266. package/test/storage/update.test.ts +2 -2
  267. package/test/utils/TestUtilsWalletStorage.ts +188 -4
  268. package/test/wallet/list/listActions.test.ts +15 -5
  269. package/test/wallet/list/listOutputs.test.ts +29 -214
  270. package/out/src/storage/methods/listActions.d.ts.map +0 -1
  271. package/out/src/storage/methods/listActions.js.map +0 -1
  272. package/out/src/storage/methods/listOutputs.d.ts.map +0 -1
  273. package/out/src/storage/methods/listOutputs.js.map +0 -1
  274. package/out/src/storage/schema/tables/Certificate.d.ts.map +0 -1
  275. package/out/src/storage/schema/tables/Certificate.js.map +0 -1
  276. package/out/src/storage/schema/tables/CertificateField.d.ts.map +0 -1
  277. package/out/src/storage/schema/tables/CertificateField.js.map +0 -1
  278. package/out/src/storage/schema/tables/Commission.d.ts.map +0 -1
  279. package/out/src/storage/schema/tables/Commission.js.map +0 -1
  280. package/out/src/storage/schema/tables/MonitorEvent.d.ts.map +0 -1
  281. package/out/src/storage/schema/tables/MonitorEvent.js.map +0 -1
  282. package/out/src/storage/schema/tables/Output.d.ts.map +0 -1
  283. package/out/src/storage/schema/tables/Output.js.map +0 -1
  284. package/out/src/storage/schema/tables/OutputBasket.d.ts.map +0 -1
  285. package/out/src/storage/schema/tables/OutputBasket.js.map +0 -1
  286. package/out/src/storage/schema/tables/OutputTag.d.ts.map +0 -1
  287. package/out/src/storage/schema/tables/OutputTag.js +0 -3
  288. package/out/src/storage/schema/tables/OutputTag.js.map +0 -1
  289. package/out/src/storage/schema/tables/OutputTagMap.d.ts.map +0 -1
  290. package/out/src/storage/schema/tables/OutputTagMap.js +0 -3
  291. package/out/src/storage/schema/tables/OutputTagMap.js.map +0 -1
  292. package/out/src/storage/schema/tables/ProvenTx.d.ts.map +0 -1
  293. package/out/src/storage/schema/tables/ProvenTx.js +0 -3
  294. package/out/src/storage/schema/tables/ProvenTx.js.map +0 -1
  295. package/out/src/storage/schema/tables/ProvenTxReq.d.ts.map +0 -1
  296. package/out/src/storage/schema/tables/ProvenTxReq.js +0 -3
  297. package/out/src/storage/schema/tables/ProvenTxReq.js.map +0 -1
  298. package/out/src/storage/schema/tables/SyncState.d.ts.map +0 -1
  299. package/out/src/storage/schema/tables/SyncState.js.map +0 -1
  300. package/out/src/storage/schema/tables/Transaction.d.ts.map +0 -1
  301. package/out/src/storage/schema/tables/Transaction.js.map +0 -1
  302. package/out/src/storage/schema/tables/TxLabel.d.ts.map +0 -1
  303. package/out/src/storage/schema/tables/TxLabel.js +0 -3
  304. package/out/src/storage/schema/tables/TxLabel.js.map +0 -1
  305. package/out/src/storage/schema/tables/TxLabelMap.d.ts.map +0 -1
  306. package/out/src/storage/schema/tables/TxLabelMap.js +0 -3
  307. package/out/src/storage/schema/tables/TxLabelMap.js.map +0 -1
  308. package/out/src/storage/schema/tables/User.d.ts.map +0 -1
  309. package/out/src/storage/schema/tables/User.js +0 -3
  310. package/out/src/storage/schema/tables/User.js.map +0 -1
  311. package/out/test/Wallet/support/opers1.man.test.d.ts +0 -2
  312. package/out/test/Wallet/support/opers1.man.test.d.ts.map +0 -1
  313. package/out/test/Wallet/support/opers1.man.test.js.map +0 -1
  314. package/unlock-migrations.sh +0 -41
  315. /package/src/storage/schema/tables/{Certificate.ts → TableCertificate.ts} +0 -0
  316. /package/src/storage/schema/tables/{CertificateField.ts → TableCertificateField.ts} +0 -0
  317. /package/src/storage/schema/tables/{Commission.ts → TableCommission.ts} +0 -0
  318. /package/src/storage/schema/tables/{MonitorEvent.ts → TableMonitorEvent.ts} +0 -0
  319. /package/src/storage/schema/tables/{Output.ts → TableOutput.ts} +0 -0
  320. /package/src/storage/schema/tables/{OutputBasket.ts → TableOutputBasket.ts} +0 -0
  321. /package/src/storage/schema/tables/{OutputTag.ts → TableOutputTag.ts} +0 -0
  322. /package/src/storage/schema/tables/{OutputTagMap.ts → TableOutputTagMap.ts} +0 -0
  323. /package/src/storage/schema/tables/{ProvenTx.ts → TableProvenTx.ts} +0 -0
  324. /package/src/storage/schema/tables/{ProvenTxReq.ts → TableProvenTxReq.ts} +0 -0
  325. /package/src/storage/schema/tables/{SyncState.ts → TableSyncState.ts} +0 -0
  326. /package/src/storage/schema/tables/{Transaction.ts → TableTransaction.ts} +0 -0
  327. /package/src/storage/schema/tables/{TxLabel.ts → TableTxLabel.ts} +0 -0
  328. /package/src/storage/schema/tables/{TxLabelMap.ts → TableTxLabelMap.ts} +0 -0
  329. /package/src/storage/schema/tables/{User.ts → TableUser.ts} +0 -0
@@ -21,7 +21,7 @@ import {
21
21
 
22
22
  setLogging(false)
23
23
 
24
- describe('update tests', () => {
24
+ describe('idb update tests', () => {
25
25
  jest.setTimeout(99999999)
26
26
 
27
27
  const chain: sdk.Chain = 'test'
@@ -57,7 +57,7 @@ describe('update tests', () => {
57
57
  }
58
58
  for (const storage of storages) {
59
59
  await storage.dropAllData()
60
- await storage.migrate('insert tests', '1'.repeat(64))
60
+ await storage.migrate('update tests', '1'.repeat(64))
61
61
  await storage.makeAvailable()
62
62
  setups.push({ storage, setup: await _tu.createTestSetup1(storage) })
63
63
  }
@@ -58,7 +58,8 @@ import {
58
58
  import { Knex, knex as makeKnex } from 'knex'
59
59
 
60
60
  import * as dotenv from 'dotenv'
61
- import { WalletServicesOptions } from '../../src/sdk'
61
+ import { TrxToken, WalletServicesOptions } from '../../src/sdk'
62
+ import { StorageIdb } from '../../src/storage/StorageIdb'
62
63
  dotenv.config()
63
64
 
64
65
  const localMySqlConnection = process.env.MYSQL_CONNECTION || ''
@@ -830,6 +831,170 @@ export abstract class TestUtilsWalletStorage {
830
831
  return r
831
832
  }
832
833
 
834
+ static wrapProfiling(o: Object, name: string): Record<string, { count: number; totalMsecs: number }> {
835
+ const getFunctionsNames = (obj: Object) => {
836
+ let fNames: string[] = []
837
+ do {
838
+ fNames = fNames.concat(
839
+ Object.getOwnPropertyNames(obj).filter(p => p !== 'constructor' && typeof obj[p] === 'function')
840
+ )
841
+ } while ((obj = Object.getPrototypeOf(obj)) && obj !== Object.prototype)
842
+
843
+ return fNames
844
+ }
845
+
846
+ const notifyPerformance = (fn, performanceDetails) => {
847
+ setTimeout(() => {
848
+ let { functionName, args, startTime, endTime } = performanceDetails
849
+ let _args = args
850
+ if (Array.isArray(args)) {
851
+ _args = args.map(arg => {
852
+ if (typeof arg === 'function') {
853
+ let fName = arg.name
854
+ if (!fName) {
855
+ fName = 'function'
856
+ } else if (fName === 'callbackWrapper') {
857
+ fName = 'callback'
858
+ }
859
+ arg = `[${fName} Function]`
860
+ }
861
+ return arg
862
+ })
863
+ }
864
+ fn({ functionName, args: _args, startTime, endTime })
865
+ }, 0)
866
+ }
867
+
868
+ const stats: Record<string, { count: number; totalMsecs: number }> = {}
869
+
870
+ function logger(args: { functionName: string; args: any; startTime: number; endTime: number }) {
871
+ let s = stats[args.functionName]
872
+ if (!s) {
873
+ s = { count: 0, totalMsecs: 0 }
874
+ stats[args.functionName] = s
875
+ }
876
+ s.count++
877
+ s.totalMsecs += args.endTime - args.startTime
878
+ }
879
+
880
+ const performanceWrapper = (obj: Object, objectName: string, performanceNotificationCallback: any) => {
881
+ let _notifyPerformance = notifyPerformance.bind(null, performanceNotificationCallback)
882
+ let fNames = getFunctionsNames(obj)
883
+ for (let fName of fNames) {
884
+ let originalFunction = obj[fName]
885
+ let wrapperFunction = (...args) => {
886
+ let callbackFnIndex = -1
887
+ let startTime = Date.now()
888
+ let _callBack = args.filter((arg, i) => {
889
+ let _isFunction = typeof arg === 'function'
890
+ if (_isFunction) {
891
+ callbackFnIndex = i
892
+ }
893
+ return _isFunction
894
+ })[0]
895
+ if (_callBack) {
896
+ let callbackWrapper = (...callbackArgs) => {
897
+ let endTime = Date.now()
898
+ _notifyPerformance({ functionName: `${objectName}.${fName}`, args, startTime, endTime })
899
+ _callBack.apply(null, callbackArgs)
900
+ }
901
+ args[callbackFnIndex] = callbackWrapper
902
+ }
903
+ let originalReturnObject = originalFunction.apply(obj, args)
904
+ let isPromiseType =
905
+ originalReturnObject &&
906
+ typeof originalReturnObject.then === 'function' &&
907
+ typeof originalReturnObject.catch === 'function'
908
+ if (isPromiseType) {
909
+ return originalReturnObject
910
+ .then(resolveArgs => {
911
+ let endTime = Date.now()
912
+ _notifyPerformance({ functionName: `${objectName}.${fName}`, args, startTime, endTime })
913
+ return Promise.resolve(resolveArgs)
914
+ })
915
+ .catch((...rejectArgs) => {
916
+ let endTime = Date.now()
917
+ _notifyPerformance({ functionName: `${objectName}.${fName}`, args, startTime, endTime })
918
+ return Promise.reject(...rejectArgs)
919
+ })
920
+ }
921
+ if (!_callBack && !isPromiseType) {
922
+ let endTime = Date.now()
923
+ _notifyPerformance({ functionName: `${objectName}.${fName}`, args, startTime, endTime })
924
+ }
925
+ return originalReturnObject
926
+ }
927
+ obj[fName] = wrapperFunction
928
+ }
929
+
930
+ return obj
931
+ }
932
+
933
+ const functionNames = getFunctionsNames(o)
934
+
935
+ performanceWrapper(o, name, logger)
936
+
937
+ return stats
938
+ }
939
+
940
+ static async createIdbLegacyWalletCopy(databaseName: string): Promise<TestWalletProviderNoSetup> {
941
+ const chain: sdk.Chain = 'test'
942
+
943
+ const readerFile = await _tu.existingDataFile(`walletLegacyTestData.sqlite`)
944
+ const readerKnex = _tu.createLocalSQLite(readerFile)
945
+ const reader = new StorageKnex({
946
+ chain,
947
+ knex: readerKnex,
948
+ commissionSatoshis: 0,
949
+ commissionPubKeyHex: undefined,
950
+ feeModel: { model: 'sat/kb', value: 1 }
951
+ })
952
+ await reader.makeAvailable()
953
+
954
+ const rootKeyHex = _tu.legacyRootKeyHex
955
+ const identityKey = '03ac2d10bdb0023f4145cc2eba2fcd2ad3070cb2107b0b48170c46a9440e4cc3fe'
956
+ const rootKey = PrivateKey.fromHex(rootKeyHex)
957
+ const keyDeriver = new KeyDeriver(rootKey)
958
+
959
+ const activeStorage = new StorageIdb({
960
+ chain,
961
+ commissionSatoshis: 0,
962
+ commissionPubKeyHex: undefined,
963
+ feeModel: { model: 'sat/kb', value: 1 }
964
+ })
965
+
966
+ await activeStorage.dropAllData()
967
+ await activeStorage.migrate(databaseName, randomBytesHex(33))
968
+ await activeStorage.makeAvailable()
969
+
970
+ const storage = new WalletStorageManager(identityKey, activeStorage)
971
+ await storage.makeAvailable()
972
+
973
+ await storage.syncFromReader(identityKey, new StorageSyncReader({ identityKey }, reader))
974
+
975
+ await reader.destroy()
976
+
977
+ const services = new Services(chain)
978
+ const monopts = Monitor.createDefaultWalletMonitorOptions(chain, storage, services)
979
+ const monitor = new Monitor(monopts)
980
+ const wallet = new Wallet({ chain, keyDeriver, storage, services, monitor })
981
+ const userId = verifyTruthy(await activeStorage.findUserByIdentityKey(identityKey)).userId
982
+ const r: TestWalletProvider<{}> = {
983
+ rootKey,
984
+ identityKey,
985
+ keyDeriver,
986
+ chain,
987
+ activeStorage,
988
+ storage,
989
+ setup: {},
990
+ services,
991
+ monitor,
992
+ wallet,
993
+ userId
994
+ }
995
+ return r
996
+ }
997
+
833
998
  static makeSampleCert(subject?: string): {
834
999
  cert: WalletCertificate
835
1000
  subject: string
@@ -854,7 +1019,7 @@ export abstract class TestUtilsWalletStorage {
854
1019
  return { cert, subject, certifier }
855
1020
  }
856
1021
 
857
- static async insertTestProvenTx(storage: StorageProvider, txid?: string) {
1022
+ static async insertTestProvenTx(storage: StorageProvider, txid?: string, trx?: TrxToken) {
858
1023
  const now = new Date()
859
1024
  const ptx: TableProvenTx = {
860
1025
  created_at: now,
@@ -868,7 +1033,7 @@ export abstract class TestUtilsWalletStorage {
868
1033
  blockHash: randomBytesHex(32),
869
1034
  merkleRoot: randomBytesHex(32)
870
1035
  }
871
- await storage.insertProvenTx(ptx)
1036
+ await storage.insertProvenTx(ptx, trx)
872
1037
  return ptx
873
1038
  }
874
1039
 
@@ -1038,7 +1203,7 @@ export abstract class TestUtilsWalletStorage {
1038
1203
  senderIdentityKey: requiredOnly ? undefined : randomBytesHex(32),
1039
1204
  derivationPrefix: requiredOnly ? undefined : randomBytesHex(16),
1040
1205
  derivationSuffix: requiredOnly ? undefined : randomBytesHex(16),
1041
- spentBy: undefined, // must be a valid transsactionId
1206
+ spentBy: undefined, // must be a valid transactionId
1042
1207
  sequenceNumber: requiredOnly ? undefined : 42,
1043
1208
  spendingDescription: requiredOnly ? undefined : randomBytesHex(16),
1044
1209
  scriptLength: requiredOnly ? undefined : 36,
@@ -1640,6 +1805,24 @@ export interface MockData {
1640
1805
 
1641
1806
  export interface TestSetup2 extends MockData {}
1642
1807
 
1808
+ export interface TestWalletProvider<T> extends TestWalletOnly {
1809
+ activeStorage: StorageProvider
1810
+ setup?: T
1811
+ userId: number
1812
+
1813
+ rootKey: PrivateKey
1814
+ identityKey: string
1815
+ keyDeriver: KeyDeriver
1816
+ chain: sdk.Chain
1817
+ storage: WalletStorageManager
1818
+ services: Services
1819
+ monitor: Monitor
1820
+ wallet: Wallet
1821
+ localStorageIdentityKey?: string
1822
+ clientStorageIdentityKey?: string
1823
+ localBackupStorageIdentityKey?: string
1824
+ }
1825
+
1643
1826
  export interface TestWallet<T> extends TestWalletOnly {
1644
1827
  activeStorage: StorageKnex
1645
1828
  setup?: T
@@ -1676,6 +1859,7 @@ async function insertEmptySetup(storage: StorageKnex, identityKey: string): Prom
1676
1859
  export type TestSetup2Wallet = TestWallet<TestSetup2>
1677
1860
  export type TestSetup1Wallet = TestWallet<TestSetup1>
1678
1861
  export type TestWalletNoSetup = TestWallet<{}>
1862
+ export type TestWalletProviderNoSetup = TestWalletProvider<{}>
1679
1863
 
1680
1864
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1681
1865
  export async function expectToThrowWERR<R>(
@@ -1,6 +1,15 @@
1
1
  import { ListActionsArgs } from '@bsv/sdk'
2
2
  import { sdk, StorageProvider } from '../../../src/index.client'
3
- import { _tu, expectToThrowWERR, TestSetup1, TestWalletNoSetup } from '../../utils/TestUtilsWalletStorage'
3
+ import {
4
+ _tu,
5
+ expectToThrowWERR,
6
+ TestSetup1,
7
+ TestWalletNoSetup,
8
+ TestWalletProviderNoSetup
9
+ } from '../../utils/TestUtilsWalletStorage'
10
+ import path from 'path'
11
+
12
+ import 'fake-indexeddb/auto'
4
13
 
5
14
  describe('listActions tests', () => {
6
15
  jest.setTimeout(99999999)
@@ -10,15 +19,16 @@ describe('listActions tests', () => {
10
19
  const setups: { setup: TestSetup1; storage: StorageProvider }[] = []
11
20
 
12
21
  const env = _tu.getEnv('test')
13
- const ctxs: TestWalletNoSetup[] = []
22
+ const ctxs: TestWalletProviderNoSetup[] = []
14
23
  const testName = () => expect.getState().currentTestName || 'test'
15
- const name = testName.name
24
+ const databaseName = path.parse(expect.getState().testPath!).name
16
25
 
17
26
  beforeAll(async () => {
18
27
  if (env.runMySQL) {
19
- ctxs.push(await _tu.createLegacyWalletMySQLCopy(name))
28
+ ctxs.push(await _tu.createLegacyWalletMySQLCopy(databaseName))
20
29
  }
21
- ctxs.push(await _tu.createLegacyWalletSQLiteCopy(name))
30
+ ctxs.push(await _tu.createIdbLegacyWalletCopy(databaseName))
31
+ ctxs.push(await _tu.createLegacyWalletSQLiteCopy(databaseName))
22
32
  })
23
33
 
24
34
  afterAll(async () => {