@bsv/wallet-toolbox 1.3.3 → 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 (320) 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/Setup.d.ts +2 -69
  8. package/out/src/Setup.d.ts.map +1 -1
  9. package/out/src/Setup.js.map +1 -1
  10. package/out/src/SetupClient.d.ts +126 -0
  11. package/out/src/SetupClient.d.ts.map +1 -0
  12. package/out/src/SetupClient.js +220 -0
  13. package/out/src/SetupClient.js.map +1 -0
  14. package/out/src/SetupWallet.d.ts +100 -0
  15. package/out/src/SetupWallet.d.ts.map +1 -0
  16. package/out/src/{storage/schema/tables/Certificate.js → SetupWallet.js} +1 -1
  17. package/out/src/SetupWallet.js.map +1 -0
  18. package/out/src/index.all.d.ts +2 -0
  19. package/out/src/index.all.d.ts.map +1 -1
  20. package/out/src/index.all.js +2 -0
  21. package/out/src/index.all.js.map +1 -1
  22. package/out/src/index.client.d.ts +1 -0
  23. package/out/src/index.client.d.ts.map +1 -1
  24. package/out/src/index.client.js +1 -0
  25. package/out/src/index.client.js.map +1 -1
  26. package/out/src/monitor/Monitor.d.ts.map +1 -1
  27. package/out/src/monitor/Monitor.js +4 -0
  28. package/out/src/monitor/Monitor.js.map +1 -1
  29. package/out/src/monitor/MonitorDaemon.d.ts.map +1 -1
  30. package/out/src/monitor/MonitorDaemon.js +0 -3
  31. package/out/src/monitor/MonitorDaemon.js.map +1 -1
  32. package/out/src/monitor/tasks/TaskUnFail.d.ts.map +1 -1
  33. package/out/src/monitor/tasks/TaskUnFail.js +1 -2
  34. package/out/src/monitor/tasks/TaskUnFail.js.map +1 -1
  35. package/out/src/sdk/WalletServices.interfaces.d.ts +1 -1
  36. package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -1
  37. package/out/src/services/__tests/postBeef.test.js +1 -1
  38. package/out/src/services/__tests/postBeef.test.js.map +1 -1
  39. package/out/src/storage/StorageIdb.d.ts +203 -0
  40. package/out/src/storage/StorageIdb.d.ts.map +1 -0
  41. package/out/src/storage/StorageIdb.js +2289 -0
  42. package/out/src/storage/StorageIdb.js.map +1 -0
  43. package/out/src/storage/StorageKnex.d.ts +6 -6
  44. package/out/src/storage/StorageKnex.d.ts.map +1 -1
  45. package/out/src/storage/StorageKnex.js +9 -29
  46. package/out/src/storage/StorageKnex.js.map +1 -1
  47. package/out/src/storage/StorageProvider.d.ts +3 -1
  48. package/out/src/storage/StorageProvider.d.ts.map +1 -1
  49. package/out/src/storage/StorageProvider.js +22 -0
  50. package/out/src/storage/StorageProvider.js.map +1 -1
  51. package/out/src/storage/StorageReader.d.ts +1 -1
  52. package/out/src/storage/StorageReader.d.ts.map +1 -1
  53. package/out/src/storage/StorageReader.js +5 -0
  54. package/out/src/storage/StorageReader.js.map +1 -1
  55. package/out/src/storage/__test/StorageIdb.test.d.ts +2 -0
  56. package/out/src/storage/__test/StorageIdb.test.d.ts.map +1 -0
  57. package/out/src/storage/__test/StorageIdb.test.js +16 -0
  58. package/out/src/storage/__test/StorageIdb.test.js.map +1 -0
  59. package/out/src/storage/methods/ListActionsSpecOp.d.ts +16 -0
  60. package/out/src/storage/methods/ListActionsSpecOp.d.ts.map +1 -0
  61. package/out/src/storage/methods/ListActionsSpecOp.js +40 -0
  62. package/out/src/storage/methods/ListActionsSpecOp.js.map +1 -0
  63. package/out/src/storage/methods/ListOutputsSpecOp.d.ts +26 -0
  64. package/out/src/storage/methods/ListOutputsSpecOp.d.ts.map +1 -0
  65. package/out/src/storage/methods/ListOutputsSpecOp.js +71 -0
  66. package/out/src/storage/methods/ListOutputsSpecOp.js.map +1 -0
  67. package/out/src/storage/methods/listActionsIdb.d.ts +5 -0
  68. package/out/src/storage/methods/listActionsIdb.d.ts.map +1 -0
  69. package/out/src/storage/methods/listActionsIdb.js +155 -0
  70. package/out/src/storage/methods/listActionsIdb.js.map +1 -0
  71. package/out/src/storage/methods/{listActions.d.ts → listActionsKnex.d.ts} +1 -1
  72. package/out/src/storage/methods/listActionsKnex.d.ts.map +1 -0
  73. package/out/src/storage/methods/{listActions.js → listActionsKnex.js} +3 -34
  74. package/out/src/storage/methods/listActionsKnex.js.map +1 -0
  75. package/out/src/storage/methods/listOutputsIdb.d.ts +5 -0
  76. package/out/src/storage/methods/listOutputsIdb.d.ts.map +1 -0
  77. package/out/src/storage/methods/listOutputsIdb.js +181 -0
  78. package/out/src/storage/methods/listOutputsIdb.js.map +1 -0
  79. package/out/src/storage/methods/{listOutputs.d.ts → listOutputsKnex.d.ts} +1 -1
  80. package/out/src/storage/methods/listOutputsKnex.d.ts.map +1 -0
  81. package/out/src/storage/methods/{listOutputs.js → listOutputsKnex.js} +7 -76
  82. package/out/src/storage/methods/listOutputsKnex.js.map +1 -0
  83. package/out/src/storage/methods/purgeDataIdb.d.ts +4 -0
  84. package/out/src/storage/methods/purgeDataIdb.d.ts.map +1 -0
  85. package/out/src/storage/methods/purgeDataIdb.js +9 -0
  86. package/out/src/storage/methods/purgeDataIdb.js.map +1 -0
  87. package/out/src/storage/methods/reviewStatus.d.ts +11 -0
  88. package/out/src/storage/methods/reviewStatus.d.ts.map +1 -1
  89. package/out/src/storage/methods/reviewStatus.js +11 -0
  90. package/out/src/storage/methods/reviewStatus.js.map +1 -1
  91. package/out/src/storage/methods/reviewStatusIdb.d.ts +20 -0
  92. package/out/src/storage/methods/reviewStatusIdb.d.ts.map +1 -0
  93. package/out/src/storage/methods/reviewStatusIdb.js +35 -0
  94. package/out/src/storage/methods/reviewStatusIdb.js.map +1 -0
  95. package/out/src/storage/schema/StorageIdbSchema.d.ts +133 -0
  96. package/out/src/storage/schema/StorageIdbSchema.d.ts.map +1 -0
  97. package/out/src/storage/schema/{tables/CertificateField.js → StorageIdbSchema.js} +1 -1
  98. package/out/src/storage/schema/StorageIdbSchema.js.map +1 -0
  99. package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js +1 -1
  100. package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js.map +1 -1
  101. package/out/src/storage/schema/tables/{Certificate.d.ts → TableCertificate.d.ts} +1 -1
  102. package/out/src/storage/schema/tables/TableCertificate.d.ts.map +1 -0
  103. package/out/src/storage/schema/tables/TableCertificate.js +3 -0
  104. package/out/src/storage/schema/tables/TableCertificate.js.map +1 -0
  105. package/out/src/storage/schema/tables/{CertificateField.d.ts → TableCertificateField.d.ts} +1 -1
  106. package/out/src/storage/schema/tables/TableCertificateField.d.ts.map +1 -0
  107. package/out/src/storage/schema/tables/TableCertificateField.js +3 -0
  108. package/out/src/storage/schema/tables/TableCertificateField.js.map +1 -0
  109. package/out/src/storage/schema/tables/{Commission.d.ts → TableCommission.d.ts} +1 -1
  110. package/out/src/storage/schema/tables/TableCommission.d.ts.map +1 -0
  111. package/out/src/storage/schema/tables/TableCommission.js +3 -0
  112. package/out/src/storage/schema/tables/TableCommission.js.map +1 -0
  113. package/out/src/storage/schema/tables/{MonitorEvent.d.ts → TableMonitorEvent.d.ts} +1 -1
  114. package/out/src/storage/schema/tables/TableMonitorEvent.d.ts.map +1 -0
  115. package/out/src/storage/schema/tables/TableMonitorEvent.js +3 -0
  116. package/out/src/storage/schema/tables/TableMonitorEvent.js.map +1 -0
  117. package/out/src/storage/schema/tables/{Output.d.ts → TableOutput.d.ts} +1 -1
  118. package/out/src/storage/schema/tables/TableOutput.d.ts.map +1 -0
  119. package/out/src/storage/schema/tables/{Output.js → TableOutput.js} +1 -1
  120. package/out/src/storage/schema/tables/TableOutput.js.map +1 -0
  121. package/out/src/storage/schema/tables/{OutputBasket.d.ts → TableOutputBasket.d.ts} +1 -1
  122. package/out/src/storage/schema/tables/TableOutputBasket.d.ts.map +1 -0
  123. package/out/src/storage/schema/tables/TableOutputBasket.js +3 -0
  124. package/out/src/storage/schema/tables/TableOutputBasket.js.map +1 -0
  125. package/out/src/storage/schema/tables/{OutputTag.d.ts → TableOutputTag.d.ts} +1 -1
  126. package/out/src/storage/schema/tables/TableOutputTag.d.ts.map +1 -0
  127. package/out/src/storage/schema/tables/{MonitorEvent.js → TableOutputTag.js} +1 -1
  128. package/out/src/storage/schema/tables/TableOutputTag.js.map +1 -0
  129. package/out/src/storage/schema/tables/{OutputTagMap.d.ts → TableOutputTagMap.d.ts} +1 -1
  130. package/out/src/storage/schema/tables/TableOutputTagMap.d.ts.map +1 -0
  131. package/out/src/storage/schema/tables/TableOutputTagMap.js +3 -0
  132. package/out/src/storage/schema/tables/TableOutputTagMap.js.map +1 -0
  133. package/out/src/storage/schema/tables/{ProvenTx.d.ts → TableProvenTx.d.ts} +1 -1
  134. package/out/src/storage/schema/tables/TableProvenTx.d.ts.map +1 -0
  135. package/out/src/storage/schema/tables/{Commission.js → TableProvenTx.js} +1 -1
  136. package/out/src/storage/schema/tables/TableProvenTx.js.map +1 -0
  137. package/out/src/storage/schema/tables/{ProvenTxReq.d.ts → TableProvenTxReq.d.ts} +1 -1
  138. package/out/src/storage/schema/tables/TableProvenTxReq.d.ts.map +1 -0
  139. package/out/src/storage/schema/tables/TableProvenTxReq.js +3 -0
  140. package/out/src/storage/schema/tables/TableProvenTxReq.js.map +1 -0
  141. package/out/src/storage/schema/tables/TableSettings.d.ts +1 -1
  142. package/out/src/storage/schema/tables/TableSettings.d.ts.map +1 -1
  143. package/out/src/storage/schema/tables/{SyncState.d.ts → TableSyncState.d.ts} +1 -1
  144. package/out/src/storage/schema/tables/TableSyncState.d.ts.map +1 -0
  145. package/out/src/storage/schema/tables/TableSyncState.js +3 -0
  146. package/out/src/storage/schema/tables/TableSyncState.js.map +1 -0
  147. package/out/src/storage/schema/tables/{Transaction.d.ts → TableTransaction.d.ts} +1 -1
  148. package/out/src/storage/schema/tables/TableTransaction.d.ts.map +1 -0
  149. package/out/src/storage/schema/tables/{Transaction.js → TableTransaction.js} +1 -1
  150. package/out/src/storage/schema/tables/TableTransaction.js.map +1 -0
  151. package/out/src/storage/schema/tables/{TxLabel.d.ts → TableTxLabel.d.ts} +1 -1
  152. package/out/src/storage/schema/tables/TableTxLabel.d.ts.map +1 -0
  153. package/out/src/storage/schema/tables/{OutputBasket.js → TableTxLabel.js} +1 -1
  154. package/out/src/storage/schema/tables/TableTxLabel.js.map +1 -0
  155. package/out/src/storage/schema/tables/{TxLabelMap.d.ts → TableTxLabelMap.d.ts} +1 -1
  156. package/out/src/storage/schema/tables/TableTxLabelMap.d.ts.map +1 -0
  157. package/out/src/storage/schema/tables/TableTxLabelMap.js +3 -0
  158. package/out/src/storage/schema/tables/TableTxLabelMap.js.map +1 -0
  159. package/out/src/storage/schema/tables/{User.d.ts → TableUser.d.ts} +1 -1
  160. package/out/src/storage/schema/tables/TableUser.d.ts.map +1 -0
  161. package/out/src/storage/schema/tables/{SyncState.js → TableUser.js} +1 -1
  162. package/out/src/storage/schema/tables/TableUser.js.map +1 -0
  163. package/out/src/storage/schema/tables/index.d.ts +15 -15
  164. package/out/src/storage/schema/tables/index.d.ts.map +1 -1
  165. package/out/src/storage/schema/tables/index.js +15 -15
  166. package/out/src/storage/schema/tables/index.js.map +1 -1
  167. package/out/test/Wallet/local/localWallet2.man.test.js +4 -0
  168. package/out/test/Wallet/local/localWallet2.man.test.js.map +1 -1
  169. package/out/test/Wallet/support/operations.man.test.d.ts +2 -0
  170. package/out/test/Wallet/support/operations.man.test.d.ts.map +1 -0
  171. package/out/test/Wallet/support/{opers1.man.test.js → operations.man.test.js} +39 -4
  172. package/out/test/Wallet/support/operations.man.test.js.map +1 -0
  173. package/out/test/storage/find.test.js +1 -1
  174. package/out/test/storage/find.test.js.map +1 -1
  175. package/out/test/storage/idb/allocateChange.test.d.ts +2 -0
  176. package/out/test/storage/idb/allocateChange.test.d.ts.map +1 -0
  177. package/out/test/storage/idb/allocateChange.test.js +110 -0
  178. package/out/test/storage/idb/allocateChange.test.js.map +1 -0
  179. package/out/test/storage/idb/count.test.d.ts +2 -0
  180. package/out/test/storage/idb/count.test.d.ts.map +1 -0
  181. package/out/test/storage/idb/count.test.js +129 -0
  182. package/out/test/storage/idb/count.test.js.map +1 -0
  183. package/out/test/storage/idb/find.test.d.ts +2 -0
  184. package/out/test/storage/idb/find.test.d.ts.map +1 -0
  185. package/out/test/storage/idb/find.test.js +131 -0
  186. package/out/test/storage/idb/find.test.js.map +1 -0
  187. package/out/test/storage/idb/idbSpeed.test.d.ts +2 -0
  188. package/out/test/storage/idb/idbSpeed.test.d.ts.map +1 -0
  189. package/out/test/storage/idb/idbSpeed.test.js +29 -0
  190. package/out/test/storage/idb/idbSpeed.test.js.map +1 -0
  191. package/out/test/storage/idb/insert.test.d.ts +2 -0
  192. package/out/test/storage/idb/insert.test.d.ts.map +1 -0
  193. package/out/test/storage/idb/insert.test.js +242 -0
  194. package/out/test/storage/idb/insert.test.js.map +1 -0
  195. package/out/test/storage/idb/transactionAbort.test.d.ts +2 -0
  196. package/out/test/storage/idb/transactionAbort.test.d.ts.map +1 -0
  197. package/out/test/storage/idb/transactionAbort.test.js +97 -0
  198. package/out/test/storage/idb/transactionAbort.test.js.map +1 -0
  199. package/out/test/storage/idb/update.test.d.ts +2 -0
  200. package/out/test/storage/idb/update.test.d.ts.map +1 -0
  201. package/out/test/storage/idb/update.test.js +902 -0
  202. package/out/test/storage/idb/update.test.js.map +1 -0
  203. package/out/test/storage/update.test.js +2 -2
  204. package/out/test/storage/update.test.js.map +1 -1
  205. package/out/test/utils/TestUtilsWalletStorage.d.ts +24 -1
  206. package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
  207. package/out/test/utils/TestUtilsWalletStorage.js +147 -3
  208. package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
  209. package/out/test/wallet/list/listActions.test.d.ts +1 -1
  210. package/out/test/wallet/list/listActions.test.d.ts.map +1 -1
  211. package/out/test/wallet/list/listActions.test.js +9 -3
  212. package/out/test/wallet/list/listActions.test.js.map +1 -1
  213. package/out/test/wallet/list/listOutputs.test.d.ts +1 -1
  214. package/out/test/wallet/list/listOutputs.test.d.ts.map +1 -1
  215. package/out/test/wallet/list/listOutputs.test.js +34 -219
  216. package/out/test/wallet/list/listOutputs.test.js.map +1 -1
  217. package/out/tsconfig.all.tsbuildinfo +1 -1
  218. package/package.json +3 -1
  219. package/src/Setup.ts +1 -71
  220. package/src/SetupClient.ts +312 -0
  221. package/src/SetupWallet.ts +105 -0
  222. package/src/index.all.ts +2 -0
  223. package/src/index.client.ts +1 -0
  224. package/src/monitor/Monitor.ts +4 -0
  225. package/src/monitor/MonitorDaemon.ts +0 -1
  226. package/src/monitor/tasks/TaskUnFail.ts +3 -4
  227. package/src/sdk/WalletServices.interfaces.ts +1 -2
  228. package/src/services/__tests/postBeef.test.ts +1 -1
  229. package/src/storage/StorageIdb.ts +2298 -0
  230. package/src/storage/StorageKnex.ts +7 -32
  231. package/src/storage/StorageProvider.ts +28 -0
  232. package/src/storage/StorageReader.ts +5 -1
  233. package/src/storage/__test/StorageIdb.test.ts +15 -0
  234. package/src/storage/methods/ListActionsSpecOp.ts +68 -0
  235. package/src/storage/methods/ListOutputsSpecOp.ts +125 -0
  236. package/src/storage/methods/listActionsIdb.ts +181 -0
  237. package/src/storage/methods/{listActions.ts → listActionsKnex.ts} +2 -64
  238. package/src/storage/methods/listOutputsIdb.ts +199 -0
  239. package/src/storage/methods/{listOutputs.ts → listOutputsKnex.ts} +9 -133
  240. package/src/storage/methods/purgeDataIdb.ts +15 -0
  241. package/src/storage/methods/reviewStatus.ts +11 -0
  242. package/src/storage/methods/reviewStatusIdb.ts +43 -0
  243. package/src/storage/schema/StorageIdbSchema.ts +150 -0
  244. package/src/storage/schema/entities/__tests/ProvenTxTests.test.ts +1 -1
  245. package/src/storage/schema/tables/TableSettings.ts +1 -1
  246. package/src/storage/schema/tables/index.ts +15 -15
  247. package/test/Wallet/local/localWallet2.man.test.ts +5 -0
  248. package/test/Wallet/support/{opers1.man.test.ts → operations.man.test.ts} +41 -12
  249. package/test/storage/find.test.ts +1 -1
  250. package/test/storage/idb/allocateChange.test.ts +251 -0
  251. package/test/storage/idb/count.test.ts +158 -0
  252. package/test/storage/idb/find.test.ts +177 -0
  253. package/test/storage/idb/idbSpeed.test.ts +34 -0
  254. package/test/storage/idb/insert.test.ts +268 -0
  255. package/test/storage/idb/transactionAbort.test.ts +108 -0
  256. package/test/storage/idb/update.test.ts +1000 -0
  257. package/test/storage/update.test.ts +2 -2
  258. package/test/utils/TestUtilsWalletStorage.ts +188 -4
  259. package/test/wallet/list/listActions.test.ts +15 -5
  260. package/test/wallet/list/listOutputs.test.ts +29 -214
  261. package/out/src/storage/methods/listActions.d.ts.map +0 -1
  262. package/out/src/storage/methods/listActions.js.map +0 -1
  263. package/out/src/storage/methods/listOutputs.d.ts.map +0 -1
  264. package/out/src/storage/methods/listOutputs.js.map +0 -1
  265. package/out/src/storage/schema/tables/Certificate.d.ts.map +0 -1
  266. package/out/src/storage/schema/tables/Certificate.js.map +0 -1
  267. package/out/src/storage/schema/tables/CertificateField.d.ts.map +0 -1
  268. package/out/src/storage/schema/tables/CertificateField.js.map +0 -1
  269. package/out/src/storage/schema/tables/Commission.d.ts.map +0 -1
  270. package/out/src/storage/schema/tables/Commission.js.map +0 -1
  271. package/out/src/storage/schema/tables/MonitorEvent.d.ts.map +0 -1
  272. package/out/src/storage/schema/tables/MonitorEvent.js.map +0 -1
  273. package/out/src/storage/schema/tables/Output.d.ts.map +0 -1
  274. package/out/src/storage/schema/tables/Output.js.map +0 -1
  275. package/out/src/storage/schema/tables/OutputBasket.d.ts.map +0 -1
  276. package/out/src/storage/schema/tables/OutputBasket.js.map +0 -1
  277. package/out/src/storage/schema/tables/OutputTag.d.ts.map +0 -1
  278. package/out/src/storage/schema/tables/OutputTag.js +0 -3
  279. package/out/src/storage/schema/tables/OutputTag.js.map +0 -1
  280. package/out/src/storage/schema/tables/OutputTagMap.d.ts.map +0 -1
  281. package/out/src/storage/schema/tables/OutputTagMap.js +0 -3
  282. package/out/src/storage/schema/tables/OutputTagMap.js.map +0 -1
  283. package/out/src/storage/schema/tables/ProvenTx.d.ts.map +0 -1
  284. package/out/src/storage/schema/tables/ProvenTx.js +0 -3
  285. package/out/src/storage/schema/tables/ProvenTx.js.map +0 -1
  286. package/out/src/storage/schema/tables/ProvenTxReq.d.ts.map +0 -1
  287. package/out/src/storage/schema/tables/ProvenTxReq.js +0 -3
  288. package/out/src/storage/schema/tables/ProvenTxReq.js.map +0 -1
  289. package/out/src/storage/schema/tables/SyncState.d.ts.map +0 -1
  290. package/out/src/storage/schema/tables/SyncState.js.map +0 -1
  291. package/out/src/storage/schema/tables/Transaction.d.ts.map +0 -1
  292. package/out/src/storage/schema/tables/Transaction.js.map +0 -1
  293. package/out/src/storage/schema/tables/TxLabel.d.ts.map +0 -1
  294. package/out/src/storage/schema/tables/TxLabel.js +0 -3
  295. package/out/src/storage/schema/tables/TxLabel.js.map +0 -1
  296. package/out/src/storage/schema/tables/TxLabelMap.d.ts.map +0 -1
  297. package/out/src/storage/schema/tables/TxLabelMap.js +0 -3
  298. package/out/src/storage/schema/tables/TxLabelMap.js.map +0 -1
  299. package/out/src/storage/schema/tables/User.d.ts.map +0 -1
  300. package/out/src/storage/schema/tables/User.js +0 -3
  301. package/out/src/storage/schema/tables/User.js.map +0 -1
  302. package/out/test/Wallet/support/opers1.man.test.d.ts +0 -2
  303. package/out/test/Wallet/support/opers1.man.test.d.ts.map +0 -1
  304. package/out/test/Wallet/support/opers1.man.test.js.map +0 -1
  305. package/unlock-migrations.sh +0 -41
  306. /package/src/storage/schema/tables/{Certificate.ts → TableCertificate.ts} +0 -0
  307. /package/src/storage/schema/tables/{CertificateField.ts → TableCertificateField.ts} +0 -0
  308. /package/src/storage/schema/tables/{Commission.ts → TableCommission.ts} +0 -0
  309. /package/src/storage/schema/tables/{MonitorEvent.ts → TableMonitorEvent.ts} +0 -0
  310. /package/src/storage/schema/tables/{Output.ts → TableOutput.ts} +0 -0
  311. /package/src/storage/schema/tables/{OutputBasket.ts → TableOutputBasket.ts} +0 -0
  312. /package/src/storage/schema/tables/{OutputTag.ts → TableOutputTag.ts} +0 -0
  313. /package/src/storage/schema/tables/{OutputTagMap.ts → TableOutputTagMap.ts} +0 -0
  314. /package/src/storage/schema/tables/{ProvenTx.ts → TableProvenTx.ts} +0 -0
  315. /package/src/storage/schema/tables/{ProvenTxReq.ts → TableProvenTxReq.ts} +0 -0
  316. /package/src/storage/schema/tables/{SyncState.ts → TableSyncState.ts} +0 -0
  317. /package/src/storage/schema/tables/{Transaction.ts → TableTransaction.ts} +0 -0
  318. /package/src/storage/schema/tables/{TxLabel.ts → TableTxLabel.ts} +0 -0
  319. /package/src/storage/schema/tables/{TxLabelMap.ts → TableTxLabelMap.ts} +0 -0
  320. /package/src/storage/schema/tables/{User.ts → TableUser.ts} +0 -0
