@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
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
asArray,
|
|
10
10
|
asString,
|
|
11
|
-
|
|
11
|
+
EntityProvenTxReq,
|
|
12
12
|
parseTxScriptOffsets,
|
|
13
13
|
randomBytesBase64,
|
|
14
14
|
sdk,
|
|
@@ -16,7 +16,11 @@ import {
|
|
|
16
16
|
stampLog,
|
|
17
17
|
stampLogFormat,
|
|
18
18
|
StorageProvider,
|
|
19
|
-
|
|
19
|
+
TableCommission,
|
|
20
|
+
TableOutput,
|
|
21
|
+
TableProvenTx,
|
|
22
|
+
TableProvenTxReq,
|
|
23
|
+
TableTransaction,
|
|
20
24
|
TxScriptOffsets,
|
|
21
25
|
validateStorageFeeModel,
|
|
22
26
|
verifyId,
|
|
@@ -38,7 +42,7 @@ export async function processAction(
|
|
|
38
42
|
sendWithResults: undefined
|
|
39
43
|
}
|
|
40
44
|
|
|
41
|
-
let req:
|
|
45
|
+
let req: EntityProvenTxReq | undefined
|
|
42
46
|
const txidsOfReqsToShareWithWorld: string[] = [...args.sendWith]
|
|
43
47
|
|
|
44
48
|
if (args.isNewTx) {
|
|
@@ -109,7 +113,7 @@ async function shareReqsWithWorld(
|
|
|
109
113
|
// Filter original txids down to reqIds that are available and need sending
|
|
110
114
|
const readyToSendReqs = r.details
|
|
111
115
|
.filter(d => d.status === 'readyToSend')
|
|
112
|
-
.map(d => new
|
|
116
|
+
.map(d => new EntityProvenTxReq(d.req!))
|
|
113
117
|
const readyToSendReqIds = readyToSendReqs.map(r => r.id)
|
|
114
118
|
const transactionIds = readyToSendReqs
|
|
115
119
|
.map(r => r.notify.transactionIds || [])
|
|
@@ -213,15 +217,15 @@ interface ValidCommitNewTxToStorageArgs {
|
|
|
213
217
|
tx: BsvTransaction
|
|
214
218
|
txScriptOffsets: TxScriptOffsets
|
|
215
219
|
transactionId: number
|
|
216
|
-
transaction:
|
|
217
|
-
inputOutputs:
|
|
218
|
-
outputOutputs:
|
|
219
|
-
commission:
|
|
220
|
+
transaction: TableTransaction
|
|
221
|
+
inputOutputs: TableOutput[]
|
|
222
|
+
outputOutputs: TableOutput[]
|
|
223
|
+
commission: TableCommission | undefined
|
|
220
224
|
beef: Beef
|
|
221
225
|
|
|
222
|
-
req:
|
|
223
|
-
outputUpdates: { id: number; update: Partial<
|
|
224
|
-
transactionUpdate: Partial<
|
|
226
|
+
req: EntityProvenTxReq
|
|
227
|
+
outputUpdates: { id: number; update: Partial<TableOutput> }[]
|
|
228
|
+
transactionUpdate: Partial<TableTransaction>
|
|
225
229
|
postStatus?: ReqTxStatus
|
|
226
230
|
}
|
|
227
231
|
|
|
@@ -292,7 +296,7 @@ async function validateCommitNewTxToStorageArgs(
|
|
|
292
296
|
)
|
|
293
297
|
}
|
|
294
298
|
|
|
295
|
-
const req =
|
|
299
|
+
const req = EntityProvenTxReq.fromTxid(
|
|
296
300
|
params.txid,
|
|
297
301
|
params.rawTx,
|
|
298
302
|
transaction.inputBEEF
|
|
@@ -368,7 +372,7 @@ async function validateCommitNewTxToStorageArgs(
|
|
|
368
372
|
throw new sdk.WERR_INVALID_OPERATION(
|
|
369
373
|
`parsed transaction output locking script for vout ${vout} not equal to expected output script.`
|
|
370
374
|
)
|
|
371
|
-
const update: Partial<
|
|
375
|
+
const update: Partial<TableOutput> = {
|
|
372
376
|
txid: vargs.txid,
|
|
373
377
|
spendable: true, // spendability is gated by transaction status. Remains true until the output is spent.
|
|
374
378
|
scriptLength: offset.length,
|
|
@@ -384,7 +388,7 @@ async function validateCommitNewTxToStorageArgs(
|
|
|
384
388
|
}
|
|
385
389
|
|
|
386
390
|
export interface CommitNewTxResults {
|
|
387
|
-
req:
|
|
391
|
+
req: EntityProvenTxReq
|
|
388
392
|
log?: string
|
|
389
393
|
}
|
|
390
394
|
|
|
@@ -397,7 +401,7 @@ async function commitNewTxToStorage(
|
|
|
397
401
|
|
|
398
402
|
log = stampLog(log, `start storage commitNewTxToStorage`)
|
|
399
403
|
|
|
400
|
-
let req:
|
|
404
|
+
let req: EntityProvenTxReq | undefined
|
|
401
405
|
|
|
402
406
|
await storage.transaction(async trx => {
|
|
403
407
|
log = stampLog(
|
|
@@ -445,8 +449,8 @@ async function commitNewTxToStorage(
|
|
|
445
449
|
|
|
446
450
|
export interface GetReqsAndBeefDetail {
|
|
447
451
|
txid: string
|
|
448
|
-
req?:
|
|
449
|
-
proven?:
|
|
452
|
+
req?: TableProvenTxReq
|
|
453
|
+
proven?: TableProvenTx
|
|
450
454
|
status: 'readyToSend' | 'alreadySent' | 'error' | 'unknown'
|
|
451
455
|
error?: string
|
|
452
456
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Beef } from '@bsv/sdk'
|
|
2
2
|
import { Knex } from 'knex'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
TableCommission,
|
|
5
|
+
TableOutput,
|
|
6
|
+
TableOutputTagMap,
|
|
7
|
+
TableTransaction,
|
|
8
|
+
TableTxLabelMap
|
|
9
|
+
} from '../index.client'
|
|
4
10
|
import { sdk } from '../../index.client'
|
|
5
11
|
import { StorageKnex } from '../StorageKnex'
|
|
6
12
|
|
|
@@ -148,25 +154,25 @@ export async function purgeData(
|
|
|
148
154
|
let qs: PurgeQuery[] = []
|
|
149
155
|
|
|
150
156
|
const spentTxsQ = storage
|
|
151
|
-
.toDb(trx)<
|
|
157
|
+
.toDb(trx)<TableTransaction>('transactions')
|
|
152
158
|
.where('updated_at', '<', before)
|
|
153
159
|
.where('status', 'completed')
|
|
154
160
|
.whereRaw(
|
|
155
161
|
`not exists(select outputId from outputs as o where o.transactionId = transactions.transactionId and o.spendable = 1)`
|
|
156
162
|
)
|
|
157
|
-
const txs:
|
|
163
|
+
const txs: TableTransaction[] = await spentTxsQ
|
|
158
164
|
// Save any spent txid still needed to prove a utxo:
|
|
159
165
|
const nptxs = txs.filter(t => !proofTxids[t.txid || ''])
|
|
160
166
|
let spentTxIds = nptxs.map(tx => tx.transactionId)
|
|
161
167
|
|
|
162
168
|
if (spentTxIds.length > 0) {
|
|
163
|
-
const update: Partial<
|
|
169
|
+
const update: Partial<TableOutput> = {
|
|
164
170
|
spentBy: null as unknown as undefined
|
|
165
171
|
}
|
|
166
172
|
qs.push({
|
|
167
173
|
log: 'spent outputs no longer tracked by spentBy',
|
|
168
174
|
q: storage
|
|
169
|
-
.toDb(trx)<
|
|
175
|
+
.toDb(trx)<TableOutput>('outputs')
|
|
170
176
|
.update(
|
|
171
177
|
storage.validatePartialForUpdate(update, undefined, ['spendable'])
|
|
172
178
|
)
|
|
@@ -214,14 +220,14 @@ export async function purgeData(
|
|
|
214
220
|
qs.push({
|
|
215
221
|
log: `${reason} output_tags_map deleted`,
|
|
216
222
|
q: storage
|
|
217
|
-
.toDb(trx)<
|
|
223
|
+
.toDb(trx)<TableOutputTagMap>('output_tags_map')
|
|
218
224
|
.whereIn('outputId', outputIds)
|
|
219
225
|
.delete()
|
|
220
226
|
})
|
|
221
227
|
qs.push({
|
|
222
228
|
log: `${reason} outputs deleted`,
|
|
223
229
|
q: storage
|
|
224
|
-
.toDb(trx)<
|
|
230
|
+
.toDb(trx)<TableOutput>('outputs')
|
|
225
231
|
.whereIn('outputId', outputIds)
|
|
226
232
|
.delete()
|
|
227
233
|
})
|
|
@@ -230,7 +236,7 @@ export async function purgeData(
|
|
|
230
236
|
qs.push({
|
|
231
237
|
log: `${reason} tx_labels_map deleted`,
|
|
232
238
|
q: storage
|
|
233
|
-
.toDb(trx)<
|
|
239
|
+
.toDb(trx)<TableTxLabelMap>('tx_labels_map')
|
|
234
240
|
.whereIn('transactionId', transactionIds)
|
|
235
241
|
.delete()
|
|
236
242
|
})
|
|
@@ -238,7 +244,7 @@ export async function purgeData(
|
|
|
238
244
|
qs.push({
|
|
239
245
|
log: `${reason} commissions deleted`,
|
|
240
246
|
q: storage
|
|
241
|
-
.toDb(trx)<
|
|
247
|
+
.toDb(trx)<TableCommission>('commissions')
|
|
242
248
|
.whereIn('transactionId', transactionIds)
|
|
243
249
|
.delete()
|
|
244
250
|
})
|
|
@@ -247,7 +253,7 @@ export async function purgeData(
|
|
|
247
253
|
qs.push({
|
|
248
254
|
log: 'unspent outputs updated to spendable',
|
|
249
255
|
q: storage
|
|
250
|
-
.toDb(trx)<
|
|
256
|
+
.toDb(trx)<TableOutput>('outputs')
|
|
251
257
|
.update({ spendable: true, spentBy: null as unknown as undefined })
|
|
252
258
|
.whereIn('spentBy', transactionIds)
|
|
253
259
|
})
|
|
@@ -256,7 +262,7 @@ export async function purgeData(
|
|
|
256
262
|
qs.push({
|
|
257
263
|
log: `${reason} transactions deleted`,
|
|
258
264
|
q: storage
|
|
259
|
-
.toDb(trx)<
|
|
265
|
+
.toDb(trx)<TableTransaction>('transactions')
|
|
260
266
|
.whereIn('transactionId', transactionIds)
|
|
261
267
|
.delete()
|
|
262
268
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Beef } from '@bsv/sdk'
|
|
2
2
|
import { Knex } from 'knex'
|
|
3
|
-
import {
|
|
3
|
+
import { TableOutput, TableTransaction } from '../index.client'
|
|
4
4
|
import { sdk } from '../../index.client'
|
|
5
5
|
import { StorageKnex } from '../StorageKnex'
|
|
6
6
|
|
|
@@ -36,7 +36,7 @@ export async function reviewStatus(
|
|
|
36
36
|
UPDATE transactions SET status = 'failed'
|
|
37
37
|
WHERE exists(select 1 from proven_tx_reqs as r where transactions.txid = r.txid and r.status = 'invalid')
|
|
38
38
|
*/
|
|
39
|
-
q: k<
|
|
39
|
+
q: k<TableTransaction>('transactions')
|
|
40
40
|
.update({ status: 'failed' })
|
|
41
41
|
.whereNot({ status: 'failed' })
|
|
42
42
|
.whereExists(function () {
|
|
@@ -52,7 +52,7 @@ export async function reviewStatus(
|
|
|
52
52
|
UPDATE outputs SET spentBy = null, spendable = 1
|
|
53
53
|
where exists(select 1 from transactions as t where outputs.spentBy = t.transactionId and t.status = 'failed')
|
|
54
54
|
*/
|
|
55
|
-
q: k<
|
|
55
|
+
q: k<TableOutput>('outputs')
|
|
56
56
|
.update({ spentBy: null as unknown as undefined, spendable: true })
|
|
57
57
|
.whereExists(function () {
|
|
58
58
|
this.select(k.raw(1))
|
|
@@ -68,7 +68,7 @@ export async function reviewStatus(
|
|
|
68
68
|
FROM proven_txs p
|
|
69
69
|
WHERE transactions.txid = p.txid AND transactions.provenTxId IS NULL
|
|
70
70
|
*/
|
|
71
|
-
q: k<
|
|
71
|
+
q: k<TableTransaction>('transactions')
|
|
72
72
|
.update({
|
|
73
73
|
status: 'completed',
|
|
74
74
|
provenTxId: k.raw(
|
|
@@ -17,7 +17,17 @@ import {
|
|
|
17
17
|
RelinquishOutputArgs,
|
|
18
18
|
WalletInterface
|
|
19
19
|
} from '@bsv/sdk'
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
sdk,
|
|
22
|
+
TableCertificate,
|
|
23
|
+
TableCertificateX,
|
|
24
|
+
TableOutput,
|
|
25
|
+
TableOutputBasket,
|
|
26
|
+
TableProvenTxReq,
|
|
27
|
+
TableSettings,
|
|
28
|
+
TableSyncState,
|
|
29
|
+
TableUser
|
|
30
|
+
} from '../../index.client'
|
|
21
31
|
import { AuthFetch } from '@bsv/sdk'
|
|
22
32
|
|
|
23
33
|
export class StorageClient implements sdk.WalletStorageProvider {
|
|
@@ -26,7 +36,7 @@ export class StorageClient implements sdk.WalletStorageProvider {
|
|
|
26
36
|
private authClient: AuthFetch
|
|
27
37
|
|
|
28
38
|
// Track ephemeral (in-memory) "settings" if you wish to align with isAvailable() checks
|
|
29
|
-
public settings?:
|
|
39
|
+
public settings?: TableSettings
|
|
30
40
|
|
|
31
41
|
constructor(wallet: WalletInterface, endpointUrl: string) {
|
|
32
42
|
this.authClient = new AuthFetch(wallet)
|
|
@@ -91,7 +101,7 @@ export class StorageClient implements sdk.WalletStorageProvider {
|
|
|
91
101
|
return !!this.settings
|
|
92
102
|
}
|
|
93
103
|
|
|
94
|
-
getSettings():
|
|
104
|
+
getSettings(): TableSettings {
|
|
95
105
|
if (!this.settings) {
|
|
96
106
|
throw new sdk.WERR_INVALID_OPERATION(
|
|
97
107
|
'call makeAvailable at least once before getSettings'
|
|
@@ -100,9 +110,9 @@ export class StorageClient implements sdk.WalletStorageProvider {
|
|
|
100
110
|
return this.settings
|
|
101
111
|
}
|
|
102
112
|
|
|
103
|
-
async makeAvailable(): Promise<
|
|
113
|
+
async makeAvailable(): Promise<TableSettings> {
|
|
104
114
|
if (!this.settings) {
|
|
105
|
-
this.settings = await this.rpcCall<
|
|
115
|
+
this.settings = await this.rpcCall<TableSettings>('makeAvailable', [])
|
|
106
116
|
}
|
|
107
117
|
return this.settings
|
|
108
118
|
}
|
|
@@ -178,8 +188,8 @@ export class StorageClient implements sdk.WalletStorageProvider {
|
|
|
178
188
|
|
|
179
189
|
async findOrInsertUser(
|
|
180
190
|
identityKey
|
|
181
|
-
): Promise<{ user:
|
|
182
|
-
return this.rpcCall<{ user:
|
|
191
|
+
): Promise<{ user: TableUser; isNew: boolean }> {
|
|
192
|
+
return this.rpcCall<{ user: TableUser; isNew: boolean }>(
|
|
183
193
|
'findOrInsertUser',
|
|
184
194
|
[identityKey]
|
|
185
195
|
)
|
|
@@ -189,8 +199,8 @@ export class StorageClient implements sdk.WalletStorageProvider {
|
|
|
189
199
|
auth: sdk.AuthId,
|
|
190
200
|
storageIdentityKey: string,
|
|
191
201
|
storageName: string
|
|
192
|
-
): Promise<{ syncState:
|
|
193
|
-
return this.rpcCall<{ syncState:
|
|
202
|
+
): Promise<{ syncState: TableSyncState; isNew: boolean }> {
|
|
203
|
+
return this.rpcCall<{ syncState: TableSyncState; isNew: boolean }>(
|
|
194
204
|
'findOrInsertSyncStateAuth',
|
|
195
205
|
[auth, storageIdentityKey, storageName]
|
|
196
206
|
)
|
|
@@ -198,7 +208,7 @@ export class StorageClient implements sdk.WalletStorageProvider {
|
|
|
198
208
|
|
|
199
209
|
async insertCertificateAuth(
|
|
200
210
|
auth: sdk.AuthId,
|
|
201
|
-
certificate:
|
|
211
|
+
certificate: TableCertificateX
|
|
202
212
|
): Promise<number> {
|
|
203
213
|
return this.rpcCall<number>('insertCertificateAuth', [auth, certificate])
|
|
204
214
|
}
|
|
@@ -230,8 +240,8 @@ export class StorageClient implements sdk.WalletStorageProvider {
|
|
|
230
240
|
async findCertificatesAuth(
|
|
231
241
|
auth: sdk.AuthId,
|
|
232
242
|
args: sdk.FindCertificatesArgs
|
|
233
|
-
): Promise<
|
|
234
|
-
return this.rpcCall<
|
|
243
|
+
): Promise<TableCertificate[]> {
|
|
244
|
+
return this.rpcCall<TableCertificate[]>('findCertificatesAuth', [
|
|
235
245
|
auth,
|
|
236
246
|
args
|
|
237
247
|
])
|
|
@@ -240,21 +250,21 @@ export class StorageClient implements sdk.WalletStorageProvider {
|
|
|
240
250
|
async findOutputBasketsAuth(
|
|
241
251
|
auth: sdk.AuthId,
|
|
242
252
|
args: sdk.FindOutputBasketsArgs
|
|
243
|
-
): Promise<
|
|
244
|
-
return this.rpcCall<
|
|
253
|
+
): Promise<TableOutputBasket[]> {
|
|
254
|
+
return this.rpcCall<TableOutputBasket[]>('findOutputBaskets', [auth, args])
|
|
245
255
|
}
|
|
246
256
|
|
|
247
257
|
async findOutputsAuth(
|
|
248
258
|
auth: sdk.AuthId,
|
|
249
259
|
args: sdk.FindOutputsArgs
|
|
250
|
-
): Promise<
|
|
251
|
-
return this.rpcCall<
|
|
260
|
+
): Promise<TableOutput[]> {
|
|
261
|
+
return this.rpcCall<TableOutput[]>('findOutputsAuth', [auth, args])
|
|
252
262
|
}
|
|
253
263
|
|
|
254
264
|
findProvenTxReqs(
|
|
255
265
|
args: sdk.FindProvenTxReqsArgs
|
|
256
|
-
): Promise<
|
|
257
|
-
return this.rpcCall<
|
|
266
|
+
): Promise<TableProvenTxReq[]> {
|
|
267
|
+
return this.rpcCall<TableProvenTxReq[]>('findProvenTxReqs', [args])
|
|
258
268
|
}
|
|
259
269
|
|
|
260
270
|
async relinquishCertificate(
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
import { MerklePath } from '@bsv/sdk'
|
|
3
3
|
import {
|
|
4
4
|
arraysEqual,
|
|
5
|
-
entity,
|
|
6
5
|
sdk,
|
|
7
|
-
|
|
6
|
+
TableCertificate,
|
|
8
7
|
verifyId,
|
|
9
8
|
verifyOneOrNone
|
|
10
9
|
} from '../../../index.client'
|
|
11
|
-
import { EntityBase } from '.'
|
|
10
|
+
import { EntityBase, EntityStorage, SyncMap } from '.'
|
|
12
11
|
|
|
13
|
-
export class
|
|
14
|
-
constructor(api?:
|
|
12
|
+
export class EntityCertificate extends EntityBase<TableCertificate> {
|
|
13
|
+
constructor(api?: TableCertificate) {
|
|
15
14
|
const now = new Date()
|
|
16
15
|
super(
|
|
17
16
|
api || {
|
|
@@ -118,13 +117,13 @@ export class Certificate extends EntityBase<table.Certificate> {
|
|
|
118
117
|
this.api.certificateId = v
|
|
119
118
|
}
|
|
120
119
|
override get entityName(): string {
|
|
121
|
-
return '
|
|
120
|
+
return 'certificate'
|
|
122
121
|
}
|
|
123
122
|
override get entityTable(): string {
|
|
124
123
|
return 'certificates'
|
|
125
124
|
}
|
|
126
125
|
|
|
127
|
-
override equals(ei:
|
|
126
|
+
override equals(ei: TableCertificate, syncMap?: SyncMap): boolean {
|
|
128
127
|
if (
|
|
129
128
|
this.type !== ei.type ||
|
|
130
129
|
this.subject !== ei.subject ||
|
|
@@ -140,12 +139,12 @@ export class Certificate extends EntityBase<table.Certificate> {
|
|
|
140
139
|
}
|
|
141
140
|
|
|
142
141
|
static async mergeFind(
|
|
143
|
-
storage:
|
|
142
|
+
storage: EntityStorage,
|
|
144
143
|
userId: number,
|
|
145
|
-
ei:
|
|
146
|
-
syncMap:
|
|
144
|
+
ei: TableCertificate,
|
|
145
|
+
syncMap: SyncMap,
|
|
147
146
|
trx?: sdk.TrxToken
|
|
148
|
-
): Promise<{ found: boolean; eo:
|
|
147
|
+
): Promise<{ found: boolean; eo: EntityCertificate; eiId: number }> {
|
|
149
148
|
const ef = verifyOneOrNone(
|
|
150
149
|
await storage.findCertificates({
|
|
151
150
|
partial: {
|
|
@@ -158,15 +157,15 @@ export class Certificate extends EntityBase<table.Certificate> {
|
|
|
158
157
|
)
|
|
159
158
|
return {
|
|
160
159
|
found: !!ef,
|
|
161
|
-
eo: new
|
|
160
|
+
eo: new EntityCertificate(ef || { ...ei }),
|
|
162
161
|
eiId: verifyId(ei.certificateId)
|
|
163
162
|
}
|
|
164
163
|
}
|
|
165
164
|
|
|
166
165
|
override async mergeNew(
|
|
167
|
-
storage:
|
|
166
|
+
storage: EntityStorage,
|
|
168
167
|
userId: number,
|
|
169
|
-
syncMap:
|
|
168
|
+
syncMap: SyncMap,
|
|
170
169
|
trx?: sdk.TrxToken
|
|
171
170
|
): Promise<void> {
|
|
172
171
|
this.userId = userId
|
|
@@ -175,10 +174,10 @@ export class Certificate extends EntityBase<table.Certificate> {
|
|
|
175
174
|
}
|
|
176
175
|
|
|
177
176
|
override async mergeExisting(
|
|
178
|
-
storage:
|
|
177
|
+
storage: EntityStorage,
|
|
179
178
|
since: Date | undefined,
|
|
180
|
-
ei:
|
|
181
|
-
syncMap:
|
|
179
|
+
ei: TableCertificate,
|
|
180
|
+
syncMap: SyncMap,
|
|
182
181
|
trx?: sdk.TrxToken
|
|
183
182
|
): Promise<boolean> {
|
|
184
183
|
let wasMerged = false
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { MerklePath } from '@bsv/sdk'
|
|
2
2
|
import {
|
|
3
3
|
arraysEqual,
|
|
4
|
-
entity,
|
|
5
4
|
sdk,
|
|
6
|
-
|
|
5
|
+
TableCertificateField,
|
|
7
6
|
verifyId,
|
|
8
7
|
verifyOneOrNone
|
|
9
8
|
} from '../../../index.client'
|
|
10
|
-
import { EntityBase } from '.'
|
|
9
|
+
import { EntityBase, EntityStorage, SyncMap } from '.'
|
|
11
10
|
|
|
12
|
-
export class
|
|
13
|
-
constructor(api?:
|
|
11
|
+
export class EntityCertificateField extends EntityBase<TableCertificateField> {
|
|
12
|
+
constructor(api?: TableCertificateField) {
|
|
14
13
|
const now = new Date()
|
|
15
14
|
super(
|
|
16
15
|
api || {
|
|
@@ -76,15 +75,15 @@ export class CertificateField extends EntityBase<table.CertificateField> {
|
|
|
76
75
|
throw new sdk.WERR_INVALID_OPERATION('entity has no "id" value')
|
|
77
76
|
}
|
|
78
77
|
override get entityName(): string {
|
|
79
|
-
return '
|
|
78
|
+
return 'certificateField'
|
|
80
79
|
}
|
|
81
80
|
override get entityTable(): string {
|
|
82
81
|
return 'certificate_fields'
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
override equals(
|
|
86
|
-
ei:
|
|
87
|
-
syncMap?:
|
|
85
|
+
ei: TableCertificateField,
|
|
86
|
+
syncMap?: SyncMap | undefined
|
|
88
87
|
): boolean {
|
|
89
88
|
if (
|
|
90
89
|
this.certificateId !==
|
|
@@ -101,12 +100,12 @@ export class CertificateField extends EntityBase<table.CertificateField> {
|
|
|
101
100
|
}
|
|
102
101
|
|
|
103
102
|
static async mergeFind(
|
|
104
|
-
storage:
|
|
103
|
+
storage: EntityStorage,
|
|
105
104
|
userId: number,
|
|
106
|
-
ei:
|
|
107
|
-
syncMap:
|
|
105
|
+
ei: TableCertificateField,
|
|
106
|
+
syncMap: SyncMap,
|
|
108
107
|
trx?: sdk.TrxToken
|
|
109
|
-
): Promise<{ found: boolean; eo:
|
|
108
|
+
): Promise<{ found: boolean; eo: EntityCertificateField; eiId: number }> {
|
|
110
109
|
const certificateId = syncMap.certificate.idMap[ei.certificateId]
|
|
111
110
|
const ef = verifyOneOrNone(
|
|
112
111
|
await storage.findCertificateFields({
|
|
@@ -116,15 +115,15 @@ export class CertificateField extends EntityBase<table.CertificateField> {
|
|
|
116
115
|
)
|
|
117
116
|
return {
|
|
118
117
|
found: !!ef,
|
|
119
|
-
eo: new
|
|
118
|
+
eo: new EntityCertificateField(ef || { ...ei }),
|
|
120
119
|
eiId: -1
|
|
121
120
|
}
|
|
122
121
|
}
|
|
123
122
|
|
|
124
123
|
override async mergeNew(
|
|
125
|
-
storage:
|
|
124
|
+
storage: EntityStorage,
|
|
126
125
|
userId: number,
|
|
127
|
-
syncMap:
|
|
126
|
+
syncMap: SyncMap,
|
|
128
127
|
trx?: sdk.TrxToken
|
|
129
128
|
): Promise<void> {
|
|
130
129
|
this.certificateId = syncMap.certificate.idMap[this.certificateId]
|
|
@@ -133,10 +132,10 @@ export class CertificateField extends EntityBase<table.CertificateField> {
|
|
|
133
132
|
}
|
|
134
133
|
|
|
135
134
|
override async mergeExisting(
|
|
136
|
-
storage:
|
|
135
|
+
storage: EntityStorage,
|
|
137
136
|
since: Date | undefined,
|
|
138
|
-
ei:
|
|
139
|
-
syncMap:
|
|
137
|
+
ei: TableCertificateField,
|
|
138
|
+
syncMap: SyncMap,
|
|
140
139
|
trx?: sdk.TrxToken
|
|
141
140
|
): Promise<boolean> {
|
|
142
141
|
let wasMerged = false
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
import { MerklePath } from '@bsv/sdk'
|
|
3
3
|
import {
|
|
4
4
|
arraysEqual,
|
|
5
|
-
entity,
|
|
6
5
|
sdk,
|
|
7
|
-
|
|
6
|
+
TableCommission,
|
|
8
7
|
verifyId,
|
|
9
8
|
verifyOneOrNone
|
|
10
9
|
} from '../../../index.client'
|
|
11
|
-
import { EntityBase } from '.'
|
|
10
|
+
import { EntityBase, EntityStorage, SyncMap } from '.'
|
|
12
11
|
|
|
13
|
-
export class
|
|
14
|
-
constructor(api?:
|
|
12
|
+
export class EntityCommission extends EntityBase<TableCommission> {
|
|
13
|
+
constructor(api?: TableCommission) {
|
|
15
14
|
const now = new Date()
|
|
16
15
|
super(
|
|
17
16
|
api || {
|
|
@@ -94,16 +93,13 @@ export class Commission extends EntityBase<table.Commission> {
|
|
|
94
93
|
this.api.commissionId = v
|
|
95
94
|
}
|
|
96
95
|
override get entityName(): string {
|
|
97
|
-
return '
|
|
96
|
+
return 'commission'
|
|
98
97
|
}
|
|
99
98
|
override get entityTable(): string {
|
|
100
99
|
return 'commissions'
|
|
101
100
|
}
|
|
102
101
|
|
|
103
|
-
override equals(
|
|
104
|
-
ei: table.Commission,
|
|
105
|
-
syncMap?: entity.SyncMap | undefined
|
|
106
|
-
): boolean {
|
|
102
|
+
override equals(ei: TableCommission, syncMap?: SyncMap | undefined): boolean {
|
|
107
103
|
if (
|
|
108
104
|
this.isRedeemed !== ei.isRedeemed ||
|
|
109
105
|
this.transactionId !==
|
|
@@ -120,27 +116,27 @@ export class Commission extends EntityBase<table.Commission> {
|
|
|
120
116
|
}
|
|
121
117
|
|
|
122
118
|
static async mergeFind(
|
|
123
|
-
storage:
|
|
119
|
+
storage: EntityStorage,
|
|
124
120
|
userId: number,
|
|
125
|
-
ei:
|
|
126
|
-
syncMap:
|
|
121
|
+
ei: TableCommission,
|
|
122
|
+
syncMap: SyncMap,
|
|
127
123
|
trx?: sdk.TrxToken
|
|
128
|
-
): Promise<{ found: boolean; eo:
|
|
124
|
+
): Promise<{ found: boolean; eo: EntityCommission; eiId: number }> {
|
|
129
125
|
const transactionId = syncMap.transaction.idMap[ei.transactionId]
|
|
130
126
|
const ef = verifyOneOrNone(
|
|
131
127
|
await storage.findCommissions({ partial: { transactionId, userId }, trx })
|
|
132
128
|
)
|
|
133
129
|
return {
|
|
134
130
|
found: !!ef,
|
|
135
|
-
eo: new
|
|
131
|
+
eo: new EntityCommission(ef || { ...ei }),
|
|
136
132
|
eiId: verifyId(ei.commissionId)
|
|
137
133
|
}
|
|
138
134
|
}
|
|
139
135
|
|
|
140
136
|
override async mergeNew(
|
|
141
|
-
storage:
|
|
137
|
+
storage: EntityStorage,
|
|
142
138
|
userId: number,
|
|
143
|
-
syncMap:
|
|
139
|
+
syncMap: SyncMap,
|
|
144
140
|
trx?: sdk.TrxToken
|
|
145
141
|
): Promise<void> {
|
|
146
142
|
if (this.transactionId)
|
|
@@ -151,10 +147,10 @@ export class Commission extends EntityBase<table.Commission> {
|
|
|
151
147
|
}
|
|
152
148
|
|
|
153
149
|
override async mergeExisting(
|
|
154
|
-
storage:
|
|
150
|
+
storage: EntityStorage,
|
|
155
151
|
since: Date | undefined,
|
|
156
|
-
ei:
|
|
157
|
-
syncMap:
|
|
152
|
+
ei: TableCommission,
|
|
153
|
+
syncMap: SyncMap,
|
|
158
154
|
trx?: sdk.TrxToken
|
|
159
155
|
): Promise<boolean> {
|
|
160
156
|
let wasMerged = false
|
|
@@ -62,7 +62,7 @@ export abstract class EntityBase<T> {
|
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* Perform a 'merge' / 'convergent' equality migration of state
|
|
65
|
-
* from external `ei` to this existing local
|
|
65
|
+
* from external `ei` to this existing local EntityUser
|
|
66
66
|
*
|
|
67
67
|
* @param ei
|
|
68
68
|
* @param syncMap
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {} from '../../index.client'
|
|
2
2
|
import { maxDate, sdk, verifyId } from '../../../index.client'
|
|
3
|
-
import { EntityBase } from './EntityBase'
|
|
3
|
+
import { EntityBase, EntityStorage, EntitySyncMap, SyncMap } from './EntityBase'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @param API one of the storage table interfaces.
|
|
@@ -15,14 +15,14 @@ export class MergeEntity<
|
|
|
15
15
|
constructor(
|
|
16
16
|
public stateArray: API[] | undefined,
|
|
17
17
|
public find: (
|
|
18
|
-
storage:
|
|
18
|
+
storage: EntityStorage,
|
|
19
19
|
userId: number,
|
|
20
20
|
ei: API,
|
|
21
|
-
syncMap:
|
|
21
|
+
syncMap: SyncMap,
|
|
22
22
|
trx?: sdk.TrxToken
|
|
23
23
|
) => Promise<{ found: boolean; eo: DE; eiId: number }>,
|
|
24
24
|
/** id map for primary id of API and DE object. */
|
|
25
|
-
public esm:
|
|
25
|
+
public esm: EntitySyncMap
|
|
26
26
|
) {
|
|
27
27
|
this.idMap = esm.idMap
|
|
28
28
|
}
|
|
@@ -43,9 +43,9 @@ export class MergeEntity<
|
|
|
43
43
|
*/
|
|
44
44
|
async merge(
|
|
45
45
|
since: Date | undefined,
|
|
46
|
-
storage:
|
|
46
|
+
storage: EntityStorage,
|
|
47
47
|
userId: number,
|
|
48
|
-
syncMap:
|
|
48
|
+
syncMap: SyncMap,
|
|
49
49
|
trx?: sdk.TrxToken
|
|
50
50
|
): Promise<{ inserts: number; updates: number }> {
|
|
51
51
|
let inserts = 0,
|