@bsv/wallet-toolbox 1.1.7 → 1.1.9

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 (317) hide show
  1. package/docs/client.md +3872 -1555
  2. package/docs/monitor.md +29 -27
  3. package/docs/services.md +22 -22
  4. package/docs/setup.md +23 -23
  5. package/docs/storage.md +2747 -438
  6. package/docs/wallet.md +3872 -1555
  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 +13 -4
  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.map +1 -1
  75. package/out/src/storage/methods/reviewStatus.js.map +1 -1
  76. package/out/src/storage/remoting/StorageClient.d.ts +230 -15
  77. package/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
  78. package/out/src/storage/remoting/StorageClient.js +222 -7
  79. package/out/src/storage/remoting/StorageClient.js.map +1 -1
  80. package/out/src/storage/schema/entities/Certificate.d.ts +9 -9
  81. package/out/src/storage/schema/entities/Certificate.d.ts.map +1 -1
  82. package/out/src/storage/schema/entities/Certificate.js +5 -5
  83. package/out/src/storage/schema/entities/Certificate.js.map +1 -1
  84. package/out/src/storage/schema/entities/CertificateField.d.ts +9 -9
  85. package/out/src/storage/schema/entities/CertificateField.d.ts.map +1 -1
  86. package/out/src/storage/schema/entities/CertificateField.js +5 -5
  87. package/out/src/storage/schema/entities/CertificateField.js.map +1 -1
  88. package/out/src/storage/schema/entities/Commission.d.ts +9 -9
  89. package/out/src/storage/schema/entities/Commission.d.ts.map +1 -1
  90. package/out/src/storage/schema/entities/Commission.js +5 -5
  91. package/out/src/storage/schema/entities/Commission.js.map +1 -1
  92. package/out/src/storage/schema/entities/EntityBase.d.ts +1 -1
  93. package/out/src/storage/schema/entities/MergeEntity.d.ts +6 -7
  94. package/out/src/storage/schema/entities/MergeEntity.d.ts.map +1 -1
  95. package/out/src/storage/schema/entities/MergeEntity.js.map +1 -1
  96. package/out/src/storage/schema/entities/Output.d.ts +9 -9
  97. package/out/src/storage/schema/entities/Output.d.ts.map +1 -1
  98. package/out/src/storage/schema/entities/Output.js +5 -5
  99. package/out/src/storage/schema/entities/Output.js.map +1 -1
  100. package/out/src/storage/schema/entities/OutputBasket.d.ts +9 -9
  101. package/out/src/storage/schema/entities/OutputBasket.d.ts.map +1 -1
  102. package/out/src/storage/schema/entities/OutputBasket.js +5 -5
  103. package/out/src/storage/schema/entities/OutputBasket.js.map +1 -1
  104. package/out/src/storage/schema/entities/OutputTag.d.ts +9 -9
  105. package/out/src/storage/schema/entities/OutputTag.d.ts.map +1 -1
  106. package/out/src/storage/schema/entities/OutputTag.js +5 -5
  107. package/out/src/storage/schema/entities/OutputTag.js.map +1 -1
  108. package/out/src/storage/schema/entities/OutputTagMap.d.ts +9 -9
  109. package/out/src/storage/schema/entities/OutputTagMap.d.ts.map +1 -1
  110. package/out/src/storage/schema/entities/OutputTagMap.js +5 -5
  111. package/out/src/storage/schema/entities/OutputTagMap.js.map +1 -1
  112. package/out/src/storage/schema/entities/ProvenTx.d.ts +11 -11
  113. package/out/src/storage/schema/entities/ProvenTx.d.ts.map +1 -1
  114. package/out/src/storage/schema/entities/ProvenTx.js +11 -11
  115. package/out/src/storage/schema/entities/ProvenTx.js.map +1 -1
  116. package/out/src/storage/schema/entities/ProvenTxReq.d.ts +19 -19
  117. package/out/src/storage/schema/entities/ProvenTxReq.d.ts.map +1 -1
  118. package/out/src/storage/schema/entities/ProvenTxReq.js +13 -13
  119. package/out/src/storage/schema/entities/ProvenTxReq.js.map +1 -1
  120. package/out/src/storage/schema/entities/SyncState.d.ts +11 -11
  121. package/out/src/storage/schema/entities/SyncState.d.ts.map +1 -1
  122. package/out/src/storage/schema/entities/SyncState.js +27 -27
  123. package/out/src/storage/schema/entities/SyncState.js.map +1 -1
  124. package/out/src/storage/schema/entities/Transaction.d.ts +11 -11
  125. package/out/src/storage/schema/entities/Transaction.d.ts.map +1 -1
  126. package/out/src/storage/schema/entities/Transaction.js +6 -6
  127. package/out/src/storage/schema/entities/Transaction.js.map +1 -1
  128. package/out/src/storage/schema/entities/TxLabel.d.ts +9 -9
  129. package/out/src/storage/schema/entities/TxLabel.d.ts.map +1 -1
  130. package/out/src/storage/schema/entities/TxLabel.js +5 -5
  131. package/out/src/storage/schema/entities/TxLabel.js.map +1 -1
  132. package/out/src/storage/schema/entities/TxLabelMap.d.ts +9 -9
  133. package/out/src/storage/schema/entities/TxLabelMap.d.ts.map +1 -1
  134. package/out/src/storage/schema/entities/TxLabelMap.js +5 -5
  135. package/out/src/storage/schema/entities/TxLabelMap.js.map +1 -1
  136. package/out/src/storage/schema/entities/User.d.ts +9 -9
  137. package/out/src/storage/schema/entities/User.d.ts.map +1 -1
  138. package/out/src/storage/schema/entities/User.js +5 -5
  139. package/out/src/storage/schema/entities/User.js.map +1 -1
  140. package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.js +20 -307
  141. package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.js.map +1 -1
  142. package/out/src/storage/schema/entities/__tests/CertificateTests.test.js +17 -158
  143. package/out/src/storage/schema/entities/__tests/CertificateTests.test.js.map +1 -1
  144. package/out/src/storage/schema/entities/__tests/CommissionTests.test.js +23 -309
  145. package/out/src/storage/schema/entities/__tests/CommissionTests.test.js.map +1 -1
  146. package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.js +19 -306
  147. package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.js.map +1 -1
  148. package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.js +19 -306
  149. package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.js.map +1 -1
  150. package/out/src/storage/schema/entities/__tests/OutputTagTests.test.js +23 -237
  151. package/out/src/storage/schema/entities/__tests/OutputTagTests.test.js.map +1 -1
  152. package/out/src/storage/schema/entities/__tests/OutputTests.test.js +20 -233
  153. package/out/src/storage/schema/entities/__tests/OutputTests.test.js.map +1 -1
  154. package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.js +27 -98
  155. package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.js.map +1 -1
  156. package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js +25 -241
  157. package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js.map +1 -1
  158. package/out/src/storage/schema/entities/__tests/SyncStateTests.test.js +38 -112
  159. package/out/src/storage/schema/entities/__tests/SyncStateTests.test.js.map +1 -1
  160. package/out/src/storage/schema/entities/__tests/TransactionTests.test.js +39 -323
  161. package/out/src/storage/schema/entities/__tests/TransactionTests.test.js.map +1 -1
  162. package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.js +31 -169
  163. package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.js.map +1 -1
  164. package/out/src/storage/schema/entities/__tests/TxLabelTests.test.js +16 -159
  165. package/out/src/storage/schema/entities/__tests/TxLabelTests.test.js.map +1 -1
  166. package/out/src/storage/schema/entities/__tests/usersTests.test.js +21 -168
  167. package/out/src/storage/schema/entities/__tests/usersTests.test.js.map +1 -1
  168. package/out/src/storage/schema/tables/Certificate.d.ts +4 -4
  169. package/out/src/storage/schema/tables/Certificate.d.ts.map +1 -1
  170. package/out/src/storage/schema/tables/CertificateField.d.ts +1 -1
  171. package/out/src/storage/schema/tables/CertificateField.d.ts.map +1 -1
  172. package/out/src/storage/schema/tables/Commission.d.ts +1 -1
  173. package/out/src/storage/schema/tables/Commission.d.ts.map +1 -1
  174. package/out/src/storage/schema/tables/MonitorEvent.d.ts +1 -1
  175. package/out/src/storage/schema/tables/MonitorEvent.d.ts.map +1 -1
  176. package/out/src/storage/schema/tables/Output.d.ts +5 -5
  177. package/out/src/storage/schema/tables/Output.d.ts.map +1 -1
  178. package/out/src/storage/schema/tables/OutputBasket.d.ts +1 -1
  179. package/out/src/storage/schema/tables/OutputBasket.d.ts.map +1 -1
  180. package/out/src/storage/schema/tables/OutputTag.d.ts +1 -1
  181. package/out/src/storage/schema/tables/OutputTag.d.ts.map +1 -1
  182. package/out/src/storage/schema/tables/OutputTagMap.d.ts +1 -1
  183. package/out/src/storage/schema/tables/OutputTagMap.d.ts.map +1 -1
  184. package/out/src/storage/schema/tables/ProvenTx.d.ts +1 -1
  185. package/out/src/storage/schema/tables/ProvenTx.d.ts.map +1 -1
  186. package/out/src/storage/schema/tables/ProvenTxReq.d.ts +2 -2
  187. package/out/src/storage/schema/tables/ProvenTxReq.d.ts.map +1 -1
  188. package/out/src/storage/schema/tables/SyncState.d.ts +1 -1
  189. package/out/src/storage/schema/tables/SyncState.d.ts.map +1 -1
  190. package/out/src/storage/schema/tables/{Settings.d.ts → TableSettings.d.ts} +2 -2
  191. package/out/src/storage/schema/tables/TableSettings.d.ts.map +1 -0
  192. package/out/src/storage/schema/tables/{Settings.js → TableSettings.js} +1 -1
  193. package/out/src/storage/schema/tables/TableSettings.js.map +1 -0
  194. package/out/src/storage/schema/tables/Transaction.d.ts +1 -1
  195. package/out/src/storage/schema/tables/Transaction.d.ts.map +1 -1
  196. package/out/src/storage/schema/tables/TxLabel.d.ts +1 -1
  197. package/out/src/storage/schema/tables/TxLabel.d.ts.map +1 -1
  198. package/out/src/storage/schema/tables/TxLabelMap.d.ts +1 -1
  199. package/out/src/storage/schema/tables/TxLabelMap.d.ts.map +1 -1
  200. package/out/src/storage/schema/tables/User.d.ts +1 -1
  201. package/out/src/storage/schema/tables/User.d.ts.map +1 -1
  202. package/out/src/storage/schema/tables/index.d.ts +1 -1
  203. package/out/src/storage/schema/tables/index.d.ts.map +1 -1
  204. package/out/src/storage/schema/tables/index.js +1 -1
  205. package/out/src/storage/schema/tables/index.js.map +1 -1
  206. package/out/src/storage/sync/StorageMySQLDojoReader.d.ts +17 -17
  207. package/out/src/storage/sync/StorageMySQLDojoReader.d.ts.map +1 -1
  208. package/out/src/storage/sync/StorageMySQLDojoReader.js +2 -2
  209. package/out/src/storage/sync/StorageMySQLDojoReader.js.map +1 -1
  210. package/out/test/Wallet/certificate/listCertificates.test.js.map +1 -1
  211. package/out/test/Wallet/live/walletLive.man.test.js +1 -1
  212. package/out/test/Wallet/live/walletLive.man.test.js.map +1 -1
  213. package/out/test/monitor/Monitor.test.js +7 -7
  214. package/out/test/monitor/Monitor.test.js.map +1 -1
  215. package/out/test/storage/StorageMySQLDojoReader.man.test.js +1 -1
  216. package/out/test/storage/StorageMySQLDojoReader.man.test.js.map +1 -1
  217. package/out/test/storage/insert.test.js.map +1 -1
  218. package/out/test/storage/update.test.js.map +1 -1
  219. package/out/test/storage/update2.test.js.map +1 -1
  220. package/out/test/utils/TestUtilsWalletStorage.d.ts +56 -56
  221. package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
  222. package/out/test/utils/TestUtilsWalletStorage.js +11 -4
  223. package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
  224. package/out/test/wallet/action/createActionToGenerateBeefs.man.test.js.map +1 -1
  225. package/out/tsconfig.all.tsbuildinfo +1 -1
  226. package/package.json +2 -2
  227. package/src/monitor/tasks/TaskCheckForProofs.ts +11 -10
  228. package/src/monitor/tasks/TaskSendWaiting.ts +5 -5
  229. package/src/sdk/StorageSyncReader.ts +48 -30
  230. package/src/sdk/StorageSyncReaderWriter.ts +77 -63
  231. package/src/sdk/WalletStorage.interfaces.ts +55 -36
  232. package/src/signer/methods/acquireDirectCertificate.ts +2 -2
  233. package/src/storage/StorageKnex.ts +137 -106
  234. package/src/storage/StorageProvider.ts +43 -30
  235. package/src/storage/StorageReader.ts +37 -21
  236. package/src/storage/StorageReaderWriter.ts +78 -65
  237. package/src/storage/StorageSyncReader.ts +35 -17
  238. package/src/storage/WalletStorageManager.ts +18 -12
  239. package/src/storage/index.all.ts +2 -2
  240. package/src/storage/index.client.ts +2 -2
  241. package/src/storage/methods/attemptToPostReqsToNetwork.ts +3 -3
  242. package/src/storage/methods/createAction.ts +29 -26
  243. package/src/storage/methods/getBeefForTransaction.ts +3 -3
  244. package/src/storage/methods/getSyncChunk.ts +28 -13
  245. package/src/storage/methods/internalizeAction.ts +19 -17
  246. package/src/storage/methods/listActions.ts +5 -5
  247. package/src/storage/methods/listCertificates.ts +2 -2
  248. package/src/storage/methods/listOutputs.ts +5 -5
  249. package/src/storage/methods/processAction.ts +21 -17
  250. package/src/storage/methods/purgeData.ts +17 -11
  251. package/src/storage/methods/reviewStatus.ts +4 -4
  252. package/src/storage/remoting/StorageClient.ts +250 -26
  253. package/src/storage/schema/entities/Certificate.ts +16 -17
  254. package/src/storage/schema/entities/CertificateField.ts +17 -18
  255. package/src/storage/schema/entities/Commission.ts +16 -20
  256. package/src/storage/schema/entities/EntityBase.ts +1 -1
  257. package/src/storage/schema/entities/MergeEntity.ts +7 -7
  258. package/src/storage/schema/entities/Output.ts +16 -20
  259. package/src/storage/schema/entities/OutputBasket.ts +16 -17
  260. package/src/storage/schema/entities/OutputTag.ts +16 -20
  261. package/src/storage/schema/entities/OutputTagMap.ts +17 -18
  262. package/src/storage/schema/entities/ProvenTx.ts +24 -28
  263. package/src/storage/schema/entities/ProvenTxReq.ts +42 -45
  264. package/src/storage/schema/entities/SyncState.ts +61 -38
  265. package/src/storage/schema/entities/Transaction.ts +23 -23
  266. package/src/storage/schema/entities/TxLabel.ts +16 -17
  267. package/src/storage/schema/entities/TxLabelMap.ts +16 -20
  268. package/src/storage/schema/entities/User.ts +15 -19
  269. package/src/storage/schema/entities/__tests/CertificateFieldTests.test.ts +39 -318
  270. package/src/storage/schema/entities/__tests/CertificateTests.test.ts +29 -169
  271. package/src/storage/schema/entities/__tests/CommissionTests.test.ts +47 -325
  272. package/src/storage/schema/entities/__tests/OutputBasketTests.test.ts +35 -316
  273. package/src/storage/schema/entities/__tests/OutputTagMapTests.test.ts +38 -318
  274. package/src/storage/schema/entities/__tests/OutputTagTests.test.ts +36 -249
  275. package/src/storage/schema/entities/__tests/OutputTests.test.ts +30 -244
  276. package/src/storage/schema/entities/__tests/ProvenTxReqTests.test.ts +35 -101
  277. package/src/storage/schema/entities/__tests/ProvenTxTests.test.ts +27 -243
  278. package/src/storage/schema/entities/__tests/SyncStateTests.test.ts +54 -122
  279. package/src/storage/schema/entities/__tests/TransactionTests.test.ts +53 -333
  280. package/src/storage/schema/entities/__tests/TxLabelMapTests.test.ts +44 -177
  281. package/src/storage/schema/entities/__tests/TxLabelTests.test.ts +19 -163
  282. package/src/storage/schema/entities/__tests/usersTests.test.ts +31 -179
  283. package/src/storage/schema/tables/Certificate.ts +4 -4
  284. package/src/storage/schema/tables/CertificateField.ts +1 -1
  285. package/src/storage/schema/tables/Commission.ts +1 -1
  286. package/src/storage/schema/tables/MonitorEvent.ts +1 -1
  287. package/src/storage/schema/tables/Output.ts +5 -5
  288. package/src/storage/schema/tables/OutputBasket.ts +1 -1
  289. package/src/storage/schema/tables/OutputTag.ts +1 -1
  290. package/src/storage/schema/tables/OutputTagMap.ts +1 -1
  291. package/src/storage/schema/tables/ProvenTx.ts +1 -1
  292. package/src/storage/schema/tables/ProvenTxReq.ts +2 -2
  293. package/src/storage/schema/tables/SyncState.ts +1 -1
  294. package/src/storage/schema/tables/{Settings.ts → TableSettings.ts} +3 -1
  295. package/src/storage/schema/tables/Transaction.ts +1 -1
  296. package/src/storage/schema/tables/TxLabel.ts +1 -1
  297. package/src/storage/schema/tables/TxLabelMap.ts +1 -1
  298. package/src/storage/schema/tables/User.ts +1 -1
  299. package/src/storage/schema/tables/index.ts +1 -1
  300. package/src/storage/sync/StorageMySQLDojoReader.ts +68 -50
  301. package/test/Wallet/certificate/listCertificates.test.ts +12 -8
  302. package/test/Wallet/live/walletLive.man.test.ts +6 -6
  303. package/test/monitor/Monitor.test.ts +8 -8
  304. package/test/storage/StorageMySQLDojoReader.man.test.ts +1 -1
  305. package/test/storage/insert.test.ts +2 -2
  306. package/test/storage/update.test.ts +30 -30
  307. package/test/storage/update2.test.ts +23 -24
  308. package/test/utils/TestUtilsWalletStorage.ts +103 -82
  309. package/test/wallet/action/createActionToGenerateBeefs.man.test.ts +1 -2
  310. package/ts2md.json +1 -1
  311. package/out/src/storage/index.db.d.ts +0 -1
  312. package/out/src/storage/index.db.d.ts.map +0 -1
  313. package/out/src/storage/index.db.js +0 -2
  314. package/out/src/storage/index.db.js.map +0 -1
  315. package/out/src/storage/schema/tables/Settings.d.ts.map +0 -1
  316. package/out/src/storage/schema/tables/Settings.js.map +0 -1
  317. package/src/storage/index.db.ts +0 -0