@@ -27,8 +27,8 @@ import {
27
27
  import { Knex } from 'knex'
28
28
  import { StorageProvider, StorageProviderOptions } from './StorageProvider'
29
29
  import { purgeData } from './methods/purgeData'
30
- import { listActions } from './methods/listActions'
31
- import { listOutputs } from './methods/listOutputs'
30
+ import { listActions } from './methods/listActionsKnex'
31
+ import { listOutputs } from './methods/listOutputsKnex'
32
32
  import { DBType } from './StorageReader'
33
33
  import { reviewStatus } from './methods/reviewStatus'
34
34
 
@@ -835,19 +835,6 @@ export class StorageKnex extends StorageProvider implements sdk.WalletStoragePro
835
835
  t.rawTx = rawTx
836
836
  }
837
837
 
838
- async validateOutputScript(o: TableOutput, trx?: sdk.TrxToken): Promise<void> {
839
- // without offset and length values return what we have (make no changes)
840
- if (!o.scriptLength || !o.scriptOffset || !o.txid) return
841
- // if there is an outputScript and its length is the expected length return what we have.
842
- if (o.lockingScript && o.lockingScript.length === o.scriptLength) return
843
-
844
- // outputScript is missing or has incorrect length...
845
-
846
- const script = await this.getRawTxOfKnownValidTransaction(o.txid, o.scriptOffset, o.scriptLength, trx)
847
- if (!script) return
848
- o.lockingScript = script
849
- }
850
-
851
838
  _verifiedReadyForDatabaseAccess: boolean = false
