@bsv/wallet-toolbox 1.1.6 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/client.md +499 -900
- package/docs/monitor.md +29 -69
- package/docs/services.md +22 -40
- package/docs/setup.md +23 -65
- package/docs/storage.md +2163 -489
- package/docs/wallet.md +499 -900
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts +4 -4
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.js +2 -2
- package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts +2 -2
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.js +2 -2
- package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -1
- package/out/src/sdk/StorageSyncReader.d.ts +30 -30
- package/out/src/sdk/StorageSyncReader.d.ts.map +1 -1
- package/out/src/sdk/StorageSyncReaderWriter.d.ts +60 -60
- package/out/src/sdk/StorageSyncReaderWriter.d.ts.map +1 -1
- package/out/src/sdk/WalletStorage.interfaces.d.ts +36 -36
- package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
- package/out/src/signer/methods/acquireDirectCertificate.d.ts.map +1 -1
- package/out/src/signer/methods/acquireDirectCertificate.js.map +1 -1
- package/out/src/storage/StorageKnex.d.ts +61 -61
- package/out/src/storage/StorageKnex.d.ts.map +1 -1
- package/out/src/storage/StorageKnex.js +2 -2
- package/out/src/storage/StorageKnex.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts +16 -15
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +8 -8
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/src/storage/StorageReader.d.ts +21 -21
- package/out/src/storage/StorageReader.d.ts.map +1 -1
- package/out/src/storage/StorageReader.js.map +1 -1
- package/out/src/storage/StorageReaderWriter.d.ts +60 -60
- package/out/src/storage/StorageReaderWriter.d.ts.map +1 -1
- package/out/src/storage/StorageReaderWriter.js.map +1 -1
- package/out/src/storage/StorageSyncReader.d.ts +17 -17
- package/out/src/storage/StorageSyncReader.d.ts.map +1 -1
- package/out/src/storage/StorageSyncReader.js.map +1 -1
- package/out/src/storage/WalletStorageManager.d.ts +9 -9
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/out/src/storage/WalletStorageManager.js +2 -2
- package/out/src/storage/WalletStorageManager.js.map +1 -1
- package/out/src/storage/index.all.d.ts +2 -2
- package/out/src/storage/index.all.d.ts.map +1 -1
- package/out/src/storage/index.all.js +3 -3
- package/out/src/storage/index.all.js.map +1 -1
- package/out/src/storage/index.client.d.ts +2 -2
- package/out/src/storage/index.client.d.ts.map +1 -1
- package/out/src/storage/index.client.js +2 -25
- package/out/src/storage/index.client.js.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +3 -3
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js.map +1 -1
- package/out/src/storage/methods/createAction.d.ts.map +1 -1
- package/out/src/storage/methods/createAction.js +1 -1
- package/out/src/storage/methods/createAction.js.map +1 -1
- package/out/src/storage/methods/getBeefForTransaction.js +2 -2
- package/out/src/storage/methods/getBeefForTransaction.js.map +1 -1
- package/out/src/storage/methods/getSyncChunk.d.ts.map +1 -1
- package/out/src/storage/methods/getSyncChunk.js.map +1 -1
- package/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
- package/out/src/storage/methods/internalizeAction.js +1 -1
- package/out/src/storage/methods/internalizeAction.js.map +1 -1
- package/out/src/storage/methods/listActions.js.map +1 -1
- package/out/src/storage/methods/listCertificates.d.ts.map +1 -1
- package/out/src/storage/methods/listCertificates.js.map +1 -1
- package/out/src/storage/methods/listOutputs.js.map +1 -1
- package/out/src/storage/methods/processAction.d.ts +4 -4
- package/out/src/storage/methods/processAction.d.ts.map +1 -1
- package/out/src/storage/methods/processAction.js +2 -2
- package/out/src/storage/methods/processAction.js.map +1 -1
- package/out/src/storage/methods/purgeData.d.ts.map +1 -1
- package/out/src/storage/methods/purgeData.js +4 -2
- package/out/src/storage/methods/purgeData.js.map +1 -1
- package/out/src/storage/methods/reviewStatus.js +1 -1
- package/out/src/storage/methods/reviewStatus.js.map +1 -1
- package/out/src/storage/remoting/StorageClient.d.ts +11 -11
- package/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageClient.js.map +1 -1
- package/out/src/storage/schema/entities/Certificate.d.ts +9 -9
- package/out/src/storage/schema/entities/Certificate.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Certificate.js +5 -5
- package/out/src/storage/schema/entities/Certificate.js.map +1 -1
- package/out/src/storage/schema/entities/CertificateField.d.ts +9 -9
- package/out/src/storage/schema/entities/CertificateField.d.ts.map +1 -1
- package/out/src/storage/schema/entities/CertificateField.js +5 -5
- package/out/src/storage/schema/entities/CertificateField.js.map +1 -1
- package/out/src/storage/schema/entities/Commission.d.ts +9 -9
- package/out/src/storage/schema/entities/Commission.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Commission.js +5 -5
- package/out/src/storage/schema/entities/Commission.js.map +1 -1
- package/out/src/storage/schema/entities/EntityBase.d.ts +1 -1
- package/out/src/storage/schema/entities/MergeEntity.d.ts +6 -7
- package/out/src/storage/schema/entities/MergeEntity.d.ts.map +1 -1
- package/out/src/storage/schema/entities/MergeEntity.js.map +1 -1
- package/out/src/storage/schema/entities/Output.d.ts +9 -9
- package/out/src/storage/schema/entities/Output.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Output.js +5 -5
- package/out/src/storage/schema/entities/Output.js.map +1 -1
- package/out/src/storage/schema/entities/OutputBasket.d.ts +9 -9
- package/out/src/storage/schema/entities/OutputBasket.d.ts.map +1 -1
- package/out/src/storage/schema/entities/OutputBasket.js +5 -5
- package/out/src/storage/schema/entities/OutputBasket.js.map +1 -1
- package/out/src/storage/schema/entities/OutputTag.d.ts +9 -9
- package/out/src/storage/schema/entities/OutputTag.d.ts.map +1 -1
- package/out/src/storage/schema/entities/OutputTag.js +5 -5
- package/out/src/storage/schema/entities/OutputTag.js.map +1 -1
- package/out/src/storage/schema/entities/OutputTagMap.d.ts +9 -9
- package/out/src/storage/schema/entities/OutputTagMap.d.ts.map +1 -1
- package/out/src/storage/schema/entities/OutputTagMap.js +5 -5
- package/out/src/storage/schema/entities/OutputTagMap.js.map +1 -1
- package/out/src/storage/schema/entities/ProvenTx.d.ts +11 -11
- package/out/src/storage/schema/entities/ProvenTx.d.ts.map +1 -1
- package/out/src/storage/schema/entities/ProvenTx.js +11 -11
- package/out/src/storage/schema/entities/ProvenTx.js.map +1 -1
- package/out/src/storage/schema/entities/ProvenTxReq.d.ts +19 -19
- package/out/src/storage/schema/entities/ProvenTxReq.d.ts.map +1 -1
- package/out/src/storage/schema/entities/ProvenTxReq.js +13 -13
- package/out/src/storage/schema/entities/ProvenTxReq.js.map +1 -1
- package/out/src/storage/schema/entities/SyncState.d.ts +11 -11
- package/out/src/storage/schema/entities/SyncState.d.ts.map +1 -1
- package/out/src/storage/schema/entities/SyncState.js +27 -27
- package/out/src/storage/schema/entities/SyncState.js.map +1 -1
- package/out/src/storage/schema/entities/Transaction.d.ts +11 -11
- package/out/src/storage/schema/entities/Transaction.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Transaction.js +6 -6
- package/out/src/storage/schema/entities/Transaction.js.map +1 -1
- package/out/src/storage/schema/entities/TxLabel.d.ts +9 -9
- package/out/src/storage/schema/entities/TxLabel.d.ts.map +1 -1
- package/out/src/storage/schema/entities/TxLabel.js +5 -5
- package/out/src/storage/schema/entities/TxLabel.js.map +1 -1
- package/out/src/storage/schema/entities/TxLabelMap.d.ts +9 -9
- package/out/src/storage/schema/entities/TxLabelMap.d.ts.map +1 -1
- package/out/src/storage/schema/entities/TxLabelMap.js +5 -5
- package/out/src/storage/schema/entities/TxLabelMap.js.map +1 -1
- package/out/src/storage/schema/entities/User.d.ts +9 -9
- package/out/src/storage/schema/entities/User.d.ts.map +1 -1
- package/out/src/storage/schema/entities/User.js +5 -5
- package/out/src/storage/schema/entities/User.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.js +20 -307
- package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/CertificateTests.test.js +17 -158
- package/out/src/storage/schema/entities/__tests/CertificateTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/CommissionTests.test.js +23 -309
- package/out/src/storage/schema/entities/__tests/CommissionTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.js +19 -306
- package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.js +19 -306
- package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputTagTests.test.js +23 -237
- package/out/src/storage/schema/entities/__tests/OutputTagTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputTests.test.js +20 -233
- package/out/src/storage/schema/entities/__tests/OutputTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.js +27 -98
- package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js +25 -241
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/SyncStateTests.test.js +38 -112
- package/out/src/storage/schema/entities/__tests/SyncStateTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/TransactionTests.test.js +39 -323
- package/out/src/storage/schema/entities/__tests/TransactionTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.js +31 -169
- package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/TxLabelTests.test.js +16 -159
- package/out/src/storage/schema/entities/__tests/TxLabelTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/usersTests.test.js +21 -168
- package/out/src/storage/schema/entities/__tests/usersTests.test.js.map +1 -1
- package/out/src/storage/schema/tables/Certificate.d.ts +4 -4
- package/out/src/storage/schema/tables/Certificate.d.ts.map +1 -1
- package/out/src/storage/schema/tables/CertificateField.d.ts +1 -1
- package/out/src/storage/schema/tables/CertificateField.d.ts.map +1 -1
- package/out/src/storage/schema/tables/Commission.d.ts +1 -1
- package/out/src/storage/schema/tables/Commission.d.ts.map +1 -1
- package/out/src/storage/schema/tables/MonitorEvent.d.ts +1 -1
- package/out/src/storage/schema/tables/MonitorEvent.d.ts.map +1 -1
- package/out/src/storage/schema/tables/Output.d.ts +5 -5
- package/out/src/storage/schema/tables/Output.d.ts.map +1 -1
- package/out/src/storage/schema/tables/OutputBasket.d.ts +1 -1
- package/out/src/storage/schema/tables/OutputBasket.d.ts.map +1 -1
- package/out/src/storage/schema/tables/OutputTag.d.ts +1 -1
- package/out/src/storage/schema/tables/OutputTag.d.ts.map +1 -1
- package/out/src/storage/schema/tables/OutputTagMap.d.ts +1 -1
- package/out/src/storage/schema/tables/OutputTagMap.d.ts.map +1 -1
- package/out/src/storage/schema/tables/ProvenTx.d.ts +1 -1
- package/out/src/storage/schema/tables/ProvenTx.d.ts.map +1 -1
- package/out/src/storage/schema/tables/ProvenTxReq.d.ts +2 -2
- package/out/src/storage/schema/tables/ProvenTxReq.d.ts.map +1 -1
- package/out/src/storage/schema/tables/SyncState.d.ts +1 -1
- package/out/src/storage/schema/tables/SyncState.d.ts.map +1 -1
- package/out/src/storage/schema/tables/{Settings.d.ts → TableSettings.d.ts} +2 -2
- package/out/src/storage/schema/tables/TableSettings.d.ts.map +1 -0
- package/out/src/storage/schema/tables/{Settings.js → TableSettings.js} +1 -1
- package/out/src/storage/schema/tables/TableSettings.js.map +1 -0
- package/out/src/storage/schema/tables/Transaction.d.ts +1 -1
- package/out/src/storage/schema/tables/Transaction.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TxLabel.d.ts +1 -1
- package/out/src/storage/schema/tables/TxLabel.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TxLabelMap.d.ts +1 -1
- package/out/src/storage/schema/tables/TxLabelMap.d.ts.map +1 -1
- package/out/src/storage/schema/tables/User.d.ts +1 -1
- package/out/src/storage/schema/tables/User.d.ts.map +1 -1
- package/out/src/storage/schema/tables/index.d.ts +1 -1
- package/out/src/storage/schema/tables/index.d.ts.map +1 -1
- package/out/src/storage/schema/tables/index.js +1 -1
- package/out/src/storage/schema/tables/index.js.map +1 -1
- package/out/src/storage/sync/StorageMySQLDojoReader.d.ts +17 -17
- package/out/src/storage/sync/StorageMySQLDojoReader.d.ts.map +1 -1
- package/out/src/storage/sync/StorageMySQLDojoReader.js +2 -2
- package/out/src/storage/sync/StorageMySQLDojoReader.js.map +1 -1
- package/out/test/Wallet/certificate/listCertificates.test.js.map +1 -1
- package/out/test/Wallet/live/walletLive.man.test.d.ts.map +1 -1
- package/out/test/Wallet/live/walletLive.man.test.js +35 -1
- package/out/test/Wallet/live/walletLive.man.test.js.map +1 -1
- package/out/test/monitor/Monitor.test.js +7 -7
- package/out/test/monitor/Monitor.test.js.map +1 -1
- package/out/test/storage/StorageMySQLDojoReader.man.test.js +1 -1
- package/out/test/storage/StorageMySQLDojoReader.man.test.js.map +1 -1
- package/out/test/storage/insert.test.js.map +1 -1
- package/out/test/storage/update.test.js.map +1 -1
- package/out/test/storage/update2.test.js.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.d.ts +56 -56
- package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.js +11 -4
- package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
- package/out/test/wallet/action/createActionToGenerateBeefs.man.test.js.map +1 -1
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/monitor/tasks/TaskCheckForProofs.ts +11 -10
- package/src/monitor/tasks/TaskSendWaiting.ts +5 -5
- package/src/sdk/StorageSyncReader.ts +47 -30
- package/src/sdk/StorageSyncReaderWriter.ts +77 -63
- package/src/sdk/WalletStorage.interfaces.ts +55 -36
- package/src/signer/methods/acquireDirectCertificate.ts +2 -2
- package/src/storage/StorageKnex.ts +124 -104
- package/src/storage/StorageProvider.ts +43 -30
- package/src/storage/StorageReader.ts +36 -21
- package/src/storage/StorageReaderWriter.ts +78 -65
- package/src/storage/StorageSyncReader.ts +34 -17
- package/src/storage/WalletStorageManager.ts +17 -12
- package/src/storage/index.all.ts +2 -2
- package/src/storage/index.client.ts +2 -2
- package/src/storage/methods/attemptToPostReqsToNetwork.ts +3 -3
- package/src/storage/methods/createAction.ts +29 -26
- package/src/storage/methods/getBeefForTransaction.ts +3 -3
- package/src/storage/methods/getSyncChunk.ts +28 -13
- package/src/storage/methods/internalizeAction.ts +19 -17
- package/src/storage/methods/listActions.ts +5 -5
- package/src/storage/methods/listCertificates.ts +2 -2
- package/src/storage/methods/listOutputs.ts +5 -5
- package/src/storage/methods/processAction.ts +21 -17
- package/src/storage/methods/purgeData.ts +20 -12
- package/src/storage/methods/reviewStatus.ts +5 -5
- package/src/storage/remoting/StorageClient.ts +28 -18
- package/src/storage/schema/entities/Certificate.ts +16 -17
- package/src/storage/schema/entities/CertificateField.ts +17 -18
- package/src/storage/schema/entities/Commission.ts +16 -20
- package/src/storage/schema/entities/EntityBase.ts +1 -1
- package/src/storage/schema/entities/MergeEntity.ts +7 -7
- package/src/storage/schema/entities/Output.ts +16 -20
- package/src/storage/schema/entities/OutputBasket.ts +16 -17
- package/src/storage/schema/entities/OutputTag.ts +16 -20
- package/src/storage/schema/entities/OutputTagMap.ts +17 -18
- package/src/storage/schema/entities/ProvenTx.ts +24 -28
- package/src/storage/schema/entities/ProvenTxReq.ts +42 -45
- package/src/storage/schema/entities/SyncState.ts +61 -38
- package/src/storage/schema/entities/Transaction.ts +23 -23
- package/src/storage/schema/entities/TxLabel.ts +16 -17
- package/src/storage/schema/entities/TxLabelMap.ts +16 -20
- package/src/storage/schema/entities/User.ts +15 -19
- package/src/storage/schema/entities/__tests/CertificateFieldTests.test.ts +39 -318
- package/src/storage/schema/entities/__tests/CertificateTests.test.ts +29 -169
- package/src/storage/schema/entities/__tests/CommissionTests.test.ts +47 -325
- package/src/storage/schema/entities/__tests/OutputBasketTests.test.ts +35 -316
- package/src/storage/schema/entities/__tests/OutputTagMapTests.test.ts +38 -318
- package/src/storage/schema/entities/__tests/OutputTagTests.test.ts +36 -249
- package/src/storage/schema/entities/__tests/OutputTests.test.ts +30 -244
- package/src/storage/schema/entities/__tests/ProvenTxReqTests.test.ts +35 -101
- package/src/storage/schema/entities/__tests/ProvenTxTests.test.ts +27 -243
- package/src/storage/schema/entities/__tests/SyncStateTests.test.ts +54 -122
- package/src/storage/schema/entities/__tests/TransactionTests.test.ts +53 -333
- package/src/storage/schema/entities/__tests/TxLabelMapTests.test.ts +44 -177
- package/src/storage/schema/entities/__tests/TxLabelTests.test.ts +19 -163
- package/src/storage/schema/entities/__tests/usersTests.test.ts +31 -179
- package/src/storage/schema/tables/Certificate.ts +4 -4
- package/src/storage/schema/tables/CertificateField.ts +1 -1
- package/src/storage/schema/tables/Commission.ts +1 -1
- package/src/storage/schema/tables/MonitorEvent.ts +1 -1
- package/src/storage/schema/tables/Output.ts +5 -5
- package/src/storage/schema/tables/OutputBasket.ts +1 -1
- package/src/storage/schema/tables/OutputTag.ts +1 -1
- package/src/storage/schema/tables/OutputTagMap.ts +1 -1
- package/src/storage/schema/tables/ProvenTx.ts +1 -1
- package/src/storage/schema/tables/ProvenTxReq.ts +2 -2
- package/src/storage/schema/tables/SyncState.ts +1 -1
- package/src/storage/schema/tables/{Settings.ts → TableSettings.ts} +3 -1
- package/src/storage/schema/tables/Transaction.ts +1 -1
- package/src/storage/schema/tables/TxLabel.ts +1 -1
- package/src/storage/schema/tables/TxLabelMap.ts +1 -1
- package/src/storage/schema/tables/User.ts +1 -1
- package/src/storage/schema/tables/index.ts +1 -1
- package/src/storage/sync/StorageMySQLDojoReader.ts +67 -50
- package/test/Wallet/certificate/listCertificates.test.ts +12 -8
- package/test/Wallet/live/walletLive.man.test.ts +46 -6
- package/test/monitor/Monitor.test.ts +8 -8
- package/test/storage/StorageMySQLDojoReader.man.test.ts +1 -1
- package/test/storage/insert.test.ts +2 -2
- package/test/storage/update.test.ts +30 -30
- package/test/storage/update2.test.ts +23 -24
- package/test/utils/TestUtilsWalletStorage.ts +103 -82
- package/test/wallet/action/createActionToGenerateBeefs.man.test.ts +1 -2
- package/ts2md.json +12 -6
- package/out/src/storage/index.db.d.ts +0 -1
- package/out/src/storage/index.db.d.ts.map +0 -1
- package/out/src/storage/index.db.js +0 -2
- package/out/src/storage/index.db.js.map +0 -1
- package/out/src/storage/schema/tables/Settings.d.ts.map +0 -1
- package/out/src/storage/schema/tables/Settings.js.map +0 -1
- package/src/storage/index.db.ts +0 -0
|
@@ -2,53 +2,53 @@ import { MerklePath } from '@bsv/sdk'
|
|
|
2
2
|
import {
|
|
3
3
|
arraysEqual,
|
|
4
4
|
asString,
|
|
5
|
-
entity,
|
|
6
5
|
sdk,
|
|
7
6
|
StorageProvider,
|
|
8
|
-
|
|
7
|
+
TableProvenTxReq,
|
|
8
|
+
TableProvenTxReqDynamics,
|
|
9
9
|
verifyId,
|
|
10
10
|
verifyOne,
|
|
11
11
|
verifyOneOrNone,
|
|
12
12
|
verifyTruthy,
|
|
13
13
|
WalletStorageManager
|
|
14
14
|
} from '../../../index.client'
|
|
15
|
-
import { EntityBase } from '.'
|
|
15
|
+
import { EntityBase, EntityStorage, SyncMap } from '.'
|
|
16
16
|
|
|
17
17
|
import { StorageProcessActionArgs } from '../../../sdk'
|
|
18
18
|
|
|
19
|
-
export class
|
|
19
|
+
export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
|
|
20
20
|
static async fromStorageTxid(
|
|
21
|
-
storage:
|
|
21
|
+
storage: EntityStorage,
|
|
22
22
|
txid: string,
|
|
23
23
|
trx?: sdk.TrxToken
|
|
24
|
-
): Promise<
|
|
24
|
+
): Promise<EntityProvenTxReq | undefined> {
|
|
25
25
|
const reqApi = verifyOneOrNone(
|
|
26
26
|
await storage.findProvenTxReqs({ partial: { txid }, trx })
|
|
27
27
|
)
|
|
28
28
|
if (!reqApi) return undefined
|
|
29
|
-
return new
|
|
29
|
+
return new EntityProvenTxReq(reqApi)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
static async fromStorageId(
|
|
33
|
-
storage:
|
|
33
|
+
storage: EntityStorage,
|
|
34
34
|
id: number,
|
|
35
35
|
trx?: sdk.TrxToken
|
|
36
|
-
): Promise<
|
|
36
|
+
): Promise<EntityProvenTxReq> {
|
|
37
37
|
const reqApi = verifyOneOrNone(
|
|
38
38
|
await storage.findProvenTxReqs({ partial: { provenTxReqId: id }, trx })
|
|
39
39
|
)
|
|
40
40
|
if (!reqApi)
|
|
41
41
|
throw new sdk.WERR_INTERNAL(`proven_tx_reqs with id ${id} is missing.`)
|
|
42
|
-
return new
|
|
42
|
+
return new EntityProvenTxReq(reqApi)
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
static fromTxid(
|
|
46
46
|
txid: string,
|
|
47
47
|
rawTx: number[],
|
|
48
48
|
inputBEEF?: number[]
|
|
49
|
-
):
|
|
49
|
+
): EntityProvenTxReq {
|
|
50
50
|
const now = new Date()
|
|
51
|
-
return new
|
|
51
|
+
return new EntityProvenTxReq({
|
|
52
52
|
provenTxReqId: 0,
|
|
53
53
|
created_at: now,
|
|
54
54
|
updated_at: now,
|
|
@@ -118,7 +118,7 @@ export class ProvenTxReq extends EntityBase<table.ProvenTxReq> {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
async refreshFromStorage(
|
|
121
|
-
storage:
|
|
121
|
+
storage: EntityStorage | WalletStorageManager
|
|
122
122
|
): Promise<void> {
|
|
123
123
|
const newApi = verifyOne(
|
|
124
124
|
await storage.findProvenTxReqs({ partial: { provenTxReqId: this.id } })
|
|
@@ -127,7 +127,7 @@ export class ProvenTxReq extends EntityBase<table.ProvenTxReq> {
|
|
|
127
127
|
this.unpackApi()
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
constructor(api?:
|
|
130
|
+
constructor(api?: TableProvenTxReq) {
|
|
131
131
|
const now = new Date()
|
|
132
132
|
super(
|
|
133
133
|
api || {
|
|
@@ -294,18 +294,18 @@ export class ProvenTxReq extends EntityBase<table.ProvenTxReq> {
|
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
/**
|
|
297
|
-
* Updates database record with current state of this
|
|
297
|
+
* Updates database record with current state of this EntityUser
|
|
298
298
|
|
|
299
299
|
* @param storage
|
|
300
300
|
* @param trx
|
|
301
301
|
*/
|
|
302
|
-
async updateStorage(storage:
|
|
302
|
+
async updateStorage(storage: EntityStorage, trx?: sdk.TrxToken) {
|
|
303
303
|
this.updated_at = new Date()
|
|
304
304
|
this.updateApi()
|
|
305
305
|
if (this.id === 0) {
|
|
306
306
|
await storage.insertProvenTxReq(this.api)
|
|
307
307
|
}
|
|
308
|
-
const update: Partial<
|
|
308
|
+
const update: Partial<TableProvenTxReq> = { ...this.api }
|
|
309
309
|
await storage.updateProvenTxReq(this.id, update, trx)
|
|
310
310
|
}
|
|
311
311
|
|
|
@@ -329,7 +329,7 @@ export class ProvenTxReq extends EntityBase<table.ProvenTxReq> {
|
|
|
329
329
|
) {
|
|
330
330
|
this.updated_at = new Date()
|
|
331
331
|
this.updateApi()
|
|
332
|
-
const update: Partial<
|
|
332
|
+
const update: Partial<TableProvenTxReqDynamics> = {
|
|
333
333
|
updated_at: this.api.updated_at,
|
|
334
334
|
provenTxId: this.api.provenTxId,
|
|
335
335
|
status: this.api.status,
|
|
@@ -351,19 +351,19 @@ export class ProvenTxReq extends EntityBase<table.ProvenTxReq> {
|
|
|
351
351
|
}
|
|
352
352
|
|
|
353
353
|
async insertOrMerge(
|
|
354
|
-
storage:
|
|
354
|
+
storage: EntityStorage,
|
|
355
355
|
trx?: sdk.TrxToken
|
|
356
|
-
): Promise<
|
|
357
|
-
const req = await storage.transaction<
|
|
356
|
+
): Promise<EntityProvenTxReq> {
|
|
357
|
+
const req = await storage.transaction<EntityProvenTxReq>(async trx => {
|
|
358
358
|
let reqApi0 = this.toApi()
|
|
359
359
|
const { req: reqApi1, isNew } = await storage.findOrInsertProvenTxReq(
|
|
360
360
|
reqApi0,
|
|
361
361
|
trx
|
|
362
362
|
)
|
|
363
363
|
if (isNew) {
|
|
364
|
-
return new
|
|
364
|
+
return new EntityProvenTxReq(reqApi1)
|
|
365
365
|
} else {
|
|
366
|
-
const req = new
|
|
366
|
+
const req = new EntityProvenTxReq(reqApi1)
|
|
367
367
|
req.mergeNotifyTransactionIds(reqApi0)
|
|
368
368
|
req.mergeHistory(reqApi0)
|
|
369
369
|
await req.updateStorage(storage, trx)
|
|
@@ -457,7 +457,7 @@ export class ProvenTxReq extends EntityBase<table.ProvenTxReq> {
|
|
|
457
457
|
this.api.provenTxReqId = v
|
|
458
458
|
}
|
|
459
459
|
override get entityName(): string {
|
|
460
|
-
return '
|
|
460
|
+
return 'provenTxReq'
|
|
461
461
|
}
|
|
462
462
|
override get entityTable(): string {
|
|
463
463
|
return 'proven_tx_reqs'
|
|
@@ -467,8 +467,8 @@ export class ProvenTxReq extends EntityBase<table.ProvenTxReq> {
|
|
|
467
467
|
* 'convergent' equality must satisfy (A sync B) equals (B sync A)
|
|
468
468
|
*/
|
|
469
469
|
override equals(
|
|
470
|
-
ei:
|
|
471
|
-
syncMap?:
|
|
470
|
+
ei: TableProvenTxReq,
|
|
471
|
+
syncMap?: SyncMap | undefined
|
|
472
472
|
): boolean {
|
|
473
473
|
const eo = this.toApi()
|
|
474
474
|
if (
|
|
@@ -513,23 +513,23 @@ export class ProvenTxReq extends EntityBase<table.ProvenTxReq> {
|
|
|
513
513
|
}
|
|
514
514
|
|
|
515
515
|
static async mergeFind(
|
|
516
|
-
storage:
|
|
516
|
+
storage: EntityStorage,
|
|
517
517
|
userId: number,
|
|
518
|
-
ei:
|
|
519
|
-
syncMap:
|
|
518
|
+
ei: TableProvenTxReq,
|
|
519
|
+
syncMap: SyncMap,
|
|
520
520
|
trx?: sdk.TrxToken
|
|
521
|
-
): Promise<{ found: boolean; eo:
|
|
521
|
+
): Promise<{ found: boolean; eo: EntityProvenTxReq; eiId: number }> {
|
|
522
522
|
const ef = verifyOneOrNone(
|
|
523
523
|
await storage.findProvenTxReqs({ partial: { txid: ei.txid }, trx })
|
|
524
524
|
)
|
|
525
525
|
return {
|
|
526
526
|
found: !!ef,
|
|
527
|
-
eo: new
|
|
527
|
+
eo: new EntityProvenTxReq(ef || { ...ei }),
|
|
528
528
|
eiId: verifyId(ei.provenTxReqId)
|
|
529
529
|
}
|
|
530
530
|
}
|
|
531
531
|
|
|
532
|
-
mapNotifyTransactionIds(syncMap:
|
|
532
|
+
mapNotifyTransactionIds(syncMap: SyncMap): void {
|
|
533
533
|
// Map external notification transaction ids to local ids
|
|
534
534
|
const externalIds = this.notify.transactionIds || []
|
|
535
535
|
this.notify.transactionIds = []
|
|
@@ -542,12 +542,9 @@ export class ProvenTxReq extends EntityBase<table.ProvenTxReq> {
|
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
544
|
|
|
545
|
-
mergeNotifyTransactionIds(
|
|
546
|
-
ei: table.ProvenTxReq,
|
|
547
|
-
syncMap?: entity.SyncMap
|
|
548
|
-
): void {
|
|
545
|
+
mergeNotifyTransactionIds(ei: TableProvenTxReq, syncMap?: SyncMap): void {
|
|
549
546
|
// Map external notification transaction ids to local ids and merge them if they exist.
|
|
550
|
-
const eie = new
|
|
547
|
+
const eie = new EntityProvenTxReq(ei)
|
|
551
548
|
if (eie.notify.transactionIds) {
|
|
552
549
|
this.notify.transactionIds ||= []
|
|
553
550
|
for (const transactionId of eie.notify.transactionIds) {
|
|
@@ -563,11 +560,11 @@ export class ProvenTxReq extends EntityBase<table.ProvenTxReq> {
|
|
|
563
560
|
|
|
564
561
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
565
562
|
mergeHistory(
|
|
566
|
-
ei:
|
|
567
|
-
syncMap?:
|
|
563
|
+
ei: TableProvenTxReq,
|
|
564
|
+
syncMap?: SyncMap,
|
|
568
565
|
noDupes?: boolean
|
|
569
566
|
): void {
|
|
570
|
-
const eie = new
|
|
567
|
+
const eie = new EntityProvenTxReq(ei)
|
|
571
568
|
if (eie.history.notes) {
|
|
572
569
|
for (const [k, v] of Object.entries(eie.history.notes)) {
|
|
573
570
|
this.addHistoryNote(v, new Date(k), noDupes)
|
|
@@ -580,9 +577,9 @@ export class ProvenTxReq extends EntityBase<table.ProvenTxReq> {
|
|
|
580
577
|
}
|
|
581
578
|
|
|
582
579
|
override async mergeNew(
|
|
583
|
-
storage:
|
|
580
|
+
storage: EntityStorage,
|
|
584
581
|
userId: number,
|
|
585
|
-
syncMap:
|
|
582
|
+
syncMap: SyncMap,
|
|
586
583
|
trx?: sdk.TrxToken
|
|
587
584
|
): Promise<void> {
|
|
588
585
|
if (this.provenTxId)
|
|
@@ -605,10 +602,10 @@ export class ProvenTxReq extends EntityBase<table.ProvenTxReq> {
|
|
|
605
602
|
* On terminal failure: `doubleSpend` trumps `invalid` as it contains more data.
|
|
606
603
|
*/
|
|
607
604
|
override async mergeExisting(
|
|
608
|
-
storage:
|
|
605
|
+
storage: EntityStorage,
|
|
609
606
|
since: Date | undefined,
|
|
610
|
-
ei:
|
|
611
|
-
syncMap:
|
|
607
|
+
ei: TableProvenTxReq,
|
|
608
|
+
syncMap: SyncMap,
|
|
612
609
|
trx?: sdk.TrxToken
|
|
613
610
|
): Promise<boolean> {
|
|
614
611
|
if (!this.batch && ei.batch) this.batch = ei.batch
|
|
@@ -1,24 +1,38 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createSyncMap,
|
|
3
3
|
EntityBase,
|
|
4
|
+
EntityCertificate,
|
|
5
|
+
EntityCertificateField,
|
|
6
|
+
EntityCommission,
|
|
7
|
+
EntityOutput,
|
|
8
|
+
EntityOutputBasket,
|
|
9
|
+
EntityOutputTag,
|
|
10
|
+
EntityOutputTagMap,
|
|
11
|
+
EntityProvenTx,
|
|
12
|
+
EntityProvenTxReq,
|
|
13
|
+
EntityStorage,
|
|
4
14
|
EntitySyncMap,
|
|
15
|
+
EntityTransaction,
|
|
16
|
+
EntityTxLabel,
|
|
17
|
+
EntityTxLabelMap,
|
|
18
|
+
EntityUser,
|
|
5
19
|
MergeEntity,
|
|
6
20
|
SyncError,
|
|
7
21
|
SyncMap
|
|
8
22
|
} from '.'
|
|
9
23
|
import {
|
|
10
|
-
entity,
|
|
11
24
|
maxDate,
|
|
12
25
|
sdk,
|
|
13
|
-
|
|
26
|
+
TableSettings,
|
|
27
|
+
TableSyncState,
|
|
14
28
|
verifyId,
|
|
15
29
|
verifyOne,
|
|
16
30
|
verifyOneOrNone,
|
|
17
31
|
verifyTruthy
|
|
18
32
|
} from '../../../index.client'
|
|
19
33
|
|
|
20
|
-
export class
|
|
21
|
-
constructor(api?:
|
|
34
|
+
export class EntitySyncState extends EntityBase<TableSyncState> {
|
|
35
|
+
constructor(api?: TableSyncState) {
|
|
22
36
|
const now = new Date()
|
|
23
37
|
super(
|
|
24
38
|
api || {
|
|
@@ -48,7 +62,7 @@ export class SyncState extends EntityBase<table.SyncState> {
|
|
|
48
62
|
this.validateSyncMap(this.syncMap)
|
|
49
63
|
}
|
|
50
64
|
|
|
51
|
-
validateSyncMap(sm:
|
|
65
|
+
validateSyncMap(sm: SyncMap) {
|
|
52
66
|
for (const key of Object.keys(sm)) {
|
|
53
67
|
const esm: EntitySyncMap = sm[key]
|
|
54
68
|
if (typeof esm.maxUpdated_at === 'string')
|
|
@@ -59,8 +73,8 @@ export class SyncState extends EntityBase<table.SyncState> {
|
|
|
59
73
|
static async fromStorage(
|
|
60
74
|
storage: sdk.WalletStorageSync,
|
|
61
75
|
userIdentityKey: string,
|
|
62
|
-
remoteSettings:
|
|
63
|
-
): Promise<
|
|
76
|
+
remoteSettings: TableSettings
|
|
77
|
+
): Promise<EntitySyncState> {
|
|
64
78
|
const { user } = verifyTruthy(
|
|
65
79
|
await storage.findOrInsertUser(userIdentityKey)
|
|
66
80
|
)
|
|
@@ -71,7 +85,7 @@ export class SyncState extends EntityBase<table.SyncState> {
|
|
|
71
85
|
remoteSettings.storageName
|
|
72
86
|
)
|
|
73
87
|
)
|
|
74
|
-
const ss = new
|
|
88
|
+
const ss = new EntitySyncState(api)
|
|
75
89
|
return ss
|
|
76
90
|
}
|
|
77
91
|
|
|
@@ -82,7 +96,7 @@ export class SyncState extends EntityBase<table.SyncState> {
|
|
|
82
96
|
* @param trx
|
|
83
97
|
*/
|
|
84
98
|
async updateStorage(
|
|
85
|
-
storage:
|
|
99
|
+
storage: EntityStorage,
|
|
86
100
|
notSyncMap?: boolean,
|
|
87
101
|
trx?: sdk.TrxToken
|
|
88
102
|
) {
|
|
@@ -91,7 +105,7 @@ export class SyncState extends EntityBase<table.SyncState> {
|
|
|
91
105
|
if (this.id === 0) {
|
|
92
106
|
await storage.insertSyncState(this.api)
|
|
93
107
|
} else {
|
|
94
|
-
const update: Partial<
|
|
108
|
+
const update: Partial<TableSyncState> = { ...this.api }
|
|
95
109
|
if (notSyncMap) delete update.syncMap
|
|
96
110
|
delete update.created_at
|
|
97
111
|
await storage.updateSyncState(verifyId(this.id), update, trx)
|
|
@@ -183,7 +197,7 @@ export class SyncState extends EntityBase<table.SyncState> {
|
|
|
183
197
|
this.api.syncStateId = id
|
|
184
198
|
}
|
|
185
199
|
override get entityName(): string {
|
|
186
|
-
return '
|
|
200
|
+
return 'syncState'
|
|
187
201
|
}
|
|
188
202
|
override get entityTable(): string {
|
|
189
203
|
return 'sync_states'
|
|
@@ -209,30 +223,39 @@ export class SyncState extends EntityBase<table.SyncState> {
|
|
|
209
223
|
* @param iSyncMap
|
|
210
224
|
*/
|
|
211
225
|
mergeSyncMap(iSyncMap: SyncMap) {
|
|
212
|
-
|
|
213
|
-
|
|
226
|
+
EntitySyncState.mergeIdMap(
|
|
227
|
+
iSyncMap.provenTx.idMap!,
|
|
228
|
+
this.syncMap.provenTx.idMap!
|
|
229
|
+
)
|
|
230
|
+
EntitySyncState.mergeIdMap(
|
|
214
231
|
iSyncMap.outputBasket.idMap!,
|
|
215
232
|
this.syncMap.outputBasket.idMap!
|
|
216
233
|
)
|
|
217
|
-
|
|
234
|
+
EntitySyncState.mergeIdMap(
|
|
218
235
|
iSyncMap.transaction.idMap!,
|
|
219
236
|
this.syncMap.transaction.idMap!
|
|
220
237
|
)
|
|
221
|
-
|
|
238
|
+
EntitySyncState.mergeIdMap(
|
|
222
239
|
iSyncMap.provenTxReq.idMap!,
|
|
223
240
|
this.syncMap.provenTxReq.idMap!
|
|
224
241
|
)
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
242
|
+
EntitySyncState.mergeIdMap(
|
|
243
|
+
iSyncMap.txLabel.idMap!,
|
|
244
|
+
this.syncMap.txLabel.idMap!
|
|
245
|
+
)
|
|
246
|
+
EntitySyncState.mergeIdMap(
|
|
247
|
+
iSyncMap.output.idMap!,
|
|
248
|
+
this.syncMap.output.idMap!
|
|
249
|
+
)
|
|
250
|
+
EntitySyncState.mergeIdMap(
|
|
228
251
|
iSyncMap.outputTag.idMap!,
|
|
229
252
|
this.syncMap.outputTag.idMap!
|
|
230
253
|
)
|
|
231
|
-
|
|
254
|
+
EntitySyncState.mergeIdMap(
|
|
232
255
|
iSyncMap.certificate.idMap!,
|
|
233
256
|
this.syncMap.certificate.idMap!
|
|
234
257
|
)
|
|
235
|
-
|
|
258
|
+
EntitySyncState.mergeIdMap(
|
|
236
259
|
iSyncMap.commission.idMap!,
|
|
237
260
|
this.syncMap.commission.idMap!
|
|
238
261
|
)
|
|
@@ -257,21 +280,21 @@ export class SyncState extends EntityBase<table.SyncState> {
|
|
|
257
280
|
return JSON.stringify(es)
|
|
258
281
|
}
|
|
259
282
|
|
|
260
|
-
override equals(ei:
|
|
283
|
+
override equals(ei: TableSyncState, syncMap?: SyncMap | undefined): boolean {
|
|
261
284
|
return false
|
|
262
285
|
}
|
|
263
286
|
|
|
264
287
|
override async mergeNew(
|
|
265
|
-
storage:
|
|
288
|
+
storage: EntityStorage,
|
|
266
289
|
userId: number,
|
|
267
290
|
syncMap: SyncMap,
|
|
268
291
|
trx?: sdk.TrxToken
|
|
269
292
|
): Promise<void> {}
|
|
270
293
|
|
|
271
294
|
override async mergeExisting(
|
|
272
|
-
storage:
|
|
295
|
+
storage: EntityStorage,
|
|
273
296
|
since: Date | undefined,
|
|
274
|
-
ei:
|
|
297
|
+
ei: TableSyncState,
|
|
275
298
|
syncMap: SyncMap,
|
|
276
299
|
trx?: sdk.TrxToken
|
|
277
300
|
): Promise<boolean> {
|
|
@@ -313,7 +336,7 @@ export class SyncState extends EntityBase<table.SyncState> {
|
|
|
313
336
|
}
|
|
314
337
|
|
|
315
338
|
async processSyncChunk(
|
|
316
|
-
writer:
|
|
339
|
+
writer: EntityStorage,
|
|
317
340
|
args: sdk.RequestSyncChunkArgs,
|
|
318
341
|
chunk: sdk.SyncChunk
|
|
319
342
|
): Promise<{
|
|
@@ -325,62 +348,62 @@ export class SyncState extends EntityBase<table.SyncState> {
|
|
|
325
348
|
const mes = [
|
|
326
349
|
new MergeEntity(
|
|
327
350
|
chunk.provenTxs,
|
|
328
|
-
|
|
351
|
+
EntityProvenTx.mergeFind,
|
|
329
352
|
this.syncMap.provenTx
|
|
330
353
|
),
|
|
331
354
|
new MergeEntity(
|
|
332
355
|
chunk.outputBaskets,
|
|
333
|
-
|
|
356
|
+
EntityOutputBasket.mergeFind,
|
|
334
357
|
this.syncMap.outputBasket
|
|
335
358
|
),
|
|
336
359
|
new MergeEntity(
|
|
337
360
|
chunk.outputTags,
|
|
338
|
-
|
|
361
|
+
EntityOutputTag.mergeFind,
|
|
339
362
|
this.syncMap.outputTag
|
|
340
363
|
),
|
|
341
364
|
new MergeEntity(
|
|
342
365
|
chunk.txLabels,
|
|
343
|
-
|
|
366
|
+
EntityTxLabel.mergeFind,
|
|
344
367
|
this.syncMap.txLabel
|
|
345
368
|
),
|
|
346
369
|
new MergeEntity(
|
|
347
370
|
chunk.transactions,
|
|
348
|
-
|
|
371
|
+
EntityTransaction.mergeFind,
|
|
349
372
|
this.syncMap.transaction
|
|
350
373
|
),
|
|
351
374
|
new MergeEntity(
|
|
352
375
|
chunk.outputs,
|
|
353
|
-
|
|
376
|
+
EntityOutput.mergeFind,
|
|
354
377
|
this.syncMap.output
|
|
355
378
|
),
|
|
356
379
|
new MergeEntity(
|
|
357
380
|
chunk.txLabelMaps,
|
|
358
|
-
|
|
381
|
+
EntityTxLabelMap.mergeFind,
|
|
359
382
|
this.syncMap.txLabelMap
|
|
360
383
|
),
|
|
361
384
|
new MergeEntity(
|
|
362
385
|
chunk.outputTagMaps,
|
|
363
|
-
|
|
386
|
+
EntityOutputTagMap.mergeFind,
|
|
364
387
|
this.syncMap.outputTagMap
|
|
365
388
|
),
|
|
366
389
|
new MergeEntity(
|
|
367
390
|
chunk.certificates,
|
|
368
|
-
|
|
391
|
+
EntityCertificate.mergeFind,
|
|
369
392
|
this.syncMap.certificate
|
|
370
393
|
),
|
|
371
394
|
new MergeEntity(
|
|
372
395
|
chunk.certificateFields,
|
|
373
|
-
|
|
396
|
+
EntityCertificateField.mergeFind,
|
|
374
397
|
this.syncMap.certificateField
|
|
375
398
|
),
|
|
376
399
|
new MergeEntity(
|
|
377
400
|
chunk.commissions,
|
|
378
|
-
|
|
401
|
+
EntityCommission.mergeFind,
|
|
379
402
|
this.syncMap.commission
|
|
380
403
|
),
|
|
381
404
|
new MergeEntity(
|
|
382
405
|
chunk.provenTxReqs,
|
|
383
|
-
|
|
406
|
+
EntityProvenTxReq.mergeFind,
|
|
384
407
|
this.syncMap.provenTxReq
|
|
385
408
|
)
|
|
386
409
|
]
|
|
@@ -393,7 +416,7 @@ export class SyncState extends EntityBase<table.SyncState> {
|
|
|
393
416
|
// Merge User
|
|
394
417
|
if (chunk.user) {
|
|
395
418
|
const ei = chunk.user
|
|
396
|
-
const { found, eo } = await
|
|
419
|
+
const { found, eo } = await EntityUser.mergeFind(writer, this.userId, ei)
|
|
397
420
|
if (found) {
|
|
398
421
|
if (await eo.mergeExisting(writer, args.since, ei)) {
|
|
399
422
|
maxUpdated_at = maxDate(maxUpdated_at, ei.updated_at)
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
import { Transaction as BsvTransaction, TransactionInput } from '@bsv/sdk'
|
|
3
3
|
import {
|
|
4
|
-
entity,
|
|
5
4
|
optionalArraysEqual,
|
|
6
5
|
sdk,
|
|
7
|
-
|
|
6
|
+
TableOutput,
|
|
7
|
+
TableTransaction,
|
|
8
8
|
verifyId,
|
|
9
9
|
verifyOneOrNone
|
|
10
10
|
} from '../../../index.client'
|
|
11
|
-
import { EntityBase } from '.'
|
|
11
|
+
import { EntityBase, EntityProvenTx, EntityStorage, SyncMap } from '.'
|
|
12
12
|
|
|
13
|
-
export class
|
|
13
|
+
export class EntityTransaction extends EntityBase<TableTransaction> {
|
|
14
14
|
/**
|
|
15
15
|
* @returns @bsv/sdk Transaction object from parsed rawTx.
|
|
16
16
|
* If rawTx is undefined, returns undefined.
|
|
@@ -36,9 +36,9 @@ export class Transaction extends EntityBase<table.Transaction> {
|
|
|
36
36
|
* Not all transaction inputs correspond to prior storage outputs.
|
|
37
37
|
*/
|
|
38
38
|
async getInputs(
|
|
39
|
-
storage:
|
|
39
|
+
storage: EntityStorage,
|
|
40
40
|
trx?: sdk.TrxToken
|
|
41
|
-
): Promise<
|
|
41
|
+
): Promise<TableOutput[]> {
|
|
42
42
|
const inputs = await storage.findOutputs({
|
|
43
43
|
partial: { userId: this.userId, spentBy: this.id },
|
|
44
44
|
trx
|
|
@@ -62,7 +62,7 @@ export class Transaction extends EntityBase<table.Transaction> {
|
|
|
62
62
|
return inputs
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
constructor(api?:
|
|
65
|
+
constructor(api?: TableTransaction) {
|
|
66
66
|
const now = new Date()
|
|
67
67
|
super(
|
|
68
68
|
api || {
|
|
@@ -202,15 +202,15 @@ export class Transaction extends EntityBase<table.Transaction> {
|
|
|
202
202
|
this.api.transactionId = v
|
|
203
203
|
}
|
|
204
204
|
override get entityName(): string {
|
|
205
|
-
return '
|
|
205
|
+
return 'transaction'
|
|
206
206
|
}
|
|
207
207
|
override get entityTable(): string {
|
|
208
208
|
return 'transactions'
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
override equals(
|
|
212
|
-
ei:
|
|
213
|
-
syncMap?:
|
|
212
|
+
ei: TableTransaction,
|
|
213
|
+
syncMap?: SyncMap | undefined
|
|
214
214
|
): boolean {
|
|
215
215
|
const eo = this.toApi()
|
|
216
216
|
|
|
@@ -251,12 +251,12 @@ export class Transaction extends EntityBase<table.Transaction> {
|
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
static async mergeFind(
|
|
254
|
-
storage:
|
|
254
|
+
storage: EntityStorage,
|
|
255
255
|
userId: number,
|
|
256
|
-
ei:
|
|
257
|
-
syncMap:
|
|
256
|
+
ei: TableTransaction,
|
|
257
|
+
syncMap: SyncMap,
|
|
258
258
|
trx?: sdk.TrxToken
|
|
259
|
-
): Promise<{ found: boolean; eo:
|
|
259
|
+
): Promise<{ found: boolean; eo: EntityTransaction; eiId: number }> {
|
|
260
260
|
const ef = verifyOneOrNone(
|
|
261
261
|
await storage.findTransactions({
|
|
262
262
|
partial: { reference: ei.reference, userId },
|
|
@@ -265,15 +265,15 @@ export class Transaction extends EntityBase<table.Transaction> {
|
|
|
265
265
|
)
|
|
266
266
|
return {
|
|
267
267
|
found: !!ef,
|
|
268
|
-
eo: new
|
|
268
|
+
eo: new EntityTransaction(ef || { ...ei }),
|
|
269
269
|
eiId: verifyId(ei.transactionId)
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
override async mergeNew(
|
|
274
|
-
storage:
|
|
274
|
+
storage: EntityStorage,
|
|
275
275
|
userId: number,
|
|
276
|
-
syncMap:
|
|
276
|
+
syncMap: SyncMap,
|
|
277
277
|
trx?: sdk.TrxToken
|
|
278
278
|
): Promise<void> {
|
|
279
279
|
if (this.provenTxId)
|
|
@@ -284,10 +284,10 @@ export class Transaction extends EntityBase<table.Transaction> {
|
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
override async mergeExisting(
|
|
287
|
-
storage:
|
|
287
|
+
storage: EntityStorage,
|
|
288
288
|
since: Date | undefined,
|
|
289
|
-
ei:
|
|
290
|
-
syncMap:
|
|
289
|
+
ei: TableTransaction,
|
|
290
|
+
syncMap: SyncMap,
|
|
291
291
|
trx?: sdk.TrxToken
|
|
292
292
|
): Promise<boolean> {
|
|
293
293
|
let wasMerged = false
|
|
@@ -318,9 +318,9 @@ export class Transaction extends EntityBase<table.Transaction> {
|
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
async getProvenTx(
|
|
321
|
-
storage:
|
|
321
|
+
storage: EntityStorage,
|
|
322
322
|
trx?: sdk.TrxToken
|
|
323
|
-
): Promise<
|
|
323
|
+
): Promise<EntityProvenTx | undefined> {
|
|
324
324
|
if (!this.provenTxId) return undefined
|
|
325
325
|
const p = verifyOneOrNone(
|
|
326
326
|
await storage.findProvenTxs({
|
|
@@ -329,6 +329,6 @@ export class Transaction extends EntityBase<table.Transaction> {
|
|
|
329
329
|
})
|
|
330
330
|
)
|
|
331
331
|
if (!p) return undefined
|
|
332
|
-
return new
|
|
332
|
+
return new EntityProvenTx(p)
|
|
333
333
|
}
|
|
334
334
|
}
|