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