852
839
 
853
840
  /**
@@ -961,20 +948,6 @@ export class StorageKnex extends StorageProvider implements sdk.WalletStoragePro
961
948
  return this.validateEntities(labels, undefined, ['isDeleted'])
962
949
  }
963
950
 
964
- async extendOutput(
965
- o: TableOutput,
966
- includeBasket = false,
967
- includeTags = false,
968
- trx?: sdk.TrxToken
969
- ): Promise<TableOutputX> {
970
- const ox = o as TableOutputX
971
- if (includeBasket && ox.basketId) ox.basket = await this.findOutputBasketById(o.basketId!, trx)
972
- if (includeTags) {
973
- ox.tags = await this.getTagsForOutputId(o.outputId)
974
- }
975
- return o
976
- }
977
-
978
951
  override async getTagsForOutputId(outputId: number, trx?: sdk.TrxToken): Promise<TableOutputTag[]> {
979
952
  const tags = await this.toDb(trx)<TableOutputTag>('output_tags')
980
953
  .join('output_tags_map', 'output_tags_map.outputTagId', 'output_tags.outputTagId')
@@ -993,9 +966,11 @@ export class StorageKnex extends StorageProvider implements sdk.WalletStoragePro
993
966
  }
994
967
 
995
968
  /**
996
- * Finds closest matching available change output to use as input for new transaction.
997
- *
998
- * Transactionally allocate the output such that
969
+ * Counts the outputs for userId in basketId that are spendable: true
970
+ * AND whose transaction status is one of:
971
+ * - completed
972
+ * - unproven
973
+ * - sending (if excludeSending is false)
999
974
  */