@@ -1,10 +1,3 @@
1
- /**
2
- * StorageClient.ts
3
- *
4
- * A client-side "remoted" WalletStorage that fulfills the WalletStorage interface
5
- * by sending JSON-RPC calls to a configured remote WalletStorageServer.
6
- */
7
-
8
1
  import {
9
2
  AbortActionArgs,
10
3
  AbortActionResult,
@@ -17,22 +10,52 @@ import {
17
10
  RelinquishOutputArgs,
18
11
  WalletInterface
19
12
  } from '@bsv/sdk'
20
- import { sdk, table } from '../../index.client'
13
+ import {
14
+ sdk,
15
+ TableCertificate,
16
+ TableCertificateX,
17
+ TableOutput,
18
+ TableOutputBasket,
19
+ TableProvenTxReq,
20
+ TableSettings,
21
+ TableSyncState,
22
+ TableUser
23
+ } from '../../index.client'
21
24
  import { AuthFetch } from '@bsv/sdk'
22
25
 
26
+ /**
27
+ * `StorageClient` implements the `WalletStorageProvider` interface which allows it to
28
+ * serve as a BRC-100 wallet's active storage.
29
+ *
30
+ * Internally, it uses JSON-RPC over HTTPS to make requests of a remote server.
31
+ * Typically this server uses the `StorageServer` class to implement the service.
32
+ *
33
+ * The `AuthFetch` component is used to secure and authenticate the requests to the remote server.
34
+ *
35
+ * `AuthFetch` is initialized with a BRC-100 wallet which establishes the identity of
36
+ * the party making requests of the remote service.
37
+ *
38
+ * For details of the API implemented, follow the "See also" link for the `WalletStorageProvider` interface.
39
+ */
23
40
  export class StorageClient implements sdk.WalletStorageProvider {
24
41
  private endpointUrl: string
25
42
  private nextId = 1
26
43
  private authClient: AuthFetch
27
44
 
28
45
  // Track ephemeral (in-memory) "settings" if you wish to align with isAvailable() checks
29
- public settings?: table.Settings
46
+ public settings?: TableSettings
30
47
 
31
48
  constructor(wallet: WalletInterface, endpointUrl: string) {
32
49
  this.authClient = new AuthFetch(wallet)
33
50
  this.endpointUrl = endpointUrl
34
51
  }
35
52
 
53
+ /**
54
+ * The `StorageClient` implements the `WalletStorageProvider` interface.
55
+ * It does not implement the lower level `StorageProvider` interface.
56
+ *
57
+ * @returns false
58
+ */
36
59
  isStorageProvider(): boolean {
37
60
  return false
38
61
  }
@@ -86,12 +109,19 @@ export class StorageClient implements sdk.WalletStorageProvider {
86
109
  // and we store them locally in `this.settings`.
87
110
  //////////////////////////////////////////////////////////////////////////////
88
111
 
112
+ /**
113
+ * @returns true once storage `TableSettings` have been retreived from remote storage.
114
+ */
89
115
  isAvailable(): boolean {
90
116
  // We'll just say "yes" if we have settings
91
117
  return !!this.settings
92
118
  }
93
119
 
94
- getSettings(): table.Settings {
120
+ /**
121
+ * @returns remote storage `TableSettings` if they have been retreived by `makeAvailable`.
122
+ * @throws WERR_INVALID_OPERATION if `makeAvailable` has not yet been called.
123
+ */
124
+ getSettings(): TableSettings {
95
125
  if (!this.settings) {
96
126
  throw new sdk.WERR_INVALID_OPERATION(
97
127
  'call makeAvailable at least once before getSettings'
@@ -100,9 +130,14 @@ export class StorageClient implements sdk.WalletStorageProvider {
100
130
  return this.settings
101
131
  }
102
132
 
103
- async makeAvailable(): Promise<table.Settings> {
133
+ /**
134
+ * Must be called prior to making use of storage.
135
+ * Retreives `TableSettings` from remote storage provider.
136
+ * @returns remote storage `TableSettings`
137
+ */
138
+ async makeAvailable(): Promise<TableSettings> {
104
139
  if (!this.settings) {
105
- this.settings = await this.rpcCall<table.Settings>('makeAvailable', [])
140
+ this.settings = await this.rpcCall<TableSettings>('makeAvailable', [])
106
141
  }
107
142
  return this.settings
108
143
  }
@@ -115,10 +150,20 @@ export class StorageClient implements sdk.WalletStorageProvider {
115
150
  // IMPORTANT: The parameter ordering must match exactly as in your interface.
116
151
  //////////////////////////////////////////////////////////////////////////////
117
152
 
153
+ /**
154
+ * Called to cleanup resources when no further use of this object will occur.
155
+ */
118
156
  async destroy(): Promise<void> {
119
157
  return this.rpcCall<void>('destroy', [])
120
158
  }
121
159
 
160
+ /**
161
+ * Requests schema migration to latest.
162
+ * Typically remote storage will ignore this request.
163
+ * @param storageName Unique human readable name for remote storage if it does not yet exist.
164
+ * @param storageIdentityKey Unique identity key for remote storage if it does not yet exist.
165
+ * @returns current schema migration identifier
166
+ */
122
167
  async migrate(
123
168
  storageName: string,
124
169
  storageIdentityKey: string
@@ -126,19 +171,35 @@ export class StorageClient implements sdk.WalletStorageProvider {
126
171
  return this.rpcCall<string>('migrate', [storageName])
127
172
  }
128
173
 
174
+ /**
175
+ * Remote storage does not offer `Services` to remote clients.
176
+ * @throws WERR_INVALID_OPERATION
177
+ */
129
178
  getServices(): sdk.WalletServices {
130
179
  // Typically, the client would not store or retrieve "Services" from a remote server.
131
180
  // The "services" in local in-memory usage is a no-op or your own approach:
132
- throw new Error(
181
+ throw new sdk.WERR_INVALID_OPERATION(
133
182
  'getServices() not implemented in remote client. This method typically is not used remotely.'
134
183
  )
135
184
  }
136
185
 
186
+ /**
187
+ * Ignored. Remote storage cannot share `Services` with remote clients.
188
+ */
137
189
  setServices(v: sdk.WalletServices): void {
138
190
  // Typically no-op for remote client
139
191
  // Because "services" are usually local definitions to the Storage.
140
192
  }
141
193
 
194
+ /**
195
+ * Storage level processing for wallet `internalizeAction`.
196
+ * Updates internalized outputs in remote storage.
197
+ * Triggers proof validation of containing transaction.
198
+ * @param auth Identifies client by identity key and the storage identity key of their currently active storage.
199
+ * This must match the `AuthFetch` identity securing the remote conneciton.
200
+ * @param args Original wallet `internalizeAction` arguments.
201
+ * @returns `internalizeAction` results
202
+ */
142
203
  async internalizeAction(
143
204
  auth: sdk.AuthId,
144
205
  args: InternalizeActionArgs
@@ -149,6 +210,13 @@ export class StorageClient implements sdk.WalletStorageProvider {
149
210
  ])
150
211
  }
151
212
 
213
+ /**
214
+ * Storage level processing for wallet `createAction`.
215
+ * @param auth Identifies client by identity key and the storage identity key of their currently active storage.
216
+ * This must match the `AuthFetch` identity securing the remote conneciton.
217
+ * @param args Validated extension of original wallet `createAction` arguments.
218
+ * @returns `StorageCreateActionResults` supporting additional wallet processing to yield `createAction` results.
219
+ */
152
220
  async createAction(
153
221
  auth: sdk.AuthId,
154
222
  args: sdk.ValidCreateActionArgs
@@ -159,6 +227,16 @@ export class StorageClient implements sdk.WalletStorageProvider {
159
227
  ])
160
228
  }
161
229
 
230
+ /**
231
+ * Storage level processing for wallet `createAction` and `signAction`.
232
+ *
233
+ * Handles remaining storage tasks once a fully signed transaction has been completed. This is common to both `createAction` and `signAction`.
234
+ *
235
+ * @param auth Identifies client by identity key and the storage identity key of their currently active storage.
236
+ * This must match the `AuthFetch` identity securing the remote conneciton.
237
+ * @param args `StorageProcessActionArgs` convey completed signed transaction to storage.
238
+ * @returns `StorageProcessActionResults` supporting final wallet processing to yield `createAction` or `signAction` results.
239
+ */
162
240
  async processAction(
163
241
  auth: sdk.AuthId,
164
242
  args: sdk.StorageProcessActionArgs
@@ -169,6 +247,13 @@ export class StorageClient implements sdk.WalletStorageProvider {
169
247
  ])
170
248
  }
171
249
 
250
+ /**
251
+ * Aborts an action by `reference` string.
252
+ * @param auth Identifies client by identity key and the storage identity key of their currently active storage.
253
+ * This must match the `AuthFetch` identity securing the remote conneciton.
254
+ * @param args original wallet `abortAction` args.
255
+ * @returns `abortAction` result.
256
+ */
172
257
  async abortAction(
173
258
  auth: sdk.AuthId,
174
259
  args: AbortActionArgs
@@ -176,33 +261,61 @@ export class StorageClient implements sdk.WalletStorageProvider {
176
261
  return this.rpcCall<AbortActionResult>('abortAction', [auth, args])
177
262
  }
178
263
 
264
+ /**
265
+ * Used to both find and initialize a new user by identity key.
266
+ * It is up to the remote storage whether to allow creation of new users by this method.
267
+ * @param identityKey of the user.
268
+ * @returns `TableUser` for the user and whether a new user was created.
269
+ */
179
270
  async findOrInsertUser(
180
271
  identityKey
181
- ): Promise<{ user: table.User; isNew: boolean }> {
182
- return this.rpcCall<{ user: table.User; isNew: boolean }>(
272
+ ): Promise<{ user: TableUser; isNew: boolean }> {
273
+ return this.rpcCall<{ user: TableUser; isNew: boolean }>(
183
274
  'findOrInsertUser',
184
275
  [identityKey]
185
276
  )
186
277
  }
187
278
 
279
+ /**
280
+ * Used to both find and insert a `TableSyncState` record for the user to track wallet data replication across storage providers.
281
+ * @param auth Identifies client by identity key and the storage identity key of their currently active storage.
282
+ * This must match the `AuthFetch` identity securing the remote conneciton.
283
+ * @param storageName the name of the remote storage being sync'd
284
+ * @param storageIdentityKey the identity key of the remote storage being sync'd
285
+ * @returns `TableSyncState` and whether a new record was created.
286
+ */
188
287
  async findOrInsertSyncStateAuth(
189
288
  auth: sdk.AuthId,
190
289
  storageIdentityKey: string,
191
290
  storageName: string
192
- ): Promise<{ syncState: table.SyncState; isNew: boolean }> {
193
- return this.rpcCall<{ syncState: table.SyncState; isNew: boolean }>(
291
+ ): Promise<{ syncState: TableSyncState; isNew: boolean }> {
292
+ return this.rpcCall<{ syncState: TableSyncState; isNew: boolean }>(
194
293
  'findOrInsertSyncStateAuth',
195
294
  [auth, storageIdentityKey, storageName]
196
295
  )
197
296
  }
198
297
 
298
+ /**
299
+ * Inserts a new certificate with fields and keyring into remote storage.
300
+ * @param auth Identifies client by identity key and the storage identity key of their currently active storage.
301
+ * This must match the `AuthFetch` identity securing the remote conneciton.
302
+ * @param certificate the certificate to insert.
303
+ * @returns record Id of the inserted `TableCertificate` record.
304
+ */
199
305
  async insertCertificateAuth(
200
306
  auth: sdk.AuthId,
201
- certificate: table.CertificateX
307
+ certificate: TableCertificateX
202
308
  ): Promise<number> {
203
309
  return this.rpcCall<number>('insertCertificateAuth', [auth, certificate])
204
310
  }
205
311
 
312
+ /**
313
+ * Storage level processing for wallet `listActions`.
314
+ * @param auth Identifies client by identity key and the storage identity key of their currently active storage.
315
+ * This must match the `AuthFetch` identity securing the remote conneciton.
316
+ * @param args Validated extension of original wallet `listActions` arguments.
317
+ * @returns `listActions` results.
318
+ */
206
319
  async listActions(
207
320
  auth: sdk.AuthId,
208
321
  vargs: sdk.ValidListActionsArgs
@@ -210,6 +323,13 @@ export class StorageClient implements sdk.WalletStorageProvider {
210
323
  return this.rpcCall<ListActionsResult>('listActions', [auth, vargs])
211
324
  }
212
325
 
326
+ /**
327
+ * Storage level processing for wallet `listOutputs`.
328
+ * @param auth Identifies client by identity key and the storage identity key of their currently active storage.
329
+ * This must match the `AuthFetch` identity securing the remote conneciton.
330
+ * @param args Validated extension of original wallet `listOutputs` arguments.
331
+ * @returns `listOutputs` results.
332
+ */
213
333
  async listOutputs(
214
334
  auth: sdk.AuthId,
215
335
  vargs: sdk.ValidListOutputsArgs
@@ -217,6 +337,13 @@ export class StorageClient implements sdk.WalletStorageProvider {
217
337
  return this.rpcCall<ListOutputsResult>('listOutputs', [auth, vargs])
218
338
  }
219
339
 
340
+ /**
341
+ * Storage level processing for wallet `listCertificates`.
342
+ * @param auth Identifies client by identity key and the storage identity key of their currently active storage.
343
+ * This must match the `AuthFetch` identity securing the remote conneciton.
344
+ * @param args Validated extension of original wallet `listCertificates` arguments.
345
+ * @returns `listCertificates` results.
346
+ */
220
347
  async listCertificates(
221
348
  auth: sdk.AuthId,
222
349
  vargs: sdk.ValidListCertificatesArgs
@@ -227,36 +354,87 @@ export class StorageClient implements sdk.WalletStorageProvider {
227
354
  ])
228
355
  }
229
356
 
357
+ /**
358
+ * Find user certificates, optionally with fields.
359
+ *
360
+ * This certificate retrieval method supports internal wallet operations.
361
+ * Field values are stored and retrieved encrypted.
362
+ *
363
+ * @param auth Identifies client by identity key and the storage identity key of their currently active storage.
364
+ * This must match the `AuthFetch` identity securing the remote conneciton.
365
+ * @param args `FindCertificatesArgs` determines which certificates to retrieve and whether to include fields.
366
+ * @returns array of certificates matching args.
367
+ */
230
368
  async findCertificatesAuth(
231
369
  auth: sdk.AuthId,
232
370
  args: sdk.FindCertificatesArgs
233
- ): Promise<table.Certificate[]> {
234
- return this.rpcCall<table.Certificate[]>('findCertificatesAuth', [
371
+ ): Promise<TableCertificateX[]> {
372
+ return this.rpcCall<TableCertificate[]>('findCertificatesAuth', [
235
373
  auth,
236
374
  args
237
375
  ])
238
376
  }
239
377
 
378
+ /**
379
+ * Find output baskets.
380
+ *
381
+ * This retrieval method supports internal wallet operations.
382
+ *
383
+ * @param auth Identifies client by identity key and the storage identity key of their currently active storage.
384
+ * This must match the `AuthFetch` identity securing the remote conneciton.
385
+ * @param args `FindOutputBasketsArgs` determines which baskets to retrieve.
386
+ * @returns array of output baskets matching args.
387
+ */
240
388
  async findOutputBasketsAuth(
241
389
  auth: sdk.AuthId,
242
390
  args: sdk.FindOutputBasketsArgs
243
- ): Promise<table.OutputBasket[]> {
244
- return this.rpcCall<table.OutputBasket[]>('findOutputBaskets', [auth, args])
391
+ ): Promise<TableOutputBasket[]> {
392
+ return this.rpcCall<TableOutputBasket[]>('findOutputBaskets', [auth, args])
245
393
  }
246
394
 
395
+ /**
396
+ * Find outputs.
397
+ *
398
+ * This retrieval method supports internal wallet operations.
399
+ *
400
+ * @param auth Identifies client by identity key and the storage identity key of their currently active storage.
401
+ * This must match the `AuthFetch` identity securing the remote conneciton.
402
+ * @param args `FindOutputsArgs` determines which outputs to retrieve.
403
+ * @returns array of outputs matching args.
404
+ */
247
405
  async findOutputsAuth(
248
406
  auth: sdk.AuthId,
249
407
  args: sdk.FindOutputsArgs
250
- ): Promise<table.Output[]> {
251
- return this.rpcCall<table.Output[]>('findOutputsAuth', [auth, args])
408
+ ): Promise<TableOutput[]> {
409
+ return this.rpcCall<TableOutput[]>('findOutputsAuth', [auth, args])
252
410
  }
253
411
 
412
+ /**
413
+ * Find requests for transaction proofs.
414
+ *
415
+ * This retrieval method supports internal wallet operations.
416
+ *
417
+ * @param auth Identifies client by identity key and the storage identity key of their currently active storage.
418
+ * This must match the `AuthFetch` identity securing the remote conneciton.
419
+ * @param args `FindProvenTxReqsArgs` determines which proof requests to retrieve.
420
+ * @returns array of proof requests matching args.
421
+ */
254
422
  findProvenTxReqs(
255
423
  args: sdk.FindProvenTxReqsArgs
256
- ): Promise<table.ProvenTxReq[]> {
257
- return this.rpcCall<table.ProvenTxReq[]>('findProvenTxReqs', [args])
424
+ ): Promise<TableProvenTxReq[]> {
425
+ return this.rpcCall<TableProvenTxReq[]>('findProvenTxReqs', [args])
258
426
  }
259
427
 
428
+ /**
429
+ * Relinquish a certificate.
430
+ *
431
+ * For storage supporting replication records must be kept of deletions. Therefore certificates are marked as deleted
432
+ * when relinquished, and no longer returned by `listCertificates`, but are still retained by storage.
433
+ *
434
+ * @param auth Identifies client by identity key and the storage identity key of their currently active storage.
435
+ * This must match the `AuthFetch` identity securing the remote conneciton.
436
+ * @param args original wallet `relinquishCertificate` args.
437
+ */
260
438
  async relinquishCertificate(
261
439
  auth: sdk.AuthId,
262
440
  args: RelinquishCertificateArgs
@@ -264,6 +442,15 @@ export class StorageClient implements sdk.WalletStorageProvider {
264
442
  return this.rpcCall<number>('relinquishCertificate', [auth, args])
265
443
  }
266
444
 
445
+ /**
446
+ * Relinquish an output.
447
+ *
448
+ * Relinquishing an output removes the output from whatever basket was tracking it.
449
+ *
450
+ * @param auth Identifies client by identity key and the storage identity key of their currently active storage.
451
+ * This must match the `AuthFetch` identity securing the remote conneciton.
452
+ * @param args original wallet `relinquishOutput` args.
453
+ */
267
454
  async relinquishOutput(
268
455
  auth: sdk.AuthId,
269
456
  args: RelinquishOutputArgs
@@ -271,6 +458,15 @@ export class StorageClient implements sdk.WalletStorageProvider {
271
458
  return this.rpcCall<number>('relinquishOutput', [auth, args])
272
459
  }
273
460
 
461
+ /**
462
+ * Process a "chunk" of replication data for the user.
463
+ *
464
+ * The normal data flow is for the active storage to push backups as a sequence of data chunks to backup storage providers.
465
+ *
466
+ * @param args a copy of the replication request args that initiated the sequence of data chunks.
467
+ * @param chunk the current data chunk to process.
468
+ * @returns whether processing is done, counts of inserts and udpates, and related progress tracking properties.
469
+ */
274
470
  async processSyncChunk(
275
471
  args: sdk.RequestSyncChunkArgs,
276
472
  chunk: sdk.SyncChunk
@@ -281,10 +477,29 @@ export class StorageClient implements sdk.WalletStorageProvider {
281
477
  ])
282
478
  }
283
479
 
480
+ /**
481
+ * Request a "chunk" of replication data for a specific user and storage provider.
482
+ *
483
+ * The normal data flow is for the active storage to push backups as a sequence of data chunks to backup storage providers.
484
+ * Also supports recovery where non-active storage can attempt to merge available data prior to becoming active.
485
+ *
486
+ * @param args that identify the non-active storage which will receive replication data and constrains the replication process.
487
+ * @returns the next "chunk" of replication data
488
+ */
284
489
  async getSyncChunk(args: sdk.RequestSyncChunkArgs): Promise<sdk.SyncChunk> {
285
490
  return this.rpcCall<sdk.SyncChunk>('getSyncChunk', [args])
286
491
  }
287
492
 
493
+ /**
494
+ * Handles the data received when a new transaction proof is found in response to an outstanding request for proof data:
495
+ *
496
+ * - Creates a new `TableProvenTx` record.
497
+ * - Notifies all user transaction records of the new status.
498
+ * - Updates the proof request record to 'completed' status which enables delayed deletion.
499
+ *
500
+ * @param args proof request and new transaction proof data
501
+ * @returns results of updates
502
+ */
288
503
  async updateProvenTxReqWithNewProvenTx(
289
504
  args: sdk.UpdateProvenTxReqWithNewProvenTxArgs
290
505
  ): Promise<sdk.UpdateProvenTxReqWithNewProvenTxResult> {
@@ -294,6 +509,15 @@ export class StorageClient implements sdk.WalletStorageProvider {
294
509
  )
295
510
  }
296
511
 
512
+ /**
513
+ * Ensures up-to-date wallet data replication to all configured backup storage providers,
514
+ * then promotes one of the configured backups to active,
515
+ * demoting the current active to new backup.
516
+ *
517
+ * @param auth Identifies client by identity key and the storage identity key of their currently active storage.
518
+ * This must match the `AuthFetch` identity securing the remote conneciton.
519
+ * @param newActiveStorageIdentityKey which must be a currently configured backup storage provider.
520
+ */
297
521
  async setActive(
298
522
  auth: sdk.AuthId,
299
523
  newActiveStorageIdentityKey: string
@@ -2,16 +2,15 @@
2
2
  import { MerklePath } from '@bsv/sdk'
3
3
  import {
4
4
  arraysEqual,
5
- entity,
6
5
  sdk,
7
- table,
6
+ TableCertificate,
8
7
  verifyId,
9
8
  verifyOneOrNone
10
9
  } from '../../../index.client'
11
- import { EntityBase } from '.'
10
+ import { EntityBase, EntityStorage, SyncMap } from '.'
12
11
 
13
- export class Certificate extends EntityBase<table.Certificate> {
14
- constructor(api?: table.Certificate) {
12
+ export class EntityCertificate extends EntityBase<TableCertificate> {
13
+ constructor(api?: TableCertificate) {
15
14
  const now = new Date()
16
15
  super(
17
16
  api || {
@@ -118,13 +117,13 @@ export class Certificate extends EntityBase<table.Certificate> {
118
117
  this.api.certificateId = v
119
118
  }
120
119
  override get entityName(): string {
121
- return 'entity.Certificate'
120
+ return 'certificate'
122
121
  }
123
122
  override get entityTable(): string {
124
123
  return 'certificates'
125
124
  }
126
125
 
127
- override equals(ei: table.Certificate, syncMap?: entity.SyncMap): boolean {
126
+ override equals(ei: TableCertificate, syncMap?: SyncMap): boolean {
128
127
  if (
129
128
  this.type !== ei.type ||
130
129
  this.subject !== ei.subject ||
@@ -140,12 +139,12 @@ export class Certificate extends EntityBase<table.Certificate> {
140
139
  }
141
140
 
142
141
  static async mergeFind(
143
- storage: entity.EntityStorage,
142
+ storage: EntityStorage,
144
143
  userId: number,
145
- ei: table.Certificate,
146
- syncMap: entity.SyncMap,
144
+ ei: TableCertificate,
145
+ syncMap: SyncMap,
147
146
  trx?: sdk.TrxToken
148
- ): Promise<{ found: boolean; eo: entity.Certificate; eiId: number }> {
147
+ ): Promise<{ found: boolean; eo: EntityCertificate; eiId: number }> {
149
148
  const ef = verifyOneOrNone(
150
149
  await storage.findCertificates({
151
150
  partial: {
@@ -158,15 +157,15 @@ export class Certificate extends EntityBase<table.Certificate> {
158
157
  )
159
158
  return {
160
159
  found: !!ef,
161
- eo: new entity.Certificate(ef || { ...ei }),
160
+ eo: new EntityCertificate(ef || { ...ei }),
162
161
  eiId: verifyId(ei.certificateId)
163
162
  }
164
163
  }
165
164
 
166
165
  override async mergeNew(
167
- storage: entity.EntityStorage,
166
+ storage: EntityStorage,
168
167
  userId: number,
169
- syncMap: entity.SyncMap,
168
+ syncMap: SyncMap,
170
169
  trx?: sdk.TrxToken
171
170
  ): Promise<void> {
172
171
  this.userId = userId
@@ -175,10 +174,10 @@ export class Certificate extends EntityBase<table.Certificate> {
175
174
  }
176
175
 
177
176
  override async mergeExisting(
178
- storage: entity.EntityStorage,
177
+ storage: EntityStorage,
179
178
  since: Date | undefined,
180
- ei: table.Certificate,
181
- syncMap: entity.SyncMap,
179
+ ei: TableCertificate,
180
+ syncMap: SyncMap,
182
181
  trx?: sdk.TrxToken
183
182
  ): Promise<boolean> {
184
183
  let wasMerged = false
@@ -1,16 +1,15 @@
1
1
  import { MerklePath } from '@bsv/sdk'
2
2
  import {
3
3
  arraysEqual,
4
- entity,
5
4
  sdk,
6
- table,
5
+ TableCertificateField,
7
6
  verifyId,
8
7
  verifyOneOrNone
9
8
  } from '../../../index.client'
10
- import { EntityBase } from '.'
9
+ import { EntityBase, EntityStorage, SyncMap } from '.'
11
10
 
12
- export class CertificateField extends EntityBase<table.CertificateField> {
13
- constructor(api?: table.CertificateField) {
11
+ export class EntityCertificateField extends EntityBase<TableCertificateField> {
12
+ constructor(api?: TableCertificateField) {
14
13
  const now = new Date()
15
14
  super(
16
15
  api || {
@@ -76,15 +75,15 @@ export class CertificateField extends EntityBase<table.CertificateField> {
76
75
  throw new sdk.WERR_INVALID_OPERATION('entity has no "id" value')
77
76
  }
78
77
  override get entityName(): string {
79
- return 'CertificateField'
78
+ return 'certificateField'
80
79
  }
81
80
  override get entityTable(): string {
82
81
  return 'certificate_fields'
83
82
  }
84
83
 
85
84
  override equals(
86
- ei: table.CertificateField,
87
- syncMap?: entity.SyncMap | undefined
85
+ ei: TableCertificateField,
86
+ syncMap?: SyncMap | undefined
88
87
  ): boolean {
89
88
  if (
90
89
  this.certificateId !==
@@ -101,12 +100,12 @@ export class CertificateField extends EntityBase<table.CertificateField> {
101
100
  }
102
101
 
103
102
  static async mergeFind(
104
- storage: entity.EntityStorage,
103
+ storage: EntityStorage,
105
104
  userId: number,
106
- ei: table.CertificateField,
107
- syncMap: entity.SyncMap,
105
+ ei: TableCertificateField,
106
+ syncMap: SyncMap,
108
107
  trx?: sdk.TrxToken
109
- ): Promise<{ found: boolean; eo: entity.CertificateField; eiId: number }> {
108
+ ): Promise<{ found: boolean; eo: EntityCertificateField; eiId: number }> {
110
109
  const certificateId = syncMap.certificate.idMap[ei.certificateId]
111
110
  const ef = verifyOneOrNone(
112
111
  await storage.findCertificateFields({
@@ -116,15 +115,15 @@ export class CertificateField extends EntityBase<table.CertificateField> {
116
115
  )
117
116
  return {
118
117
  found: !!ef,
119
- eo: new entity.CertificateField(ef || { ...ei }),
118
+ eo: new EntityCertificateField(ef || { ...ei }),
120
119
  eiId: -1
121
120
  }
122
121
  }
123
122
 
124
123
  override async mergeNew(
125
- storage: entity.EntityStorage,
124
+ storage: EntityStorage,
126
125
  userId: number,
127
- syncMap: entity.SyncMap,
126
+ syncMap: SyncMap,
128
127
  trx?: sdk.TrxToken
129
128
  ): Promise<void> {
130
129
  this.certificateId = syncMap.certificate.idMap[this.certificateId]
@@ -133,10 +132,10 @@ export class CertificateField extends EntityBase<table.CertificateField> {
133
132
  }
134
133
 
135
134
  override async mergeExisting(
136
- storage: entity.EntityStorage,
135
+ storage: EntityStorage,
137
136
  since: Date | undefined,
138
- ei: table.CertificateField,
139
- syncMap: entity.SyncMap,
137
+ ei: TableCertificateField,
138
+ syncMap: SyncMap,
140
139
  trx?: sdk.TrxToken
141
140
  ): Promise<boolean> {
142
141
  let wasMerged = false