@bsv/wallet-toolbox 1.1.7 → 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 -486
- package/docs/monitor.md +29 -27
- package/docs/services.md +22 -22
- package/docs/setup.md +23 -23
- package/docs/storage.md +2177 -419
- package/docs/wallet.md +499 -486
- 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.map +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.js +1 -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 +17 -11
- package/src/storage/methods/reviewStatus.ts +4 -4
- 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 +6 -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 +1 -1
- 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
|
@@ -5,7 +5,29 @@ import {
|
|
|
5
5
|
ListOutputsResult
|
|
6
6
|
} from '@bsv/sdk'
|
|
7
7
|
import { sdk, verifyOne, verifyOneOrNone, verifyTruthy } from '../index.all'
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
KnexMigrations,
|
|
10
|
+
outputColumnsWithoutLockingScript,
|
|
11
|
+
TableCertificate,
|
|
12
|
+
TableCertificateField,
|
|
13
|
+
TableCertificateX,
|
|
14
|
+
TableCommission,
|
|
15
|
+
TableMonitorEvent,
|
|
16
|
+
TableOutput,
|
|
17
|
+
TableOutputBasket,
|
|
18
|
+
TableOutputTag,
|
|
19
|
+
TableOutputTagMap,
|
|
20
|
+
TableOutputX,
|
|
21
|
+
TableProvenTx,
|
|
22
|
+
TableProvenTxReq,
|
|
23
|
+
TableSettings,
|
|
24
|
+
TableSyncState,
|
|
25
|
+
TableTransaction,
|
|
26
|
+
TableTxLabel,
|
|
27
|
+
TableTxLabelMap,
|
|
28
|
+
TableUser,
|
|
29
|
+
transactionColumnsWithoutRawTx
|
|
30
|
+
} from './index.all'
|
|
9
31
|
|
|
10
32
|
import { Knex } from 'knex'
|
|
11
33
|
import { StorageProvider, StorageProviderOptions } from './StorageProvider'
|
|
@@ -35,9 +57,9 @@ export class StorageKnex
|
|
|
35
57
|
this.knex = options.knex
|
|
36
58
|
}
|
|
37
59
|
|
|
38
|
-
async readSettings(): Promise<
|
|
60
|
+
async readSettings(): Promise<TableSettings> {
|
|
39
61
|
return this.validateEntity(
|
|
40
|
-
verifyOne(await this.toDb(undefined)<
|
|
62
|
+
verifyOne(await this.toDb(undefined)<TableSettings>('settings'))
|
|
41
63
|
)
|
|
42
64
|
}
|
|
43
65
|
|
|
@@ -143,7 +165,7 @@ export class StorageKnex
|
|
|
143
165
|
}
|
|
144
166
|
override async getProvenTxsForUser(
|
|
145
167
|
args: sdk.FindForUserSincePagedArgs
|
|
146
|
-
): Promise<
|
|
168
|
+
): Promise<TableProvenTx[]> {
|
|
147
169
|
const q = this.getProvenTxsForUserQuery(args)
|
|
148
170
|
const rs = await q
|
|
149
171
|
return this.validateEntities(rs)
|
|
@@ -172,7 +194,7 @@ export class StorageKnex
|
|
|
172
194
|
}
|
|
173
195
|
override async getProvenTxReqsForUser(
|
|
174
196
|
args: sdk.FindForUserSincePagedArgs
|
|
175
|
-
): Promise<
|
|
197
|
+
): Promise<TableProvenTxReq[]> {
|
|
176
198
|
const q = this.getProvenTxReqsForUserQuery(args)
|
|
177
199
|
const rs = await q
|
|
178
200
|
return this.validateEntities(rs, undefined, ['notified'])
|
|
@@ -200,7 +222,7 @@ export class StorageKnex
|
|
|
200
222
|
}
|
|
201
223
|
override async getTxLabelMapsForUser(
|
|
202
224
|
args: sdk.FindForUserSincePagedArgs
|
|
203
|
-
): Promise<
|
|
225
|
+
): Promise<TableTxLabelMap[]> {
|
|
204
226
|
const q = this.getTxLabelMapsForUserQuery(args)
|
|
205
227
|
const rs = await q
|
|
206
228
|
return this.validateEntities(rs, undefined, ['isDeleted'])
|
|
@@ -228,7 +250,7 @@ export class StorageKnex
|
|
|
228
250
|
}
|
|
229
251
|
override async getOutputTagMapsForUser(
|
|
230
252
|
args: sdk.FindForUserSincePagedArgs
|
|
231
|
-
): Promise<
|
|
253
|
+
): Promise<TableOutputTagMap[]> {
|
|
232
254
|
const q = this.getOutputTagMapsForUserQuery(args)
|
|
233
255
|
const rs = await q
|
|
234
256
|
return this.validateEntities(rs, undefined, ['isDeleted'])
|
|
@@ -250,42 +272,42 @@ export class StorageKnex
|
|
|
250
272
|
}
|
|
251
273
|
|
|
252
274
|
override async insertProvenTx(
|
|
253
|
-
tx:
|
|
275
|
+
tx: TableProvenTx,
|
|
254
276
|
trx?: sdk.TrxToken
|
|
255
277
|
): Promise<number> {
|
|
256
278
|
const e = await this.validateEntityForInsert(tx, trx)
|
|
257
279
|
if (e.provenTxId === 0) delete e.provenTxId
|
|
258
|
-
const [id] = await this.toDb(trx)<
|
|
280
|
+
const [id] = await this.toDb(trx)<TableProvenTx>('proven_txs').insert(e)
|
|
259
281
|
tx.provenTxId = id
|
|
260
282
|
return tx.provenTxId
|
|
261
283
|
}
|
|
262
284
|
|
|
263
285
|
override async insertProvenTxReq(
|
|
264
|
-
tx:
|
|
286
|
+
tx: TableProvenTxReq,
|
|
265
287
|
trx?: sdk.TrxToken
|
|
266
288
|
): Promise<number> {
|
|
267
289
|
const e = await this.validateEntityForInsert(tx, trx)
|
|
268
290
|
if (e.provenTxReqId === 0) delete e.provenTxReqId
|
|
269
291
|
const [id] =
|
|
270
|
-
await this.toDb(trx)<
|
|
292
|
+
await this.toDb(trx)<TableProvenTxReq>('proven_tx_reqs').insert(e)
|
|
271
293
|
tx.provenTxReqId = id
|
|
272
294
|
return tx.provenTxReqId
|
|
273
295
|
}
|
|
274
296
|
|
|
275
297
|
override async insertUser(
|
|
276
|
-
user:
|
|
298
|
+
user: TableUser,
|
|
277
299
|
trx?: sdk.TrxToken
|
|
278
300
|
): Promise<number> {
|
|
279
301
|
const e = await this.validateEntityForInsert(user, trx)
|
|
280
302
|
if (e.userId === 0) delete e.userId
|
|
281
|
-
const [id] = await this.toDb(trx)<
|
|
303
|
+
const [id] = await this.toDb(trx)<TableUser>('users').insert(e)
|
|
282
304
|
user.userId = id
|
|
283
305
|
return user.userId
|
|
284
306
|
}
|
|
285
307
|
|
|
286
308
|
override async insertCertificateAuth(
|
|
287
309
|
auth: sdk.AuthId,
|
|
288
|
-
certificate:
|
|
310
|
+
certificate: TableCertificateX
|
|
289
311
|
): Promise<number> {
|
|
290
312
|
if (
|
|
291
313
|
!auth.userId ||
|
|
@@ -297,7 +319,7 @@ export class StorageKnex
|
|
|
297
319
|
}
|
|
298
320
|
|
|
299
321
|
override async insertCertificate(
|
|
300
|
-
certificate:
|
|
322
|
+
certificate: TableCertificateX,
|
|
301
323
|
trx?: sdk.TrxToken
|
|
302
324
|
): Promise<number> {
|
|
303
325
|
const e = await this.validateEntityForInsert(certificate, trx, undefined, [
|
|
@@ -307,7 +329,7 @@ export class StorageKnex
|
|
|
307
329
|
if (e.fields) delete e.fields
|
|
308
330
|
if (e.certificateId === 0) delete e.certificateId
|
|
309
331
|
const [id] =
|
|
310
|
-
await this.toDb(trx)<
|
|
332
|
+
await this.toDb(trx)<TableCertificate>('certificates').insert(e)
|
|
311
333
|
certificate.certificateId = id
|
|
312
334
|
|
|
313
335
|
if (fields) {
|
|
@@ -322,15 +344,15 @@ export class StorageKnex
|
|
|
322
344
|
}
|
|
323
345
|
|
|
324
346
|
override async insertCertificateField(
|
|
325
|
-
certificateField:
|
|
347
|
+
certificateField: TableCertificateField,
|
|
326
348
|
trx?: sdk.TrxToken
|
|
327
349
|
): Promise<void> {
|
|
328
350
|
const e = await this.validateEntityForInsert(certificateField, trx)
|
|
329
|
-
await this.toDb(trx)<
|
|
351
|
+
await this.toDb(trx)<TableCertificate>('certificate_fields').insert(e)
|
|
330
352
|
}
|
|
331
353
|
|
|
332
354
|
override async insertOutputBasket(
|
|
333
|
-
basket:
|
|
355
|
+
basket: TableOutputBasket,
|
|
334
356
|
trx?: sdk.TrxToken
|
|
335
357
|
): Promise<number> {
|
|
336
358
|
const e = await this.validateEntityForInsert(basket, trx, undefined, [
|
|
@@ -338,107 +360,107 @@ export class StorageKnex
|
|
|
338
360
|
])
|
|
339
361
|
if (e.basketId === 0) delete e.basketId
|
|
340
362
|
const [id] =
|
|
341
|
-
await this.toDb(trx)<
|
|
363
|
+
await this.toDb(trx)<TableOutputBasket>('output_baskets').insert(e)
|
|
342
364
|
basket.basketId = id
|
|
343
365
|
return basket.basketId
|
|
344
366
|
}
|
|
345
367
|
|
|
346
368
|
override async insertTransaction(
|
|
347
|
-
tx:
|
|
369
|
+
tx: TableTransaction,
|
|
348
370
|
trx?: sdk.TrxToken
|
|
349
371
|
): Promise<number> {
|
|
350
372
|
const e = await this.validateEntityForInsert(tx, trx)
|
|
351
373
|
if (e.transactionId === 0) delete e.transactionId
|
|
352
374
|
const [id] =
|
|
353
|
-
await this.toDb(trx)<
|
|
375
|
+
await this.toDb(trx)<TableTransaction>('transactions').insert(e)
|
|
354
376
|
tx.transactionId = id
|
|
355
377
|
return tx.transactionId
|
|
356
378
|
}
|
|
357
379
|
|
|
358
380
|
override async insertCommission(
|
|
359
|
-
commission:
|
|
381
|
+
commission: TableCommission,
|
|
360
382
|
trx?: sdk.TrxToken
|
|
361
383
|
): Promise<number> {
|
|
362
384
|
const e = await this.validateEntityForInsert(commission, trx)
|
|
363
385
|
if (e.commissionId === 0) delete e.commissionId
|
|
364
|
-
const [id] = await this.toDb(trx)<
|
|
386
|
+
const [id] = await this.toDb(trx)<TableCommission>('commissions').insert(e)
|
|
365
387
|
commission.commissionId = id
|
|
366
388
|
return commission.commissionId
|
|
367
389
|
}
|
|
368
390
|
|
|
369
391
|
override async insertOutput(
|
|
370
|
-
output:
|
|
392
|
+
output: TableOutput,
|
|
371
393
|
trx?: sdk.TrxToken
|
|
372
394
|
): Promise<number> {
|
|
373
395
|
const e = await this.validateEntityForInsert(output, trx)
|
|
374
396
|
if (e.outputId === 0) delete e.outputId
|
|
375
|
-
const [id] = await this.toDb(trx)<
|
|
397
|
+
const [id] = await this.toDb(trx)<TableOutput>('outputs').insert(e)
|
|
376
398
|
output.outputId = id
|
|
377
399
|
return output.outputId
|
|
378
400
|
}
|
|
379
401
|
|
|
380
402
|
override async insertOutputTag(
|
|
381
|
-
tag:
|
|
403
|
+
tag: TableOutputTag,
|
|
382
404
|
trx?: sdk.TrxToken
|
|
383
405
|
): Promise<number> {
|
|
384
406
|
const e = await this.validateEntityForInsert(tag, trx, undefined, [
|
|
385
407
|
'isDeleted'
|
|
386
408
|
])
|
|
387
409
|
if (e.outputTagId === 0) delete e.outputTagId
|
|
388
|
-
const [id] = await this.toDb(trx)<
|
|
410
|
+
const [id] = await this.toDb(trx)<TableOutputTag>('output_tags').insert(e)
|
|
389
411
|
tag.outputTagId = id
|
|
390
412
|
return tag.outputTagId
|
|
391
413
|
}
|
|
392
414
|
|
|
393
415
|
override async insertOutputTagMap(
|
|
394
|
-
tagMap:
|
|
416
|
+
tagMap: TableOutputTagMap,
|
|
395
417
|
trx?: sdk.TrxToken
|
|
396
418
|
): Promise<void> {
|
|
397
419
|
const e = await this.validateEntityForInsert(tagMap, trx, undefined, [
|
|
398
420
|
'isDeleted'
|
|
399
421
|
])
|
|
400
422
|
const [id] =
|
|
401
|
-
await this.toDb(trx)<
|
|
423
|
+
await this.toDb(trx)<TableOutputTagMap>('output_tags_map').insert(e)
|
|
402
424
|
}
|
|
403
425
|
|
|
404
426
|
override async insertTxLabel(
|
|
405
|
-
label:
|
|
427
|
+
label: TableTxLabel,
|
|
406
428
|
trx?: sdk.TrxToken
|
|
407
429
|
): Promise<number> {
|
|
408
430
|
const e = await this.validateEntityForInsert(label, trx, undefined, [
|
|
409
431
|
'isDeleted'
|
|
410
432
|
])
|
|
411
433
|
if (e.txLabelId === 0) delete e.txLabelId
|
|
412
|
-
const [id] = await this.toDb(trx)<
|
|
434
|
+
const [id] = await this.toDb(trx)<TableTxLabel>('tx_labels').insert(e)
|
|
413
435
|
label.txLabelId = id
|
|
414
436
|
return label.txLabelId
|
|
415
437
|
}
|
|
416
438
|
|
|
417
439
|
override async insertTxLabelMap(
|
|
418
|
-
labelMap:
|
|
440
|
+
labelMap: TableTxLabelMap,
|
|
419
441
|
trx?: sdk.TrxToken
|
|
420
442
|
): Promise<void> {
|
|
421
443
|
const e = await this.validateEntityForInsert(labelMap, trx, undefined, [
|
|
422
444
|
'isDeleted'
|
|
423
445
|
])
|
|
424
446
|
const [id] =
|
|
425
|
-
await this.toDb(trx)<
|
|
447
|
+
await this.toDb(trx)<TableTxLabelMap>('tx_labels_map').insert(e)
|
|
426
448
|
}
|
|
427
449
|
|
|
428
450
|
override async insertMonitorEvent(
|
|
429
|
-
event:
|
|
451
|
+
event: TableMonitorEvent,
|
|
430
452
|
trx?: sdk.TrxToken
|
|
431
453
|
): Promise<number> {
|
|
432
454
|
const e = await this.validateEntityForInsert(event, trx)
|
|
433
455
|
if (e.id === 0) delete e.id
|
|
434
456
|
const [id] =
|
|
435
|
-
await this.toDb(trx)<
|
|
457
|
+
await this.toDb(trx)<TableMonitorEvent>('monitor_events').insert(e)
|
|
436
458
|
event.id = id
|
|
437
459
|
return event.id
|
|
438
460
|
}
|
|
439
461
|
|
|
440
462
|
override async insertSyncState(
|
|
441
|
-
syncState:
|
|
463
|
+
syncState: TableSyncState,
|
|
442
464
|
trx?: sdk.TrxToken
|
|
443
465
|
): Promise<number> {
|
|
444
466
|
const e = await this.validateEntityForInsert(
|
|
@@ -448,7 +470,7 @@ export class StorageKnex
|
|
|
448
470
|
['init']
|
|
449
471
|
)
|
|
450
472
|
if (e.syncStateId === 0) delete e.syncStateId
|
|
451
|
-
const [id] = await this.toDb(trx)<
|
|
473
|
+
const [id] = await this.toDb(trx)<TableSyncState>('sync_states').insert(e)
|
|
452
474
|
syncState.syncStateId = id
|
|
453
475
|
return syncState.syncStateId
|
|
454
476
|
}
|
|
@@ -456,88 +478,88 @@ export class StorageKnex
|
|
|
456
478
|
override async updateCertificateField(
|
|
457
479
|
certificateId: number,
|
|
458
480
|
fieldName: string,
|
|
459
|
-
update: Partial<
|
|
481
|
+
update: Partial<TableCertificateField>,
|
|
460
482
|
trx?: sdk.TrxToken
|
|
461
483
|
): Promise<number> {
|
|
462
484
|
await this.verifyReadyForDatabaseAccess(trx)
|
|
463
|
-
return await this.toDb(trx)<
|
|
485
|
+
return await this.toDb(trx)<TableCertificateField>('certificate_fields')
|
|
464
486
|
.where({ certificateId, fieldName })
|
|
465
487
|
.update(this.validatePartialForUpdate(update))
|
|
466
488
|
}
|
|
467
489
|
override async updateCertificate(
|
|
468
490
|
id: number,
|
|
469
|
-
update: Partial<
|
|
491
|
+
update: Partial<TableCertificate>,
|
|
470
492
|
trx?: sdk.TrxToken
|
|
471
493
|
): Promise<number> {
|
|
472
494
|
await this.verifyReadyForDatabaseAccess(trx)
|
|
473
|
-
return await this.toDb(trx)<
|
|
495
|
+
return await this.toDb(trx)<TableCertificate>('certificates')
|
|
474
496
|
.where({ certificateId: id })
|
|
475
497
|
.update(this.validatePartialForUpdate(update, undefined, ['isDeleted']))
|
|
476
498
|
}
|
|
477
499
|
override async updateCommission(
|
|
478
500
|
id: number,
|
|
479
|
-
update: Partial<
|
|
501
|
+
update: Partial<TableCommission>,
|
|
480
502
|
trx?: sdk.TrxToken
|
|
481
503
|
): Promise<number> {
|
|
482
504
|
await this.verifyReadyForDatabaseAccess(trx)
|
|
483
|
-
return await this.toDb(trx)<
|
|
505
|
+
return await this.toDb(trx)<TableCommission>('commissions')
|
|
484
506
|
.where({ commissionId: id })
|
|
485
507
|
.update(this.validatePartialForUpdate(update))
|
|
486
508
|
}
|
|
487
509
|
override async updateOutputBasket(
|
|
488
510
|
id: number,
|
|
489
|
-
update: Partial<
|
|
511
|
+
update: Partial<TableOutputBasket>,
|
|
490
512
|
trx?: sdk.TrxToken
|
|
491
513
|
): Promise<number> {
|
|
492
514
|
await this.verifyReadyForDatabaseAccess(trx)
|
|
493
|
-
return await this.toDb(trx)<
|
|
515
|
+
return await this.toDb(trx)<TableOutputBasket>('output_baskets')
|
|
494
516
|
.where({ basketId: id })
|
|
495
517
|
.update(this.validatePartialForUpdate(update, undefined, ['isDeleted']))
|
|
496
518
|
}
|
|
497
519
|
override async updateOutput(
|
|
498
520
|
id: number,
|
|
499
|
-
update: Partial<
|
|
521
|
+
update: Partial<TableOutput>,
|
|
500
522
|
trx?: sdk.TrxToken
|
|
501
523
|
): Promise<number> {
|
|
502
524
|
await this.verifyReadyForDatabaseAccess(trx)
|
|
503
|
-
return await this.toDb(trx)<
|
|
525
|
+
return await this.toDb(trx)<TableOutput>('outputs')
|
|
504
526
|
.where({ outputId: id })
|
|
505
527
|
.update(this.validatePartialForUpdate(update))
|
|
506
528
|
}
|
|
507
529
|
override async updateOutputTagMap(
|
|
508
530
|
outputId: number,
|
|
509
531
|
tagId: number,
|
|
510
|
-
update: Partial<
|
|
532
|
+
update: Partial<TableOutputTagMap>,
|
|
511
533
|
trx?: sdk.TrxToken
|
|
512
534
|
): Promise<number> {
|
|
513
535
|
await this.verifyReadyForDatabaseAccess(trx)
|
|
514
|
-
return await this.toDb(trx)<
|
|
536
|
+
return await this.toDb(trx)<TableOutputTagMap>('output_tags_map')
|
|
515
537
|
.where({ outputId, outputTagId: tagId })
|
|
516
538
|
.update(this.validatePartialForUpdate(update, undefined, ['isDeleted']))
|
|
517
539
|
}
|
|
518
540
|
override async updateOutputTag(
|
|
519
541
|
id: number,
|
|
520
|
-
update: Partial<
|
|
542
|
+
update: Partial<TableOutputTag>,
|
|
521
543
|
trx?: sdk.TrxToken
|
|
522
544
|
): Promise<number> {
|
|
523
545
|
await this.verifyReadyForDatabaseAccess(trx)
|
|
524
|
-
return await this.toDb(trx)<
|
|
546
|
+
return await this.toDb(trx)<TableOutputTag>('output_tags')
|
|
525
547
|
.where({ outputTagId: id })
|
|
526
548
|
.update(this.validatePartialForUpdate(update, undefined, ['isDeleted']))
|
|
527
549
|
}
|
|
528
550
|
override async updateProvenTxReq(
|
|
529
551
|
id: number | number[],
|
|
530
|
-
update: Partial<
|
|
552
|
+
update: Partial<TableProvenTxReq>,
|
|
531
553
|
trx?: sdk.TrxToken
|
|
532
554
|
): Promise<number> {
|
|
533
555
|
await this.verifyReadyForDatabaseAccess(trx)
|
|
534
556
|
let r: number
|
|
535
557
|
if (Array.isArray(id)) {
|
|
536
|
-
r = await this.toDb(trx)<
|
|
558
|
+
r = await this.toDb(trx)<TableProvenTxReq>('proven_tx_reqs')
|
|
537
559
|
.whereIn('provenTxReqId', id)
|
|
538
560
|
.update(this.validatePartialForUpdate(update))
|
|
539
561
|
} else if (Number.isInteger(id)) {
|
|
540
|
-
r = await this.toDb(trx)<
|
|
562
|
+
r = await this.toDb(trx)<TableProvenTxReq>('proven_tx_reqs')
|
|
541
563
|
.where({ provenTxReqId: id })
|
|
542
564
|
.update(this.validatePartialForUpdate(update))
|
|
543
565
|
} else {
|
|
@@ -550,37 +572,37 @@ export class StorageKnex
|
|
|
550
572
|
}
|
|
551
573
|
override async updateProvenTx(
|
|
552
574
|
id: number,
|
|
553
|
-
update: Partial<
|
|
575
|
+
update: Partial<TableProvenTx>,
|
|
554
576
|
trx?: sdk.TrxToken
|
|
555
577
|
): Promise<number> {
|
|
556
578
|
await this.verifyReadyForDatabaseAccess(trx)
|
|
557
|
-
return await this.toDb(trx)<
|
|
579
|
+
return await this.toDb(trx)<TableProvenTx>('proven_txs')
|
|
558
580
|
.where({ provenTxId: id })
|
|
559
581
|
.update(this.validatePartialForUpdate(update))
|
|
560
582
|
}
|
|
561
583
|
override async updateSyncState(
|
|
562
584
|
id: number,
|
|
563
|
-
update: Partial<
|
|
585
|
+
update: Partial<TableSyncState>,
|
|
564
586
|
trx?: sdk.TrxToken
|
|
565
587
|
): Promise<number> {
|
|
566
588
|
await this.verifyReadyForDatabaseAccess(trx)
|
|
567
|
-
return await this.toDb(trx)<
|
|
589
|
+
return await this.toDb(trx)<TableSyncState>('sync_states')
|
|
568
590
|
.where({ syncStateId: id })
|
|
569
591
|
.update(this.validatePartialForUpdate(update, ['when'], ['init']))
|
|
570
592
|
}
|
|
571
593
|
override async updateTransaction(
|
|
572
594
|
id: number | number[],
|
|
573
|
-
update: Partial<
|
|
595
|
+
update: Partial<TableTransaction>,
|
|
574
596
|
trx?: sdk.TrxToken
|
|
575
597
|
): Promise<number> {
|
|
576
598
|
await this.verifyReadyForDatabaseAccess(trx)
|
|
577
599
|
let r: number
|
|
578
600
|
if (Array.isArray(id)) {
|
|
579
|
-
r = await this.toDb(trx)<
|
|
601
|
+
r = await this.toDb(trx)<TableTransaction>('transactions')
|
|
580
602
|
.whereIn('transactionId', id)
|
|
581
603
|
.update(await this.validatePartialForUpdate(update))
|
|
582
604
|
} else if (Number.isInteger(id)) {
|
|
583
|
-
r = await this.toDb(trx)<
|
|
605
|
+
r = await this.toDb(trx)<TableTransaction>('transactions')
|
|
584
606
|
.where({ transactionId: id })
|
|
585
607
|
.update(await this.validatePartialForUpdate(update))
|
|
586
608
|
} else {
|
|
@@ -594,41 +616,41 @@ export class StorageKnex
|
|
|
594
616
|
override async updateTxLabelMap(
|
|
595
617
|
transactionId: number,
|
|
596
618
|
txLabelId: number,
|
|
597
|
-
update: Partial<
|
|
619
|
+
update: Partial<TableTxLabelMap>,
|
|
598
620
|
trx?: sdk.TrxToken
|
|
599
621
|
): Promise<number> {
|
|
600
622
|
await this.verifyReadyForDatabaseAccess(trx)
|
|
601
|
-
return await this.toDb(trx)<
|
|
623
|
+
return await this.toDb(trx)<TableTxLabelMap>('tx_labels_map')
|
|
602
624
|
.where({ transactionId, txLabelId })
|
|
603
625
|
.update(this.validatePartialForUpdate(update, undefined, ['isDeleted']))
|
|
604
626
|
}
|
|
605
627
|
override async updateTxLabel(
|
|
606
628
|
id: number,
|
|
607
|
-
update: Partial<
|
|
629
|
+
update: Partial<TableTxLabel>,
|
|
608
630
|
trx?: sdk.TrxToken
|
|
609
631
|
): Promise<number> {
|
|
610
632
|
await this.verifyReadyForDatabaseAccess(trx)
|
|
611
|
-
return await this.toDb(trx)<
|
|
633
|
+
return await this.toDb(trx)<TableTxLabel>('tx_labels')
|
|
612
634
|
.where({ txLabelId: id })
|
|
613
635
|
.update(this.validatePartialForUpdate(update, undefined, ['isDeleted']))
|
|
614
636
|
}
|
|
615
637
|
override async updateUser(
|
|
616
638
|
id: number,
|
|
617
|
-
update: Partial<
|
|
639
|
+
update: Partial<TableUser>,
|
|
618
640
|
trx?: sdk.TrxToken
|
|
619
641
|
): Promise<number> {
|
|
620
642
|
await this.verifyReadyForDatabaseAccess(trx)
|
|
621
|
-
return await this.toDb(trx)<
|
|
643
|
+
return await this.toDb(trx)<TableUser>('users')
|
|
622
644
|
.where({ userId: id })
|
|
623
645
|
.update(this.validatePartialForUpdate(update))
|
|
624
646
|
}
|
|
625
647
|
override async updateMonitorEvent(
|
|
626
648
|
id: number,
|
|
627
|
-
update: Partial<
|
|
649
|
+
update: Partial<TableMonitorEvent>,
|
|
628
650
|
trx?: sdk.TrxToken
|
|
629
651
|
): Promise<number> {
|
|
630
652
|
await this.verifyReadyForDatabaseAccess(trx)
|
|
631
|
-
return await this.toDb(trx)<
|
|
653
|
+
return await this.toDb(trx)<TableMonitorEvent>('monitor_events')
|
|
632
654
|
.where({ id })
|
|
633
655
|
.update(this.validatePartialForUpdate(update))
|
|
634
656
|
}
|
|
@@ -688,9 +710,7 @@ export class StorageKnex
|
|
|
688
710
|
)
|
|
689
711
|
}
|
|
690
712
|
if (args.noScript && !count) {
|
|
691
|
-
const columns =
|
|
692
|
-
c => `outputs.${c}`
|
|
693
|
-
)
|
|
713
|
+
const columns = outputColumnsWithoutLockingScript.map(c => `outputs.${c}`)
|
|
694
714
|
q.select(columns)
|
|
695
715
|
}
|
|
696
716
|
return q
|
|
@@ -753,7 +773,7 @@ export class StorageKnex
|
|
|
753
773
|
const q = this.setupQuery('transactions', args)
|
|
754
774
|
if (args.status && args.status.length > 0) q.whereIn('status', args.status)
|
|
755
775
|
if (args.noRawTx && !count) {
|
|
756
|
-
const columns =
|
|
776
|
+
const columns = transactionColumnsWithoutRawTx.map(
|
|
757
777
|
c => `transactions.${c}`
|
|
758
778
|
)
|
|
759
779
|
q.select(columns)
|
|
@@ -779,7 +799,7 @@ export class StorageKnex
|
|
|
779
799
|
override async findCertificatesAuth(
|
|
780
800
|
auth: sdk.AuthId,
|
|
781
801
|
args: sdk.FindCertificatesArgs
|
|
782
|
-
): Promise<
|
|
802
|
+
): Promise<TableCertificate[]> {
|
|
783
803
|
if (
|
|
784
804
|
!auth.userId ||
|
|
785
805
|
(args.partial.userId && args.partial.userId !== auth.userId)
|
|
@@ -791,7 +811,7 @@ export class StorageKnex
|
|
|
791
811
|
override async findOutputBasketsAuth(
|
|
792
812
|
auth: sdk.AuthId,
|
|
793
813
|
args: sdk.FindOutputBasketsArgs
|
|
794
|
-
): Promise<
|
|
814
|
+
): Promise<TableOutputBasket[]> {
|
|
795
815
|
if (
|
|
796
816
|
!auth.userId ||
|
|
797
817
|
(args.partial.userId && args.partial.userId !== auth.userId)
|
|
@@ -803,7 +823,7 @@ export class StorageKnex
|
|
|
803
823
|
override async findOutputsAuth(
|
|
804
824
|
auth: sdk.AuthId,
|
|
805
825
|
args: sdk.FindOutputsArgs
|
|
806
|
-
): Promise<
|
|
826
|
+
): Promise<TableOutput[]> {
|
|
807
827
|
if (
|
|
808
828
|
!auth.userId ||
|
|
809
829
|
(args.partial.userId && args.partial.userId !== auth.userId)
|
|
@@ -815,33 +835,33 @@ export class StorageKnex
|
|
|
815
835
|
|
|
816
836
|
override async findCertificateFields(
|
|
817
837
|
args: sdk.FindCertificateFieldsArgs
|
|
818
|
-
): Promise<
|
|
838
|
+
): Promise<TableCertificateField[]> {
|
|
819
839
|
return this.validateEntities(await this.findCertificateFieldsQuery(args))
|
|
820
840
|
}
|
|
821
841
|
override async findCertificates(
|
|
822
842
|
args: sdk.FindCertificatesArgs
|
|
823
|
-
): Promise<
|
|
843
|
+
): Promise<TableCertificate[]> {
|
|
824
844
|
const q = this.findCertificatesQuery(args)
|
|
825
845
|
const r = await q
|
|
826
846
|
return this.validateEntities(r, undefined, ['isDeleted'])
|
|
827
847
|
}
|
|
828
848
|
override async findCommissions(
|
|
829
849
|
args: sdk.FindCommissionsArgs
|
|
830
|
-
): Promise<
|
|
850
|
+
): Promise<TableCommission[]> {
|
|
831
851
|
const q = this.findCommissionsQuery(args)
|
|
832
852
|
const r = await q
|
|
833
853
|
return this.validateEntities(r, undefined, ['isRedeemed'])
|
|
834
854
|
}
|
|
835
855
|
override async findOutputBaskets(
|
|
836
856
|
args: sdk.FindOutputBasketsArgs
|
|
837
|
-
): Promise<
|
|
857
|
+
): Promise<TableOutputBasket[]> {
|
|
838
858
|
const q = this.findOutputBasketsQuery(args)
|
|
839
859
|
const r = await q
|
|
840
860
|
return this.validateEntities(r, undefined, ['isDeleted'])
|
|
841
861
|
}
|
|
842
862
|
override async findOutputs(
|
|
843
863
|
args: sdk.FindOutputsArgs
|
|
844
|
-
): Promise<
|
|
864
|
+
): Promise<TableOutput[]> {
|
|
845
865
|
const q = this.findOutputsQuery(args)
|
|
846
866
|
const r = await q
|
|
847
867
|
if (!args.noScript) {
|
|
@@ -853,42 +873,42 @@ export class StorageKnex
|
|
|
853
873
|
}
|
|
854
874
|
override async findOutputTagMaps(
|
|
855
875
|
args: sdk.FindOutputTagMapsArgs
|
|
856
|
-
): Promise<
|
|
876
|
+
): Promise<TableOutputTagMap[]> {
|
|
857
877
|
const q = this.findOutputTagMapsQuery(args)
|
|
858
878
|
const r = await q
|
|
859
879
|
return this.validateEntities(r, undefined, ['isDeleted'])
|
|
860
880
|
}
|
|
861
881
|
override async findOutputTags(
|
|
862
882
|
args: sdk.FindOutputTagsArgs
|
|
863
|
-
): Promise<
|
|
883
|
+
): Promise<TableOutputTag[]> {
|
|
864
884
|
const q = this.findOutputTagsQuery(args)
|
|
865
885
|
const r = await q
|
|
866
886
|
return this.validateEntities(r, undefined, ['isDeleted'])
|
|
867
887
|
}
|
|
868
888
|
override async findProvenTxReqs(
|
|
869
889
|
args: sdk.FindProvenTxReqsArgs
|
|
870
|
-
): Promise<
|
|
890
|
+
): Promise<TableProvenTxReq[]> {
|
|
871
891
|
const q = this.findProvenTxReqsQuery(args)
|
|
872
892
|
const r = await q
|
|
873
893
|
return this.validateEntities(r, undefined, ['notified'])
|
|
874
894
|
}
|
|
875
895
|
override async findProvenTxs(
|
|
876
896
|
args: sdk.FindProvenTxsArgs
|
|
877
|
-
): Promise<
|
|
897
|
+
): Promise<TableProvenTx[]> {
|
|
878
898
|
const q = this.findProvenTxsQuery(args)
|
|
879
899
|
const r = await q
|
|
880
900
|
return this.validateEntities(r)
|
|
881
901
|
}
|
|
882
902
|
override async findSyncStates(
|
|
883
903
|
args: sdk.FindSyncStatesArgs
|
|
884
|
-
): Promise<
|
|
904
|
+
): Promise<TableSyncState[]> {
|
|
885
905
|
const q = this.findSyncStatesQuery(args)
|
|
886
906
|
const r = await q
|
|
887
907
|
return this.validateEntities(r, ['when'], ['init'])
|
|
888
908
|
}
|
|
889
909
|
override async findTransactions(
|
|
890
910
|
args: sdk.FindTransactionsArgs
|
|
891
|
-
): Promise<
|
|
911
|
+
): Promise<TableTransaction[]> {
|
|
892
912
|
const q = this.findTransactionsQuery(args)
|
|
893
913
|
const r = await q
|
|
894
914
|
if (!args.noRawTx) {
|
|
@@ -900,26 +920,26 @@ export class StorageKnex
|
|
|
900
920
|
}
|
|
901
921
|
override async findTxLabelMaps(
|
|
902
922
|
args: sdk.FindTxLabelMapsArgs
|
|
903
|
-
): Promise<
|
|
923
|
+
): Promise<TableTxLabelMap[]> {
|
|
904
924
|
const q = this.findTxLabelMapsQuery(args)
|
|
905
925
|
const r = await q
|
|
906
926
|
return this.validateEntities(r, undefined, ['isDeleted'])
|
|
907
927
|
}
|
|
908
928
|
override async findTxLabels(
|
|
909
929
|
args: sdk.FindTxLabelsArgs
|
|
910
|
-
): Promise<
|
|
930
|
+
): Promise<TableTxLabel[]> {
|
|
911
931
|
const q = this.findTxLabelsQuery(args)
|
|
912
932
|
const r = await q
|
|
913
933
|
return this.validateEntities(r, undefined, ['isDeleted'])
|
|
914
934
|
}
|
|
915
|
-
override async findUsers(args: sdk.FindUsersArgs): Promise<
|
|
935
|
+
override async findUsers(args: sdk.FindUsersArgs): Promise<TableUser[]> {
|
|
916
936
|
const q = this.findUsersQuery(args)
|
|
917
937
|
const r = await q
|
|
918
938
|
return this.validateEntities(r)
|
|
919
939
|
}
|
|
920
940
|
override async findMonitorEvents(
|
|
921
941
|
args: sdk.FindMonitorEventsArgs
|
|
922
|
-
): Promise<
|
|
942
|
+
): Promise<TableMonitorEvent[]> {
|
|
923
943
|
const q = this.findMonitorEventsQuery(args)
|
|
924
944
|
const r = await q
|
|
925
945
|
return this.validateEntities(r, ['when'], undefined)
|
|
@@ -1062,7 +1082,7 @@ export class StorageKnex
|
|
|
1062
1082
|
}
|
|
1063
1083
|
|
|
1064
1084
|
async validateRawTransaction(
|
|
1065
|
-
t:
|
|
1085
|
+
t: TableTransaction,
|
|
1066
1086
|
trx?: sdk.TrxToken
|
|
1067
1087
|
): Promise<void> {
|
|
1068
1088
|
// if there is no txid or there is a rawTransaction return what we have.
|
|
@@ -1081,7 +1101,7 @@ export class StorageKnex
|
|
|
1081
1101
|
}
|
|
1082
1102
|
|
|
1083
1103
|
async validateOutputScript(
|
|
1084
|
-
o:
|
|
1104
|
+
o: TableOutput,
|
|
1085
1105
|
trx?: sdk.TrxToken
|
|
1086
1106
|
): Promise<void> {
|
|
1087
1107
|
// without offset and length values return what we have (make no changes)
|
|
@@ -1216,9 +1236,9 @@ export class StorageKnex
|
|
|
1216
1236
|
override async getLabelsForTransactionId(
|
|
1217
1237
|
transactionId?: number,
|
|
1218
1238
|
trx?: sdk.TrxToken
|
|
1219
|
-
): Promise<
|
|
1239
|
+
): Promise<TableTxLabel[]> {
|
|
1220
1240
|
if (transactionId === undefined) return []
|
|
1221
|
-
const labels = await this.toDb(trx)<
|
|
1241
|
+
const labels = await this.toDb(trx)<TableTxLabel>('tx_labels')
|
|
1222
1242
|
.join('tx_labels_map', 'tx_labels_map.txLabelId', 'tx_labels.txLabelId')
|
|
1223
1243
|
.where('tx_labels_map.transactionId', transactionId)
|
|
1224
1244
|
.whereNot('tx_labels_map.isDeleted', true)
|
|
@@ -1227,12 +1247,12 @@ export class StorageKnex
|
|
|
1227
1247
|
}
|
|
1228
1248
|
|
|
1229
1249
|
async extendOutput(
|
|
1230
|
-
o:
|
|
1250
|
+
o: TableOutput,
|
|
1231
1251
|
includeBasket = false,
|
|
1232
1252
|
includeTags = false,
|
|
1233
1253
|
trx?: sdk.TrxToken
|
|
1234
|
-
): Promise<
|
|
1235
|
-
const ox = o as
|
|
1254
|
+
): Promise<TableOutputX> {
|
|
1255
|
+
const ox = o as TableOutputX
|
|
1236
1256
|
if (includeBasket && ox.basketId)
|
|
1237
1257
|
ox.basket = await this.findOutputBasketById(o.basketId!, trx)
|
|
1238
1258
|
if (includeTags) {
|
|
@@ -1244,8 +1264,8 @@ export class StorageKnex
|
|
|
1244
1264
|
override async getTagsForOutputId(
|
|
1245
1265
|
outputId: number,
|
|
1246
1266
|
trx?: sdk.TrxToken
|
|
1247
|
-
): Promise<
|
|
1248
|
-
const tags = await this.toDb(trx)<
|
|
1267
|
+
): Promise<TableOutputTag[]> {
|
|
1268
|
+
const tags = await this.toDb(trx)<TableOutputTag>('output_tags')
|
|
1249
1269
|
.join(
|
|
1250
1270
|
'output_tags_map',
|
|
1251
1271
|
'output_tags_map.outputTagId',
|
|
@@ -1285,7 +1305,7 @@ export class StorageKnex
|
|
|
1285
1305
|
if (!excludeSending) status.push('sending')
|
|
1286
1306
|
const statusText = status.map(s => `'${s}'`).join(',')
|
|
1287
1307
|
const txStatusCondition = `(SELECT status FROM transactions WHERE outputs.transactionId = transactions.transactionId) in (${statusText})`
|
|
1288
|
-
let q = this.knex<
|
|
1308
|
+
let q = this.knex<TableOutput>('outputs')
|
|
1289
1309
|
.where({ userId, spendable: true, basketId })
|
|
1290
1310
|
.whereRaw(txStatusCondition)
|
|
1291
1311
|
const count = await this.getCount(q)
|
|
@@ -1304,12 +1324,12 @@ export class StorageKnex
|
|
|
1304
1324
|
exactSatoshis: number | undefined,
|
|
1305
1325
|
excludeSending: boolean,
|
|
1306
1326
|
transactionId: number
|
|
1307
|
-
): Promise<
|
|
1327
|
+
): Promise<TableOutput | undefined> {
|
|
1308
1328
|
const status: sdk.TransactionStatus[] = ['completed', 'unproven']
|
|
1309
1329
|
if (!excludeSending) status.push('sending')
|
|
1310
1330
|
const statusText = status.map(s => `'${s}'`).join(',')
|
|
1311
1331
|
|
|
1312
|
-
const r:
|
|
1332
|
+
const r: TableOutput | undefined = await this.knex.transaction(
|
|
1313
1333
|
async trx => {
|
|
1314
1334
|
const txStatusCondition = `AND (SELECT status FROM transactions WHERE outputs.transactionId = transactions.transactionId) in (${statusText})`
|
|
1315
1335
|
|