1000
975
  async countChangeInputs(userId: number, basketId: number, excludeSending: boolean): Promise<number> {
1001
976
  const status: sdk.TransactionStatus[] = ['completed', 'unproven']
@@ -22,6 +22,7 @@ import {
22
22
  TableOutput,
23
23
  TableOutputBasket,
24
24
  TableOutputTag,
25
+ TableOutputX,
25
26
  TableProvenTxReq,
26
27
  TableProvenTxReqDynamics,
27
28
  TableTransaction,
@@ -635,6 +636,33 @@ export abstract class StorageProvider extends StorageReaderWriter implements sdk
635
636
 
636
637
  return await this.updateProvenTxReq(id, partial, trx)
637
638
  }
639
+
640
+ async extendOutput(
641
+ o: TableOutput,
642
+ includeBasket = false,
643
+ includeTags = false,
644
+ trx?: sdk.TrxToken
645
+ ): Promise<TableOutputX> {
646
+ const ox = o as TableOutputX
647
+ if (includeBasket && ox.basketId) ox.basket = await this.findOutputBasketById(o.basketId!, trx)
648
+ if (includeTags) {
649
+ ox.tags = await this.getTagsForOutputId(o.outputId)
650
+ }
651
+ return o
652
+ }
653
+
654
+ async validateOutputScript(o: TableOutput, trx?: sdk.TrxToken): Promise<void> {
655
+ // without offset and length values return what we have (make no changes)
656
+ if (!o.scriptLength || !o.scriptOffset || !o.txid) return
657
+ // if there is an outputScript and its length is the expected length return what we have.
658
+ if (o.lockingScript && o.lockingScript.length === o.scriptLength) return
659
+
660
+ // outputScript is missing or has incorrect length...
661
+
662
+ const script = await this.getRawTxOfKnownValidTransaction(o.txid, o.scriptOffset, o.scriptLength, trx)
663
+ if (!script) return
664
+ o.lockingScript = script
665
+ }
638
666
  }
