@bsv/wallet-toolbox 2.1.25 → 3.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/docs/CREATEACTION_BLOCKERS.md +391 -0
  2. package/docs/CUTOVER_RUNBOOK.md +95 -0
  3. package/docs/REQUIREMENTS_COMPLIANCE.md +157 -0
  4. package/docs/ROLLOUT_PLAN.md +273 -0
  5. package/docs/SESSION_HANDOFF.md +298 -0
  6. package/docs/STORAGE_METHOD_WIRING.md +176 -0
  7. package/docs/client.md +3765 -1325
  8. package/docs/monitor.md +255 -33
  9. package/docs/services.md +304 -280
  10. package/docs/setup.md +24 -24
  11. package/docs/storage.md +2783 -251
  12. package/docs/v3-upgrade/index.html +911 -0
  13. package/docs/wallet.md +4956 -9455
  14. package/out/src/Wallet.d.ts.map +1 -1
  15. package/out/src/Wallet.js.map +1 -1
  16. package/out/src/WalletLogger.d.ts.map +1 -1
  17. package/out/src/WalletLogger.js.map +1 -1
  18. package/out/src/__tests/CWIStyleWalletManager.test.js.map +1 -1
  19. package/out/src/__tests/WalletPermissionsManager.fixtures.d.ts.map +1 -1
  20. package/out/src/__tests/WalletPermissionsManager.fixtures.js.map +1 -1
  21. package/out/src/entropy/EntropyCollector.d.ts.map +1 -1
  22. package/out/src/entropy/EntropyCollector.js.map +1 -1
  23. package/out/src/monitor/LeasedMonitorTask.d.ts +43 -0
  24. package/out/src/monitor/LeasedMonitorTask.d.ts.map +1 -0
  25. package/out/src/monitor/LeasedMonitorTask.js +89 -0
  26. package/out/src/monitor/LeasedMonitorTask.js.map +1 -0
  27. package/out/src/monitor/Monitor.d.ts +7 -0
  28. package/out/src/monitor/Monitor.d.ts.map +1 -1
  29. package/out/src/monitor/Monitor.js +7 -0
  30. package/out/src/monitor/Monitor.js.map +1 -1
  31. package/out/src/monitor/MonitorDaemon.d.ts.map +1 -1
  32. package/out/src/monitor/MonitorDaemon.js.map +1 -1
  33. package/out/src/monitor/V7LeasedTask.d.ts +43 -0
  34. package/out/src/monitor/V7LeasedTask.d.ts.map +1 -0
  35. package/out/src/monitor/V7LeasedTask.js +89 -0
  36. package/out/src/monitor/V7LeasedTask.js.map +1 -0
  37. package/out/src/monitor/index.all.d.ts +1 -0
  38. package/out/src/monitor/index.all.d.ts.map +1 -1
  39. package/out/src/monitor/index.all.js +1 -0
  40. package/out/src/monitor/index.all.js.map +1 -1
  41. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts +2 -0
  42. package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
  43. package/out/src/monitor/tasks/TaskCheckForProofs.js +55 -0
  44. package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -1
  45. package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -1
  46. package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -1
  47. package/out/src/sdk/WalletStorage.interfaces.d.ts +59 -59
  48. package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
  49. package/out/src/sdk/types.d.ts +32 -0
  50. package/out/src/sdk/types.d.ts.map +1 -1
  51. package/out/src/sdk/types.js +50 -1
  52. package/out/src/sdk/types.js.map +1 -1
  53. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.d.ts.map +1 -1
  54. package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js.map +1 -1
  55. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.d.ts.map +1 -1
  56. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js.map +1 -1
  57. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.d.ts.map +1 -1
  58. package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageKnex.js.map +1 -1
  59. package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.d.ts.map +1 -1
  60. package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.js.map +1 -1
  61. package/out/src/services/chaintracker/chaintracks/createDefaultKnexChaintracksOptions.d.ts.map +1 -1
  62. package/out/src/services/chaintracker/chaintracks/createDefaultKnexChaintracksOptions.js.map +1 -1
  63. package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.d.ts.map +1 -1
  64. package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.js.map +1 -1
  65. package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.d.ts.map +1 -1
  66. package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.js.map +1 -1
  67. package/out/src/services/chaintracker/chaintracks/createKnexChaintracks.d.ts.map +1 -1
  68. package/out/src/services/chaintracker/chaintracks/createKnexChaintracks.js.map +1 -1
  69. package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.d.ts.map +1 -1
  70. package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.js.map +1 -1
  71. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.d.ts.map +1 -1
  72. package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js.map +1 -1
  73. package/out/src/services/chaintracker/chaintracks/util/ChaintracksFs.d.ts.map +1 -1
  74. package/out/src/services/chaintracker/chaintracks/util/ChaintracksFs.js.map +1 -1
  75. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts.map +1 -1
  76. package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.js.map +1 -1
  77. package/out/src/services/chaintracker/chaintracks/util/__tests/SingleWriterMultiReaderLock.test.js.map +1 -1
  78. package/out/src/storage/StorageIdb.d.ts.map +1 -1
  79. package/out/src/storage/StorageIdb.js +10 -5
  80. package/out/src/storage/StorageIdb.js.map +1 -1
  81. package/out/src/storage/StorageKnex.d.ts +133 -3
  82. package/out/src/storage/StorageKnex.d.ts.map +1 -1
  83. package/out/src/storage/StorageKnex.js +691 -94
  84. package/out/src/storage/StorageKnex.js.map +1 -1
  85. package/out/src/storage/StorageProvider.d.ts +114 -1
  86. package/out/src/storage/StorageProvider.d.ts.map +1 -1
  87. package/out/src/storage/StorageProvider.js +164 -4
  88. package/out/src/storage/StorageProvider.js.map +1 -1
  89. package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
  90. package/out/src/storage/WalletStorageManager.js.map +1 -1
  91. package/out/src/storage/idbHelpers.d.ts +5 -0
  92. package/out/src/storage/idbHelpers.d.ts.map +1 -1
  93. package/out/src/storage/idbHelpers.js +42 -0
  94. package/out/src/storage/idbHelpers.js.map +1 -1
  95. package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
  96. package/out/src/storage/methods/attemptToPostReqsToNetwork.js +116 -4
  97. package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
  98. package/out/src/storage/methods/createAction.d.ts.map +1 -1
  99. package/out/src/storage/methods/createAction.js +22 -5
  100. package/out/src/storage/methods/createAction.js.map +1 -1
  101. package/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
  102. package/out/src/storage/methods/internalizeAction.js +172 -5
  103. package/out/src/storage/methods/internalizeAction.js.map +1 -1
  104. package/out/src/storage/methods/listActionsKnex.d.ts +49 -0
  105. package/out/src/storage/methods/listActionsKnex.d.ts.map +1 -1
  106. package/out/src/storage/methods/listActionsKnex.js +179 -69
  107. package/out/src/storage/methods/listActionsKnex.js.map +1 -1
  108. package/out/src/storage/methods/listOutputsKnex.d.ts.map +1 -1
  109. package/out/src/storage/methods/listOutputsKnex.js +51 -4
  110. package/out/src/storage/methods/listOutputsKnex.js.map +1 -1
  111. package/out/src/storage/methods/processAction.d.ts.map +1 -1
  112. package/out/src/storage/methods/processAction.js +82 -14
  113. package/out/src/storage/methods/processAction.js.map +1 -1
  114. package/out/src/storage/methods/purgeData.d.ts.map +1 -1
  115. package/out/src/storage/methods/purgeData.js +22 -14
  116. package/out/src/storage/methods/purgeData.js.map +1 -1
  117. package/out/src/storage/methods/reviewStatus.d.ts.map +1 -1
  118. package/out/src/storage/methods/reviewStatus.js +18 -9
  119. package/out/src/storage/methods/reviewStatus.js.map +1 -1
  120. package/out/src/storage/schema/KnexMigrations.d.ts.map +1 -1
  121. package/out/src/storage/schema/KnexMigrations.js +134 -0
  122. package/out/src/storage/schema/KnexMigrations.js.map +1 -1
  123. package/out/src/storage/schema/StorageIdbSchema.d.ts +43 -2
  124. package/out/src/storage/schema/StorageIdbSchema.d.ts.map +1 -1
  125. package/out/src/storage/schema/__tests/backfill.runner.test.d.ts +2 -0
  126. package/out/src/storage/schema/__tests/backfill.runner.test.d.ts.map +1 -0
  127. package/out/src/storage/schema/__tests/backfill.runner.test.js +148 -0
  128. package/out/src/storage/schema/__tests/backfill.runner.test.js.map +1 -0
  129. package/out/src/storage/schema/__tests/backfill.test.d.ts +2 -0
  130. package/out/src/storage/schema/__tests/backfill.test.d.ts.map +1 -0
  131. package/out/src/storage/schema/__tests/backfill.test.js +96 -0
  132. package/out/src/storage/schema/__tests/backfill.test.js.map +1 -0
  133. package/out/src/storage/schema/__tests/processingFsm.test.d.ts +2 -0
  134. package/out/src/storage/schema/__tests/processingFsm.test.d.ts.map +1 -0
  135. package/out/src/storage/schema/__tests/processingFsm.test.js +42 -0
  136. package/out/src/storage/schema/__tests/processingFsm.test.js.map +1 -0
  137. package/out/src/storage/schema/__tests/processingFsmLegacyMapping.test.d.ts +2 -0
  138. package/out/src/storage/schema/__tests/processingFsmLegacyMapping.test.d.ts.map +1 -0
  139. package/out/src/storage/schema/__tests/processingFsmLegacyMapping.test.js +82 -0
  140. package/out/src/storage/schema/__tests/processingFsmLegacyMapping.test.js.map +1 -0
  141. package/out/src/storage/schema/__tests/spendabilityRule.test.d.ts +2 -0
  142. package/out/src/storage/schema/__tests/spendabilityRule.test.d.ts.map +1 -0
  143. package/out/src/storage/schema/__tests/spendabilityRule.test.js +29 -0
  144. package/out/src/storage/schema/__tests/spendabilityRule.test.js.map +1 -0
  145. package/out/src/storage/schema/__tests/v7FsmLegacyMapping.test.d.ts +2 -0
  146. package/out/src/storage/schema/__tests/v7FsmLegacyMapping.test.d.ts.map +1 -0
  147. package/out/src/storage/schema/__tests/v7FsmLegacyMapping.test.js +77 -0
  148. package/out/src/storage/schema/__tests/v7FsmLegacyMapping.test.js.map +1 -0
  149. package/out/src/storage/schema/backfill.d.ts +35 -0
  150. package/out/src/storage/schema/backfill.d.ts.map +1 -0
  151. package/out/src/storage/schema/backfill.idb.d.ts +32 -0
  152. package/out/src/storage/schema/backfill.idb.d.ts.map +1 -0
  153. package/out/src/storage/schema/backfill.idb.js +95 -0
  154. package/out/src/storage/schema/backfill.idb.js.map +1 -0
  155. package/out/src/storage/schema/backfill.js +150 -0
  156. package/out/src/storage/schema/backfill.js.map +1 -0
  157. package/out/src/storage/schema/backfill.knex.d.ts +32 -0
  158. package/out/src/storage/schema/backfill.knex.d.ts.map +1 -0
  159. package/out/src/storage/schema/backfill.knex.js +240 -0
  160. package/out/src/storage/schema/backfill.knex.js.map +1 -0
  161. package/out/src/storage/schema/backfill.runner.d.ts +63 -0
  162. package/out/src/storage/schema/backfill.runner.d.ts.map +1 -0
  163. package/out/src/storage/schema/backfill.runner.js +64 -0
  164. package/out/src/storage/schema/backfill.runner.js.map +1 -0
  165. package/out/src/storage/schema/coinbaseMaturityBackfill.d.ts +25 -0
  166. package/out/src/storage/schema/coinbaseMaturityBackfill.d.ts.map +1 -0
  167. package/out/src/storage/schema/coinbaseMaturityBackfill.js +75 -0
  168. package/out/src/storage/schema/coinbaseMaturityBackfill.js.map +1 -0
  169. package/out/src/storage/schema/monitorLease.d.ts +57 -0
  170. package/out/src/storage/schema/monitorLease.d.ts.map +1 -0
  171. package/out/src/storage/schema/monitorLease.js +101 -0
  172. package/out/src/storage/schema/monitorLease.js.map +1 -0
  173. package/out/src/storage/schema/processingFsm.d.ts +27 -0
  174. package/out/src/storage/schema/processingFsm.d.ts.map +1 -0
  175. package/out/src/storage/schema/processingFsm.js +132 -0
  176. package/out/src/storage/schema/processingFsm.js.map +1 -0
  177. package/out/src/storage/schema/schemaCutover.d.ts +34 -0
  178. package/out/src/storage/schema/schemaCutover.d.ts.map +1 -0
  179. package/out/src/storage/schema/schemaCutover.js +230 -0
  180. package/out/src/storage/schema/schemaCutover.js.map +1 -0
  181. package/out/src/storage/schema/schemaCutoverIdb.d.ts +26 -0
  182. package/out/src/storage/schema/schemaCutoverIdb.d.ts.map +1 -0
  183. package/out/src/storage/schema/schemaCutoverIdb.js +90 -0
  184. package/out/src/storage/schema/schemaCutoverIdb.js.map +1 -0
  185. package/out/src/storage/schema/spendabilityRefresh.d.ts +49 -0
  186. package/out/src/storage/schema/spendabilityRefresh.d.ts.map +1 -0
  187. package/out/src/storage/schema/spendabilityRefresh.js +120 -0
  188. package/out/src/storage/schema/spendabilityRefresh.js.map +1 -0
  189. package/out/src/storage/schema/spendabilityRule.d.ts +45 -0
  190. package/out/src/storage/schema/spendabilityRule.d.ts.map +1 -0
  191. package/out/src/storage/schema/spendabilityRule.js +52 -0
  192. package/out/src/storage/schema/spendabilityRule.js.map +1 -0
  193. package/out/src/storage/schema/tables/TableAction.d.ts +3 -3
  194. package/out/src/storage/schema/tables/TableAction.d.ts.map +1 -1
  195. package/out/src/storage/schema/tables/TableChainTip.d.ts +1 -1
  196. package/out/src/storage/schema/tables/TableMonitorLease.d.ts +1 -1
  197. package/out/src/storage/schema/tables/TableOutput.d.ts +7 -0
  198. package/out/src/storage/schema/tables/TableOutput.d.ts.map +1 -1
  199. package/out/src/storage/schema/tables/TableOutput.js.map +1 -1
  200. package/out/src/storage/schema/tables/TableTransactionNew.d.ts +50 -0
  201. package/out/src/storage/schema/tables/TableTransactionNew.d.ts.map +1 -0
  202. package/out/src/storage/schema/tables/TableTransactionNew.js +3 -0
  203. package/out/src/storage/schema/tables/TableTransactionNew.js.map +1 -0
  204. package/out/src/storage/schema/tables/TableTxAudit.d.ts +1 -1
  205. package/out/src/storage/schema/tables/index.d.ts +5 -0
  206. package/out/src/storage/schema/tables/index.d.ts.map +1 -1
  207. package/out/src/storage/schema/tables/index.js +5 -0
  208. package/out/src/storage/schema/tables/index.js.map +1 -1
  209. package/out/src/storage/schema/transactionCrud.d.ts +41 -0
  210. package/out/src/storage/schema/transactionCrud.d.ts.map +1 -0
  211. package/out/src/storage/schema/transactionCrud.js +205 -0
  212. package/out/src/storage/schema/transactionCrud.js.map +1 -0
  213. package/out/src/storage/schema/transactionService.d.ts +315 -0
  214. package/out/src/storage/schema/transactionService.d.ts.map +1 -0
  215. package/out/src/storage/schema/transactionService.js +783 -0
  216. package/out/src/storage/schema/transactionService.js.map +1 -0
  217. package/out/src/storage/schema/txAudit.d.ts +33 -0
  218. package/out/src/storage/schema/txAudit.d.ts.map +1 -0
  219. package/out/src/storage/schema/txAudit.js +64 -0
  220. package/out/src/storage/schema/txAudit.js.map +1 -0
  221. package/out/src/storage/schema/v7Backfill.d.ts.map +1 -1
  222. package/out/src/storage/schema/v7Backfill.js +4 -1
  223. package/out/src/storage/schema/v7Backfill.js.map +1 -1
  224. package/out/src/storage/schema/v7Backfill.runner.d.ts.map +1 -1
  225. package/out/src/storage/schema/v7Backfill.runner.js +3 -1
  226. package/out/src/storage/schema/v7Backfill.runner.js.map +1 -1
  227. package/out/src/storage/schema/v7CoinbaseMaturityBackfill.d.ts +25 -0
  228. package/out/src/storage/schema/v7CoinbaseMaturityBackfill.d.ts.map +1 -0
  229. package/out/src/storage/schema/v7CoinbaseMaturityBackfill.js +75 -0
  230. package/out/src/storage/schema/v7CoinbaseMaturityBackfill.js.map +1 -0
  231. package/out/src/storage/schema/v7Crud.d.ts +5 -3
  232. package/out/src/storage/schema/v7Crud.d.ts.map +1 -1
  233. package/out/src/storage/schema/v7Crud.js +11 -9
  234. package/out/src/storage/schema/v7Crud.js.map +1 -1
  235. package/out/src/storage/schema/v7Cutover.d.ts +34 -0
  236. package/out/src/storage/schema/v7Cutover.d.ts.map +1 -0
  237. package/out/src/storage/schema/v7Cutover.js +223 -0
  238. package/out/src/storage/schema/v7Cutover.js.map +1 -0
  239. package/out/src/storage/schema/v7CutoverIdb.d.ts +26 -0
  240. package/out/src/storage/schema/v7CutoverIdb.d.ts.map +1 -0
  241. package/out/src/storage/schema/v7CutoverIdb.js +90 -0
  242. package/out/src/storage/schema/v7CutoverIdb.js.map +1 -0
  243. package/out/src/storage/schema/v7Fsm.d.ts.map +1 -1
  244. package/out/src/storage/schema/v7Fsm.js +22 -6
  245. package/out/src/storage/schema/v7Fsm.js.map +1 -1
  246. package/out/src/storage/schema/v7Service.d.ts +305 -0
  247. package/out/src/storage/schema/v7Service.d.ts.map +1 -0
  248. package/out/src/storage/schema/v7Service.js +757 -0
  249. package/out/src/storage/schema/v7Service.js.map +1 -0
  250. package/out/src/storage/schema/v7SpendabilityRefresh.d.ts +49 -0
  251. package/out/src/storage/schema/v7SpendabilityRefresh.d.ts.map +1 -0
  252. package/out/src/storage/schema/v7SpendabilityRefresh.js +111 -0
  253. package/out/src/storage/schema/v7SpendabilityRefresh.js.map +1 -0
  254. package/out/src/storage/storageProviderHelpers.js +1 -1
  255. package/out/src/storage/storageProviderHelpers.js.map +1 -1
  256. package/out/src/utility/Format.js.map +1 -1
  257. package/package.json +7 -4
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const processingFsm_1 = require("../processingFsm");
4
+ const legacyMappingCases = [
5
+ // §4 trigger: processAction / isNoSend && !isSendWith → "nosend → nosend"
6
+ // queued (pre-send) → nosend
7
+ { legacy: 'processAction nosend mark', from: 'queued', to: 'nosend' },
8
+ // §4 trigger: processAction delayed broadcast (collapses to queued → queued
9
+ // via `nextActionAt`); covered by identity rule but listed for completeness.
10
+ { legacy: 'processAction delayed (identity)', from: 'queued', to: 'queued' },
11
+ // §4 trigger: processAction pre-broadcast → "queued → broadcasting"
12
+ // queued → sending (sending = "in flight" per ProcessingStatus jsdoc)
13
+ { legacy: 'processAction pre-broadcast', from: 'queued', to: 'sending' },
14
+ // §4 trigger: processAction post-broadcast → "broadcasting → broadcasted"
15
+ // sending → sent (handoff acknowledged)
16
+ { legacy: 'processAction post-broadcast (handoff)', from: 'sending', to: 'sent' },
17
+ // §4 trigger: same post-broadcast path may land at `seen` when the provider
18
+ // ack arrives with a first observation, not just a queue receipt.
19
+ { legacy: 'processAction post-broadcast (seen)', from: 'sending', to: 'seen' },
20
+ // §4 trigger: internalizeAction bump-absent → "unsent → unproven"
21
+ // queued → sent (rawTx exists, handoff implied by bump-absent path)
22
+ { legacy: 'internalizeAction bump-absent', from: 'queued', to: 'sent' },
23
+ // §4 trigger: attemptToPostReqsToNetwork / `invalid` → "* → invalid"
24
+ // each non-terminal state that may host a tx during the attempt loop.
25
+ { legacy: 'attemptToPost invalid (from queued)', from: 'queued', to: 'invalid' },
26
+ { legacy: 'attemptToPost invalid (from sending)', from: 'sending', to: 'invalid' },
27
+ { legacy: 'attemptToPost invalid (from sent)', from: 'sent', to: 'invalid' },
28
+ { legacy: 'attemptToPost invalid (from seen)', from: 'seen', to: 'invalid' },
29
+ { legacy: 'attemptToPost invalid (from seen_multi)', from: 'seen_multi', to: 'invalid' },
30
+ { legacy: 'attemptToPost invalid (from unconfirmed)', from: 'unconfirmed', to: 'invalid' },
31
+ // NOTE: `reorging → invalid` is intentionally NOT a legal direct edge per
32
+ // bsv_wallet_transaction_requirements v1.0 §5: "A reorg SHALL never cause
33
+ // a transaction to be marked Invalid or DoubleSpend." Callers must first
34
+ // transition reorging → unconfirmed (or another recovery state) before
35
+ // marking invalid.
36
+ { legacy: 'attemptToPost invalid (from nosend)', from: 'nosend', to: 'invalid' },
37
+ { legacy: 'attemptToPost invalid (from nonfinal)', from: 'nonfinal', to: 'invalid' },
38
+ // §4 trigger: attemptToPost success → "broadcasting → broadcasted" with
39
+ // wasBroadcast=true. new-schema: sending → sent. Also covers queued → sent on the
40
+ // bump-absent path executed inside the attempt loop.
41
+ { legacy: 'attemptToPost success (queued)', from: 'queued', to: 'sent' },
42
+ { legacy: 'attemptToPost success (sending)', from: 'sending', to: 'sent' },
43
+ // §4 trigger: attemptToPost doubleSpend → "* → doubleSpend" (terminal).
44
+ // every non-terminal state that may host a tx when a doubleSpend
45
+ // notification arrives.
46
+ { legacy: 'attemptToPost doubleSpend (from queued)', from: 'queued', to: 'doubleSpend' },
47
+ { legacy: 'attemptToPost doubleSpend (from sending)', from: 'sending', to: 'doubleSpend' },
48
+ { legacy: 'attemptToPost doubleSpend (from sent)', from: 'sent', to: 'doubleSpend' },
49
+ { legacy: 'attemptToPost doubleSpend (from seen)', from: 'seen', to: 'doubleSpend' },
50
+ { legacy: 'attemptToPost doubleSpend (from seen_multi)', from: 'seen_multi', to: 'doubleSpend' },
51
+ { legacy: 'attemptToPost doubleSpend (from unconfirmed)', from: 'unconfirmed', to: 'doubleSpend' },
52
+ // NOTE: `reorging → doubleSpend` is intentionally NOT a legal direct edge.
53
+ // See note above for reorging → invalid; same spec rationale applies.
54
+ { legacy: 'attemptToPost doubleSpend (from nosend)', from: 'nosend', to: 'doubleSpend' },
55
+ { legacy: 'attemptToPost doubleSpend (from nonfinal)', from: 'nonfinal', to: 'doubleSpend' },
56
+ // §4 trigger: attemptToPost serviceError → "* → sending + attempts++".
57
+ // retry path from any state where a live re-broadcast makes sense.
58
+ // Excludes terminal states (invalid/doubleSpend/proven enter via unfail or
59
+ // reorging, not directly) and excludes `frozen` (operator-paused).
60
+ { legacy: 'attemptToPost serviceError retry (from queued)', from: 'queued', to: 'sending' },
61
+ { legacy: 'attemptToPost serviceError retry (self-retry)', from: 'sending', to: 'sending' },
62
+ { legacy: 'attemptToPost serviceError retry (from sent)', from: 'sent', to: 'sending' },
63
+ { legacy: 'attemptToPost serviceError retry (from seen)', from: 'seen', to: 'sending' },
64
+ { legacy: 'attemptToPost serviceError retry (from seen_multi)', from: 'seen_multi', to: 'sending' },
65
+ { legacy: 'attemptToPost serviceError retry (from unconfirmed)', from: 'unconfirmed', to: 'sending' },
66
+ { legacy: 'attemptToPost serviceError retry (from nosend)', from: 'nosend', to: 'sending' },
67
+ { legacy: 'attemptToPost serviceError retry (from nonfinal)', from: 'nonfinal', to: 'sending' },
68
+ // §4 trigger: Monitor proof → "* → confirmed". new-schema: only states that have
69
+ // observed the tx on-chain may transition to confirmed directly (terminal
70
+ // proof). Pre-observation states must pass through `seen`/`unconfirmed`
71
+ // first — enforced by the FSM, not asserted here.
72
+ { legacy: 'Monitor proof (from seen)', from: 'seen', to: 'confirmed' },
73
+ { legacy: 'Monitor proof (from seen_multi)', from: 'seen_multi', to: 'confirmed' },
74
+ { legacy: 'Monitor proof (from unconfirmed)', from: 'unconfirmed', to: 'confirmed' },
75
+ { legacy: 'Monitor proof (from reorging)', from: 'reorging', to: 'confirmed' }
76
+ ];
77
+ describe('Processing FSM legacy mapping coverage (STORAGE_METHOD_WIRING §4)', () => {
78
+ it.each(legacyMappingCases)('$legacy: $from -> $to is permitted', ({ from, to }) => {
79
+ expect((0, processingFsm_1.isValidProcessingTransition)(from, to)).toBe(true);
80
+ });
81
+ });
82
+ //# sourceMappingURL=processingFsmLegacyMapping.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processingFsmLegacyMapping.test.js","sourceRoot":"","sources":["../../../../../src/storage/schema/__tests/processingFsmLegacyMapping.test.ts"],"names":[],"mappings":";;AACA,oDAA8D;AAqB9D,MAAM,kBAAkB,GAAwB;IAC9C,0EAA0E;IAC1E,6BAA6B;IAC7B,EAAE,MAAM,EAAE,2BAA2B,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE;IAErE,4EAA4E;IAC5E,6EAA6E;IAC7E,EAAE,MAAM,EAAE,kCAAkC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE;IAE5E,oEAAoE;IACpE,sEAAsE;IACtE,EAAE,MAAM,EAAE,6BAA6B,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE;IAExE,0EAA0E;IAC1E,wCAAwC;IACxC,EAAE,MAAM,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ityRule.test.d.ts","sourceRoot":"","sources":["../../../../../src/storage/schema/__tests/spendabilityRule.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const spendabilityRule_1 = require("../spendabilityRule");
4
+ describe('Spendability rules', () => {
5
+ const tip = { height: 1000 };
6
+ test('non-spendable processing state rejects', () => {
7
+ expect((0, spendabilityRule_1.isOutputSpendable)({ spentBy: null, lockingScript: [0x76] }, { processing: 'queued' }, tip)).toBe(false);
8
+ expect((0, spendabilityRule_1.isOutputSpendable)({ spentBy: null, lockingScript: [0x76] }, { processing: 'invalid' }, tip)).toBe(false);
9
+ });
10
+ test('spent output rejects', () => {
11
+ expect((0, spendabilityRule_1.isOutputSpendable)({ spentBy: 7, lockingScript: [0x76] }, { processing: 'confirmed' }, tip)).toBe(false);
12
+ });
13
+ test('missing locking script rejects', () => {
14
+ expect((0, spendabilityRule_1.isOutputSpendable)({ spentBy: null, lockingScript: null }, { processing: 'confirmed' }, tip)).toBe(false);
15
+ });
16
+ test('immature coinbase rejects', () => {
17
+ expect((0, spendabilityRule_1.isOutputSpendable)({ spentBy: null, lockingScript: [0x76], isCoinbase: true, maturesAtHeight: 1001 }, { processing: 'confirmed' }, tip)).toBe(false);
18
+ });
19
+ test('mature coinbase passes', () => {
20
+ expect((0, spendabilityRule_1.isOutputSpendable)({ spentBy: null, lockingScript: [0x76], isCoinbase: true, maturesAtHeight: 1000 }, { processing: 'confirmed' }, tip)).toBe(true);
21
+ });
22
+ test('non-coinbase spendable in sent state', () => {
23
+ expect((0, spendabilityRule_1.isOutputSpendable)({ spentBy: null, lockingScript: [0x76], isCoinbase: false }, { processing: 'sent' }, tip)).toBe(true);
24
+ });
25
+ test('coinbase without chain tip cannot mature', () => {
26
+ expect((0, spendabilityRule_1.isOutputSpendable)({ spentBy: null, lockingScript: [0x76], isCoinbase: true, maturesAtHeight: 100 }, { processing: 'confirmed' }, undefined)).toBe(false);
27
+ });
28
+ });
29
+ //# sourceMappingURL=spendabilityRule.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spendabilityRule.test.js","sourceRoot":"","sources":["../../../../../src/storage/schema/__tests/spendabilityRule.test.ts"],"names":[],"mappings":";;AAAA,0DAAuD;AAEvD,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,MAAM,GAAG,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;IAE5B,IAAI,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAClD,MAAM,CACJ,IAAA,oCAAiB,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,GAAG,CAAC,CAC3F,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACb,MAAM,CACJ,IAAA,oCAAiB,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,GAAG,CAAC,CAC5F,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACf,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,sBAAsB,EAAE,GAAG,EAAE;QAChC,MAAM,CACJ,IAAA,oCAAiB,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,GAAG,CAAC,CAC3F,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACf,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,gCAAgC,EAAE,GAAG,EAAE;QAC1C,MAAM,CACJ,IAAA,oCAAiB,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,GAAG,CAAC,CAC5F,CA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,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACf,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=v7FsmLegacyMapping.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v7FsmLegacyMapping.test.d.ts","sourceRoot":"","sources":["../../../../../src/storage/schema/__tests/v7FsmLegacyMapping.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const v7Fsm_1 = require("../v7Fsm");
4
+ const legacyMappingCases = [
5
+ // §4 trigger: processAction / isNoSend && !isSendWith → "nosend → nosend"
6
+ // V7: queued (pre-send) → nosend
7
+ { legacy: 'processAction nosend mark', from: 'queued', to: 'nosend' },
8
+ // §4 trigger: processAction delayed broadcast (collapses to queued → queued
9
+ // via `nextActionAt`); covered by identity rule but listed for completeness.
10
+ { legacy: 'processAction delayed (identity)', from: 'queued', to: 'queued' },
11
+ // §4 trigger: processAction pre-broadcast → "queued → broadcasting"
12
+ // V7: queued → sending (sending = "in flight" per ProcessingStatus jsdoc)
13
+ { legacy: 'processAction pre-broadcast', from: 'queued', to: 'sending' },
14
+ // §4 trigger: processAction post-broadcast → "broadcasting → broadcasted"
15
+ // V7: sending → sent (handoff acknowledged)
16
+ { legacy: 'processAction post-broadcast (handoff)', from: 'sending', to: 'sent' },
17
+ // §4 trigger: same post-broadcast path may land at `seen` when the provider
18
+ // ack arrives with a first observation, not just a queue receipt.
19
+ { legacy: 'processAction post-broadcast (seen)', from: 'sending', to: 'seen' },
20
+ // §4 trigger: internalizeAction bump-absent → "unsent → unproven"
21
+ // V7: queued → sent (rawTx exists, handoff implied by bump-absent path)
22
+ { legacy: 'internalizeAction bump-absent', from: 'queued', to: 'sent' },
23
+ // §4 trigger: attemptToPostReqsToNetwork / `invalid` → "* → invalid"
24
+ // V7: each non-terminal state that may host a tx during the attempt loop.
25
+ { legacy: 'attemptToPost invalid (from queued)', from: 'queued', to: 'invalid' },
26
+ { legacy: 'attemptToPost invalid (from sending)', from: 'sending', to: 'invalid' },
27
+ { legacy: 'attemptToPost invalid (from sent)', from: 'sent', to: 'invalid' },
28
+ { legacy: 'attemptToPost invalid (from seen)', from: 'seen', to: 'invalid' },
29
+ { legacy: 'attemptToPost invalid (from seen_multi)', from: 'seen_multi', to: 'invalid' },
30
+ { legacy: 'attemptToPost invalid (from unconfirmed)', from: 'unconfirmed', to: 'invalid' },
31
+ { legacy: 'attemptToPost invalid (from reorging)', from: 'reorging', to: 'invalid' },
32
+ { legacy: 'attemptToPost invalid (from nosend)', from: 'nosend', to: 'invalid' },
33
+ { legacy: 'attemptToPost invalid (from nonfinal)', from: 'nonfinal', to: 'invalid' },
34
+ // §4 trigger: attemptToPost success → "broadcasting → broadcasted" with
35
+ // wasBroadcast=true. V7: sending → sent. Also covers queued → sent on the
36
+ // bump-absent path executed inside the attempt loop.
37
+ { legacy: 'attemptToPost success (queued)', from: 'queued', to: 'sent' },
38
+ { legacy: 'attemptToPost success (sending)', from: 'sending', to: 'sent' },
39
+ // §4 trigger: attemptToPost doubleSpend → "* → doubleSpend" (terminal).
40
+ // V7: every non-terminal state that may host a tx when a doubleSpend
41
+ // notification arrives.
42
+ { legacy: 'attemptToPost doubleSpend (from queued)', from: 'queued', to: 'doubleSpend' },
43
+ { legacy: 'attemptToPost doubleSpend (from sending)', from: 'sending', to: 'doubleSpend' },
44
+ { legacy: 'attemptToPost doubleSpend (from sent)', from: 'sent', to: 'doubleSpend' },
45
+ { legacy: 'attemptToPost doubleSpend (from seen)', from: 'seen', to: 'doubleSpend' },
46
+ { legacy: 'attemptToPost doubleSpend (from seen_multi)', from: 'seen_multi', to: 'doubleSpend' },
47
+ { legacy: 'attemptToPost doubleSpend (from unconfirmed)', from: 'unconfirmed', to: 'doubleSpend' },
48
+ { legacy: 'attemptToPost doubleSpend (from reorging)', from: 'reorging', to: 'doubleSpend' },
49
+ { legacy: 'attemptToPost doubleSpend (from nosend)', from: 'nosend', to: 'doubleSpend' },
50
+ { legacy: 'attemptToPost doubleSpend (from nonfinal)', from: 'nonfinal', to: 'doubleSpend' },
51
+ // §4 trigger: attemptToPost serviceError → "* → sending + attempts++".
52
+ // V7: retry path from any state where a live re-broadcast makes sense.
53
+ // Excludes terminal states (invalid/doubleSpend/proven enter via unfail or
54
+ // reorging, not directly) and excludes `frozen` (operator-paused).
55
+ { legacy: 'attemptToPost serviceError retry (from queued)', from: 'queued', to: 'sending' },
56
+ { legacy: 'attemptToPost serviceError retry (self-retry)', from: 'sending', to: 'sending' },
57
+ { legacy: 'attemptToPost serviceError retry (from sent)', from: 'sent', to: 'sending' },
58
+ { legacy: 'attemptToPost serviceError retry (from seen)', from: 'seen', to: 'sending' },
59
+ { legacy: 'attemptToPost serviceError retry (from seen_multi)', from: 'seen_multi', to: 'sending' },
60
+ { legacy: 'attemptToPost serviceError retry (from unconfirmed)', from: 'unconfirmed', to: 'sending' },
61
+ { legacy: 'attemptToPost serviceError retry (from nosend)', from: 'nosend', to: 'sending' },
62
+ { legacy: 'attemptToPost serviceError retry (from nonfinal)', from: 'nonfinal', to: 'sending' },
63
+ // §4 trigger: Monitor proof → "* → proven". V7: only states that have
64
+ // observed the tx on-chain may transition to proven directly (terminal
65
+ // proof). Pre-observation states must pass through `seen`/`unconfirmed`
66
+ // first — enforced by the FSM, not asserted here.
67
+ { legacy: 'Monitor proof (from seen)', from: 'seen', to: 'proven' },
68
+ { legacy: 'Monitor proof (from seen_multi)', from: 'seen_multi', to: 'proven' },
69
+ { legacy: 'Monitor proof (from unconfirmed)', from: 'unconfirmed', to: 'proven' },
70
+ { legacy: 'Monitor proof (from reorging)', from: 'reorging', to: 'proven' }
71
+ ];
72
+ describe('v7Fsm legacy mapping coverage (V7_STORAGE_METHOD_WIRING §4)', () => {
73
+ it.each(legacyMappingCases)('$legacy: $from -> $to is permitted', ({ from, to }) => {
74
+ expect((0, v7Fsm_1.isValidProcessingTransition)(from, to)).toBe(true);
75
+ });
76
+ });
77
+ //# sourceMappingURL=v7FsmLegacyMapping.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v7FsmLegacyMapping.test.js","sourceRoot":"","sources":["../../../../../src/storage/schema/__tests/v7FsmLegacyMapping.test.ts"],"names":[],"mappings":";;AACA,oCAAsD;AAqBtD,MAAM,kBAAkB,GAAwB;IAC9C,0EAA0E;IAC1E,iCAAiC;IACjC,EAAE,MAAM,EAAE,2BAA2B,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE;IAErE,4EAA4E;IAC5E,6EAA6E;IAC7E,EAAE,MAAM,EAAE,kCAAkC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE;IAE5E,oEAAoE;IACpE,0EAA0E;IAC1E,EAAE,MAAM,EAAE,6BAA6B,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE;IAExE,0EAA0E;IAC1E,4CAA4C;IAC5C,EAAE,MAAM,EAAE,wCAAwC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE;IAEjF,4EAA4E;IAC5E,kEAAkE;IAClE,EAAE,MAAM,EAAE,qCAAqC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE;IAE9E,kEAAkE;IAClE,wEAAwE;IACxE,EAAE,MAAM,EAAE,+BAA+B,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE;IAEvE,qEAAqE;IACrE,0EAA0E;IAC1E,EAAE,MAAM,EAAE,qCAAqC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,EAAE;IAChF,EAAE,MAAM,EAAE,sCAAsC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE;IAClF,EAAE,MAAM,EAAE,mCAAmC,EAAE,IAAI,EAAE,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E,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE;IACnE,EAAE,MAAM,EAAE,iCAAiC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,EAAE;IAC/E,EAAE,MAAM,EAAE,kCAAkC,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,QAAQ,EAAE;IACjF,EAAE,MAAM,EAAE,+BAA+B,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,QAAQ,EAAE;CAC5E,CAAA;AAED,QAAQ,CAAC,6DAA6D,EAAE,GAAG,EAAE;IAC3E,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,CACzB,oCAAoC,EACpC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAqB,EAAE,EAAE;QAClC,MAAM,CAAC,IAAA,mCAA2B,EAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC1D,CAAC,CACF,CAAA;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,35 @@
1
+ import { TableAction, TableProvenTx, TableProvenTxReq, TableTransaction, TableTransactionNew } from './tables';
2
+ /**
3
+ * Pure transformation helpers for the the new schema backfill.
4
+ *
5
+ * These functions are deliberately storage-agnostic — they accept the legacy
6
+ * rows and return the new shapes. A storage driver (Knex or IDB) is responsible
7
+ * for reading the source rows and inserting the returned objects.
8
+ *
9
+ * No row in this module ever talks to the database; this keeps the
10
+ * transformation under unit-test control and lets us run dry-run migrations.
11
+ */
12
+ /**
13
+ * Merge a legacy `proven_tx_reqs` row together with an optional `proven_txs`
14
+ * row into a single new `transactions` (transactions_new) row.
15
+ *
16
+ * The proof fields come from `proven_txs` when present; otherwise they are
17
+ * left undefined. Processing state is derived from the request's legacy status.
18
+ */
19
+ export declare function buildTransactionNewRow(req: TableProvenTxReq, proven: TableProvenTx | undefined, now?: Date): Omit<TableTransactionNew, 'transactionId'>;
20
+ /**
21
+ * Build a new `transactions` row from a legacy per-user `transactions` row when
22
+ * no `proven_tx_reqs` entry exists (e.g. locally-created actions that never
23
+ * reached the broadcast queue).
24
+ *
25
+ * Returns `undefined` when the legacy row has no txid — such rows belong to
26
+ * incomplete actions and have no canonical new-schema representation yet.
27
+ */
28
+ export declare function buildTransactionNewRowFromLegacyTx(tx: TableTransaction, now?: Date): Omit<TableTransactionNew, 'transactionId'> | undefined;
29
+ /**
30
+ * Build a new `actions` row from a legacy per-user `transactions` row.
31
+ * The caller is responsible for resolving `transactionId` to the
32
+ * newly-inserted `transactions_new.transactionId`.
33
+ */
34
+ export declare function buildActionRow(legacy: TableTransaction, newTransactionId: number, now?: Date): Omit<TableAction, 'actionId'>;
35
+ //# sourceMappingURL=backfill.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backfill.d.ts","sourceRoot":"","sources":["../../../../src/storage/schema/backfill.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,UAAU,CAAA;AAEjB;;;;;;;;;GASG;AAEH;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,aAAa,GAAG,SAAS,EACjC,GAAG,GAAE,IAAiB,GACrB,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC,CA2B5C;AAED;;;;;;;GAOG;AACH,wBAAgB,kCAAkC,CAChD,EAAE,EAAE,gBAAgB,EACpB,GAAG,GAAE,IAAiB,GACrB,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC,GAAG,SAAS,CA8BxD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,gBAAgB,EACxB,gBAAgB,EAAE,MAAM,EACxB,GAAG,GAAE,IAAiB,GACrB,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAgB/B"}
@@ -0,0 +1,32 @@
1
+ import { IDBPDatabase, IDBPTransaction } from 'idb';
2
+ import { StorageIdbSchema } from './StorageIdbSchema';
3
+ import { TableAction, TableProvenTx, TableProvenTxReq, TableTransaction, TableTransactionNew } from './tables';
4
+ import { BackfillDriver, BackfillStats } from './backfill.runner';
5
+ type IdbStoreName = keyof StorageIdbSchema;
6
+ /**
7
+ * IndexedDB driver for the the backfill.
8
+ *
9
+ * The orchestrator is driven entirely from this driver inside a single
10
+ * `readwrite` transaction across the legacy + new-schema stores. The streams cache
11
+ * the keys up-front (`getAllKeys`) and then walk them one at a time so the
12
+ * idb cursor lifetime does not span an external `await`.
13
+ */
14
+ export declare class IdbBackfillDriver implements BackfillDriver {
15
+ private readonly trx;
16
+ constructor(trx: IDBPTransaction<StorageIdbSchema, IdbStoreName[], 'readwrite'>);
17
+ streamLegacyReqs(): AsyncIterable<{
18
+ req: TableProvenTxReq;
19
+ proven?: TableProvenTx;
20
+ }>;
21
+ streamLegacyTransactions(): AsyncIterable<TableTransaction>;
22
+ upsertTransactionNew(row: Omit<TableTransactionNew, 'transactionId'>): Promise<number>;
23
+ upsertAction(row: Omit<TableAction, 'actionId'>): Promise<number>;
24
+ repointTxLabelMap(legacyTransactionId: number, actionId: number): Promise<void>;
25
+ }
26
+ /**
27
+ * Convenience entry point that opens the required readwrite transaction and
28
+ * runs the orchestrator against it.
29
+ */
30
+ export declare function runIdbBackfill(db: IDBPDatabase<StorageIdbSchema>, now?: Date): Promise<BackfillStats>;
31
+ export {};
32
+ //# sourceMappingURL=backfill.idb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backfill.idb.d.ts","sourceRoot":"","sources":["../../../../src/storage/schema/backfill.idb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,KAAK,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EACL,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAe,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAE9E,KAAK,YAAY,GAAG,MAAM,gBAAgB,CAAA;AAW1C;;;;;;;GAOG;AACH,qBAAa,iBAAkB,YAAW,cAAc;IAEpD,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,eAAe,CAAC,gBAAgB,EAAE,YAAY,EAAE,EAAE,WAAW,CAAC;IAG9E,gBAAgB,IAAK,aAAa,CAAC;QAAE,GAAG,EAAE,gBAAgB,CAAC;QAAC,MAAM,CAAC,EAAE,aAAa,CAAA;KAAE,CAAC;IAYrF,wBAAwB,IAAK,aAAa,CAAC,gBAAgB,CAAC;IAS9D,oBAAoB,CAAE,GAAG,EAAE,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAavF,YAAY,CAAE,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAalE,iBAAiB,CAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAWvF;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,EAAE,EAAE,YAAY,CAAC,gBAAgB,CAAC,EAClC,GAAG,GAAE,IAAiB,GACrB,OAAO,CAAC,aAAa,CAAC,CAMxB"}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IdbBackfillDriver = void 0;
4
+ exports.runIdbBackfill = runIdbBackfill;
5
+ const backfill_runner_1 = require("./backfill.runner");
6
+ const BACKFILL_STORES = [
7
+ 'proven_tx_reqs',
8
+ 'proven_txs',
9
+ 'transactions',
10
+ 'transactions_new',
11
+ 'actions',
12
+ 'tx_labels_map'
13
+ ];
14
+ /**
15
+ * IndexedDB driver for the the backfill.
16
+ *
17
+ * The orchestrator is driven entirely from this driver inside a single
18
+ * `readwrite` transaction across the legacy + new-schema stores. The streams cache
19
+ * the keys up-front (`getAllKeys`) and then walk them one at a time so the
20
+ * idb cursor lifetime does not span an external `await`.
21
+ */
22
+ class IdbBackfillDriver {
23
+ constructor(trx) {
24
+ this.trx = trx;
25
+ }
26
+ async *streamLegacyReqs() {
27
+ const reqStore = this.trx.objectStore('proven_tx_reqs');
28
+ const provenStore = this.trx.objectStore('proven_txs');
29
+ const reqKeys = await reqStore.getAllKeys();
30
+ for (const key of reqKeys) {
31
+ const req = await reqStore.get(key);
32
+ let proven;
33
+ if (req.provenTxId != null)
34
+ proven = await provenStore.get(req.provenTxId);
35
+ yield { req, proven };
36
+ }
37
+ }
38
+ async *streamLegacyTransactions() {
39
+ const store = this.trx.objectStore('transactions');
40
+ const keys = await store.getAllKeys();
41
+ for (const key of keys) {
42
+ const row = await store.get(key);
43
+ yield row;
44
+ }
45
+ }
46
+ async upsertTransactionNew(row) {
47
+ const store = this.trx.objectStore('transactions_new');
48
+ const txidIndex = store.index('txid');
49
+ const existing = await txidIndex.get(row.txid);
50
+ if (existing != null) {
51
+ const merged = { ...existing, ...row, transactionId: existing.transactionId };
52
+ await store.put(merged);
53
+ return existing.transactionId;
54
+ }
55
+ const newId = await store.add(row);
56
+ return newId;
57
+ }
58
+ async upsertAction(row) {
59
+ const store = this.trx.objectStore('actions');
60
+ const idx = store.index('userId_transactionId');
61
+ const existing = await idx.get([row.userId, row.transactionId]);
62
+ if (existing != null) {
63
+ const merged = { ...existing, ...row, actionId: existing.actionId };
64
+ await store.put(merged);
65
+ return existing.actionId;
66
+ }
67
+ const newId = await store.add(row);
68
+ return newId;
69
+ }
70
+ async repointTxLabelMap(legacyTransactionId, actionId) {
71
+ if (legacyTransactionId === actionId)
72
+ return;
73
+ const store = this.trx.objectStore('tx_labels_map');
74
+ const idx = store.index('transactionId');
75
+ const matches = await idx.getAll(legacyTransactionId);
76
+ for (const m of matches) {
77
+ const updated = { ...m, transactionId: actionId };
78
+ await store.delete([m.txLabelId, legacyTransactionId]);
79
+ await store.add(updated);
80
+ }
81
+ }
82
+ }
83
+ exports.IdbBackfillDriver = IdbBackfillDriver;
84
+ /**
85
+ * Convenience entry point that opens the required readwrite transaction and
86
+ * runs the orchestrator against it.
87
+ */
88
+ async function runIdbBackfill(db, now = new Date()) {
89
+ const trx = db.transaction(BACKFILL_STORES, 'readwrite');
90
+ const driver = new IdbBackfillDriver(trx);
91
+ const stats = await (0, backfill_runner_1.runBackfill)(driver, now);
92
+ await trx.done;
93
+ return stats;
94
+ }
95
+ //# sourceMappingURL=backfill.idb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backfill.idb.js","sourceRoot":"","sources":["../../../../src/storage/schema/backfill.idb.ts"],"names":[],"mappings":";;;AAmGA,wCASC;AAnGD,uDAA8E;AAI9E,MAAM,eAAe,GAAmB;IACtC,gBAAgC;IAChC,YAA4B;IAC5B,cAA8B;IAC9B,kBAAkC;IAClC,SAAyB;IACzB,eAA+B;CAChC,CAAA;AAED;;;;;;;GAOG;AACH,MAAa,iBAAiB;IAC5B,YACmB,GAAmE;QAAnE,QAAG,GAAH,GAAG,CAAgE;IACnF,CAAC;IAEJ,KAAK,CAAC,CAAE,gBAAgB;QACtB,MAAM,QAAQ,GAAI,IAAI,CAAC,GAAG,CAAC,WAAmB,CAAC,gBAAgB,CAAC,CAAA;QAChE,MAAM,WAAW,GAAI,IAAI,CAAC,GAAG,CAAC,WAAmB,CAAC,YAAY,CAAC,CAAA;QAC/D,MAAM,OAAO,GAAa,MAAM,QAAQ,CAAC,UAAU,EAAE,CAAA;QACrD,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,MAAM,GAAG,GAAqB,MAAM,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACrD,IAAI,MAAiC,CAAA;YACrC,IAAI,GAAG,CAAC,UAAU,IAAI,IAAI;gBAAE,MAAM,GAAG,MAAM,WAAW,CAAC,GAAG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ClC,MAAY,IAAI,IAAI,EAAE;IAEtB,MAAM,GAAG,GAAI,EAAE,CAAC,WAAmB,CAAC,eAAe,EAAE,WAAW,CAAC,CAAA;IACjE,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,GAAG,CAAC,CAAA;IACzC,MAAM,KAAK,GAAG,MAAM,IAAA,6BAAW,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC5C,MAAM,GAAG,CAAC,IAAI,CAAA;IACd,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.buildTransactionNewRow = buildTransactionNewRow;
37
+ exports.buildTransactionNewRowFromLegacyTx = buildTransactionNewRowFromLegacyTx;
38
+ exports.buildActionRow = buildActionRow;
39
+ const sdk = __importStar(require("../../sdk"));
40
+ /**
41
+ * Pure transformation helpers for the the new schema backfill.
42
+ *
43
+ * These functions are deliberately storage-agnostic — they accept the legacy
44
+ * rows and return the new shapes. A storage driver (Knex or IDB) is responsible
45
+ * for reading the source rows and inserting the returned objects.
46
+ *
47
+ * No row in this module ever talks to the database; this keeps the
48
+ * transformation under unit-test control and lets us run dry-run migrations.
49
+ */
50
+ /**
51
+ * Merge a legacy `proven_tx_reqs` row together with an optional `proven_txs`
52
+ * row into a single new `transactions` (transactions_new) row.
53
+ *
54
+ * The proof fields come from `proven_txs` when present; otherwise they are
55
+ * left undefined. Processing state is derived from the request's legacy status.
56
+ */
57
+ function buildTransactionNewRow(req, proven, now = new Date()) {
58
+ var _a, _b, _c;
59
+ const processing = sdk.provenTxReqStatusToProcessing(req.status);
60
+ return {
61
+ created_at: req.created_at,
62
+ updated_at: now,
63
+ txid: req.txid,
64
+ processing,
65
+ processingChangedAt: (_a = req.updated_at) !== null && _a !== void 0 ? _a : now,
66
+ nextActionAt: undefined,
67
+ attempts: (_b = req.attempts) !== null && _b !== void 0 ? _b : 0,
68
+ rebroadcastCycles: (_c = req.rebroadcastAttempts) !== null && _c !== void 0 ? _c : 0,
69
+ wasBroadcast: req.wasBroadcast === true,
70
+ idempotencyKey: undefined,
71
+ batch: req.batch,
72
+ rawTx: req.rawTx,
73
+ inputBeef: req.inputBEEF,
74
+ height: proven === null || proven === void 0 ? void 0 : proven.height,
75
+ merkleIndex: proven === null || proven === void 0 ? void 0 : proven.index,
76
+ merklePath: proven === null || proven === void 0 ? void 0 : proven.merklePath,
77
+ merkleRoot: proven === null || proven === void 0 ? void 0 : proven.merkleRoot,
78
+ blockHash: proven === null || proven === void 0 ? void 0 : proven.blockHash,
79
+ isCoinbase: false,
80
+ lastProvider: undefined,
81
+ lastProviderStatus: undefined,
82
+ frozenReason: undefined,
83
+ rowVersion: 0
84
+ };
85
+ }
86
+ /**
87
+ * Build a new `transactions` row from a legacy per-user `transactions` row when
88
+ * no `proven_tx_reqs` entry exists (e.g. locally-created actions that never
89
+ * reached the broadcast queue).
90
+ *
91
+ * Returns `undefined` when the legacy row has no txid — such rows belong to
92
+ * incomplete actions and have no canonical new-schema representation yet.
93
+ */
94
+ function buildTransactionNewRowFromLegacyTx(tx, now = new Date()) {
95
+ var _a;
96
+ if (tx.txid == null)
97
+ return undefined;
98
+ // Unsigned/unprocessed transactions may have an empty-string txid.
99
+ // Give them a stable placeholder so each gets its own new schema row and actions entry.
100
+ const txid = tx.txid === '' ? `pending:legacy:${tx.transactionId}` : tx.txid;
101
+ return {
102
+ created_at: tx.created_at,
103
+ updated_at: now,
104
+ txid,
105
+ processing: sdk.transactionStatusToProcessing(tx.status),
106
+ processingChangedAt: (_a = tx.updated_at) !== null && _a !== void 0 ? _a : now,
107
+ nextActionAt: undefined,
108
+ attempts: 0,
109
+ rebroadcastCycles: 0,
110
+ wasBroadcast: false,
111
+ idempotencyKey: undefined,
112
+ batch: undefined,
113
+ rawTx: tx.rawTx,
114
+ inputBeef: tx.inputBEEF,
115
+ height: undefined,
116
+ merkleIndex: undefined,
117
+ merklePath: undefined,
118
+ merkleRoot: undefined,
119
+ blockHash: undefined,
120
+ isCoinbase: false,
121
+ lastProvider: undefined,
122
+ lastProviderStatus: undefined,
123
+ frozenReason: undefined,
124
+ rowVersion: 0
125
+ };
126
+ }
127
+ /**
128
+ * Build a new `actions` row from a legacy per-user `transactions` row.
129
+ * The caller is responsible for resolving `transactionId` to the
130
+ * newly-inserted `transactions_new.transactionId`.
131
+ */
132
+ function buildActionRow(legacy, newTransactionId, now = new Date()) {
133
+ var _a;
134
+ return {
135
+ created_at: legacy.created_at,
136
+ updated_at: now,
137
+ userId: legacy.userId,
138
+ transactionId: newTransactionId,
139
+ reference: legacy.reference,
140
+ description: legacy.description,
141
+ isOutgoing: legacy.isOutgoing,
142
+ satoshisDelta: (_a = legacy.satoshis) !== null && _a !== void 0 ? _a : 0,
143
+ userNosend: legacy.status === 'nosend',
144
+ hidden: false,
145
+ userAborted: legacy.status === 'failed',
146
+ notifyJson: undefined,
147
+ rowVersion: 0
148
+ };
149
+ }
150
+ //# sourceMappingURL=backfill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backfill.js","sourceRoot":"","sources":["../../../../src/storage/schema/backfill.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,wDA+BC;AAUD,gFAiCC;AAOD,wCAoBC;AAhID,+CAAgC;AAShC;;;;;;;;;GASG;AAEH;;;;;;GAMG;AACH,SAAgB,sBAAsB,CACpC,GAAqB,EACrB,MAAiC,EACjC,MAAY,IAAI,IAAI,EAAE;;IAEtB,MAAM,UAAU,GAAG,GAAG,CAAC,6BAA6B,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAChE,OAAO;QACL,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,UAAU,EAAE,GAAG;QACf,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,UAAU;QACV,mBAAmB,EAAE,MAAA,GAAG,CAAC,UAAU,mCAAI,GAAG;QAC1C,YAAY,EAAE,SAAS;QACvB,QAAQ,EAAE,MAAA,GAAG,CAAC,QAAQ,mCAAI,CAAC;QAC3B,iBAAiB,EAAE,MAAA,GAAG,CAAC,mBAAmB,mCAAI,CAAC;QAC/C,YAAY,EAAE,GAAG,CAAC,YAAY,KAAK,IAAI;QACvC,cAAc,EAAE,SAAS;QACzB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,MAAM,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM;QACtB,WAAW,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAA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K;QACjB,YAAY,EAAE,SAAS;QACvB,kBAAkB,EAAE,SAAS;QAC7B,YAAY,EAAE,SAAS;QACvB,UAAU,EAAE,CAAC;KACd,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAC5B,MAAwB,EACxB,gBAAwB,EACxB,MAAY,IAAI,IAAI,EAAE;;IAEtB,OAAO;QACL,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,UAAU,EAAE,GAAG;QACf,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,aAAa,EAAE,gBAAgB;QAC/B,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,aAAa,EAAE,MAAA,MAAM,CAAC,QAAQ,mCAAI,CAAC;QACnC,UAAU,EAAE,MAAM,CAAC,MAAM,KAAK,QAAQ;QACtC,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,MAAM,CAAC,MAAM,KAAK,QAAQ;QACvC,UAAU,EAAE,SAAS;QACrB,UAAU,EAAE,CAAC;KACd,CAAA;AACH,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { Knex } from 'knex';
2
+ import { TableAction, TableProvenTx, TableProvenTxReq, TableTransaction, TableTransactionNew } from './tables';
3
+ import { BackfillDriver, BackfillStats } from './backfill.runner';
4
+ /**
5
+ * Knex driver for the the backfill.
6
+ *
7
+ * Reads from the legacy `proven_tx_reqs`, `proven_txs`, and `transactions`
8
+ * tables, writes into the new `transactions_new` and `actions` tables, and
9
+ * re-points `tx_labels_map` rows to the new `actionId`.
10
+ *
11
+ * All work is performed against the `knex` (or transaction) handle passed in.
12
+ * The caller is responsible for opening a transaction around the orchestrator
13
+ * call when atomicity is desired.
14
+ */
15
+ export declare class KnexBackfillDriver implements BackfillDriver {
16
+ private readonly knex;
17
+ constructor(knex: Knex);
18
+ streamLegacyReqs(): AsyncIterable<{
19
+ req: TableProvenTxReq;
20
+ proven?: TableProvenTx;
21
+ }>;
22
+ streamLegacyTransactions(): AsyncIterable<TableTransaction>;
23
+ upsertTransactionNew(row: Omit<TableTransactionNew, 'transactionId'>): Promise<number>;
24
+ upsertAction(row: Omit<TableAction, 'actionId'>): Promise<number>;
25
+ repointTxLabelMap(legacyTransactionId: number, actionId: number): Promise<void>;
26
+ }
27
+ /**
28
+ * Convenience entry point. Opens a Knex transaction and runs the orchestrator
29
+ * inside it so that the entire backfill either succeeds or rolls back.
30
+ */
31
+ export declare function runKnexBackfill(knex: Knex, now?: Date): Promise<BackfillStats>;
32
+ //# sourceMappingURL=backfill.knex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backfill.knex.d.ts","sourceRoot":"","sources":["../../../../src/storage/schema/backfill.knex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EACL,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAe,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAI9E;;;;;;;;;;GAUG;AACH,qBAAa,kBAAmB,YAAW,cAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,IAAI;IAEhC,gBAAgB,IAAK,aAAa,CAAC;QAAE,GAAG,EAAE,gBAAgB,CAAC;QAAC,MAAM,CAAC,EAAE,aAAa,CAAA;KAAE,CAAC;IA6DrF,wBAAwB,IAAK,aAAa,CAAC,gBAAgB,CAAC;IAiC9D,oBAAoB,CAAE,GAAG,EAAE,IAAI,CAAC,mBAAmB,EAAE,eAAe,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAuDvF,YAAY,CAAE,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IA0ClE,iBAAiB,CAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAMvF;AAED;;;GAGG;AACH,wBAAsB,eAAe,CAAE,IAAI,EAAE,IAAI,EAAE,GAAG,GAAE,IAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,CAKjG"}