639
667
 
640
668
  export interface StorageProviderOptions extends StorageReaderWriterOptions {
@@ -51,6 +51,7 @@ export abstract class StorageReader implements sdk.WalletStorageSyncReader {
51
51
  return !!this._settings
52
52
  }
53
53
  async makeAvailable(): Promise<TableSettings> {
54
+ if (this._settings) return this._settings
54
55
  return (this._settings = await this.readSettings())
55
56
  }
56
57
 
@@ -115,6 +116,7 @@ export abstract class StorageReader implements sdk.WalletStorageSyncReader {
115
116
  if (!this.dbtype) throw new sdk.WERR_INTERNAL('must call verifyReadyForDatabaseAccess first')
116
117
  let r: Date | string = this.validateDate(date)
117
118
  switch (this.dbtype) {
119
+ case 'IndexedDB':
118
120
  case 'MySQL':
119
121
  break
120
122
  case 'SQLite':
@@ -140,6 +142,7 @@ export abstract class StorageReader implements sdk.WalletStorageSyncReader {
140
142
  let r: Date | string | undefined = this.validateOptionalDate(date)
141
143
  if (!r && useNowAsDefault) r = new Date()
142
144
  switch (this.dbtype) {
145
+ case 'IndexedDB':
143
146
  case 'MySQL':
144
147
  break
145
148
  case 'SQLite':
@@ -169,6 +172,7 @@ export abstract class StorageReader implements sdk.WalletStorageSyncReader {
169
172
  const vdate = verifyTruthy(this.validateDate(date))
170
173
  let r: Date | string | number
171
174
  switch (this.dbtype) {
175
+ case 'IndexedDB':
172
176
  case 'MySQL':
173
177
  r = vdate
174
178
  break
@@ -186,7 +190,7 @@ export interface StorageReaderOptions {
186
190
  chain: sdk.Chain
187
191
  }
188
192
 
189
- export type DBType = 'SQLite' | 'MySQL'
193
+ export type DBType = 'SQLite' | 'MySQL' | 'IndexedDB'
190
194
 
191
195
  type DbEntityTimeStamp<T extends sdk.EntityTimeStamp> = {
192
196
  [K in keyof T]: T[K] extends Date ? Date | string : T[K]
@@ -0,0 +1,15 @@
1
+ import { StorageIdb } from '../StorageIdb'
2
+ import { StorageProvider, StorageProviderOptions } from '../StorageProvider'
3
+ import 'fake-indexeddb/auto'
4
+
5
+ describe('StorageIdb tests', () => {
6
+ jest.setTimeout(99999999)
7
+
8
+ test('0', async () => {
9
+ const options: StorageProviderOptions = StorageProvider.createStorageBaseOptions('main')
10
+ const storage = new StorageIdb(options)
11
+ const r = await storage.migrate('storageIdbTest', `42`.repeat(32))
12
+ const db = storage.db!
13
+ expect(db).toBeTruthy()
14
+ })
15
+ })
@@ -0,0 +1,68 @@
1
+ import { sdk } from '../../index.client'
2
+ import { TableTransaction } from '../index.client'
3
+ import { StorageProvider } from '../StorageProvider'
4
+
5
+ export interface ListActionsSpecOp {
6
+ name: string
7
+ /**
8
+ * undefined to intercept no labels from vargs,
9
+ * empty array to intercept all labels,
10
+ * or an explicit array of labels to intercept.
11
+ */
12
+ labelsToIntercept?: string[]
13
+ setStatusFilter?: () => sdk.TransactionStatus[]
14
+ postProcess?: (
15
+ s: StorageProvider,
16
+ auth: sdk.AuthId,
17
+ vargs: sdk.ValidListActionsArgs,
18
+ specOpLabels: string[],
19
+ txs: Partial<TableTransaction>[]
20
+ ) => Promise<void>
21
+ }
22
+
23
+ export const getLabelToSpecOp: () => Record<string, ListActionsSpecOp> = () => {
24
+ return {
25
+ [sdk.specOpNoSendActions]: {
26
+ name: 'noSendActions',
27
+ labelsToIntercept: ['abort'],
28
+ setStatusFilter: () => ['nosend'],
29
+ postProcess: async (
30
+ s: StorageProvider,
31
+ auth: sdk.AuthId,
32
+ vargs: sdk.ValidListActionsArgs,
33
+ specOpLabels: string[],
34
+ txs: Partial<TableTransaction>[]
35
+ ): Promise<void> => {
36
+ if (specOpLabels.indexOf('abort') >= 0) {
37
+ for (const tx of txs) {
38
+ if (tx.status === 'nosend') {
39
+ await s.abortAction(auth, { reference: tx.reference! })
40
+ tx.status = 'failed'
41
+ }
42
+ }
43
+ }
44
+ }
45
+ },
46
+ [sdk.specOpFailedActions]: {
47
+ name: 'failedActions',
48
+ labelsToIntercept: ['unfail'],
49
+ setStatusFilter: () => ['failed'],
50
+ postProcess: async (
51
+ s: StorageProvider,
52
+ auth: sdk.AuthId,
53
+ vargs: sdk.ValidListActionsArgs,
54
+ specOpLabels: string[],
55
+ txs: Partial<TableTransaction>[]
56
+ ): Promise<void> => {
57
+ if (specOpLabels.indexOf('unfail') >= 0) {
58
+ for (const tx of txs) {
59
+ if (tx.status === 'failed') {
60
+ await s.updateTransaction(tx.transactionId!, { status: 'unfail' })
61
+ // wallet wire does not support 'unfail' status, return as 'failed'.
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
@@ -0,0 +1,125 @@
1
+ import { ListOutputsResult } from '@bsv/sdk'
2
+ import { StorageProvider, TableOutput } from '../index.client'
3
+ import { asString, sdk, verifyId, verifyInteger, verifyOne } from '../../index.client'
4
+ import { ValidListOutputsArgs } from '../../sdk/validationHelpers'
5
+
6
+ export interface ListOutputsSpecOp {
7
+ name: string
8
+ useBasket?: string
9
+ ignoreLimit?: boolean
10
+ includeOutputScripts?: boolean
11
+ includeSpent?: boolean
12
+ resultFromTags?: (
13
+ s: StorageProvider,
14
+ auth: sdk.AuthId,
15
+ vargs: ValidListOutputsArgs,
16
+ specOpTags: string[]
17
+ ) => Promise<ListOutputsResult>
18
+ resultFromOutputs?: (
19
+ s: StorageProvider,
20
+ auth: sdk.AuthId,
21
+ vargs: ValidListOutputsArgs,
22
+ specOpTags: string[],
23
+ outputs: TableOutput[]
24
+ ) => Promise<ListOutputsResult>
25
+ filterOutputs?: (
26
+ s: StorageProvider,
27
+ auth: sdk.AuthId,
28
+ vargs: ValidListOutputsArgs,
29
+ specOpTags: string[],
30
+ outputs: TableOutput[]
31
+ ) => Promise<TableOutput[]>
32
+ /**
33
+ * undefined to intercept no tags from vargs,
34
+ * empty array to intercept all tags,
35
+ * or an explicit array of tags to intercept.
36
+ */
37
+ tagsToIntercept?: string[]
38
+ /**
39
+ * How many positional tags to intercept.
40
+ */
41
+ tagsParamsCount?: number
42
+ }
43
+
44
+ export const getBasketToSpecOp: () => Record<string, ListOutputsSpecOp> = () => {
45
+ return {
46
+ [sdk.specOpWalletBalance]: {
47
+ name: 'totalOutputsIsWalletBalance',
48
+ useBasket: 'default',
49
+ ignoreLimit: true,
50
+ resultFromOutputs: async (
51
+ s: StorageProvider,
52
+ auth: sdk.AuthId,
53
+ vargs: ValidListOutputsArgs,
54
+ specOpTags: string[],
55
+ outputs: TableOutput[]
56
+ ): Promise<ListOutputsResult> => {
57
+ let totalOutputs = 0
58
+ for (const o of outputs) totalOutputs += o.satoshis
59
+ return { totalOutputs, outputs: [] }
60
+ }
61
+ },
62
+ [sdk.specOpInvalidChange]: {
63
+ name: 'invalidChangeOutputs',
64
+ useBasket: 'default',
65
+ ignoreLimit: true,
66
+ includeOutputScripts: true,
67
+ includeSpent: false,
68
+ tagsToIntercept: ['release', 'all'],
69
+ filterOutputs: async (
70
+ s: StorageProvider,
71
+ auth: sdk.AuthId,
72
+ vargs: ValidListOutputsArgs,
73
+ specOpTags: string[],
74
+ outputs: TableOutput[]
75
+ ): Promise<TableOutput[]> => {
76
+ const filteredOutputs: TableOutput[] = []
77
+ const services = s.getServices()
78
+ for (const o of outputs) {
79
+ await s.validateOutputScript(o)
80
+ let ok: boolean | undefined = false
81
+ if (o.lockingScript && o.lockingScript.length > 0) {
82
+ ok = await services.isUtxo(o)
83
+ } else {
84
+ ok = undefined
85
+ }
86
+ if (ok === false) {
87
+ filteredOutputs.push(o)
88
+ }
89
+ }
90
+ if (specOpTags.indexOf('release') >= 0) {
91
+ for (const o of filteredOutputs) {
92
+ await s.updateOutput(o.outputId, { spendable: false })
93
+ o.spendable = false
94
+ }
95
+ }
96
+ return filteredOutputs
97
+ }
98
+ },
99
+ [sdk.specOpSetWalletChangeParams]: {
100
+ name: 'setWalletChangeParams',
101
+ tagsParamsCount: 2,
102
+ resultFromTags: async (
103
+ s: StorageProvider,
104
+ auth: sdk.AuthId,
105
+ vargs: ValidListOutputsArgs,
106
+ specOpTags: string[]
107
+ ): Promise<ListOutputsResult> => {
108
+ if (specOpTags.length !== 2)
109
+ throw new sdk.WERR_INVALID_PARAMETER('numberOfDesiredUTXOs and minimumDesiredUTXOValue', 'valid')
110
+ const numberOfDesiredUTXOs: number = verifyInteger(Number(specOpTags[0]))
111
+ const minimumDesiredUTXOValue: number = verifyInteger(Number(specOpTags[1]))
112
+ const basket = verifyOne(
113
+ await s.findOutputBaskets({
114
+ partial: { userId: verifyId(auth.userId), name: 'default' }
115
+ })
116
+ )
117
+ await s.updateOutputBasket(basket.basketId, {
118
+ numberOfDesiredUTXOs,
119
+ minimumDesiredUTXOValue
120
+ })
121
+ return { totalOutputs: 0, outputs: [] }
122
+ }
123
+ }
124
+ }
125
+ }
@@ -0,0 +1,181 @@
1
+ import {
2
+ Transaction as BsvTransaction,
3
+ ActionStatus,
4
+ ListActionsResult,
5
+ WalletAction,
6
+ WalletActionOutput,
7
+ WalletActionInput
8
+ } from '@bsv/sdk'
9
+ import { TableOutputX, TableTransaction, TableTxLabel } from '../index.client'
10
+ import { asString, sdk, verifyOne } from '../../index.client'
11
+ import { isListActionsSpecOp, TransactionStatus } from '../../sdk'
12
+ import { StorageIdb } from '../StorageIdb'
13
+ import { getLabelToSpecOp, ListActionsSpecOp } from './ListActionsSpecOp'
14
+
15
+ export async function listActionsIdb(
16
+ storage: StorageIdb,
17
+ auth: sdk.AuthId,
18
+ vargs: sdk.ValidListActionsArgs
19
+ ): Promise<ListActionsResult> {
20
+ const limit = vargs.limit
21
+ const offset = vargs.offset
22
+
23
+ const r: ListActionsResult = {
24
+ totalActions: 0,
25
+ actions: []
26
+ }
27
+
28
+ let specOp: ListActionsSpecOp | undefined = undefined
29
+ let specOpLabels: string[] = []
30
+ let labels: string[] = []
31
+ for (const label of vargs.labels) {
32
+ if (isListActionsSpecOp(label)) {
33
+ specOp = getLabelToSpecOp()[label]
34
+ } else {
35
+ labels.push(label)
36
+ }
37
+ }
38
+ if (specOp?.labelsToIntercept !== undefined) {
39
+ const intercept = specOp.labelsToIntercept!
40
+ const labels2 = labels
41
+ labels = []
42
+ if (intercept.length === 0) {
43
+ specOpLabels = labels2
44
+ }
45
+ for (const label of labels2) {
46
+ if (intercept.indexOf(label) >= 0) {
47
+ specOpLabels.push(label)
48
+ } else {
49
+ labels.push(label)
50
+ }
51
+ }
52
+ }
53
+
54
+ let labelIds: number[] = []
55
+ if (labels.length > 0) {
56
+ await storage.filterTxLabels({ partial: { userId: auth.userId, isDeleted: false } }, tl => {
57
+ if (labels.includes(tl.label)) {
58
+ labelIds.push(tl.txLabelId)
59
+ }
60
+ })
61
+ }
62
+
63
+ const isQueryModeAll = vargs.labelQueryMode === 'all'
64
+ if (isQueryModeAll && labelIds.length < labels.length)
65
+ // all the required labels don't exist, impossible to satisfy.
66
+ return r
67
+
68
+ if (!isQueryModeAll && labelIds.length === 0 && labels.length > 0)
69
+ // any and only non-existing labels, impossible to satisfy.
70
+ return r
71
+
72
+ const stati: TransactionStatus[] = specOp?.setStatusFilter
73
+ ? specOp.setStatusFilter()
74
+ : ['completed', 'unprocessed', 'sending', 'unproven', 'unsigned', 'nosend', 'nonfinal']
75
+
76
+ const noLabels = labelIds.length === 0
77
+
78
+ const txs = await storage.findTransactions(
79
+ {
80
+ partial: { userId: auth.userId },
81
+ status: stati,
82
+ paged: { limit: vargs.limit, offset: vargs.offset },
83
+ noRawTx: true
84
+ },
85
+ labelIds,
86
+ isQueryModeAll
87
+ )
88
+ if (txs.length === vargs.limit) {
89
+ r.totalActions = await storage.countTransactions(
90
+ { partial: { userId: auth.userId }, status: stati },
91
+ labelIds,
92
+ isQueryModeAll
93
+ )
94
+ } else {
95
+ r.totalActions = txs.length
96
+ }
97
+
98
+ if (specOp?.postProcess) {
99
+ await specOp.postProcess(storage, auth, vargs, specOpLabels, txs)
100
+ }
101
+
102
+ for (const tx of txs) {
103
+ const wtx: WalletAction = {
104
+ txid: tx.txid || '',
105
+ satoshis: tx.satoshis || 0,
106
+ status: <ActionStatus>tx.status!,
107
+ isOutgoing: !!tx.isOutgoing,
108
+ description: tx.description || '',
109
+ version: tx.version || 0,
110
+ lockTime: tx.lockTime || 0
111
+ }
112
+ r.actions.push(wtx)
113
+ }
114
+
115
+ if (vargs.includeLabels || vargs.includeInputs || vargs.includeOutputs) {
116
+ await Promise.all(
117
+ txs.map(async (tx, i) => {
118
+ //let i = -1
119
+ //for (const tx of txs) {
120
+ // i++
121
+ const action = r.actions[i]
122
+ if (vargs.includeLabels) {
123
+ action.labels = (await storage.getLabelsForTransactionId(tx.transactionId)).map(l => l.label)
124
+ }
125
+ if (vargs.includeOutputs) {
126
+ const outputs: TableOutputX[] = await storage.findOutputs({
127
+ partial: { transactionId: tx.transactionId },
128
+ noScript: !vargs.includeOutputLockingScripts
129
+ })
130
+ action.outputs = []
131
+ for (const o of outputs) {
132
+ await storage.extendOutput(o, true, true)
133
+ const wo: WalletActionOutput = {
134
+ satoshis: o.satoshis || 0,
135
+ spendable: !!o.spendable,
136
+ tags: o.tags?.map(t => t.tag) || [],
137
+ outputIndex: Number(o.vout),
138
+ outputDescription: o.outputDescription || '',
139
+ basket: o.basket?.name || ''
140
+ }
141
+ if (vargs.includeOutputLockingScripts) wo.lockingScript = asString(o.lockingScript || [])
142
+ action.outputs.push(wo)
143
+ }
144
+ }
145
+ if (vargs.includeInputs) {
146
+ const inputs: TableOutputX[] = await storage.findOutputs({
147
+ partial: { spentBy: tx.transactionId },
148
+ noScript: !vargs.includeInputSourceLockingScripts
149
+ })
150
+ action.inputs = []
151
+ if (inputs.length > 0) {
152
+ const rawTx = await storage.getRawTxOfKnownValidTransaction(tx.txid)
153
+ let bsvTx: BsvTransaction | undefined = undefined
154
+ if (rawTx) {
155
+ bsvTx = BsvTransaction.fromBinary(rawTx)
156
+ }
157
+ for (const o of inputs) {
158
+ await storage.extendOutput(o, true, true)
159
+ const input = bsvTx?.inputs.find(v => v.sourceTXID === o.txid && v.sourceOutputIndex === o.vout)
160
+ const wo: WalletActionInput = {
161
+ sourceOutpoint: `${o.txid}.${o.vout}`,
162
+ sourceSatoshis: o.satoshis || 0,
163
+ inputDescription: o.outputDescription || '',
164
+ sequenceNumber: input?.sequence || 0
165
+ }
166
+ action.inputs.push(wo)
167
+ if (vargs.includeInputSourceLockingScripts) {
168
+ wo.sourceLockingScript = asString(o.lockingScript || [])
169
+ }
170
+ if (vargs.includeInputUnlockingScripts) {
171
+ wo.unlockingScript = input?.unlockingScript?.toHex()
172
+ }
173
+ }
174
+ }
175
+ }
176
+ //}
177
+ })
178
+ )
179
+ }
180
+ return r
181
+ }
@@ -10,69 +10,7 @@ import { TableOutputX, TableTransaction, TableTxLabel } from '../index.client'
10
10
  import { asString, sdk, verifyOne } from '../../index.client'
11
11
  import { StorageKnex } from '../StorageKnex'
12
12
  import { isListActionsSpecOp } from '../../sdk'
13
-
14
- interface ListActionsSpecOp {
15
- name: string
16
- /**
17
- * undefined to intercept no labels from vargs,
18
- * empty array to intercept all labels,
19
- * or an explicit array of labels to intercept.
20
- */
21
- labelsToIntercept?: string[]
22
- setStatusFilter?: () => string[]
23
- postProcess?: (
24
- s: StorageKnex,
25
- auth: sdk.AuthId,
26
- vargs: sdk.ValidListActionsArgs,
27
- specOpLabels: string[],
28
- txs: Partial<TableTransaction>[]
29
- ) => Promise<void>
30
- }
31
-
32
- const labelToSpecOp: Record<string, ListActionsSpecOp> = {
33
- [sdk.specOpNoSendActions]: {
34
- name: 'noSendActions',
35
- labelsToIntercept: ['abort'],
36
- setStatusFilter: () => ['nosend'],
37
- postProcess: async (
38
- s: StorageKnex,
39
- auth: sdk.AuthId,
40
- vargs: sdk.ValidListActionsArgs,
41
- specOpLabels: string[],
42
- txs: Partial<TableTransaction>[]
43
- ): Promise<void> => {
44
- if (specOpLabels.indexOf('abort') >= 0) {
45
- for (const tx of txs) {
46
- if (tx.status === 'nosend') {
47
- await s.abortAction(auth, { reference: tx.reference! })
48
- tx.status = 'failed'
49
- }
50
- }
51
- }
52
- }
53
- },
54
- [sdk.specOpFailedActions]: {
55
- name: 'failedActions',
56
- labelsToIntercept: ['unfail'],
57
- setStatusFilter: () => ['failed'],
58
- postProcess: async (
59
- s: StorageKnex,
60
- auth: sdk.AuthId,
61
- vargs: sdk.ValidListActionsArgs,
62
- specOpLabels: string[],
63
- txs: Partial<TableTransaction>[]
64
- ): Promise<void> => {
65
- if (specOpLabels.indexOf('unfail') >= 0) {
66
- for (const tx of txs) {
67
- if (tx.status === 'failed') {
68
- await s.updateTransaction(tx.transactionId!, { status: 'unfail' })
69
- // wallet wire does not support 'unfail' status, return as 'failed'.
70
- }
71
- }
72
- }
73
- }
74
- }
75
- }
13
+ import { getLabelToSpecOp, ListActionsSpecOp } from './ListActionsSpecOp'
76
14
 
77
15
  export async function listActions(
78
16
  storage: StorageKnex,
@@ -94,7 +32,7 @@ export async function listActions(
94
32
  let labels: string[] = []
95
33
  for (const label of vargs.labels) {
96
34
  if (isListActionsSpecOp(label)) {
97
- specOp = labelToSpecOp[label]
35
+ specOp = getLabelToSpecOp()[label]
98
36
  } else {
99
37
  labels.push(label)
100
38
  }