@bsv/wallet-toolbox-client 2.1.23 → 2.1.25
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/out/src/CWIStyleWalletManager.d.ts +33 -7
- package/out/src/CWIStyleWalletManager.d.ts.map +1 -1
- package/out/src/CWIStyleWalletManager.js +281 -313
- package/out/src/CWIStyleWalletManager.js.map +1 -1
- package/out/src/SetupClient.d.ts +6 -6
- package/out/src/SetupClient.d.ts.map +1 -1
- package/out/src/SetupClient.js +5 -5
- package/out/src/SetupClient.js.map +1 -1
- package/out/src/SetupWallet.d.ts.map +1 -1
- package/out/src/SimpleWalletManager.d.ts +12 -2
- package/out/src/SimpleWalletManager.d.ts.map +1 -1
- package/out/src/SimpleWalletManager.js +46 -30
- package/out/src/SimpleWalletManager.js.map +1 -1
- package/out/src/Wallet.d.ts +1 -1
- package/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js +102 -100
- package/out/src/Wallet.js.map +1 -1
- package/out/src/WalletAuthenticationManager.d.ts +1 -1
- package/out/src/WalletAuthenticationManager.d.ts.map +1 -1
- package/out/src/WalletAuthenticationManager.js +3 -3
- package/out/src/WalletAuthenticationManager.js.map +1 -1
- package/out/src/WalletLogger.d.ts.map +1 -1
- package/out/src/WalletLogger.js +16 -8
- package/out/src/WalletLogger.js.map +1 -1
- package/out/src/WalletPermissionsManager.d.ts +89 -18
- package/out/src/WalletPermissionsManager.d.ts.map +1 -1
- package/out/src/WalletPermissionsManager.js +656 -870
- package/out/src/WalletPermissionsManager.js.map +1 -1
- package/out/src/WalletSettingsManager.d.ts +2 -2
- package/out/src/WalletSettingsManager.d.ts.map +1 -1
- package/out/src/WalletSettingsManager.js.map +1 -1
- package/out/src/fundWalletP2PKH.d.ts +2 -2
- package/out/src/fundWalletP2PKH.d.ts.map +1 -1
- package/out/src/fundWalletP2PKH.js +11 -10
- package/out/src/fundWalletP2PKH.js.map +1 -1
- package/out/src/mockchain/MockChainMigrations.d.ts +3 -3
- package/out/src/mockchain/MockChainMigrations.d.ts.map +1 -1
- package/out/src/mockchain/MockChainMigrations.js.map +1 -1
- package/out/src/mockchain/MockChainStorage.d.ts.map +1 -1
- package/out/src/mockchain/MockChainStorage.js +5 -5
- package/out/src/mockchain/MockChainStorage.js.map +1 -1
- package/out/src/mockchain/MockChainTracker.d.ts.map +1 -1
- package/out/src/mockchain/MockChainTracker.js +10 -10
- package/out/src/mockchain/MockChainTracker.js.map +1 -1
- package/out/src/mockchain/MockMiner.d.ts.map +1 -1
- package/out/src/mockchain/MockMiner.js +3 -3
- package/out/src/mockchain/MockMiner.js.map +1 -1
- package/out/src/mockchain/MockServices.d.ts +9 -0
- package/out/src/mockchain/MockServices.d.ts.map +1 -1
- package/out/src/mockchain/MockServices.js +195 -238
- package/out/src/mockchain/MockServices.js.map +1 -1
- package/out/src/mockchain/merkleTree.d.ts.map +1 -1
- package/out/src/mockchain/merkleTree.js +21 -12
- package/out/src/mockchain/merkleTree.js.map +1 -1
- package/out/src/monitor/Monitor.d.ts +17 -0
- package/out/src/monitor/Monitor.d.ts.map +1 -1
- package/out/src/monitor/Monitor.js +56 -75
- package/out/src/monitor/Monitor.js.map +1 -1
- package/out/src/monitor/tasks/TaskArcSSE.d.ts +2 -2
- package/out/src/monitor/tasks/TaskArcSSE.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskArcSSE.js +10 -23
- package/out/src/monitor/tasks/TaskArcSSE.js.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts +2 -2
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.js +28 -16
- package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -1
- package/out/src/monitor/tasks/TaskCheckNoSends.d.ts +1 -1
- package/out/src/monitor/tasks/TaskCheckNoSends.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskCheckNoSends.js +1 -2
- package/out/src/monitor/tasks/TaskCheckNoSends.js.map +1 -1
- package/out/src/monitor/tasks/TaskClock.d.ts +1 -1
- package/out/src/monitor/tasks/TaskClock.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskClock.js +0 -1
- package/out/src/monitor/tasks/TaskClock.js.map +1 -1
- package/out/src/monitor/tasks/TaskFailAbandoned.d.ts +1 -1
- package/out/src/monitor/tasks/TaskFailAbandoned.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskFailAbandoned.js.map +1 -1
- package/out/src/monitor/tasks/TaskMineBlock.d.ts +1 -1
- package/out/src/monitor/tasks/TaskMineBlock.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskMineBlock.js.map +1 -1
- package/out/src/monitor/tasks/TaskMonitorCallHistory.d.ts +1 -1
- package/out/src/monitor/tasks/TaskMonitorCallHistory.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskMonitorCallHistory.js +1 -1
- package/out/src/monitor/tasks/TaskMonitorCallHistory.js.map +1 -1
- package/out/src/monitor/tasks/TaskNewHeader.d.ts +2 -2
- package/out/src/monitor/tasks/TaskNewHeader.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskNewHeader.js +7 -5
- package/out/src/monitor/tasks/TaskNewHeader.js.map +1 -1
- package/out/src/monitor/tasks/TaskPurge.d.ts +1 -1
- package/out/src/monitor/tasks/TaskPurge.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskPurge.js.map +1 -1
- package/out/src/monitor/tasks/TaskReorg.d.ts +1 -1
- package/out/src/monitor/tasks/TaskReorg.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReorg.js +2 -2
- package/out/src/monitor/tasks/TaskReorg.js.map +1 -1
- package/out/src/monitor/tasks/TaskReviewDoubleSpends.d.ts +1 -1
- package/out/src/monitor/tasks/TaskReviewDoubleSpends.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewDoubleSpends.js +10 -10
- package/out/src/monitor/tasks/TaskReviewDoubleSpends.js.map +1 -1
- package/out/src/monitor/tasks/TaskReviewProvenTxs.d.ts +1 -1
- package/out/src/monitor/tasks/TaskReviewProvenTxs.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewProvenTxs.js +2 -2
- package/out/src/monitor/tasks/TaskReviewProvenTxs.js.map +1 -1
- package/out/src/monitor/tasks/TaskReviewStatus.d.ts +1 -1
- package/out/src/monitor/tasks/TaskReviewStatus.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewStatus.js.map +1 -1
- package/out/src/monitor/tasks/TaskReviewUtxos.d.ts +1 -1
- package/out/src/monitor/tasks/TaskReviewUtxos.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewUtxos.js.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.js +4 -5
- package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -1
- package/out/src/monitor/tasks/TaskUnFail.d.ts +1 -1
- package/out/src/monitor/tasks/TaskUnFail.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskUnFail.js +13 -15
- package/out/src/monitor/tasks/TaskUnFail.js.map +1 -1
- package/out/src/monitor/tasks/WalletMonitorTask.d.ts.map +1 -1
- package/out/src/monitor/tasks/WalletMonitorTask.js +3 -1
- package/out/src/monitor/tasks/WalletMonitorTask.js.map +1 -1
- package/out/src/sdk/CertOpsWallet.d.ts +3 -3
- package/out/src/sdk/CertOpsWallet.d.ts.map +1 -1
- package/out/src/sdk/PrivilegedKeyManager.d.ts +3 -3
- package/out/src/sdk/PrivilegedKeyManager.d.ts.map +1 -1
- package/out/src/sdk/PrivilegedKeyManager.js +26 -21
- package/out/src/sdk/PrivilegedKeyManager.js.map +1 -1
- package/out/src/sdk/WERR_errors.d.ts.map +1 -1
- package/out/src/sdk/WERR_errors.js +5 -5
- package/out/src/sdk/WERR_errors.js.map +1 -1
- package/out/src/sdk/WalletError.d.ts +1 -1
- package/out/src/sdk/WalletError.d.ts.map +1 -1
- package/out/src/sdk/WalletError.js +10 -3
- package/out/src/sdk/WalletError.js.map +1 -1
- package/out/src/sdk/WalletErrorFromJson.d.ts.map +1 -1
- package/out/src/sdk/WalletErrorFromJson.js +1 -3
- package/out/src/sdk/WalletErrorFromJson.js.map +1 -1
- package/out/src/sdk/WalletServices.interfaces.d.ts +19 -19
- package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -1
- package/out/src/sdk/types.d.ts +4 -4
- package/out/src/sdk/types.d.ts.map +1 -1
- package/out/src/sdk/types.js +3 -3
- package/out/src/sdk/types.js.map +1 -1
- package/out/src/services/ServiceCollection.d.ts +6 -6
- package/out/src/services/ServiceCollection.d.ts.map +1 -1
- package/out/src/services/ServiceCollection.js +3 -4
- package/out/src/services/ServiceCollection.js.map +1 -1
- package/out/src/services/Services.d.ts +5 -0
- package/out/src/services/Services.d.ts.map +1 -1
- package/out/src/services/Services.js +174 -182
- package/out/src/services/Services.js.map +1 -1
- package/out/src/services/chaintracker/BHServiceClient.d.ts.map +1 -1
- package/out/src/services/chaintracker/BHServiceClient.js +7 -7
- package/out/src/services/chaintracker/BHServiceClient.js.map +1 -1
- package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts.map +1 -1
- package/out/src/services/chaintracker/ChaintracksChainTracker.js +5 -5
- package/out/src/services/chaintracker/ChaintracksChainTracker.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.d.ts +5 -3
- package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Api/BlockHeaderApi.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Api/BulkStorageApi.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Chaintracks.d.ts +20 -10
- package/out/src/services/chaintracker/chaintracks/Chaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Chaintracks.js +228 -221
- package/out/src/services/chaintracker/chaintracks/Chaintracks.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js +9 -10
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.js +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorBase.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.d.ts +1 -2
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js +3 -3
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDN.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorCDNBabbage.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.js +3 -3
- package/out/src/services/chaintracker/chaintracks/Ingest/BulkIngestorWhatsOnChainCdn.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.js +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorBase.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js +2 -2
- package/out/src/services/chaintracker/chaintracks/Ingest/LiveIngestorWhatsOnChainPoll.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.d.ts +2 -2
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js +6 -39
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainIngestorWs.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.d.ts +3 -3
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.js +8 -6
- package/out/src/services/chaintracker/chaintracks/Ingest/WhatsOnChainServices.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.js +9 -16
- package/out/src/services/chaintracker/chaintracks/Storage/BulkStorageBase.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js +34 -22
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageBase.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.js +31 -30
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageIdb.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.d.ts +2 -2
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js +11 -10
- package/out/src/services/chaintracker/chaintracks/Storage/ChaintracksStorageNoDb.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts +6 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js +247 -227
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataManager.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataReader.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataReader.js +8 -7
- package/out/src/services/chaintracker/chaintracks/util/BulkFileDataReader.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js +35 -25
- package/out/src/services/chaintracker/chaintracks/util/BulkFilesReader.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.d.ts +5 -5
- package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.js +13 -11
- package/out/src/services/chaintracker/chaintracks/util/BulkHeaderFile.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts +0 -1
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/ChaintracksFetch.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/HeightRange.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/HeightRange.js +21 -13
- package/out/src/services/chaintracker/chaintracks/util/HeightRange.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts +2 -2
- package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/SingleWriterMultiReaderLock.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts +1 -1
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js +28 -24
- package/out/src/services/chaintracker/chaintracks/util/blockHeaderUtilities.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/dirtyHashes.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.js +9 -10
- package/out/src/services/chaintracker/chaintracks/util/validBulkHeaderFilesByFileHash.js.map +1 -1
- package/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -1
- package/out/src/services/createDefaultWalletServicesOptions.js +3 -3
- package/out/src/services/createDefaultWalletServicesOptions.js.map +1 -1
- package/out/src/services/providers/ARC.d.ts.map +1 -1
- package/out/src/services/providers/ARC.js +7 -14
- package/out/src/services/providers/ARC.js.map +1 -1
- package/out/src/services/providers/ArcSSEClient.d.ts.map +1 -1
- package/out/src/services/providers/ArcSSEClient.js +1 -1
- package/out/src/services/providers/ArcSSEClient.js.map +1 -1
- package/out/src/services/providers/Bitails.d.ts.map +1 -1
- package/out/src/services/providers/Bitails.js +17 -17
- package/out/src/services/providers/Bitails.js.map +1 -1
- package/out/src/services/providers/SdkWhatsOnChain.d.ts.map +1 -1
- package/out/src/services/providers/SdkWhatsOnChain.js.map +1 -1
- package/out/src/services/providers/WhatsOnChain.d.ts +2 -0
- package/out/src/services/providers/WhatsOnChain.d.ts.map +1 -1
- package/out/src/services/providers/WhatsOnChain.js +109 -233
- package/out/src/services/providers/WhatsOnChain.js.map +1 -1
- package/out/src/services/providers/exchangeRates.d.ts.map +1 -1
- package/out/src/services/providers/exchangeRates.js +3 -3
- package/out/src/services/providers/exchangeRates.js.map +1 -1
- package/out/src/services/providers/getBeefForTxid.d.ts +1 -1
- package/out/src/services/providers/getBeefForTxid.d.ts.map +1 -1
- package/out/src/services/providers/getBeefForTxid.js.map +1 -1
- package/out/src/services/providers/whatsOnChainHelpers.d.ts +68 -0
- package/out/src/services/providers/whatsOnChainHelpers.d.ts.map +1 -0
- package/out/src/services/providers/whatsOnChainHelpers.js +147 -0
- package/out/src/services/providers/whatsOnChainHelpers.js.map +1 -0
- package/out/src/signer/WalletSigner.d.ts.map +1 -1
- package/out/src/signer/WalletSigner.js.map +1 -1
- package/out/src/signer/methods/acquireDirectCertificate.js +1 -1
- package/out/src/signer/methods/acquireDirectCertificate.js.map +1 -1
- package/out/src/signer/methods/buildSignableTransaction.d.ts.map +1 -1
- package/out/src/signer/methods/buildSignableTransaction.js +21 -13
- package/out/src/signer/methods/buildSignableTransaction.js.map +1 -1
- package/out/src/signer/methods/completeSignedTransaction.d.ts.map +1 -1
- package/out/src/signer/methods/completeSignedTransaction.js +20 -21
- package/out/src/signer/methods/completeSignedTransaction.js.map +1 -1
- package/out/src/signer/methods/createAction.d.ts.map +1 -1
- package/out/src/signer/methods/createAction.js +8 -7
- package/out/src/signer/methods/createAction.js.map +1 -1
- package/out/src/signer/methods/internalizeAction.d.ts.map +1 -1
- package/out/src/signer/methods/internalizeAction.js +8 -6
- package/out/src/signer/methods/internalizeAction.js.map +1 -1
- package/out/src/signer/methods/proveCertificate.js +1 -1
- package/out/src/signer/methods/signAction.d.ts.map +1 -1
- package/out/src/signer/methods/signAction.js +8 -10
- package/out/src/signer/methods/signAction.js.map +1 -1
- package/out/src/storage/StorageIdb.d.ts +16 -1
- package/out/src/storage/StorageIdb.d.ts.map +1 -1
- package/out/src/storage/StorageIdb.js +536 -1221
- package/out/src/storage/StorageIdb.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts +10 -0
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +152 -182
- package/out/src/storage/StorageProvider.js.map +1 -1
- package/out/src/storage/StorageReader.d.ts.map +1 -1
- package/out/src/storage/StorageReader.js +8 -7
- package/out/src/storage/StorageReader.js.map +1 -1
- package/out/src/storage/StorageReaderWriter.d.ts.map +1 -1
- package/out/src/storage/StorageReaderWriter.js +32 -32
- package/out/src/storage/StorageReaderWriter.js.map +1 -1
- package/out/src/storage/StorageSyncReader.d.ts.map +1 -1
- package/out/src/storage/StorageSyncReader.js +3 -3
- package/out/src/storage/StorageSyncReader.js.map +1 -1
- package/out/src/storage/WalletStorageManager.d.ts +3 -0
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/out/src/storage/WalletStorageManager.js +83 -73
- package/out/src/storage/WalletStorageManager.js.map +1 -1
- package/out/src/storage/idbHelpers.d.ts +42 -0
- package/out/src/storage/idbHelpers.d.ts.map +1 -0
- package/out/src/storage/idbHelpers.js +375 -0
- package/out/src/storage/idbHelpers.js.map +1 -0
- package/out/src/storage/methods/ListActionsSpecOp.d.ts +6 -1
- package/out/src/storage/methods/ListActionsSpecOp.d.ts.map +1 -1
- package/out/src/storage/methods/ListActionsSpecOp.js +28 -2
- package/out/src/storage/methods/ListActionsSpecOp.js.map +1 -1
- package/out/src/storage/methods/ListOutputsSpecOp.d.ts.map +1 -1
- package/out/src/storage/methods/ListOutputsSpecOp.js +8 -11
- package/out/src/storage/methods/ListOutputsSpecOp.js.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts +83 -0
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js +224 -61
- 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 +230 -270
- package/out/src/storage/methods/createAction.js.map +1 -1
- package/out/src/storage/methods/generateChange.d.ts.map +1 -1
- package/out/src/storage/methods/generateChange.js +99 -80
- package/out/src/storage/methods/generateChange.js.map +1 -1
- package/out/src/storage/methods/getBeefForTransaction.js +15 -13
- 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 +4 -3
- package/out/src/storage/methods/getSyncChunk.js.map +1 -1
- package/out/src/storage/methods/internalizeAction.js +41 -51
- package/out/src/storage/methods/internalizeAction.js.map +1 -1
- package/out/src/storage/methods/listActionsIdb.d.ts.map +1 -1
- package/out/src/storage/methods/listActionsIdb.js +85 -110
- package/out/src/storage/methods/listActionsIdb.js.map +1 -1
- package/out/src/storage/methods/listCertificates.d.ts +1 -1
- package/out/src/storage/methods/listCertificates.d.ts.map +1 -1
- package/out/src/storage/methods/listCertificates.js +7 -7
- package/out/src/storage/methods/listCertificates.js.map +1 -1
- package/out/src/storage/methods/listOutputsIdb.d.ts.map +1 -1
- package/out/src/storage/methods/listOutputsIdb.js +24 -27
- package/out/src/storage/methods/listOutputsIdb.js.map +1 -1
- package/out/src/storage/methods/offsetKey.d.ts +1 -1
- package/out/src/storage/methods/offsetKey.d.ts.map +1 -1
- package/out/src/storage/methods/offsetKey.js +3 -5
- package/out/src/storage/methods/offsetKey.js.map +1 -1
- package/out/src/storage/methods/processAction.d.ts +0 -11
- package/out/src/storage/methods/processAction.d.ts.map +1 -1
- package/out/src/storage/methods/processAction.js +90 -83
- package/out/src/storage/methods/processAction.js.map +1 -1
- package/out/src/storage/methods/purgeDataIdb.d.ts.map +1 -1
- package/out/src/storage/methods/purgeDataIdb.js +1 -1
- package/out/src/storage/methods/purgeDataIdb.js.map +1 -1
- package/out/src/storage/methods/reviewStatusIdb.d.ts +1 -1
- package/out/src/storage/methods/reviewStatusIdb.d.ts.map +1 -1
- package/out/src/storage/methods/reviewStatusIdb.js.map +1 -1
- package/out/src/storage/methods/utils.d.ts.map +1 -1
- package/out/src/storage/methods/utils.js +7 -1
- package/out/src/storage/methods/utils.js.map +1 -1
- package/out/src/storage/remoting/StorageClient.d.ts +4 -270
- package/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageClient.js +16 -423
- package/out/src/storage/remoting/StorageClient.js.map +1 -1
- package/out/src/storage/remoting/StorageClientBase.d.ts +289 -0
- package/out/src/storage/remoting/StorageClientBase.d.ts.map +1 -0
- package/out/src/storage/remoting/StorageClientBase.js +375 -0
- package/out/src/storage/remoting/StorageClientBase.js.map +1 -0
- package/out/src/storage/remoting/entityValidationHelpers.d.ts +29 -0
- package/out/src/storage/remoting/entityValidationHelpers.d.ts.map +1 -0
- package/out/src/storage/remoting/entityValidationHelpers.js +91 -0
- package/out/src/storage/remoting/entityValidationHelpers.js.map +1 -0
- package/out/src/storage/schema/StorageIdbSchema.d.ts +1 -1
- package/out/src/storage/schema/StorageIdbSchema.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityBase.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityBase.js.map +1 -1
- package/out/src/storage/schema/entities/EntityCertificate.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityCertificate.js +5 -4
- package/out/src/storage/schema/entities/EntityCertificate.js.map +1 -1
- package/out/src/storage/schema/entities/EntityCertificateField.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityCertificateField.js +5 -7
- package/out/src/storage/schema/entities/EntityCertificateField.js.map +1 -1
- package/out/src/storage/schema/entities/EntityCommission.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityCommission.js +6 -8
- package/out/src/storage/schema/entities/EntityCommission.js.map +1 -1
- package/out/src/storage/schema/entities/EntityOutput.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityOutput.js +21 -24
- package/out/src/storage/schema/entities/EntityOutput.js.map +1 -1
- package/out/src/storage/schema/entities/EntityOutputBasket.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityOutputBasket.js +6 -6
- package/out/src/storage/schema/entities/EntityOutputBasket.js.map +1 -1
- package/out/src/storage/schema/entities/EntityOutputTag.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityOutputTag.js +2 -2
- package/out/src/storage/schema/entities/EntityOutputTag.js.map +1 -1
- package/out/src/storage/schema/entities/EntityOutputTagMap.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityOutputTagMap.js +4 -6
- package/out/src/storage/schema/entities/EntityOutputTagMap.js.map +1 -1
- package/out/src/storage/schema/entities/EntityProvenTx.d.ts +3 -3
- package/out/src/storage/schema/entities/EntityProvenTx.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityProvenTx.js +22 -23
- package/out/src/storage/schema/entities/EntityProvenTx.js.map +1 -1
- package/out/src/storage/schema/entities/EntityProvenTxReq.d.ts +9 -0
- package/out/src/storage/schema/entities/EntityProvenTxReq.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityProvenTxReq.js +116 -68
- package/out/src/storage/schema/entities/EntityProvenTxReq.js.map +1 -1
- package/out/src/storage/schema/entities/EntitySyncState.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntitySyncState.js +19 -18
- package/out/src/storage/schema/entities/EntitySyncState.js.map +1 -1
- package/out/src/storage/schema/entities/EntityTransaction.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityTransaction.js +25 -26
- package/out/src/storage/schema/entities/EntityTransaction.js.map +1 -1
- package/out/src/storage/schema/entities/EntityTxLabel.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityTxLabel.js +2 -2
- package/out/src/storage/schema/entities/EntityTxLabel.js.map +1 -1
- package/out/src/storage/schema/entities/EntityTxLabelMap.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityTxLabelMap.js +4 -6
- package/out/src/storage/schema/entities/EntityTxLabelMap.js.map +1 -1
- package/out/src/storage/schema/entities/EntityUser.d.ts.map +1 -1
- package/out/src/storage/schema/entities/EntityUser.js +3 -3
- package/out/src/storage/schema/entities/EntityUser.js.map +1 -1
- package/out/src/storage/schema/entities/MergeEntity.d.ts.map +1 -1
- package/out/src/storage/schema/entities/MergeEntity.js +6 -6
- package/out/src/storage/schema/entities/MergeEntity.js.map +1 -1
- package/out/src/storage/schema/tables/TableCertificate.d.ts +2 -1
- package/out/src/storage/schema/tables/TableCertificate.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableCertificateField.d.ts +1 -1
- package/out/src/storage/schema/tables/TableCertificateField.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableCommission.d.ts +1 -1
- package/out/src/storage/schema/tables/TableCommission.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableMonitorEvent.d.ts +1 -1
- package/out/src/storage/schema/tables/TableMonitorEvent.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableOutput.d.ts +3 -2
- package/out/src/storage/schema/tables/TableOutput.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableOutput.js +1 -1
- package/out/src/storage/schema/tables/TableOutput.js.map +1 -1
- package/out/src/storage/schema/tables/TableOutputBasket.d.ts +1 -1
- package/out/src/storage/schema/tables/TableOutputBasket.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableOutputTag.d.ts +1 -1
- package/out/src/storage/schema/tables/TableOutputTag.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableOutputTagMap.d.ts +1 -1
- package/out/src/storage/schema/tables/TableOutputTagMap.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableProvenTx.d.ts +1 -1
- package/out/src/storage/schema/tables/TableProvenTx.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableProvenTxReq.d.ts +24 -1
- package/out/src/storage/schema/tables/TableProvenTxReq.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableSettings.d.ts +1 -1
- package/out/src/storage/schema/tables/TableSettings.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableSyncState.d.ts +1 -1
- package/out/src/storage/schema/tables/TableSyncState.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableTransaction.d.ts +1 -1
- package/out/src/storage/schema/tables/TableTransaction.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableTxLabel.d.ts +1 -1
- package/out/src/storage/schema/tables/TableTxLabel.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableTxLabelMap.d.ts +1 -1
- package/out/src/storage/schema/tables/TableTxLabelMap.d.ts.map +1 -1
- package/out/src/storage/schema/tables/TableUser.d.ts +1 -1
- package/out/src/storage/schema/tables/TableUser.d.ts.map +1 -1
- package/out/src/storage/storageProviderHelpers.d.ts +34 -0
- package/out/src/storage/storageProviderHelpers.d.ts.map +1 -0
- package/out/src/storage/storageProviderHelpers.js +100 -0
- package/out/src/storage/storageProviderHelpers.js.map +1 -0
- package/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -1
- package/out/src/utility/ScriptTemplateBRC29.js +2 -1
- package/out/src/utility/ScriptTemplateBRC29.js.map +1 -1
- package/out/src/utility/aggregateResults.d.ts +1 -1
- package/out/src/utility/aggregateResults.d.ts.map +1 -1
- package/out/src/utility/aggregateResults.js +2 -2
- package/out/src/utility/aggregateResults.js.map +1 -1
- package/out/src/utility/brc114ActionTimeLabels.d.ts +2 -2
- package/out/src/utility/brc114ActionTimeLabels.d.ts.map +1 -1
- package/out/src/utility/brc114ActionTimeLabels.js +16 -9
- package/out/src/utility/brc114ActionTimeLabels.js.map +1 -1
- package/out/src/utility/identityUtils.js +1 -1
- package/out/src/utility/identityUtils.js.map +1 -1
- package/out/src/utility/parseTxScriptOffsets.d.ts +4 -4
- package/out/src/utility/parseTxScriptOffsets.d.ts.map +1 -1
- package/out/src/utility/parseTxScriptOffsets.js.map +1 -1
- package/out/src/utility/stampLog.d.ts.map +1 -1
- package/out/src/utility/stampLog.js +7 -5
- package/out/src/utility/stampLog.js.map +1 -1
- package/out/src/utility/tscProofToMerklePath.d.ts.map +1 -1
- package/out/src/utility/tscProofToMerklePath.js +1 -1
- package/out/src/utility/tscProofToMerklePath.js.map +1 -1
- package/out/src/utility/utilityHelpers.d.ts +1 -2
- package/out/src/utility/utilityHelpers.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.js +10 -10
- package/out/src/utility/utilityHelpers.js.map +1 -1
- package/out/src/utility/utilityHelpers.noBuffer.d.ts +7 -3
- package/out/src/utility/utilityHelpers.noBuffer.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.noBuffer.js +3 -3
- package/out/src/utility/utilityHelpers.noBuffer.js.map +1 -1
- package/out/src/wab-client/WABClient.d.ts +1 -1
- package/out/src/wab-client/WABClient.d.ts.map +1 -1
- package/out/src/wab-client/WABClient.js +12 -12
- package/out/src/wab-client/WABClient.js.map +1 -1
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.d.ts.map +1 -1
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js +3 -3
- package/out/src/wab-client/auth-method-interactors/AuthMethodInteractor.js.map +1 -1
- package/out/tsconfig.client.tsbuildinfo +1 -1
- package/package.json +7 -6
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StorageIdb = void 0;
|
|
4
4
|
const idb_1 = require("idb");
|
|
5
|
+
const idbHelpers_1 = require("./idbHelpers");
|
|
5
6
|
const utilityHelpers_1 = require("../utility/utilityHelpers");
|
|
6
7
|
const StorageProvider_1 = require("./StorageProvider");
|
|
7
8
|
const listActionsIdb_1 = require("./methods/listActionsIdb");
|
|
@@ -9,6 +10,39 @@ const listOutputsIdb_1 = require("./methods/listOutputsIdb");
|
|
|
9
10
|
const reviewStatusIdb_1 = require("./methods/reviewStatusIdb");
|
|
10
11
|
const purgeDataIdb_1 = require("./methods/purgeDataIdb");
|
|
11
12
|
const WERR_errors_1 = require("../sdk/WERR_errors");
|
|
13
|
+
/**
|
|
14
|
+
* Shared cursor-scan loop used by all `filterXxx` methods of StorageIdb.
|
|
15
|
+
*
|
|
16
|
+
* Walks `cursor` forward, applying `since`, a caller-supplied `matches`
|
|
17
|
+
* predicate, paging (offset / limit), and an async `accept` callback for
|
|
18
|
+
* records that pass all filters. Returns the number of accepted records.
|
|
19
|
+
*
|
|
20
|
+
* Implemented as a module-level helper (not a class method) so that
|
|
21
|
+
* profiling/instrumentation that wraps class-prototype methods cannot
|
|
22
|
+
* intercept or mutate its `matches` / `accept` callbacks.
|
|
23
|
+
*/
|
|
24
|
+
async function scanCursor(
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
cursor, since, offset, limit, matches, accept) {
|
|
27
|
+
let skipped = 0;
|
|
28
|
+
let count = 0;
|
|
29
|
+
for (; cursor != null; cursor = await cursor.continue()) {
|
|
30
|
+
const r = cursor.value;
|
|
31
|
+
if (since != null && since > r.updated_at)
|
|
32
|
+
continue;
|
|
33
|
+
if (!await matches(r))
|
|
34
|
+
continue;
|
|
35
|
+
if (skipped < offset) {
|
|
36
|
+
skipped++;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
accept(r);
|
|
40
|
+
count++;
|
|
41
|
+
if (limit && count >= limit)
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
return count;
|
|
45
|
+
}
|
|
12
46
|
/**
|
|
13
47
|
* This class implements the `StorageProvider` interface using IndexedDB,
|
|
14
48
|
* via the promises wrapper package `idb`.
|
|
@@ -61,7 +95,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
61
95
|
* @returns
|
|
62
96
|
*/
|
|
63
97
|
async verifyDB(storageName, storageIdentityKey) {
|
|
64
|
-
if (this.db)
|
|
98
|
+
if (this.db != null)
|
|
65
99
|
return this.db;
|
|
66
100
|
this.db = await this.initDB(storageName, storageIdentityKey);
|
|
67
101
|
this._settings = (await this.db.getAll('settings'))[0];
|
|
@@ -73,12 +107,12 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
73
107
|
* or a Knex.Transaction as appropriate.
|
|
74
108
|
*/
|
|
75
109
|
toDbTrx(stores, mode, trx) {
|
|
76
|
-
if (trx) {
|
|
110
|
+
if (trx != null) {
|
|
77
111
|
const t = trx;
|
|
78
112
|
return t;
|
|
79
113
|
}
|
|
80
114
|
else {
|
|
81
|
-
if (
|
|
115
|
+
if (this.db == null)
|
|
82
116
|
throw new Error('not initialized');
|
|
83
117
|
const db = this.db;
|
|
84
118
|
const trx = db.transaction(stores || this.allStores, mode || 'readwrite');
|
|
@@ -103,150 +137,13 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
103
137
|
const chain = this.chain;
|
|
104
138
|
const maxOutputScript = 1024;
|
|
105
139
|
const db = await (0, idb_1.openDB)(this.dbName, 1, {
|
|
106
|
-
upgrade(db
|
|
107
|
-
|
|
108
|
-
// proven_txs object store
|
|
109
|
-
const provenTxsStore = db.createObjectStore('proven_txs', {
|
|
110
|
-
keyPath: 'provenTxId',
|
|
111
|
-
autoIncrement: true
|
|
112
|
-
});
|
|
113
|
-
provenTxsStore.createIndex('txid', 'txid', { unique: true });
|
|
114
|
-
}
|
|
115
|
-
if (!db.objectStoreNames.contains('proven_tx_reqs')) {
|
|
116
|
-
// proven_tx_reqs object store
|
|
117
|
-
const provenTxReqsStore = db.createObjectStore('proven_tx_reqs', {
|
|
118
|
-
keyPath: 'provenTxReqId',
|
|
119
|
-
autoIncrement: true
|
|
120
|
-
});
|
|
121
|
-
provenTxReqsStore.createIndex('provenTxId', 'provenTxId');
|
|
122
|
-
provenTxReqsStore.createIndex('txid', 'txid', { unique: true });
|
|
123
|
-
provenTxReqsStore.createIndex('status', 'status');
|
|
124
|
-
provenTxReqsStore.createIndex('batch', 'batch');
|
|
125
|
-
}
|
|
126
|
-
if (!db.objectStoreNames.contains('users')) {
|
|
127
|
-
const users = db.createObjectStore('users', {
|
|
128
|
-
keyPath: 'userId',
|
|
129
|
-
autoIncrement: true
|
|
130
|
-
});
|
|
131
|
-
users.createIndex('identityKey', 'identityKey', { unique: true });
|
|
132
|
-
}
|
|
133
|
-
if (!db.objectStoreNames.contains('certificates')) {
|
|
134
|
-
// certificates object store
|
|
135
|
-
const certificatesStore = db.createObjectStore('certificates', {
|
|
136
|
-
keyPath: 'certificateId',
|
|
137
|
-
autoIncrement: true
|
|
138
|
-
});
|
|
139
|
-
certificatesStore.createIndex('userId', 'userId');
|
|
140
|
-
certificatesStore.createIndex('userId_type_certifier_serialNumber', ['userId', 'type', 'certifier', 'serialNumber'], { unique: true });
|
|
141
|
-
}
|
|
142
|
-
if (!db.objectStoreNames.contains('certificate_fields')) {
|
|
143
|
-
// certificate_fields object store
|
|
144
|
-
const certificateFieldsStore = db.createObjectStore('certificate_fields', {
|
|
145
|
-
keyPath: ['certificateId', 'fieldName'] // Composite key
|
|
146
|
-
});
|
|
147
|
-
certificateFieldsStore.createIndex('userId', 'userId');
|
|
148
|
-
certificateFieldsStore.createIndex('certificateId', 'certificateId');
|
|
149
|
-
}
|
|
150
|
-
if (!db.objectStoreNames.contains('output_baskets')) {
|
|
151
|
-
// output_baskets object store
|
|
152
|
-
const outputBasketsStore = db.createObjectStore('output_baskets', {
|
|
153
|
-
keyPath: 'basketId',
|
|
154
|
-
autoIncrement: true
|
|
155
|
-
});
|
|
156
|
-
outputBasketsStore.createIndex('userId', 'userId');
|
|
157
|
-
outputBasketsStore.createIndex('name_userId', ['name', 'userId'], { unique: true });
|
|
158
|
-
}
|
|
159
|
-
if (!db.objectStoreNames.contains('transactions')) {
|
|
160
|
-
// transactions object store
|
|
161
|
-
const transactionsStore = db.createObjectStore('transactions', {
|
|
162
|
-
keyPath: 'transactionId',
|
|
163
|
-
autoIncrement: true
|
|
164
|
-
});
|
|
165
|
-
transactionsStore.createIndex('userId', 'userId');
|
|
166
|
-
transactionsStore.createIndex('status', 'status');
|
|
167
|
-
transactionsStore.createIndex('status_userId', ['status', 'userId']);
|
|
168
|
-
transactionsStore.createIndex('provenTxId', 'provenTxId');
|
|
169
|
-
transactionsStore.createIndex('reference', 'reference', { unique: true });
|
|
170
|
-
}
|
|
171
|
-
if (!db.objectStoreNames.contains('commissions')) {
|
|
172
|
-
// commissions object store
|
|
173
|
-
const commissionsStore = db.createObjectStore('commissions', {
|
|
174
|
-
keyPath: 'commissionId',
|
|
175
|
-
autoIncrement: true
|
|
176
|
-
});
|
|
177
|
-
commissionsStore.createIndex('userId', 'userId');
|
|
178
|
-
commissionsStore.createIndex('transactionId', 'transactionId', { unique: true });
|
|
179
|
-
}
|
|
180
|
-
if (!db.objectStoreNames.contains('outputs')) {
|
|
181
|
-
// outputs object store
|
|
182
|
-
const outputsStore = db.createObjectStore('outputs', {
|
|
183
|
-
keyPath: 'outputId',
|
|
184
|
-
autoIncrement: true
|
|
185
|
-
});
|
|
186
|
-
outputsStore.createIndex('userId', 'userId');
|
|
187
|
-
outputsStore.createIndex('transactionId', 'transactionId');
|
|
188
|
-
outputsStore.createIndex('basketId', 'basketId');
|
|
189
|
-
outputsStore.createIndex('spentBy', 'spentBy');
|
|
190
|
-
outputsStore.createIndex('transactionId_vout_userId', ['transactionId', 'vout', 'userId'], { unique: true });
|
|
191
|
-
}
|
|
192
|
-
if (!db.objectStoreNames.contains('output_tags')) {
|
|
193
|
-
// output_tags object store
|
|
194
|
-
const outputTagsStore = db.createObjectStore('output_tags', {
|
|
195
|
-
keyPath: 'outputTagId',
|
|
196
|
-
autoIncrement: true
|
|
197
|
-
});
|
|
198
|
-
outputTagsStore.createIndex('userId', 'userId');
|
|
199
|
-
outputTagsStore.createIndex('tag_userId', ['tag', 'userId'], { unique: true });
|
|
200
|
-
}
|
|
201
|
-
if (!db.objectStoreNames.contains('output_tags_map')) {
|
|
202
|
-
// output_tags_map object store
|
|
203
|
-
const outputTagsMapStore = db.createObjectStore('output_tags_map', {
|
|
204
|
-
keyPath: ['outputTagId', 'outputId']
|
|
205
|
-
});
|
|
206
|
-
outputTagsMapStore.createIndex('outputTagId', 'outputTagId');
|
|
207
|
-
outputTagsMapStore.createIndex('outputId', 'outputId');
|
|
208
|
-
}
|
|
209
|
-
if (!db.objectStoreNames.contains('tx_labels')) {
|
|
210
|
-
// tx_labels object store
|
|
211
|
-
const txLabelsStore = db.createObjectStore('tx_labels', {
|
|
212
|
-
keyPath: 'txLabelId',
|
|
213
|
-
autoIncrement: true
|
|
214
|
-
});
|
|
215
|
-
txLabelsStore.createIndex('userId', 'userId');
|
|
216
|
-
txLabelsStore.createIndex('label_userId', ['label', 'userId'], { unique: true });
|
|
217
|
-
}
|
|
218
|
-
if (!db.objectStoreNames.contains('tx_labels_map')) {
|
|
219
|
-
// tx_labels_map object store
|
|
220
|
-
const txLabelsMapStore = db.createObjectStore('tx_labels_map', {
|
|
221
|
-
keyPath: ['txLabelId', 'transactionId']
|
|
222
|
-
});
|
|
223
|
-
txLabelsMapStore.createIndex('txLabelId', 'txLabelId');
|
|
224
|
-
txLabelsMapStore.createIndex('transactionId', 'transactionId');
|
|
225
|
-
}
|
|
226
|
-
if (!db.objectStoreNames.contains('monitor_events')) {
|
|
227
|
-
// monitor_events object store
|
|
228
|
-
const monitorEventsStore = db.createObjectStore('monitor_events', {
|
|
229
|
-
keyPath: 'id',
|
|
230
|
-
autoIncrement: true
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
if (!db.objectStoreNames.contains('sync_states')) {
|
|
234
|
-
// sync_states object store
|
|
235
|
-
const syncStatesStore = db.createObjectStore('sync_states', {
|
|
236
|
-
keyPath: 'syncStateId',
|
|
237
|
-
autoIncrement: true
|
|
238
|
-
});
|
|
239
|
-
syncStatesStore.createIndex('userId', 'userId');
|
|
240
|
-
syncStatesStore.createIndex('refNum', 'refNum', { unique: true });
|
|
241
|
-
syncStatesStore.createIndex('status', 'status');
|
|
242
|
-
}
|
|
140
|
+
upgrade(db) {
|
|
141
|
+
(0, idbHelpers_1.upgradeAllStoresV1)(db);
|
|
243
142
|
if (!db.objectStoreNames.contains('settings')) {
|
|
244
143
|
if (!storageName || !storageIdentityKey) {
|
|
245
144
|
throw new WERR_errors_1.WERR_INVALID_OPERATION('migrate must be called before first access');
|
|
246
145
|
}
|
|
247
|
-
const settings = db.createObjectStore('settings', {
|
|
248
|
-
keyPath: 'storageIdentityKey'
|
|
249
|
-
});
|
|
146
|
+
const settings = db.createObjectStore('settings', { keyPath: 'storageIdentityKey' });
|
|
250
147
|
const s = {
|
|
251
148
|
created_at: new Date(),
|
|
252
149
|
updated_at: new Date(),
|
|
@@ -315,25 +212,25 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
315
212
|
const score = o.satoshis - targetSatoshis;
|
|
316
213
|
scores.push({ output: o, score });
|
|
317
214
|
}
|
|
318
|
-
if (
|
|
215
|
+
if (output == null) {
|
|
319
216
|
// sort scores increasing by score property
|
|
320
217
|
scores = scores.sort((a, b) => a.score - b.score);
|
|
321
218
|
// find the first score that is greater than or equal to 0
|
|
322
219
|
const o = scores.find(s => s.score >= 0);
|
|
323
|
-
if (o) {
|
|
220
|
+
if (o != null) {
|
|
324
221
|
// stage 2 satisfied (minimally funded)
|
|
325
222
|
output = o.output;
|
|
326
223
|
}
|
|
327
224
|
else if (scores.length > 0) {
|
|
328
225
|
// stage 3 satisfied (minimally under-funded)
|
|
329
|
-
output = scores.
|
|
226
|
+
output = scores.at(-1).output;
|
|
330
227
|
}
|
|
331
228
|
else {
|
|
332
229
|
// no available funding outputs
|
|
333
230
|
output = undefined;
|
|
334
231
|
}
|
|
335
232
|
}
|
|
336
|
-
if (output) {
|
|
233
|
+
if (output != null) {
|
|
337
234
|
// mark output as spent by transactionId
|
|
338
235
|
await this.updateOutput(output.outputId, { spendable: false, spentBy: transactionId }, dbTrx);
|
|
339
236
|
// Hydrate the locking script for the chosen output. Identical to Knex canon at
|
|
@@ -353,10 +250,10 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
353
250
|
rawTx: undefined,
|
|
354
251
|
inputBEEF: undefined
|
|
355
252
|
};
|
|
356
|
-
r.proven = (0, utilityHelpers_1.verifyOneOrNone)(await this.findProvenTxs({ partial: { txid
|
|
357
|
-
if (
|
|
358
|
-
const req = (0, utilityHelpers_1.verifyOneOrNone)(await this.findProvenTxReqs({ partial: { txid
|
|
359
|
-
if (req && ['unsent', 'unmined', 'unconfirmed', 'sending', 'nosend', 'completed'].includes(req.status)) {
|
|
253
|
+
r.proven = (0, utilityHelpers_1.verifyOneOrNone)(await this.findProvenTxs({ partial: { txid }, trx }));
|
|
254
|
+
if (r.proven == null) {
|
|
255
|
+
const req = (0, utilityHelpers_1.verifyOneOrNone)(await this.findProvenTxReqs({ partial: { txid }, trx }));
|
|
256
|
+
if ((req != null) && ['unsent', 'unmined', 'unconfirmed', 'sending', 'nosend', 'completed'].includes(req.status)) {
|
|
360
257
|
r.rawTx = req.rawTx;
|
|
361
258
|
r.inputBEEF = req.inputBEEF;
|
|
362
259
|
}
|
|
@@ -368,35 +265,32 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
368
265
|
return undefined;
|
|
369
266
|
if (!this.isAvailable())
|
|
370
267
|
await this.makeAvailable();
|
|
371
|
-
let rawTx = undefined;
|
|
372
268
|
const sliceRequested = offset !== undefined && length !== undefined && Number.isInteger(offset) && Number.isInteger(length);
|
|
373
269
|
// Slice path uses an extended status set that includes 'unfail' — matches Knex
|
|
374
270
|
// canon at StorageKnex.ts:131. The non-slice path continues to delegate to
|
|
375
271
|
// getProvenOrRawTx which uses the narrower set.
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
else {
|
|
382
|
-
const req = (0, utilityHelpers_1.verifyOneOrNone)(await this.findProvenTxReqs({ partial: { txid }, trx }));
|
|
383
|
-
if (req && ['unsent', 'nosend', 'sending', 'unmined', 'completed', 'unfail'].includes(req.status)) {
|
|
384
|
-
rawTx = req.rawTx;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
389
|
-
const r = await this.getProvenOrRawTx(txid, trx);
|
|
390
|
-
if (r.proven)
|
|
391
|
-
rawTx = r.proven.rawTx;
|
|
392
|
-
else
|
|
393
|
-
rawTx = r.rawTx;
|
|
394
|
-
}
|
|
395
|
-
if (rawTx && sliceRequested) {
|
|
396
|
-
rawTx = rawTx.slice(offset, offset + length);
|
|
272
|
+
const rawTx = sliceRequested
|
|
273
|
+
? await this.getRawTxForSlice(txid, trx)
|
|
274
|
+
: await this.getRawTxFull(txid, trx);
|
|
275
|
+
if (rawTx != null && sliceRequested) {
|
|
276
|
+
return rawTx.slice(offset, offset + length);
|
|
397
277
|
}
|
|
398
278
|
return rawTx;
|
|
399
279
|
}
|
|
280
|
+
async getRawTxForSlice(txid, trx) {
|
|
281
|
+
const proven = (0, utilityHelpers_1.verifyOneOrNone)(await this.findProvenTxs({ partial: { txid }, trx }));
|
|
282
|
+
if (proven != null)
|
|
283
|
+
return proven.rawTx;
|
|
284
|
+
const req = (0, utilityHelpers_1.verifyOneOrNone)(await this.findProvenTxReqs({ partial: { txid }, trx }));
|
|
285
|
+
const validStatuses = ['unsent', 'nosend', 'sending', 'unmined', 'completed', 'unfail'];
|
|
286
|
+
if (req != null && validStatuses.includes(req.status))
|
|
287
|
+
return req.rawTx;
|
|
288
|
+
return undefined;
|
|
289
|
+
}
|
|
290
|
+
async getRawTxFull(txid, trx) {
|
|
291
|
+
const r = await this.getProvenOrRawTx(txid, trx);
|
|
292
|
+
return r.proven != null ? r.proven.rawTx : r.rawTx;
|
|
293
|
+
}
|
|
400
294
|
async getLabelsForTransactionId(transactionId, trx) {
|
|
401
295
|
const maps = await this.findTxLabelMaps({ partial: { transactionId, isDeleted: false }, trx });
|
|
402
296
|
const labelIds = maps.map(m => m.txLabelId);
|
|
@@ -406,7 +300,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
406
300
|
// Knex/Bun drop it via JOIN; we must do the same silently or we'd break the whole
|
|
407
301
|
// listActions response. Skip + log so persistent orphans still produce a signal.
|
|
408
302
|
const label = (0, utilityHelpers_1.verifyOneOrNone)(await this.findTxLabels({ partial: { txLabelId, isDeleted: false }, trx }));
|
|
409
|
-
if (label)
|
|
303
|
+
if (label != null)
|
|
410
304
|
labels.push(label);
|
|
411
305
|
else
|
|
412
306
|
console.debug(`[StorageIdb] orphan tx_labels_map row skipped: transactionId=${transactionId} txLabelId=${txLabelId}`);
|
|
@@ -419,7 +313,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
419
313
|
const tags = [];
|
|
420
314
|
for (const outputTagId of tagIds) {
|
|
421
315
|
const tag = (0, utilityHelpers_1.verifyOneOrNone)(await this.findOutputTags({ partial: { outputTagId, isDeleted: false }, trx }));
|
|
422
|
-
if (tag)
|
|
316
|
+
if (tag != null)
|
|
423
317
|
tags.push(tag);
|
|
424
318
|
else
|
|
425
319
|
console.debug(`[StorageIdb] orphan output_tags_map row skipped: outputId=${outputId} outputTagId=${outputTagId}`);
|
|
@@ -485,7 +379,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
485
379
|
* you need IS NULL semantics (only meaningful for nullable columns).
|
|
486
380
|
*/
|
|
487
381
|
assertNoUndefinedInPartial(partial) {
|
|
488
|
-
if (
|
|
382
|
+
if (partial == null)
|
|
489
383
|
return;
|
|
490
384
|
for (const k of Object.keys(partial)) {
|
|
491
385
|
if (partial[k] === undefined) {
|
|
@@ -496,59 +390,32 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
496
390
|
async filterOutputTagMaps(args, filtered, userId) {
|
|
497
391
|
var _a, _b, _c, _d;
|
|
498
392
|
this.assertNoUndefinedInPartial(args.partial);
|
|
499
|
-
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
500
|
-
let skipped = 0;
|
|
501
|
-
let count = 0;
|
|
502
393
|
const dbTrx = this.toDbTrx(['output_tags_map', 'output_tags'], 'readonly', args.trx);
|
|
394
|
+
const store = dbTrx.objectStore('output_tags_map');
|
|
395
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
503
396
|
let cursor;
|
|
504
|
-
if (((
|
|
505
|
-
cursor = await
|
|
397
|
+
if (((_a = args.partial) === null || _a === void 0 ? void 0 : _a.outputTagId) !== undefined) {
|
|
398
|
+
cursor = await store.index('outputTagId').openCursor(args.partial.outputTagId);
|
|
506
399
|
}
|
|
507
|
-
else if (((
|
|
508
|
-
cursor = await
|
|
400
|
+
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.outputId) !== undefined) {
|
|
401
|
+
cursor = await store.index('outputId').openCursor(args.partial.outputId);
|
|
509
402
|
}
|
|
510
403
|
else {
|
|
511
|
-
cursor = await
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
break;
|
|
519
|
-
firstTime = false;
|
|
520
|
-
const r = cursor.value;
|
|
521
|
-
if (args.since && args.since > r.updated_at)
|
|
522
|
-
continue;
|
|
523
|
-
if (args.tagIds && !args.tagIds.includes(r.outputTagId))
|
|
524
|
-
continue;
|
|
525
|
-
if (args.partial) {
|
|
526
|
-
if (args.partial.outputTagId !== undefined && r.outputTagId !== args.partial.outputTagId)
|
|
527
|
-
continue;
|
|
528
|
-
if (args.partial.outputId !== undefined && r.outputId !== args.partial.outputId)
|
|
529
|
-
continue;
|
|
530
|
-
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
531
|
-
continue;
|
|
532
|
-
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
533
|
-
continue;
|
|
534
|
-
if (args.partial.isDeleted !== undefined && r.isDeleted !== args.partial.isDeleted)
|
|
535
|
-
continue;
|
|
536
|
-
}
|
|
404
|
+
cursor = await store.openCursor();
|
|
405
|
+
}
|
|
406
|
+
await scanCursor(cursor, args.since, ((_c = args.paged) === null || _c === void 0 ? void 0 : _c.offset) || 0, (_d = args.paged) === null || _d === void 0 ? void 0 : _d.limit, async (r) => {
|
|
407
|
+
if (args.tagIds != null && !args.tagIds.includes(r.outputTagId))
|
|
408
|
+
return false;
|
|
409
|
+
if (!(0, idbHelpers_1.matchesOutputTagMapPartial)(r, args.partial))
|
|
410
|
+
return false;
|
|
537
411
|
if (userId !== undefined) {
|
|
538
412
|
const tagsForUser = await this.countOutputTags({ partial: { userId, outputTagId: r.outputTagId }, trx: dbTrx });
|
|
539
413
|
if (tagsForUser === 0)
|
|
540
|
-
|
|
541
|
-
}
|
|
542
|
-
if (skipped < offset) {
|
|
543
|
-
skipped++;
|
|
544
|
-
continue;
|
|
414
|
+
return false;
|
|
545
415
|
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
break;
|
|
550
|
-
}
|
|
551
|
-
if (!args.trx)
|
|
416
|
+
return true;
|
|
417
|
+
}, filtered);
|
|
418
|
+
if (args.trx == null)
|
|
552
419
|
await dbTrx.done;
|
|
553
420
|
}
|
|
554
421
|
async findOutputTagMaps(args) {
|
|
@@ -558,93 +425,54 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
558
425
|
});
|
|
559
426
|
return results;
|
|
560
427
|
}
|
|
428
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
429
|
+
async openProvenTxReqsCursor(
|
|
430
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
431
|
+
store,
|
|
432
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
433
|
+
partial, direction
|
|
434
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
435
|
+
) {
|
|
436
|
+
if (partial === null || partial === void 0 ? void 0 : partial.provenTxReqId)
|
|
437
|
+
return store.openCursor(partial.provenTxReqId, direction);
|
|
438
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.provenTxId) !== undefined)
|
|
439
|
+
return store.index('provenTxId').openCursor(partial.provenTxId, direction);
|
|
440
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.txid) !== undefined)
|
|
441
|
+
return store.index('txid').openCursor(partial.txid, direction);
|
|
442
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.status) !== undefined)
|
|
443
|
+
return store.index('status').openCursor(partial.status, direction);
|
|
444
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.batch) !== undefined)
|
|
445
|
+
return store.index('batch').openCursor(partial.batch, direction);
|
|
446
|
+
return store.openCursor(null, direction);
|
|
447
|
+
}
|
|
561
448
|
async filterProvenTxReqs(args, filtered, userId) {
|
|
562
|
-
var _a, _b
|
|
449
|
+
var _a, _b;
|
|
563
450
|
this.assertNoUndefinedInPartial(args.partial);
|
|
564
|
-
if (args.partial.rawTx)
|
|
565
|
-
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.rawTx',
|
|
566
|
-
if (args.partial.inputBEEF)
|
|
567
|
-
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.inputBEEF', `undefined. ProvenTxReqs may not be found by inputBEEF value.`);
|
|
568
|
-
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
569
|
-
let skipped = 0;
|
|
570
|
-
let count = 0;
|
|
571
|
-
const dbTrx = this.toDbTrx(['proven_tx_reqs', 'transactions'], 'readonly', args.trx);
|
|
572
|
-
const direction = args.orderDescending ? 'prev' : 'next';
|
|
573
|
-
let cursor;
|
|
574
|
-
if ((_b = args.partial) === null || _b === void 0 ? void 0 : _b.provenTxReqId) {
|
|
575
|
-
cursor = await dbTrx.objectStore('proven_tx_reqs').openCursor(args.partial.provenTxReqId, direction);
|
|
576
|
-
}
|
|
577
|
-
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.provenTxId) !== undefined) {
|
|
578
|
-
cursor = await dbTrx
|
|
579
|
-
.objectStore('proven_tx_reqs')
|
|
580
|
-
.index('provenTxId')
|
|
581
|
-
.openCursor(args.partial.provenTxId, direction);
|
|
451
|
+
if (args.partial.rawTx != null) {
|
|
452
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.rawTx', 'undefined. ProvenTxReqs may not be found by rawTx value.');
|
|
582
453
|
}
|
|
583
|
-
|
|
584
|
-
|
|
454
|
+
if (args.partial.inputBEEF != null) {
|
|
455
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.inputBEEF', 'undefined. ProvenTxReqs may not be found by inputBEEF value.');
|
|
585
456
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
if (!firstTime)
|
|
598
|
-
cursor = await cursor.continue();
|
|
599
|
-
if (!cursor)
|
|
600
|
-
break;
|
|
601
|
-
firstTime = false;
|
|
602
|
-
const r = cursor.value;
|
|
603
|
-
if (args.since && args.since > r.updated_at)
|
|
604
|
-
continue;
|
|
605
|
-
if (args.partial) {
|
|
606
|
-
if (args.partial.provenTxReqId !== undefined && r.provenTxReqId !== args.partial.provenTxReqId)
|
|
607
|
-
continue;
|
|
608
|
-
if (args.partial.provenTxId !== undefined && r.provenTxId !== args.partial.provenTxId)
|
|
609
|
-
continue;
|
|
610
|
-
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
611
|
-
continue;
|
|
612
|
-
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
613
|
-
continue;
|
|
614
|
-
if (args.partial.status !== undefined && r.status !== args.partial.status)
|
|
615
|
-
continue;
|
|
616
|
-
if (args.partial.attempts !== undefined && r.attempts !== args.partial.attempts)
|
|
617
|
-
continue;
|
|
618
|
-
if (args.partial.notified !== undefined && r.notified !== args.partial.notified)
|
|
619
|
-
continue;
|
|
620
|
-
if (args.partial.txid !== undefined && r.txid !== args.partial.txid)
|
|
621
|
-
continue;
|
|
622
|
-
if (args.partial.batch !== undefined && r.batch !== args.partial.batch)
|
|
623
|
-
continue;
|
|
624
|
-
if (args.partial.history !== undefined && r.history !== args.partial.history)
|
|
625
|
-
continue;
|
|
626
|
-
if (args.partial.notify !== undefined && r.notify !== args.partial.notify)
|
|
627
|
-
continue;
|
|
628
|
-
}
|
|
629
|
-
if (args.status && args.status.length > 0 && !args.status.includes(r.status))
|
|
630
|
-
continue;
|
|
631
|
-
if (args.txids && args.txids.length > 0 && !args.txids.includes(r.txid))
|
|
632
|
-
continue;
|
|
457
|
+
const dbTrx = this.toDbTrx(['proven_tx_reqs', 'transactions'], 'readonly', args.trx);
|
|
458
|
+
const direction = args.orderDescending ? 'prev' : 'next';
|
|
459
|
+
const store = dbTrx.objectStore('proven_tx_reqs');
|
|
460
|
+
const cursor = await this.openProvenTxReqsCursor(store, args.partial, direction);
|
|
461
|
+
await scanCursor(cursor, args.since, ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0, (_b = args.paged) === null || _b === void 0 ? void 0 : _b.limit, async (r) => {
|
|
462
|
+
if (!(0, idbHelpers_1.matchesProvenTxReqPartial)(r, args.partial))
|
|
463
|
+
return false;
|
|
464
|
+
if (args.status != null && args.status.length > 0 && !args.status.includes(r.status))
|
|
465
|
+
return false;
|
|
466
|
+
if (args.txids != null && args.txids.length > 0 && !args.txids.includes(r.txid))
|
|
467
|
+
return false;
|
|
633
468
|
if (userId !== undefined) {
|
|
634
469
|
const txsForUser = await this.countTransactions({ partial: { userId, txid: r.txid }, trx: dbTrx });
|
|
635
470
|
if (txsForUser === 0)
|
|
636
|
-
|
|
637
|
-
}
|
|
638
|
-
if (skipped < offset) {
|
|
639
|
-
skipped++;
|
|
640
|
-
continue;
|
|
471
|
+
return false;
|
|
641
472
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
break;
|
|
646
|
-
}
|
|
647
|
-
if (!args.trx)
|
|
473
|
+
return true;
|
|
474
|
+
}, filtered);
|
|
475
|
+
if (args.trx == null)
|
|
648
476
|
await dbTrx.done;
|
|
649
477
|
}
|
|
650
478
|
async findProvenTxReqs(args) {
|
|
@@ -657,68 +485,37 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
657
485
|
async filterProvenTxs(args, filtered, userId) {
|
|
658
486
|
var _a, _b, _c, _d;
|
|
659
487
|
this.assertNoUndefinedInPartial(args.partial);
|
|
660
|
-
if (args.partial.rawTx)
|
|
661
|
-
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.rawTx',
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
let count = 0;
|
|
488
|
+
if (args.partial.rawTx != null) {
|
|
489
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.rawTx', 'undefined. ProvenTxs may not be found by rawTx value.');
|
|
490
|
+
}
|
|
491
|
+
if (args.partial.merklePath != null) {
|
|
492
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.merklePath', 'undefined. ProvenTxs may not be found by merklePath value.');
|
|
493
|
+
}
|
|
667
494
|
const dbTrx = this.toDbTrx(['proven_txs', 'transactions'], 'readonly', args.trx);
|
|
668
495
|
const direction = args.orderDescending ? 'prev' : 'next';
|
|
496
|
+
const store = dbTrx.objectStore('proven_txs');
|
|
497
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
669
498
|
let cursor;
|
|
670
|
-
if ((
|
|
671
|
-
cursor = await
|
|
499
|
+
if ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.provenTxId) {
|
|
500
|
+
cursor = await store.openCursor(args.partial.provenTxId, direction);
|
|
672
501
|
}
|
|
673
|
-
else if (((
|
|
674
|
-
cursor = await
|
|
502
|
+
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.txid) !== undefined) {
|
|
503
|
+
cursor = await store.index('txid').openCursor(args.partial.txid, direction);
|
|
675
504
|
}
|
|
676
505
|
else {
|
|
677
|
-
cursor = await
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
cursor = await cursor.continue();
|
|
683
|
-
if (!cursor)
|
|
684
|
-
break;
|
|
685
|
-
firstTime = false;
|
|
686
|
-
const r = cursor.value;
|
|
687
|
-
if (args.since && args.since > r.updated_at)
|
|
688
|
-
continue;
|
|
689
|
-
if (args.partial) {
|
|
690
|
-
if (args.partial.provenTxId !== undefined && r.provenTxId !== args.partial.provenTxId)
|
|
691
|
-
continue;
|
|
692
|
-
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
693
|
-
continue;
|
|
694
|
-
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
695
|
-
continue;
|
|
696
|
-
if (args.partial.txid !== undefined && r.txid !== args.partial.txid)
|
|
697
|
-
continue;
|
|
698
|
-
if (args.partial.height !== undefined && r.height !== args.partial.height)
|
|
699
|
-
continue;
|
|
700
|
-
if (args.partial.index !== undefined && r.index !== args.partial.index)
|
|
701
|
-
continue;
|
|
702
|
-
if (args.partial.blockHash !== undefined && r.blockHash !== args.partial.blockHash)
|
|
703
|
-
continue;
|
|
704
|
-
if (args.partial.merkleRoot !== undefined && r.merkleRoot !== args.partial.merkleRoot)
|
|
705
|
-
continue;
|
|
706
|
-
}
|
|
506
|
+
cursor = await store.openCursor(null, direction);
|
|
507
|
+
}
|
|
508
|
+
await scanCursor(cursor, args.since, ((_c = args.paged) === null || _c === void 0 ? void 0 : _c.offset) || 0, (_d = args.paged) === null || _d === void 0 ? void 0 : _d.limit, async (r) => {
|
|
509
|
+
if (!(0, idbHelpers_1.matchesProvenTxPartial)(r, args.partial))
|
|
510
|
+
return false;
|
|
707
511
|
if (userId !== undefined) {
|
|
708
|
-
const
|
|
709
|
-
if (
|
|
710
|
-
|
|
711
|
-
}
|
|
712
|
-
if (skipped < offset) {
|
|
713
|
-
skipped++;
|
|
714
|
-
continue;
|
|
512
|
+
const txCount = await this.countTransactions({ partial: { userId, provenTxId: r.provenTxId }, trx: dbTrx });
|
|
513
|
+
if (txCount === 0)
|
|
514
|
+
return false;
|
|
715
515
|
}
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
break;
|
|
720
|
-
}
|
|
721
|
-
if (!args.trx)
|
|
516
|
+
return true;
|
|
517
|
+
}, filtered);
|
|
518
|
+
if (args.trx == null)
|
|
722
519
|
await dbTrx.done;
|
|
723
520
|
}
|
|
724
521
|
async findProvenTxs(args) {
|
|
@@ -731,57 +528,30 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
731
528
|
async filterTxLabelMaps(args, filtered, userId) {
|
|
732
529
|
var _a, _b, _c, _d;
|
|
733
530
|
this.assertNoUndefinedInPartial(args.partial);
|
|
734
|
-
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
735
|
-
let skipped = 0;
|
|
736
|
-
let count = 0;
|
|
737
531
|
const dbTrx = this.toDbTrx(['tx_labels_map', 'tx_labels'], 'readonly', args.trx);
|
|
532
|
+
const store = dbTrx.objectStore('tx_labels_map');
|
|
533
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
738
534
|
let cursor;
|
|
739
|
-
if (((
|
|
740
|
-
cursor = await
|
|
535
|
+
if (((_a = args.partial) === null || _a === void 0 ? void 0 : _a.transactionId) !== undefined) {
|
|
536
|
+
cursor = await store.index('transactionId').openCursor(args.partial.transactionId);
|
|
741
537
|
}
|
|
742
|
-
else if (((
|
|
743
|
-
cursor = await
|
|
538
|
+
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.txLabelId) !== undefined) {
|
|
539
|
+
cursor = await store.index('txLabelId').openCursor(args.partial.txLabelId);
|
|
744
540
|
}
|
|
745
541
|
else {
|
|
746
|
-
cursor = await
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
cursor = await cursor.continue();
|
|
752
|
-
if (!cursor)
|
|
753
|
-
break;
|
|
754
|
-
firstTime = false;
|
|
755
|
-
const r = cursor.value;
|
|
756
|
-
if (args.since && args.since > r.updated_at)
|
|
757
|
-
continue;
|
|
758
|
-
if (args.partial) {
|
|
759
|
-
if (args.partial.txLabelId !== undefined && r.txLabelId !== args.partial.txLabelId)
|
|
760
|
-
continue;
|
|
761
|
-
if (args.partial.transactionId !== undefined && r.transactionId !== args.partial.transactionId)
|
|
762
|
-
continue;
|
|
763
|
-
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
764
|
-
continue;
|
|
765
|
-
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
766
|
-
continue;
|
|
767
|
-
if (args.partial.isDeleted !== undefined && r.isDeleted !== args.partial.isDeleted)
|
|
768
|
-
continue;
|
|
769
|
-
}
|
|
542
|
+
cursor = await store.openCursor();
|
|
543
|
+
}
|
|
544
|
+
await scanCursor(cursor, args.since, ((_c = args.paged) === null || _c === void 0 ? void 0 : _c.offset) || 0, (_d = args.paged) === null || _d === void 0 ? void 0 : _d.limit, async (r) => {
|
|
545
|
+
if (!(0, idbHelpers_1.matchesTxLabelMapPartial)(r, args.partial))
|
|
546
|
+
return false;
|
|
770
547
|
if (userId !== undefined) {
|
|
771
|
-
const
|
|
772
|
-
if (
|
|
773
|
-
|
|
548
|
+
const labelCount = await this.countTxLabels({ partial: { userId, txLabelId: r.txLabelId }, trx: dbTrx });
|
|
549
|
+
if (labelCount === 0)
|
|
550
|
+
return false;
|
|
774
551
|
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
}
|
|
779
|
-
filtered(r);
|
|
780
|
-
count++;
|
|
781
|
-
if (((_d = args.paged) === null || _d === void 0 ? void 0 : _d.limit) && count >= args.paged.limit)
|
|
782
|
-
break;
|
|
783
|
-
}
|
|
784
|
-
if (!args.trx)
|
|
552
|
+
return true;
|
|
553
|
+
}, filtered);
|
|
554
|
+
if (args.trx == null)
|
|
785
555
|
await dbTrx.done;
|
|
786
556
|
}
|
|
787
557
|
async findTxLabelMaps(args) {
|
|
@@ -843,7 +613,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
843
613
|
}
|
|
844
614
|
}
|
|
845
615
|
finally {
|
|
846
|
-
if (
|
|
616
|
+
if (trx == null)
|
|
847
617
|
await dbTrx.done;
|
|
848
618
|
}
|
|
849
619
|
return certificate.certificateId;
|
|
@@ -856,7 +626,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
856
626
|
await store.add(e);
|
|
857
627
|
}
|
|
858
628
|
finally {
|
|
859
|
-
if (
|
|
629
|
+
if (trx == null)
|
|
860
630
|
await dbTrx.done;
|
|
861
631
|
}
|
|
862
632
|
}
|
|
@@ -871,7 +641,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
871
641
|
commission.commissionId = id;
|
|
872
642
|
}
|
|
873
643
|
finally {
|
|
874
|
-
if (
|
|
644
|
+
if (trx == null)
|
|
875
645
|
await dbTrx.done;
|
|
876
646
|
}
|
|
877
647
|
return commission.commissionId;
|
|
@@ -887,7 +657,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
887
657
|
event.id = id;
|
|
888
658
|
}
|
|
889
659
|
finally {
|
|
890
|
-
if (
|
|
660
|
+
if (trx == null)
|
|
891
661
|
await dbTrx.done;
|
|
892
662
|
}
|
|
893
663
|
return event.id;
|
|
@@ -903,7 +673,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
903
673
|
output.outputId = id;
|
|
904
674
|
}
|
|
905
675
|
finally {
|
|
906
|
-
if (
|
|
676
|
+
if (trx == null)
|
|
907
677
|
await dbTrx.done;
|
|
908
678
|
}
|
|
909
679
|
return output.outputId;
|
|
@@ -919,7 +689,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
919
689
|
basket.basketId = id;
|
|
920
690
|
}
|
|
921
691
|
finally {
|
|
922
|
-
if (
|
|
692
|
+
if (trx == null)
|
|
923
693
|
await dbTrx.done;
|
|
924
694
|
}
|
|
925
695
|
return basket.basketId;
|
|
@@ -935,7 +705,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
935
705
|
tag.outputTagId = id;
|
|
936
706
|
}
|
|
937
707
|
finally {
|
|
938
|
-
if (
|
|
708
|
+
if (trx == null)
|
|
939
709
|
await dbTrx.done;
|
|
940
710
|
}
|
|
941
711
|
return tag.outputTagId;
|
|
@@ -948,7 +718,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
948
718
|
await store.add(e);
|
|
949
719
|
}
|
|
950
720
|
finally {
|
|
951
|
-
if (
|
|
721
|
+
if (trx == null)
|
|
952
722
|
await dbTrx.done;
|
|
953
723
|
}
|
|
954
724
|
}
|
|
@@ -963,7 +733,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
963
733
|
tx.provenTxId = id;
|
|
964
734
|
}
|
|
965
735
|
finally {
|
|
966
|
-
if (
|
|
736
|
+
if (trx == null)
|
|
967
737
|
await dbTrx.done;
|
|
968
738
|
}
|
|
969
739
|
return tx.provenTxId;
|
|
@@ -979,7 +749,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
979
749
|
tx.provenTxReqId = id;
|
|
980
750
|
}
|
|
981
751
|
finally {
|
|
982
|
-
if (
|
|
752
|
+
if (trx == null)
|
|
983
753
|
await dbTrx.done;
|
|
984
754
|
}
|
|
985
755
|
return tx.provenTxReqId;
|
|
@@ -995,7 +765,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
995
765
|
syncState.syncStateId = id;
|
|
996
766
|
}
|
|
997
767
|
finally {
|
|
998
|
-
if (
|
|
768
|
+
if (trx == null)
|
|
999
769
|
await dbTrx.done;
|
|
1000
770
|
}
|
|
1001
771
|
return syncState.syncStateId;
|
|
@@ -1011,7 +781,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1011
781
|
tx.transactionId = id;
|
|
1012
782
|
}
|
|
1013
783
|
finally {
|
|
1014
|
-
if (
|
|
784
|
+
if (trx == null)
|
|
1015
785
|
await dbTrx.done;
|
|
1016
786
|
}
|
|
1017
787
|
return tx.transactionId;
|
|
@@ -1027,7 +797,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1027
797
|
label.txLabelId = id;
|
|
1028
798
|
}
|
|
1029
799
|
finally {
|
|
1030
|
-
if (
|
|
800
|
+
if (trx == null)
|
|
1031
801
|
await dbTrx.done;
|
|
1032
802
|
}
|
|
1033
803
|
return label.txLabelId;
|
|
@@ -1040,7 +810,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1040
810
|
await store.add(e);
|
|
1041
811
|
}
|
|
1042
812
|
finally {
|
|
1043
|
-
if (
|
|
813
|
+
if (trx == null)
|
|
1044
814
|
await dbTrx.done;
|
|
1045
815
|
}
|
|
1046
816
|
}
|
|
@@ -1055,14 +825,14 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1055
825
|
user.userId = id;
|
|
1056
826
|
}
|
|
1057
827
|
finally {
|
|
1058
|
-
if (
|
|
828
|
+
if (trx == null)
|
|
1059
829
|
await dbTrx.done;
|
|
1060
830
|
}
|
|
1061
831
|
return user.userId;
|
|
1062
832
|
}
|
|
1063
833
|
async updateIdb(id, update, keyProp, storeName, trx) {
|
|
1064
834
|
if (update[keyProp] !== undefined && (Array.isArray(id) || update[keyProp] !== id)) {
|
|
1065
|
-
throw new WERR_errors_1.WERR_INVALID_PARAMETER(`update.${keyProp}`,
|
|
835
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER(`update.${keyProp}`, 'undefined');
|
|
1066
836
|
}
|
|
1067
837
|
const u = this.validatePartialForUpdate(update);
|
|
1068
838
|
const dbTrx = this.toDbTrx([storeName], 'readwrite', trx);
|
|
@@ -1082,22 +852,23 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1082
852
|
};
|
|
1083
853
|
const uid = await store.put(v);
|
|
1084
854
|
if (uid !== i)
|
|
1085
|
-
throw new WERR_errors_1.WERR_INTERNAL(`updated id ${uid} does not match original ${id}`);
|
|
855
|
+
throw new WERR_errors_1.WERR_INTERNAL(`updated id ${String(uid)} does not match original ${String(id)}`);
|
|
1086
856
|
updated++;
|
|
1087
857
|
}
|
|
1088
858
|
}
|
|
1089
859
|
finally {
|
|
1090
|
-
if (
|
|
860
|
+
if (trx == null)
|
|
1091
861
|
await dbTrx.done;
|
|
1092
862
|
}
|
|
1093
863
|
return updated;
|
|
1094
864
|
}
|
|
1095
865
|
async updateIdbKey(key, update, keyProps, storeName, trx) {
|
|
1096
|
-
if (key.length !== keyProps.length)
|
|
866
|
+
if (key.length !== keyProps.length) {
|
|
1097
867
|
throw new WERR_errors_1.WERR_INTERNAL(`key.length ${key.length} !== keyProps.length ${keyProps.length}`);
|
|
868
|
+
}
|
|
1098
869
|
for (let i = 0; i < key.length; i++) {
|
|
1099
870
|
if (update[keyProps[i]] !== undefined && update[keyProps[i]] !== key[i]) {
|
|
1100
|
-
throw new WERR_errors_1.WERR_INVALID_PARAMETER(`update.${keyProps[i]}`,
|
|
871
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER(`update.${keyProps[i]}`, 'undefined');
|
|
1101
872
|
}
|
|
1102
873
|
}
|
|
1103
874
|
const u = this.validatePartialForUpdate(update);
|
|
@@ -1105,8 +876,9 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1105
876
|
const store = dbTrx.objectStore(storeName);
|
|
1106
877
|
try {
|
|
1107
878
|
const e = await store.get(key);
|
|
1108
|
-
if (!e)
|
|
879
|
+
if (!e) {
|
|
1109
880
|
throw new WERR_errors_1.WERR_INVALID_PARAMETER('key', `an existing record to update ${keyProps.join(',')} ${key.join(',')} not found`);
|
|
881
|
+
}
|
|
1110
882
|
const v = {
|
|
1111
883
|
...e,
|
|
1112
884
|
...u
|
|
@@ -1118,61 +890,61 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1118
890
|
}
|
|
1119
891
|
}
|
|
1120
892
|
finally {
|
|
1121
|
-
if (
|
|
893
|
+
if (trx == null)
|
|
1122
894
|
await dbTrx.done;
|
|
1123
895
|
}
|
|
1124
896
|
return 1;
|
|
1125
897
|
}
|
|
1126
898
|
async updateCertificate(id, update, trx) {
|
|
1127
|
-
return this.updateIdb(id, update, 'certificateId', 'certificates', trx);
|
|
899
|
+
return await this.updateIdb(id, update, 'certificateId', 'certificates', trx);
|
|
1128
900
|
}
|
|
1129
901
|
async updateCertificateField(certificateId, fieldName, update, trx) {
|
|
1130
|
-
return this.updateIdbKey([certificateId, fieldName], update, ['certificateId', 'fieldName'], 'certificate_fields', trx);
|
|
902
|
+
return await this.updateIdbKey([certificateId, fieldName], update, ['certificateId', 'fieldName'], 'certificate_fields', trx);
|
|
1131
903
|
}
|
|
1132
904
|
async updateCommission(id, update, trx) {
|
|
1133
|
-
return this.updateIdb(id, update, 'commissionId', 'commissions', trx);
|
|
905
|
+
return await this.updateIdb(id, update, 'commissionId', 'commissions', trx);
|
|
1134
906
|
}
|
|
1135
907
|
async updateMonitorEvent(id, update, trx) {
|
|
1136
|
-
return this.updateIdb(id, update, 'id', 'monitor_events', trx);
|
|
908
|
+
return await this.updateIdb(id, update, 'id', 'monitor_events', trx);
|
|
1137
909
|
}
|
|
1138
910
|
async updateOutput(id, update, trx) {
|
|
1139
|
-
return this.updateIdb(id, update, 'outputId', 'outputs', trx);
|
|
911
|
+
return await this.updateIdb(id, update, 'outputId', 'outputs', trx);
|
|
1140
912
|
}
|
|
1141
913
|
async updateOutputBasket(id, update, trx) {
|
|
1142
|
-
return this.updateIdb(id, update, 'basketId', 'output_baskets', trx);
|
|
914
|
+
return await this.updateIdb(id, update, 'basketId', 'output_baskets', trx);
|
|
1143
915
|
}
|
|
1144
916
|
async updateOutputTag(id, update, trx) {
|
|
1145
|
-
return this.updateIdb(id, update, 'outputTagId', 'output_tags', trx);
|
|
917
|
+
return await this.updateIdb(id, update, 'outputTagId', 'output_tags', trx);
|
|
1146
918
|
}
|
|
1147
919
|
async updateProvenTx(id, update, trx) {
|
|
1148
|
-
return this.updateIdb(id, update, 'provenTxId', 'proven_txs', trx);
|
|
920
|
+
return await this.updateIdb(id, update, 'provenTxId', 'proven_txs', trx);
|
|
1149
921
|
}
|
|
1150
922
|
async updateProvenTxReq(id, update, trx) {
|
|
1151
|
-
return this.updateIdb(id, update, 'provenTxReqId', 'proven_tx_reqs', trx);
|
|
923
|
+
return await this.updateIdb(id, update, 'provenTxReqId', 'proven_tx_reqs', trx);
|
|
1152
924
|
}
|
|
1153
925
|
async updateSyncState(id, update, trx) {
|
|
1154
|
-
return this.updateIdb(id, update, 'syncStateId', 'sync_states', trx);
|
|
926
|
+
return await this.updateIdb(id, update, 'syncStateId', 'sync_states', trx);
|
|
1155
927
|
}
|
|
1156
928
|
async updateTransaction(id, update, trx) {
|
|
1157
|
-
return this.updateIdb(id, update, 'transactionId', 'transactions', trx);
|
|
929
|
+
return await this.updateIdb(id, update, 'transactionId', 'transactions', trx);
|
|
1158
930
|
}
|
|
1159
931
|
async updateTxLabel(id, update, trx) {
|
|
1160
|
-
return this.updateIdb(id, update, 'txLabelId', 'tx_labels', trx);
|
|
932
|
+
return await this.updateIdb(id, update, 'txLabelId', 'tx_labels', trx);
|
|
1161
933
|
}
|
|
1162
934
|
async updateUser(id, update, trx) {
|
|
1163
|
-
return this.updateIdb(id, update, 'userId', 'users', trx);
|
|
935
|
+
return await this.updateIdb(id, update, 'userId', 'users', trx);
|
|
1164
936
|
}
|
|
1165
937
|
async updateOutputTagMap(outputId, tagId, update, trx) {
|
|
1166
|
-
return this.updateIdbKey([tagId, outputId], update, ['outputTagId', 'outputId'], 'output_tags_map', trx);
|
|
938
|
+
return await this.updateIdbKey([tagId, outputId], update, ['outputTagId', 'outputId'], 'output_tags_map', trx);
|
|
1167
939
|
}
|
|
1168
940
|
async updateTxLabelMap(transactionId, txLabelId, update, trx) {
|
|
1169
|
-
return this.updateIdbKey([txLabelId, transactionId], update, ['txLabelId', 'transactionId'], 'tx_labels_map', trx);
|
|
941
|
+
return await this.updateIdbKey([txLabelId, transactionId], update, ['txLabelId', 'transactionId'], 'tx_labels_map', trx);
|
|
1170
942
|
}
|
|
1171
943
|
//
|
|
1172
944
|
// StorageReader abstract methods
|
|
1173
945
|
//
|
|
1174
946
|
async destroy() {
|
|
1175
|
-
if (this.db) {
|
|
947
|
+
if (this.db != null) {
|
|
1176
948
|
this.db.close();
|
|
1177
949
|
}
|
|
1178
950
|
this.db = undefined;
|
|
@@ -1184,7 +956,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1184
956
|
* @returns
|
|
1185
957
|
*/
|
|
1186
958
|
async transaction(scope, trx) {
|
|
1187
|
-
if (trx)
|
|
959
|
+
if (trx != null)
|
|
1188
960
|
return await scope(trx);
|
|
1189
961
|
const stores = this.allStores;
|
|
1190
962
|
const db = await this.verifyDB();
|
|
@@ -1203,59 +975,21 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1203
975
|
async filterCertificateFields(args, filtered) {
|
|
1204
976
|
var _a, _b, _c, _d;
|
|
1205
977
|
this.assertNoUndefinedInPartial(args.partial);
|
|
1206
|
-
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1207
|
-
let skipped = 0;
|
|
1208
|
-
let count = 0;
|
|
1209
978
|
const dbTrx = this.toDbTrx(['certificate_fields'], 'readonly', args.trx);
|
|
979
|
+
const store = dbTrx.objectStore('certificate_fields');
|
|
980
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1210
981
|
let cursor;
|
|
1211
|
-
if (((
|
|
1212
|
-
cursor = await
|
|
1213
|
-
.objectStore('certificate_fields')
|
|
1214
|
-
.index('certificateId')
|
|
1215
|
-
.openCursor(args.partial.certificateId);
|
|
982
|
+
if (((_a = args.partial) === null || _a === void 0 ? void 0 : _a.certificateId) !== undefined) {
|
|
983
|
+
cursor = await store.index('certificateId').openCursor(args.partial.certificateId);
|
|
1216
984
|
}
|
|
1217
|
-
else if (((
|
|
1218
|
-
cursor = await
|
|
985
|
+
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.userId) !== undefined) {
|
|
986
|
+
cursor = await store.index('userId').openCursor(args.partial.userId);
|
|
1219
987
|
}
|
|
1220
988
|
else {
|
|
1221
|
-
cursor = await
|
|
1222
|
-
}
|
|
1223
|
-
let firstTime = true;
|
|
1224
|
-
while (cursor) {
|
|
1225
|
-
if (!firstTime)
|
|
1226
|
-
cursor = await cursor.continue();
|
|
1227
|
-
if (!cursor)
|
|
1228
|
-
break;
|
|
1229
|
-
firstTime = false;
|
|
1230
|
-
const r = cursor.value;
|
|
1231
|
-
if (args.since && args.since > r.updated_at)
|
|
1232
|
-
continue;
|
|
1233
|
-
if (args.partial) {
|
|
1234
|
-
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
1235
|
-
continue;
|
|
1236
|
-
if (args.partial.certificateId !== undefined && r.certificateId !== args.partial.certificateId)
|
|
1237
|
-
continue;
|
|
1238
|
-
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1239
|
-
continue;
|
|
1240
|
-
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1241
|
-
continue;
|
|
1242
|
-
if (args.partial.fieldName !== undefined && r.fieldName !== args.partial.fieldName)
|
|
1243
|
-
continue;
|
|
1244
|
-
if (args.partial.fieldValue !== undefined && r.fieldValue !== args.partial.fieldValue)
|
|
1245
|
-
continue;
|
|
1246
|
-
if (args.partial.masterKey !== undefined && r.masterKey !== args.partial.masterKey)
|
|
1247
|
-
continue;
|
|
1248
|
-
}
|
|
1249
|
-
if (skipped < offset) {
|
|
1250
|
-
skipped++;
|
|
1251
|
-
continue;
|
|
1252
|
-
}
|
|
1253
|
-
filtered(r);
|
|
1254
|
-
count++;
|
|
1255
|
-
if (((_d = args.paged) === null || _d === void 0 ? void 0 : _d.limit) && count >= args.paged.limit)
|
|
1256
|
-
break;
|
|
989
|
+
cursor = await store.openCursor();
|
|
1257
990
|
}
|
|
1258
|
-
|
|
991
|
+
await scanCursor(cursor, args.since, ((_c = args.paged) === null || _c === void 0 ? void 0 : _c.offset) || 0, (_d = args.paged) === null || _d === void 0 ? void 0 : _d.limit, r => (0, idbHelpers_1.matchesCertificateFieldPartial)(r, args.partial), filtered);
|
|
992
|
+
if (args.trx == null)
|
|
1259
993
|
await dbTrx.done;
|
|
1260
994
|
}
|
|
1261
995
|
async findCertificateFields(args) {
|
|
@@ -1265,81 +999,40 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1265
999
|
});
|
|
1266
1000
|
return result;
|
|
1267
1001
|
}
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
if (
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
cursor = await dbTrx
|
|
1282
|
-
.objectStore('certificates')
|
|
1002
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1003
|
+
async openCertificatesCursor(
|
|
1004
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1005
|
+
store,
|
|
1006
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1007
|
+
partial
|
|
1008
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1009
|
+
) {
|
|
1010
|
+
if (partial === null || partial === void 0 ? void 0 : partial.certificateId)
|
|
1011
|
+
return store.openCursor(partial.certificateId);
|
|
1012
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.userId) !== undefined) {
|
|
1013
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.type) && (partial === null || partial === void 0 ? void 0 : partial.certifier) && (partial === null || partial === void 0 ? void 0 : partial.serialNumber)) {
|
|
1014
|
+
return store
|
|
1283
1015
|
.index('userId_type_certifier_serialNumber')
|
|
1284
|
-
.openCursor([
|
|
1285
|
-
}
|
|
1286
|
-
else {
|
|
1287
|
-
cursor = await dbTrx.objectStore('certificates').index('userId').openCursor(args.partial.userId);
|
|
1016
|
+
.openCursor([partial.userId, partial.type, partial.certifier, partial.serialNumber]);
|
|
1288
1017
|
}
|
|
1018
|
+
return store.index('userId').openCursor(partial.userId);
|
|
1289
1019
|
}
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
if (args.
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
continue;
|
|
1307
|
-
if (args.partial) {
|
|
1308
|
-
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
1309
|
-
continue;
|
|
1310
|
-
if (args.partial.certificateId !== undefined && r.certificateId !== args.partial.certificateId)
|
|
1311
|
-
continue;
|
|
1312
|
-
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1313
|
-
continue;
|
|
1314
|
-
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1315
|
-
continue;
|
|
1316
|
-
if (args.partial.type !== undefined && r.type !== args.partial.type)
|
|
1317
|
-
continue;
|
|
1318
|
-
if (args.partial.serialNumber !== undefined && r.serialNumber !== args.partial.serialNumber)
|
|
1319
|
-
continue;
|
|
1320
|
-
if (args.partial.certifier !== undefined && r.certifier !== args.partial.certifier)
|
|
1321
|
-
continue;
|
|
1322
|
-
if (args.partial.subject !== undefined && r.subject !== args.partial.subject)
|
|
1323
|
-
continue;
|
|
1324
|
-
if (args.partial.verifier !== undefined && r.verifier !== args.partial.verifier)
|
|
1325
|
-
continue;
|
|
1326
|
-
if (args.partial.revocationOutpoint !== undefined && r.revocationOutpoint !== args.partial.revocationOutpoint)
|
|
1327
|
-
continue;
|
|
1328
|
-
if (args.partial.signature !== undefined && r.signature !== args.partial.signature)
|
|
1329
|
-
continue;
|
|
1330
|
-
if (args.partial.isDeleted !== undefined && r.isDeleted !== args.partial.isDeleted)
|
|
1331
|
-
continue;
|
|
1332
|
-
}
|
|
1333
|
-
if (skipped < offset) {
|
|
1334
|
-
skipped++;
|
|
1335
|
-
continue;
|
|
1336
|
-
}
|
|
1337
|
-
filtered(r);
|
|
1338
|
-
count++;
|
|
1339
|
-
if (((_g = args.paged) === null || _g === void 0 ? void 0 : _g.limit) && count >= args.paged.limit)
|
|
1340
|
-
break;
|
|
1341
|
-
}
|
|
1342
|
-
if (!args.trx)
|
|
1020
|
+
return store.openCursor();
|
|
1021
|
+
}
|
|
1022
|
+
async filterCertificates(args, filtered) {
|
|
1023
|
+
var _a, _b;
|
|
1024
|
+
this.assertNoUndefinedInPartial(args.partial);
|
|
1025
|
+
const dbTrx = this.toDbTrx(['certificates'], 'readonly', args.trx);
|
|
1026
|
+
const store = dbTrx.objectStore('certificates');
|
|
1027
|
+
const cursor = await this.openCertificatesCursor(store, args.partial);
|
|
1028
|
+
await scanCursor(cursor, args.since, ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0, (_b = args.paged) === null || _b === void 0 ? void 0 : _b.limit, r => {
|
|
1029
|
+
if (args.certifiers != null && !args.certifiers.includes(r.certifier))
|
|
1030
|
+
return false;
|
|
1031
|
+
if (args.types != null && !args.types.includes(r.type))
|
|
1032
|
+
return false;
|
|
1033
|
+
return (0, idbHelpers_1.matchesCertificatePartial)(r, args.partial);
|
|
1034
|
+
}, filtered);
|
|
1035
|
+
if (args.trx == null)
|
|
1343
1036
|
await dbTrx.done;
|
|
1344
1037
|
}
|
|
1345
1038
|
async findCertificates(args) {
|
|
@@ -1358,63 +1051,27 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1358
1051
|
async filterCommissions(args, filtered) {
|
|
1359
1052
|
var _a, _b, _c, _d, _e;
|
|
1360
1053
|
this.assertNoUndefinedInPartial(args.partial);
|
|
1361
|
-
if (args.partial.lockingScript)
|
|
1362
|
-
throw new WERR_errors_1.WERR_INVALID_PARAMETER('partial.lockingScript',
|
|
1363
|
-
|
|
1364
|
-
let skipped = 0;
|
|
1365
|
-
let count = 0;
|
|
1054
|
+
if (args.partial.lockingScript != null) {
|
|
1055
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('partial.lockingScript', 'undefined. Commissions may not be found by lockingScript value.');
|
|
1056
|
+
}
|
|
1366
1057
|
const dbTrx = this.toDbTrx(['commissions'], 'readonly', args.trx);
|
|
1058
|
+
const store = dbTrx.objectStore('commissions');
|
|
1059
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1367
1060
|
let cursor;
|
|
1368
|
-
if ((
|
|
1369
|
-
cursor = await
|
|
1061
|
+
if ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.commissionId) {
|
|
1062
|
+
cursor = await store.openCursor(args.partial.commissionId);
|
|
1370
1063
|
}
|
|
1371
|
-
else if (((
|
|
1372
|
-
cursor = await
|
|
1064
|
+
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.userId) !== undefined) {
|
|
1065
|
+
cursor = await store.index('userId').openCursor(args.partial.userId);
|
|
1373
1066
|
}
|
|
1374
|
-
else if (((
|
|
1375
|
-
cursor = await
|
|
1067
|
+
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.transactionId) !== undefined) {
|
|
1068
|
+
cursor = await store.index('transactionId').openCursor(args.partial.transactionId);
|
|
1376
1069
|
}
|
|
1377
1070
|
else {
|
|
1378
|
-
cursor = await
|
|
1379
|
-
}
|
|
1380
|
-
let firstTime = true;
|
|
1381
|
-
while (cursor) {
|
|
1382
|
-
if (!firstTime)
|
|
1383
|
-
cursor = await cursor.continue();
|
|
1384
|
-
if (!cursor)
|
|
1385
|
-
break;
|
|
1386
|
-
firstTime = false;
|
|
1387
|
-
const r = cursor.value;
|
|
1388
|
-
if (args.since && args.since > r.updated_at)
|
|
1389
|
-
continue;
|
|
1390
|
-
if (args.partial) {
|
|
1391
|
-
if (args.partial.commissionId !== undefined && r.commissionId !== args.partial.commissionId)
|
|
1392
|
-
continue;
|
|
1393
|
-
if (args.partial.transactionId !== undefined && r.transactionId !== args.partial.transactionId)
|
|
1394
|
-
continue;
|
|
1395
|
-
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
1396
|
-
continue;
|
|
1397
|
-
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1398
|
-
continue;
|
|
1399
|
-
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1400
|
-
continue;
|
|
1401
|
-
if (args.partial.satoshis !== undefined && r.satoshis !== args.partial.satoshis)
|
|
1402
|
-
continue;
|
|
1403
|
-
if (args.partial.keyOffset !== undefined && r.keyOffset !== args.partial.keyOffset)
|
|
1404
|
-
continue;
|
|
1405
|
-
if (args.partial.isRedeemed !== undefined && r.isRedeemed !== args.partial.isRedeemed)
|
|
1406
|
-
continue;
|
|
1407
|
-
}
|
|
1408
|
-
if (skipped < offset) {
|
|
1409
|
-
skipped++;
|
|
1410
|
-
continue;
|
|
1411
|
-
}
|
|
1412
|
-
filtered(r);
|
|
1413
|
-
count++;
|
|
1414
|
-
if (((_e = args.paged) === null || _e === void 0 ? void 0 : _e.limit) && count >= args.paged.limit)
|
|
1415
|
-
break;
|
|
1071
|
+
cursor = await store.openCursor();
|
|
1416
1072
|
}
|
|
1417
|
-
|
|
1073
|
+
await scanCursor(cursor, args.since, ((_d = args.paged) === null || _d === void 0 ? void 0 : _d.offset) || 0, (_e = args.paged) === null || _e === void 0 ? void 0 : _e.limit, r => (0, idbHelpers_1.matchesCommissionPartial)(r, args.partial), filtered);
|
|
1074
|
+
if (args.trx == null)
|
|
1418
1075
|
await dbTrx.done;
|
|
1419
1076
|
}
|
|
1420
1077
|
async findCommissions(args) {
|
|
@@ -1427,49 +1084,11 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1427
1084
|
async filterMonitorEvents(args, filtered) {
|
|
1428
1085
|
var _a, _b, _c;
|
|
1429
1086
|
this.assertNoUndefinedInPartial(args.partial);
|
|
1430
|
-
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1431
|
-
let skipped = 0;
|
|
1432
|
-
let count = 0;
|
|
1433
1087
|
const dbTrx = this.toDbTrx(['monitor_events'], 'readonly', args.trx);
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
else {
|
|
1439
|
-
cursor = await dbTrx.objectStore('monitor_events').openCursor();
|
|
1440
|
-
}
|
|
1441
|
-
let firstTime = true;
|
|
1442
|
-
while (cursor) {
|
|
1443
|
-
if (!firstTime)
|
|
1444
|
-
cursor = await cursor.continue();
|
|
1445
|
-
if (!cursor)
|
|
1446
|
-
break;
|
|
1447
|
-
firstTime = false;
|
|
1448
|
-
const r = cursor.value;
|
|
1449
|
-
if (args.since && args.since > r.updated_at)
|
|
1450
|
-
continue;
|
|
1451
|
-
if (args.partial) {
|
|
1452
|
-
if (args.partial.id !== undefined && r.id !== args.partial.id)
|
|
1453
|
-
continue;
|
|
1454
|
-
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1455
|
-
continue;
|
|
1456
|
-
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1457
|
-
continue;
|
|
1458
|
-
if (args.partial.event !== undefined && r.event !== args.partial.event)
|
|
1459
|
-
continue;
|
|
1460
|
-
if (args.partial.details !== undefined && r.details !== args.partial.details)
|
|
1461
|
-
continue;
|
|
1462
|
-
}
|
|
1463
|
-
if (skipped < offset) {
|
|
1464
|
-
skipped++;
|
|
1465
|
-
continue;
|
|
1466
|
-
}
|
|
1467
|
-
filtered(r);
|
|
1468
|
-
count++;
|
|
1469
|
-
if (((_c = args.paged) === null || _c === void 0 ? void 0 : _c.limit) && count >= args.paged.limit)
|
|
1470
|
-
break;
|
|
1471
|
-
}
|
|
1472
|
-
if (!args.trx)
|
|
1088
|
+
const store = dbTrx.objectStore('monitor_events');
|
|
1089
|
+
const cursor = ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.id) ? await store.openCursor(args.partial.id) : await store.openCursor();
|
|
1090
|
+
await scanCursor(cursor, args.since, ((_b = args.paged) === null || _b === void 0 ? void 0 : _b.offset) || 0, (_c = args.paged) === null || _c === void 0 ? void 0 : _c.limit, r => (0, idbHelpers_1.matchesMonitorEventPartial)(r, args.partial), filtered);
|
|
1091
|
+
if (args.trx == null)
|
|
1473
1092
|
await dbTrx.done;
|
|
1474
1093
|
}
|
|
1475
1094
|
async findMonitorEvents(args) {
|
|
@@ -1480,70 +1099,26 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1480
1099
|
return result;
|
|
1481
1100
|
}
|
|
1482
1101
|
async filterOutputBaskets(args, filtered) {
|
|
1483
|
-
var _a, _b, _c, _d, _e;
|
|
1102
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1484
1103
|
this.assertNoUndefinedInPartial(args.partial);
|
|
1485
|
-
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1486
|
-
let skipped = 0;
|
|
1487
|
-
let count = 0;
|
|
1488
1104
|
const dbTrx = this.toDbTrx(['output_baskets'], 'readonly', args.trx);
|
|
1105
|
+
const store = dbTrx.objectStore('output_baskets');
|
|
1106
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1489
1107
|
let cursor;
|
|
1490
|
-
if ((
|
|
1491
|
-
cursor = await
|
|
1492
|
-
}
|
|
1493
|
-
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
.openCursor([args.partial.name, args.partial.userId]);
|
|
1499
|
-
}
|
|
1500
|
-
else {
|
|
1501
|
-
cursor = await dbTrx.objectStore('output_baskets').index('userId').openCursor(args.partial.userId);
|
|
1502
|
-
}
|
|
1108
|
+
if ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.basketId) {
|
|
1109
|
+
cursor = await store.openCursor(args.partial.basketId);
|
|
1110
|
+
}
|
|
1111
|
+
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.userId) !== undefined && ((_c = args.partial) === null || _c === void 0 ? void 0 : _c.name) !== undefined) {
|
|
1112
|
+
cursor = await store.index('name_userId').openCursor([args.partial.name, args.partial.userId]);
|
|
1113
|
+
}
|
|
1114
|
+
else if (((_d = args.partial) === null || _d === void 0 ? void 0 : _d.userId) !== undefined) {
|
|
1115
|
+
cursor = await store.index('userId').openCursor(args.partial.userId);
|
|
1503
1116
|
}
|
|
1504
1117
|
else {
|
|
1505
|
-
cursor = await
|
|
1506
|
-
}
|
|
1507
|
-
let firstTime = true;
|
|
1508
|
-
while (cursor) {
|
|
1509
|
-
if (!firstTime)
|
|
1510
|
-
cursor = await cursor.continue();
|
|
1511
|
-
if (!cursor)
|
|
1512
|
-
break;
|
|
1513
|
-
firstTime = false;
|
|
1514
|
-
const r = cursor.value;
|
|
1515
|
-
if (args.since && args.since > r.updated_at)
|
|
1516
|
-
continue;
|
|
1517
|
-
if (args.partial) {
|
|
1518
|
-
if (args.partial.basketId !== undefined && r.basketId !== args.partial.basketId)
|
|
1519
|
-
continue;
|
|
1520
|
-
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
1521
|
-
continue;
|
|
1522
|
-
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1523
|
-
continue;
|
|
1524
|
-
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1525
|
-
continue;
|
|
1526
|
-
if (args.partial.name !== undefined && r.name !== args.partial.name)
|
|
1527
|
-
continue;
|
|
1528
|
-
if (args.partial.numberOfDesiredUTXOs !== undefined &&
|
|
1529
|
-
r.numberOfDesiredUTXOs !== args.partial.numberOfDesiredUTXOs)
|
|
1530
|
-
continue;
|
|
1531
|
-
if (args.partial.minimumDesiredUTXOValue !== undefined &&
|
|
1532
|
-
r.numberOfDesiredSatoshis !== args.partial.minimumDesiredUTXOValue)
|
|
1533
|
-
continue;
|
|
1534
|
-
if (args.partial.isDeleted !== undefined && r.isDeleted !== args.partial.isDeleted)
|
|
1535
|
-
continue;
|
|
1536
|
-
}
|
|
1537
|
-
if (skipped < offset) {
|
|
1538
|
-
skipped++;
|
|
1539
|
-
continue;
|
|
1540
|
-
}
|
|
1541
|
-
filtered(r);
|
|
1542
|
-
count++;
|
|
1543
|
-
if (((_e = args.paged) === null || _e === void 0 ? void 0 : _e.limit) && count >= args.paged.limit)
|
|
1544
|
-
break;
|
|
1118
|
+
cursor = await store.openCursor();
|
|
1545
1119
|
}
|
|
1546
|
-
|
|
1120
|
+
await scanCursor(cursor, args.since, ((_e = args.paged) === null || _e === void 0 ? void 0 : _e.offset) || 0, (_f = args.paged) === null || _f === void 0 ? void 0 : _f.limit, r => (0, idbHelpers_1.matchesOutputBasketPartial)(r, args.partial), filtered);
|
|
1121
|
+
if (args.trx == null)
|
|
1547
1122
|
await dbTrx.done;
|
|
1548
1123
|
}
|
|
1549
1124
|
async findOutputBaskets(args) {
|
|
@@ -1553,227 +1128,121 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1553
1128
|
});
|
|
1554
1129
|
return result;
|
|
1555
1130
|
}
|
|
1131
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1132
|
+
async openOutputsCursor(
|
|
1133
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1134
|
+
store,
|
|
1135
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1136
|
+
partial, direction
|
|
1137
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1138
|
+
) {
|
|
1139
|
+
if (partial === null || partial === void 0 ? void 0 : partial.outputId)
|
|
1140
|
+
return store.openCursor(partial.outputId, direction);
|
|
1141
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.userId) !== undefined) {
|
|
1142
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.transactionId) && (partial === null || partial === void 0 ? void 0 : partial.vout) !== undefined) {
|
|
1143
|
+
return store.index('transactionId_vout_userId').openCursor([partial.transactionId, partial.vout, partial.userId], direction);
|
|
1144
|
+
}
|
|
1145
|
+
return store.index('userId').openCursor(partial.userId, direction);
|
|
1146
|
+
}
|
|
1147
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.transactionId) !== undefined)
|
|
1148
|
+
return store.index('transactionId').openCursor(partial.transactionId, direction);
|
|
1149
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.basketId) !== undefined)
|
|
1150
|
+
return store.index('basketId').openCursor(partial.basketId, direction);
|
|
1151
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.spentBy) !== undefined)
|
|
1152
|
+
return store.index('spentBy').openCursor(partial.spentBy, direction);
|
|
1153
|
+
return store.openCursor(null, direction);
|
|
1154
|
+
}
|
|
1556
1155
|
async filterOutputs(args, filtered, tagIds, isQueryModeAll) {
|
|
1557
|
-
var _a, _b
|
|
1156
|
+
var _a, _b;
|
|
1558
1157
|
this.assertNoUndefinedInPartial(args.partial);
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.lockingScript', `undefined. Outputs may not be found by lockingScript value.`);
|
|
1563
|
-
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1564
|
-
let skipped = 0;
|
|
1565
|
-
let count = 0;
|
|
1158
|
+
if (args.partial.lockingScript != null) {
|
|
1159
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.lockingScript', 'undefined. Outputs may not be found by lockingScript value.');
|
|
1160
|
+
}
|
|
1566
1161
|
const stores = ['outputs'];
|
|
1567
|
-
if (tagIds && tagIds.length > 0)
|
|
1162
|
+
if (tagIds != null && tagIds.length > 0)
|
|
1568
1163
|
stores.push('output_tags_map');
|
|
1569
|
-
|
|
1570
|
-
if (args.txStatus) {
|
|
1164
|
+
if (args.txStatus != null)
|
|
1571
1165
|
stores.push('transactions');
|
|
1572
|
-
}
|
|
1573
1166
|
const dbTrx = this.toDbTrx(stores, 'readonly', args.trx);
|
|
1574
1167
|
const direction = args.orderDescending ? 'prev' : 'next';
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
if (
|
|
1581
|
-
|
|
1582
|
-
.objectStore('outputs')
|
|
1583
|
-
.index('transactionId_vout_userId')
|
|
1584
|
-
.openCursor([args.partial.transactionId, args.partial.vout, args.partial.userId], direction);
|
|
1585
|
-
}
|
|
1586
|
-
else {
|
|
1587
|
-
cursor = await dbTrx.objectStore('outputs').index('userId').openCursor(args.partial.userId, direction);
|
|
1588
|
-
}
|
|
1589
|
-
}
|
|
1590
|
-
else if (((_f = args.partial) === null || _f === void 0 ? void 0 : _f.transactionId) !== undefined) {
|
|
1591
|
-
cursor = await dbTrx
|
|
1592
|
-
.objectStore('outputs')
|
|
1593
|
-
.index('transactionId')
|
|
1594
|
-
.openCursor(args.partial.transactionId, direction);
|
|
1595
|
-
}
|
|
1596
|
-
else if (((_g = args.partial) === null || _g === void 0 ? void 0 : _g.basketId) !== undefined) {
|
|
1597
|
-
cursor = await dbTrx.objectStore('outputs').index('basketId').openCursor(args.partial.basketId, direction);
|
|
1598
|
-
}
|
|
1599
|
-
else if (((_h = args.partial) === null || _h === void 0 ? void 0 : _h.spentBy) !== undefined) {
|
|
1600
|
-
cursor = await dbTrx.objectStore('outputs').index('spentBy').openCursor(args.partial.spentBy, direction);
|
|
1601
|
-
}
|
|
1602
|
-
else {
|
|
1603
|
-
cursor = await dbTrx.objectStore('outputs').openCursor(null, direction);
|
|
1604
|
-
}
|
|
1605
|
-
let firstTime = true;
|
|
1606
|
-
while (cursor) {
|
|
1607
|
-
if (!firstTime)
|
|
1608
|
-
cursor = await cursor.continue();
|
|
1609
|
-
if (!cursor)
|
|
1610
|
-
break;
|
|
1611
|
-
firstTime = false;
|
|
1612
|
-
const r = cursor.value;
|
|
1613
|
-
if (args.since && args.since > r.updated_at)
|
|
1614
|
-
continue;
|
|
1615
|
-
if (args.partial) {
|
|
1616
|
-
if (args.partial.outputId !== undefined && r.outputId !== args.partial.outputId)
|
|
1617
|
-
continue;
|
|
1618
|
-
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
1619
|
-
continue;
|
|
1620
|
-
if (args.partial.transactionId !== undefined && r.transactionId !== args.partial.transactionId)
|
|
1621
|
-
continue;
|
|
1622
|
-
if (args.partial.basketId !== undefined && r.basketId !== args.partial.basketId)
|
|
1623
|
-
continue;
|
|
1624
|
-
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1625
|
-
continue;
|
|
1626
|
-
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1627
|
-
continue;
|
|
1628
|
-
if (args.partial.spendable !== undefined && r.spendable !== args.partial.spendable)
|
|
1629
|
-
continue;
|
|
1630
|
-
if (args.partial.change !== undefined && r.change !== args.partial.change)
|
|
1631
|
-
continue;
|
|
1632
|
-
if (args.partial.outputDescription !== undefined && r.outputDescription !== args.partial.outputDescription)
|
|
1633
|
-
continue;
|
|
1634
|
-
if (args.partial.vout !== undefined && r.vout !== args.partial.vout)
|
|
1635
|
-
continue;
|
|
1636
|
-
if (args.partial.satoshis !== undefined && r.satoshis !== args.partial.satoshis)
|
|
1637
|
-
continue;
|
|
1638
|
-
if (args.partial.providedBy !== undefined && r.providedBy !== args.partial.providedBy)
|
|
1639
|
-
continue;
|
|
1640
|
-
if (args.partial.purpose !== undefined && r.purpose !== args.partial.purpose)
|
|
1641
|
-
continue;
|
|
1642
|
-
if (args.partial.type !== undefined && r.type !== args.partial.type)
|
|
1643
|
-
continue;
|
|
1644
|
-
if (args.partial.txid !== undefined && r.txid !== args.partial.txid)
|
|
1645
|
-
continue;
|
|
1646
|
-
if (args.partial.senderIdentityKey !== undefined && r.senderIdentityKey !== args.partial.senderIdentityKey)
|
|
1647
|
-
continue;
|
|
1648
|
-
if (args.partial.derivationPrefix !== undefined && r.derivationPrefix !== args.partial.derivationPrefix)
|
|
1649
|
-
continue;
|
|
1650
|
-
if (args.partial.derivationSuffix !== undefined && r.derivationSuffix !== args.partial.derivationSuffix)
|
|
1651
|
-
continue;
|
|
1652
|
-
if (args.partial.customInstructions !== undefined && r.customInstructions !== args.partial.customInstructions)
|
|
1653
|
-
continue;
|
|
1654
|
-
if (args.partial.spentBy !== undefined && r.spentBy !== args.partial.spentBy)
|
|
1655
|
-
continue;
|
|
1656
|
-
if (args.partial.sequenceNumber !== undefined && r.sequenceNumber !== args.partial.sequenceNumber)
|
|
1657
|
-
continue;
|
|
1658
|
-
if (args.partial.scriptLength !== undefined && r.scriptLength !== args.partial.scriptLength)
|
|
1659
|
-
continue;
|
|
1660
|
-
if (args.partial.scriptOffset !== undefined && r.scriptOffset !== args.partial.scriptOffset)
|
|
1661
|
-
continue;
|
|
1662
|
-
}
|
|
1663
|
-
if (args.txStatus !== undefined && args.txStatus.length > 0) {
|
|
1664
|
-
const count = await this.countTransactions({
|
|
1168
|
+
const store = dbTrx.objectStore('outputs');
|
|
1169
|
+
const cursor = await this.openOutputsCursor(store, args.partial, direction);
|
|
1170
|
+
await scanCursor(cursor, args.since, ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0, (_b = args.paged) === null || _b === void 0 ? void 0 : _b.limit, async (r) => {
|
|
1171
|
+
if (!(0, idbHelpers_1.matchesOutputPartial)(r, args.partial))
|
|
1172
|
+
return false;
|
|
1173
|
+
if (args.txStatus !== undefined) {
|
|
1174
|
+
const txCount = await this.countTransactions({
|
|
1665
1175
|
partial: { transactionId: r.transactionId },
|
|
1666
1176
|
status: args.txStatus,
|
|
1667
1177
|
trx: dbTrx
|
|
1668
1178
|
});
|
|
1669
|
-
if (
|
|
1670
|
-
|
|
1671
|
-
}
|
|
1672
|
-
if (tagIds && tagIds.length > 0)
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
if (isQueryModeAll) {
|
|
1679
|
-
ids.splice(i, 1);
|
|
1680
|
-
}
|
|
1681
|
-
else {
|
|
1682
|
-
ids = [];
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
}
|
|
1686
|
-
});
|
|
1687
|
-
if (ids.length > 0)
|
|
1688
|
-
continue;
|
|
1689
|
-
}
|
|
1690
|
-
if (skipped < offset) {
|
|
1691
|
-
skipped++;
|
|
1692
|
-
continue;
|
|
1693
|
-
}
|
|
1694
|
-
if (args.noScript === true) {
|
|
1179
|
+
if (txCount === 0)
|
|
1180
|
+
return false;
|
|
1181
|
+
}
|
|
1182
|
+
if (tagIds != null && tagIds.length > 0 && !await this.outputMatchesTags(r.outputId, tagIds, isQueryModeAll, dbTrx))
|
|
1183
|
+
return false;
|
|
1184
|
+
return true;
|
|
1185
|
+
}, r => {
|
|
1186
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1187
|
+
if (args.noScript === true)
|
|
1695
1188
|
r.script = undefined;
|
|
1696
|
-
}
|
|
1697
1189
|
filtered(r);
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
break;
|
|
1701
|
-
}
|
|
1702
|
-
if (!args.trx)
|
|
1190
|
+
});
|
|
1191
|
+
if (args.trx == null)
|
|
1703
1192
|
await dbTrx.done;
|
|
1704
1193
|
}
|
|
1194
|
+
async outputMatchesTags(outputId, tagIds, isQueryModeAll, dbTrx) {
|
|
1195
|
+
let ids = [...tagIds];
|
|
1196
|
+
await this.filterOutputTagMaps({ partial: { outputId }, trx: dbTrx }, tm => {
|
|
1197
|
+
if (ids.length > 0) {
|
|
1198
|
+
const i = ids.indexOf(tm.outputTagId);
|
|
1199
|
+
if (i >= 0) {
|
|
1200
|
+
if (isQueryModeAll) {
|
|
1201
|
+
ids.splice(i, 1);
|
|
1202
|
+
}
|
|
1203
|
+
else {
|
|
1204
|
+
ids = [];
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
});
|
|
1209
|
+
return ids.length === 0;
|
|
1210
|
+
}
|
|
1705
1211
|
async findOutputs(args, tagIds, isQueryModeAll) {
|
|
1706
1212
|
const results = [];
|
|
1707
1213
|
await this.filterOutputs(args, r => {
|
|
1708
1214
|
results.push(this.validateEntity(r));
|
|
1709
1215
|
}, tagIds, isQueryModeAll);
|
|
1710
1216
|
for (const o of results) {
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1217
|
+
if (args.noScript) {
|
|
1218
|
+
o.lockingScript = undefined;
|
|
1219
|
+
}
|
|
1220
|
+
else {
|
|
1714
1221
|
await this.validateOutputScript(o, args.trx);
|
|
1222
|
+
}
|
|
1715
1223
|
}
|
|
1716
1224
|
return results;
|
|
1717
1225
|
}
|
|
1718
1226
|
async filterOutputTags(args, filtered) {
|
|
1719
|
-
var _a, _b, _c, _d, _e;
|
|
1720
|
-
this.assertNoUndefinedInPartial(args.partial);
|
|
1721
|
-
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1722
|
-
let skipped = 0;
|
|
1723
|
-
let count = 0;
|
|
1227
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1724
1228
|
const dbTrx = this.toDbTrx(['output_tags'], 'readonly', args.trx);
|
|
1229
|
+
const store = dbTrx.objectStore('output_tags');
|
|
1230
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1725
1231
|
let cursor;
|
|
1726
|
-
if ((
|
|
1727
|
-
cursor = await
|
|
1728
|
-
}
|
|
1729
|
-
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
.openCursor([args.partial.tag, args.partial.userId]);
|
|
1735
|
-
}
|
|
1736
|
-
else {
|
|
1737
|
-
cursor = await dbTrx.objectStore('output_tags').index('userId').openCursor(args.partial.userId);
|
|
1738
|
-
}
|
|
1232
|
+
if ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.outputTagId) {
|
|
1233
|
+
cursor = await store.openCursor(args.partial.outputTagId);
|
|
1234
|
+
}
|
|
1235
|
+
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.userId) !== undefined && ((_c = args.partial) === null || _c === void 0 ? void 0 : _c.tag) !== undefined) {
|
|
1236
|
+
cursor = await store.index('tag_userId').openCursor([args.partial.tag, args.partial.userId]);
|
|
1237
|
+
}
|
|
1238
|
+
else if (((_d = args.partial) === null || _d === void 0 ? void 0 : _d.userId) !== undefined) {
|
|
1239
|
+
cursor = await store.index('userId').openCursor(args.partial.userId);
|
|
1739
1240
|
}
|
|
1740
1241
|
else {
|
|
1741
|
-
cursor = await
|
|
1742
|
-
}
|
|
1743
|
-
let firstTime = true;
|
|
1744
|
-
while (cursor) {
|
|
1745
|
-
if (!firstTime)
|
|
1746
|
-
cursor = await cursor.continue();
|
|
1747
|
-
if (!cursor)
|
|
1748
|
-
break;
|
|
1749
|
-
firstTime = false;
|
|
1750
|
-
const r = cursor.value;
|
|
1751
|
-
if (args.since && args.since > r.updated_at)
|
|
1752
|
-
continue;
|
|
1753
|
-
if (args.partial) {
|
|
1754
|
-
if (args.partial.outputTagId !== undefined && r.outputTagId !== args.partial.outputTagId)
|
|
1755
|
-
continue;
|
|
1756
|
-
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
1757
|
-
continue;
|
|
1758
|
-
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1759
|
-
continue;
|
|
1760
|
-
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1761
|
-
continue;
|
|
1762
|
-
if (args.partial.tag !== undefined && r.tag !== args.partial.tag)
|
|
1763
|
-
continue;
|
|
1764
|
-
if (args.partial.isDeleted !== undefined && r.isDeleted !== args.partial.isDeleted)
|
|
1765
|
-
continue;
|
|
1766
|
-
}
|
|
1767
|
-
if (skipped < offset) {
|
|
1768
|
-
skipped++;
|
|
1769
|
-
continue;
|
|
1770
|
-
}
|
|
1771
|
-
filtered(r);
|
|
1772
|
-
count++;
|
|
1773
|
-
if (((_e = args.paged) === null || _e === void 0 ? void 0 : _e.limit) && count >= args.paged.limit)
|
|
1774
|
-
break;
|
|
1242
|
+
cursor = await store.openCursor();
|
|
1775
1243
|
}
|
|
1776
|
-
|
|
1244
|
+
await scanCursor(cursor, args.since, ((_e = args.paged) === null || _e === void 0 ? void 0 : _e.offset) || 0, (_f = args.paged) === null || _f === void 0 ? void 0 : _f.limit, r => (0, idbHelpers_1.matchesOutputTagPartial)(r, args.partial), filtered);
|
|
1245
|
+
if (args.trx == null)
|
|
1777
1246
|
await dbTrx.done;
|
|
1778
1247
|
}
|
|
1779
1248
|
async findOutputTags(args) {
|
|
@@ -1784,78 +1253,31 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1784
1253
|
return result;
|
|
1785
1254
|
}
|
|
1786
1255
|
async filterSyncStates(args, filtered) {
|
|
1787
|
-
var _a, _b, _c, _d, _e, _f
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
1792
|
-
let skipped = 0;
|
|
1793
|
-
let count = 0;
|
|
1256
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1257
|
+
if (args.partial.syncMap) {
|
|
1258
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.syncMap', 'undefined. SyncStates may not be found by syncMap value.');
|
|
1259
|
+
}
|
|
1794
1260
|
const dbTrx = this.toDbTrx(['sync_states'], 'readonly', args.trx);
|
|
1261
|
+
const store = dbTrx.objectStore('sync_states');
|
|
1262
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1795
1263
|
let cursor;
|
|
1796
|
-
if ((
|
|
1797
|
-
cursor = await
|
|
1264
|
+
if ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.syncStateId) {
|
|
1265
|
+
cursor = await store.openCursor(args.partial.syncStateId);
|
|
1798
1266
|
}
|
|
1799
|
-
else if (((
|
|
1800
|
-
cursor = await
|
|
1267
|
+
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.userId) !== undefined) {
|
|
1268
|
+
cursor = await store.index('userId').openCursor(args.partial.userId);
|
|
1801
1269
|
}
|
|
1802
|
-
else if (((
|
|
1803
|
-
cursor = await
|
|
1270
|
+
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.refNum) !== undefined) {
|
|
1271
|
+
cursor = await store.index('refNum').openCursor(args.partial.refNum);
|
|
1804
1272
|
}
|
|
1805
|
-
else if (((
|
|
1806
|
-
cursor = await
|
|
1273
|
+
else if (((_d = args.partial) === null || _d === void 0 ? void 0 : _d.status) !== undefined) {
|
|
1274
|
+
cursor = await store.index('status').openCursor(args.partial.status);
|
|
1807
1275
|
}
|
|
1808
1276
|
else {
|
|
1809
|
-
cursor = await
|
|
1810
|
-
}
|
|
1811
|
-
let firstTime = true;
|
|
1812
|
-
while (cursor) {
|
|
1813
|
-
if (!firstTime)
|
|
1814
|
-
cursor = await cursor.continue();
|
|
1815
|
-
if (!cursor)
|
|
1816
|
-
break;
|
|
1817
|
-
firstTime = false;
|
|
1818
|
-
const r = cursor.value;
|
|
1819
|
-
if (args.since && args.since > r.updated_at)
|
|
1820
|
-
continue;
|
|
1821
|
-
if (args.partial) {
|
|
1822
|
-
if (args.partial.syncStateId !== undefined && r.syncStateId !== args.partial.syncStateId)
|
|
1823
|
-
continue;
|
|
1824
|
-
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
1825
|
-
continue;
|
|
1826
|
-
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1827
|
-
continue;
|
|
1828
|
-
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1829
|
-
continue;
|
|
1830
|
-
if (args.partial.storageIdentityKey !== undefined && r.storageIdentityKey !== args.partial.storageIdentityKey)
|
|
1831
|
-
continue;
|
|
1832
|
-
if (args.partial.storageName !== undefined && r.storageName !== args.partial.storageName)
|
|
1833
|
-
continue;
|
|
1834
|
-
if (args.partial.status !== undefined && r.status !== args.partial.status)
|
|
1835
|
-
continue;
|
|
1836
|
-
if (args.partial.init !== undefined && r.init !== args.partial.init)
|
|
1837
|
-
continue;
|
|
1838
|
-
if (args.partial.refNum !== undefined && r.refNum !== args.partial.refNum)
|
|
1839
|
-
continue;
|
|
1840
|
-
if (args.partial.when !== undefined && ((_f = r.when) === null || _f === void 0 ? void 0 : _f.getTime()) !== args.partial.when.getTime())
|
|
1841
|
-
continue;
|
|
1842
|
-
if (args.partial.satoshis !== undefined && r.satoshis !== args.partial.satoshis)
|
|
1843
|
-
continue;
|
|
1844
|
-
if (args.partial.errorLocal !== undefined && r.errorLocale !== args.partial.errorLocal)
|
|
1845
|
-
continue;
|
|
1846
|
-
if (args.partial.errorOther !== undefined && r.errorOther !== args.partial.errorOther)
|
|
1847
|
-
continue;
|
|
1848
|
-
}
|
|
1849
|
-
if (skipped < offset) {
|
|
1850
|
-
skipped++;
|
|
1851
|
-
continue;
|
|
1852
|
-
}
|
|
1853
|
-
filtered(r);
|
|
1854
|
-
count++;
|
|
1855
|
-
if (((_g = args.paged) === null || _g === void 0 ? void 0 : _g.limit) && count >= args.paged.limit)
|
|
1856
|
-
break;
|
|
1277
|
+
cursor = await store.openCursor();
|
|
1857
1278
|
}
|
|
1858
|
-
|
|
1279
|
+
await scanCursor(cursor, args.since, ((_e = args.paged) === null || _e === void 0 ? void 0 : _e.offset) || 0, (_f = args.paged) === null || _f === void 0 ? void 0 : _f.limit, r => (0, idbHelpers_1.matchesSyncStatePartial)(r, args.partial), filtered);
|
|
1280
|
+
if (args.trx == null)
|
|
1859
1281
|
await dbTrx.done;
|
|
1860
1282
|
}
|
|
1861
1283
|
async findSyncStates(args) {
|
|
@@ -1865,125 +1287,77 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1865
1287
|
});
|
|
1866
1288
|
return result;
|
|
1867
1289
|
}
|
|
1290
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1291
|
+
async openTransactionsCursor(
|
|
1292
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1293
|
+
store,
|
|
1294
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1295
|
+
partial, direction
|
|
1296
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1297
|
+
) {
|
|
1298
|
+
if (partial === null || partial === void 0 ? void 0 : partial.transactionId)
|
|
1299
|
+
return store.openCursor(partial.transactionId, direction);
|
|
1300
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.userId) !== undefined) {
|
|
1301
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.status) !== undefined) {
|
|
1302
|
+
return store.index('status_userId').openCursor([partial.status, partial.userId], direction);
|
|
1303
|
+
}
|
|
1304
|
+
return store.index('userId').openCursor(partial.userId, direction);
|
|
1305
|
+
}
|
|
1306
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.status) !== undefined)
|
|
1307
|
+
return store.index('status').openCursor(partial.status, direction);
|
|
1308
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.provenTxId) !== undefined)
|
|
1309
|
+
return store.index('provenTxId').openCursor(partial.provenTxId, direction);
|
|
1310
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.reference) !== undefined)
|
|
1311
|
+
return store.index('reference').openCursor(partial.reference, direction);
|
|
1312
|
+
return store.openCursor(null, direction);
|
|
1313
|
+
}
|
|
1868
1314
|
async filterTransactions(args, filtered, labelIds, isQueryModeAll) {
|
|
1869
|
-
var _a, _b
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
if (args.partial.inputBEEF)
|
|
1874
|
-
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.inputBEEF',
|
|
1875
|
-
|
|
1876
|
-
let skipped = 0;
|
|
1877
|
-
let count = 0;
|
|
1315
|
+
var _a, _b;
|
|
1316
|
+
if (args.partial.rawTx != null) {
|
|
1317
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.rawTx', 'undefined. Transactions may not be found by rawTx value.');
|
|
1318
|
+
}
|
|
1319
|
+
if (args.partial.inputBEEF != null) {
|
|
1320
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.inputBEEF', 'undefined. Transactions may not be found by inputBEEF value.');
|
|
1321
|
+
}
|
|
1878
1322
|
const stores = ['transactions'];
|
|
1879
|
-
if (labelIds && labelIds.length > 0)
|
|
1323
|
+
if (labelIds != null && labelIds.length > 0)
|
|
1880
1324
|
stores.push('tx_labels_map');
|
|
1881
|
-
}
|
|
1882
1325
|
const dbTrx = this.toDbTrx(stores, 'readonly', args.trx);
|
|
1883
1326
|
const direction = args.orderDescending ? 'prev' : 'next';
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
if (
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
}
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
.
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
}
|
|
1911
|
-
else {
|
|
1912
|
-
cursor = await dbTrx.objectStore('transactions').openCursor(null, direction);
|
|
1913
|
-
}
|
|
1914
|
-
let firstTime = true;
|
|
1915
|
-
while (cursor) {
|
|
1916
|
-
if (!firstTime)
|
|
1917
|
-
cursor = await cursor.continue();
|
|
1918
|
-
if (!cursor)
|
|
1919
|
-
break;
|
|
1920
|
-
firstTime = false;
|
|
1921
|
-
const r = cursor.value;
|
|
1922
|
-
if (args.since && args.since > r.updated_at)
|
|
1923
|
-
continue;
|
|
1924
|
-
if (args.from && r.created_at.getTime() < args.from.getTime())
|
|
1925
|
-
continue;
|
|
1926
|
-
if (args.to && r.created_at.getTime() >= args.to.getTime())
|
|
1927
|
-
continue;
|
|
1928
|
-
if (args.status && args.status.length > 0 && !args.status.includes(r.status))
|
|
1929
|
-
continue;
|
|
1930
|
-
if (args.partial) {
|
|
1931
|
-
if (args.partial.transactionId !== undefined && r.transactionId !== args.partial.transactionId)
|
|
1932
|
-
continue;
|
|
1933
|
-
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
1934
|
-
continue;
|
|
1935
|
-
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
1936
|
-
continue;
|
|
1937
|
-
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
1938
|
-
continue;
|
|
1939
|
-
if (args.partial.provenTxId !== undefined && r.provenTxId !== args.partial.provenTxId)
|
|
1940
|
-
continue;
|
|
1941
|
-
if (args.partial.status !== undefined && r.status !== args.partial.status)
|
|
1942
|
-
continue;
|
|
1943
|
-
if (args.partial.reference !== undefined && r.reference !== args.partial.reference)
|
|
1944
|
-
continue;
|
|
1945
|
-
if (args.partial.isOutgoing !== undefined && r.isOutgoing !== args.partial.isOutgoing)
|
|
1946
|
-
continue;
|
|
1947
|
-
if (args.partial.satoshis !== undefined && r.satoshis !== args.partial.satoshis)
|
|
1948
|
-
continue;
|
|
1949
|
-
if (args.partial.description !== undefined && r.description !== args.partial.description)
|
|
1950
|
-
continue;
|
|
1951
|
-
if (args.partial.version !== undefined && r.version !== args.partial.version)
|
|
1952
|
-
continue;
|
|
1953
|
-
if (args.partial.lockTime !== undefined && r.lockTime !== args.partial.lockTime)
|
|
1954
|
-
continue;
|
|
1955
|
-
if (args.partial.txid !== undefined && r.txid !== args.partial.txid)
|
|
1956
|
-
continue;
|
|
1957
|
-
}
|
|
1958
|
-
if (labelIds && labelIds.length > 0) {
|
|
1959
|
-
let ids = [...labelIds];
|
|
1960
|
-
await this.filterTxLabelMaps({ partial: { transactionId: r.transactionId }, trx: dbTrx }, lm => {
|
|
1961
|
-
if (ids.length > 0) {
|
|
1962
|
-
const i = ids.indexOf(lm.txLabelId);
|
|
1963
|
-
if (i >= 0) {
|
|
1964
|
-
if (isQueryModeAll) {
|
|
1965
|
-
ids.splice(i, 1);
|
|
1966
|
-
}
|
|
1967
|
-
else {
|
|
1968
|
-
ids = [];
|
|
1969
|
-
}
|
|
1970
|
-
}
|
|
1327
|
+
const store = dbTrx.objectStore('transactions');
|
|
1328
|
+
const cursor = await this.openTransactionsCursor(store, args.partial, direction);
|
|
1329
|
+
await scanCursor(cursor, args.since, ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0, (_b = args.paged) === null || _b === void 0 ? void 0 : _b.limit, async (r) => {
|
|
1330
|
+
if (args.from != null && r.created_at.getTime() < args.from.getTime())
|
|
1331
|
+
return false;
|
|
1332
|
+
if (args.to != null && r.created_at.getTime() >= args.to.getTime())
|
|
1333
|
+
return false;
|
|
1334
|
+
if (args.status != null && !args.status.includes(r.status))
|
|
1335
|
+
return false;
|
|
1336
|
+
if (!(0, idbHelpers_1.matchesTransactionPartial)(r, args.partial))
|
|
1337
|
+
return false;
|
|
1338
|
+
if (labelIds != null && labelIds.length > 0 && !await this.transactionMatchesLabels(r.transactionId, labelIds, isQueryModeAll, dbTrx))
|
|
1339
|
+
return false;
|
|
1340
|
+
return true;
|
|
1341
|
+
}, filtered);
|
|
1342
|
+
if (args.trx == null)
|
|
1343
|
+
await dbTrx.done;
|
|
1344
|
+
}
|
|
1345
|
+
async transactionMatchesLabels(transactionId, labelIds, isQueryModeAll, dbTrx) {
|
|
1346
|
+
let ids = [...labelIds];
|
|
1347
|
+
await this.filterTxLabelMaps({ partial: { transactionId }, trx: dbTrx }, lm => {
|
|
1348
|
+
if (ids.length > 0) {
|
|
1349
|
+
const i = ids.indexOf(lm.txLabelId);
|
|
1350
|
+
if (i >= 0) {
|
|
1351
|
+
if (isQueryModeAll) {
|
|
1352
|
+
ids.splice(i, 1);
|
|
1971
1353
|
}
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
if (skipped < offset) {
|
|
1977
|
-
skipped++;
|
|
1978
|
-
continue;
|
|
1354
|
+
else {
|
|
1355
|
+
ids = [];
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1979
1358
|
}
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
if (((_h = args.paged) === null || _h === void 0 ? void 0 : _h.limit) && count >= args.paged.limit)
|
|
1983
|
-
break;
|
|
1984
|
-
}
|
|
1985
|
-
if (!args.trx)
|
|
1986
|
-
await dbTrx.done;
|
|
1359
|
+
});
|
|
1360
|
+
return ids.length === 0;
|
|
1987
1361
|
}
|
|
1988
1362
|
async findTransactions(args, labelIds, isQueryModeAll) {
|
|
1989
1363
|
const results = [];
|
|
@@ -1991,75 +1365,36 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1991
1365
|
results.push(this.validateEntity(r));
|
|
1992
1366
|
}, labelIds, isQueryModeAll);
|
|
1993
1367
|
for (const t of results) {
|
|
1994
|
-
|
|
1995
|
-
// transactionColumnsWithoutRawTx only strips rawTx, and callers such as
|
|
1996
|
-
// getReqsAndBeefToShareWithWorld legitimately need inputBEEF when noRawTx is set.
|
|
1997
|
-
if (!args.noRawTx)
|
|
1998
|
-
await this.validateRawTransaction(t, args.trx);
|
|
1999
|
-
else
|
|
1368
|
+
if (args.noRawTx) {
|
|
2000
1369
|
t.rawTx = undefined;
|
|
1370
|
+
t.inputBEEF = undefined;
|
|
1371
|
+
}
|
|
1372
|
+
else {
|
|
1373
|
+
await this.validateRawTransaction(t, args.trx);
|
|
1374
|
+
}
|
|
2001
1375
|
}
|
|
2002
1376
|
return results;
|
|
2003
1377
|
}
|
|
2004
1378
|
async filterTxLabels(args, filtered) {
|
|
2005
|
-
var _a, _b, _c, _d, _e;
|
|
2006
|
-
this.assertNoUndefinedInPartial(args.partial);
|
|
2007
|
-
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
2008
|
-
let skipped = 0;
|
|
2009
|
-
let count = 0;
|
|
1379
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2010
1380
|
const dbTrx = this.toDbTrx(['tx_labels'], 'readonly', args.trx);
|
|
1381
|
+
const store = dbTrx.objectStore('tx_labels');
|
|
1382
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2011
1383
|
let cursor;
|
|
2012
|
-
if ((
|
|
2013
|
-
cursor = await
|
|
2014
|
-
}
|
|
2015
|
-
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
.openCursor([args.partial.label, args.partial.userId]);
|
|
2021
|
-
}
|
|
2022
|
-
else {
|
|
2023
|
-
cursor = await dbTrx.objectStore('tx_labels').index('userId').openCursor(args.partial.userId);
|
|
2024
|
-
}
|
|
1384
|
+
if ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.txLabelId) {
|
|
1385
|
+
cursor = await store.openCursor(args.partial.txLabelId);
|
|
1386
|
+
}
|
|
1387
|
+
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.userId) !== undefined && ((_c = args.partial) === null || _c === void 0 ? void 0 : _c.label) !== undefined) {
|
|
1388
|
+
cursor = await store.index('label_userId').openCursor([args.partial.label, args.partial.userId]);
|
|
1389
|
+
}
|
|
1390
|
+
else if (((_d = args.partial) === null || _d === void 0 ? void 0 : _d.userId) !== undefined) {
|
|
1391
|
+
cursor = await store.index('userId').openCursor(args.partial.userId);
|
|
2025
1392
|
}
|
|
2026
1393
|
else {
|
|
2027
|
-
cursor = await
|
|
2028
|
-
}
|
|
2029
|
-
let firstTime = true;
|
|
2030
|
-
while (cursor) {
|
|
2031
|
-
if (!firstTime)
|
|
2032
|
-
cursor = await cursor.continue();
|
|
2033
|
-
if (!cursor)
|
|
2034
|
-
break;
|
|
2035
|
-
firstTime = false;
|
|
2036
|
-
const r = cursor.value;
|
|
2037
|
-
if (args.since && args.since > r.updated_at)
|
|
2038
|
-
continue;
|
|
2039
|
-
if (args.partial) {
|
|
2040
|
-
if (args.partial.txLabelId !== undefined && r.txLabelId !== args.partial.txLabelId)
|
|
2041
|
-
continue;
|
|
2042
|
-
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
2043
|
-
continue;
|
|
2044
|
-
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
2045
|
-
continue;
|
|
2046
|
-
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
2047
|
-
continue;
|
|
2048
|
-
if (args.partial.label !== undefined && r.label !== args.partial.label)
|
|
2049
|
-
continue;
|
|
2050
|
-
if (args.partial.isDeleted !== undefined && r.isDeleted !== args.partial.isDeleted)
|
|
2051
|
-
continue;
|
|
2052
|
-
}
|
|
2053
|
-
if (skipped < offset) {
|
|
2054
|
-
skipped++;
|
|
2055
|
-
continue;
|
|
2056
|
-
}
|
|
2057
|
-
filtered(r);
|
|
2058
|
-
count++;
|
|
2059
|
-
if (((_e = args.paged) === null || _e === void 0 ? void 0 : _e.limit) && count >= args.paged.limit)
|
|
2060
|
-
break;
|
|
1394
|
+
cursor = await store.openCursor();
|
|
2061
1395
|
}
|
|
2062
|
-
|
|
1396
|
+
await scanCursor(cursor, args.since, ((_e = args.paged) === null || _e === void 0 ? void 0 : _e.offset) || 0, (_f = args.paged) === null || _f === void 0 ? void 0 : _f.limit, r => (0, idbHelpers_1.matchesTxLabelPartial)(r, args.partial), filtered);
|
|
1397
|
+
if (args.trx == null)
|
|
2063
1398
|
await dbTrx.done;
|
|
2064
1399
|
}
|
|
2065
1400
|
async findTxLabels(args) {
|
|
@@ -2069,46 +1404,27 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
2069
1404
|
});
|
|
2070
1405
|
return result;
|
|
2071
1406
|
}
|
|
1407
|
+
matchesUserPartial(r, partial) {
|
|
1408
|
+
if (!partial)
|
|
1409
|
+
return true;
|
|
1410
|
+
if (partial.userId && r.userId !== partial.userId)
|
|
1411
|
+
return false;
|
|
1412
|
+
if ((partial.created_at != null) && r.created_at.getTime() !== partial.created_at.getTime())
|
|
1413
|
+
return false;
|
|
1414
|
+
if ((partial.updated_at != null) && r.updated_at.getTime() !== partial.updated_at.getTime())
|
|
1415
|
+
return false;
|
|
1416
|
+
if (partial.identityKey && r.identityKey !== partial.identityKey)
|
|
1417
|
+
return false;
|
|
1418
|
+
if (partial.activeStorage && r.activeStorage !== partial.activeStorage)
|
|
1419
|
+
return false;
|
|
1420
|
+
return true;
|
|
1421
|
+
}
|
|
2072
1422
|
async filterUsers(args, filtered) {
|
|
2073
1423
|
var _a, _b;
|
|
2074
|
-
this.assertNoUndefinedInPartial(args.partial);
|
|
2075
|
-
const offset = ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0;
|
|
2076
|
-
let skipped = 0;
|
|
2077
|
-
let count = 0;
|
|
2078
1424
|
const dbTrx = this.toDbTrx(['users'], 'readonly', args.trx);
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
if (!firstTime)
|
|
2083
|
-
cursor = await cursor.continue();
|
|
2084
|
-
if (!cursor)
|
|
2085
|
-
break;
|
|
2086
|
-
firstTime = false;
|
|
2087
|
-
const r = cursor.value;
|
|
2088
|
-
if (args.since && args.since > r.updated_at)
|
|
2089
|
-
continue;
|
|
2090
|
-
if (args.partial) {
|
|
2091
|
-
if (args.partial.userId !== undefined && r.userId !== args.partial.userId)
|
|
2092
|
-
continue;
|
|
2093
|
-
if (args.partial.created_at !== undefined && r.created_at.getTime() !== args.partial.created_at.getTime())
|
|
2094
|
-
continue;
|
|
2095
|
-
if (args.partial.updated_at !== undefined && r.updated_at.getTime() !== args.partial.updated_at.getTime())
|
|
2096
|
-
continue;
|
|
2097
|
-
if (args.partial.identityKey !== undefined && r.identityKey !== args.partial.identityKey)
|
|
2098
|
-
continue;
|
|
2099
|
-
if (args.partial.activeStorage !== undefined && r.activeStorage !== args.partial.activeStorage)
|
|
2100
|
-
continue;
|
|
2101
|
-
}
|
|
2102
|
-
if (skipped < offset) {
|
|
2103
|
-
skipped++;
|
|
2104
|
-
continue;
|
|
2105
|
-
}
|
|
2106
|
-
filtered(r);
|
|
2107
|
-
count++;
|
|
2108
|
-
if (((_b = args.paged) === null || _b === void 0 ? void 0 : _b.limit) && count >= args.paged.limit)
|
|
2109
|
-
break;
|
|
2110
|
-
}
|
|
2111
|
-
if (!args.trx)
|
|
1425
|
+
const cursor = await dbTrx.objectStore('users').openCursor();
|
|
1426
|
+
await scanCursor(cursor, args.since, ((_a = args.paged) === null || _a === void 0 ? void 0 : _a.offset) || 0, (_b = args.paged) === null || _b === void 0 ? void 0 : _b.limit, r => this.matchesUserPartial(r, args.partial), filtered);
|
|
1427
|
+
if (args.trx == null)
|
|
2112
1428
|
await dbTrx.done;
|
|
2113
1429
|
}
|
|
2114
1430
|
async findUsers(args) {
|
|
@@ -2248,9 +1564,8 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
2248
1564
|
return results;
|
|
2249
1565
|
}
|
|
2250
1566
|
async verifyReadyForDatabaseAccess(trx) {
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
}
|
|
1567
|
+
var _a;
|
|
1568
|
+
(_a = this._settings) !== null && _a !== void 0 ? _a : (this._settings = await this.readSettings());
|
|
2254
1569
|
return this._settings.dbtype;
|
|
2255
1570
|
}
|
|
2256
1571
|
/**
|
|
@@ -2260,18 +1575,30 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
2260
1575
|
validateEntity(entity, dateFields, booleanFields) {
|
|
2261
1576
|
entity.created_at = this.validateDate(entity.created_at);
|
|
2262
1577
|
entity.updated_at = this.validateDate(entity.updated_at);
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
1578
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1579
|
+
const e = entity;
|
|
1580
|
+
this.applyDateFields(e, dateFields);
|
|
1581
|
+
this.applyBooleanFields(e, booleanFields);
|
|
1582
|
+
this.normalizeEntityValues(e);
|
|
1583
|
+
return entity;
|
|
1584
|
+
}
|
|
1585
|
+
applyDateFields(entity, dateFields) {
|
|
1586
|
+
if (dateFields == null)
|
|
1587
|
+
return;
|
|
1588
|
+
for (const df of dateFields) {
|
|
1589
|
+
if (entity[df])
|
|
1590
|
+
entity[df] = this.validateDate(entity[df]);
|
|
2268
1591
|
}
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
1592
|
+
}
|
|
1593
|
+
applyBooleanFields(entity, booleanFields) {
|
|
1594
|
+
if (booleanFields == null)
|
|
1595
|
+
return;
|
|
1596
|
+
for (const df of booleanFields) {
|
|
1597
|
+
if (entity[df] !== undefined)
|
|
1598
|
+
entity[df] = !!entity[df];
|
|
2274
1599
|
}
|
|
1600
|
+
}
|
|
1601
|
+
normalizeEntityValues(entity) {
|
|
2275
1602
|
for (const key of Object.keys(entity)) {
|
|
2276
1603
|
const val = entity[key];
|
|
2277
1604
|
if (val === null) {
|
|
@@ -2281,7 +1608,6 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
2281
1608
|
entity[key] = Array.from(val);
|
|
2282
1609
|
}
|
|
2283
1610
|
}
|
|
2284
|
-
return entity;
|
|
2285
1611
|
}
|
|
2286
1612
|
/**
|
|
2287
1613
|
* Helper to force uniform behavior across database engines.
|
|
@@ -2302,26 +1628,35 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
2302
1628
|
if (!this.dbtype)
|
|
2303
1629
|
throw new WERR_errors_1.WERR_INTERNAL('must call verifyReadyForDatabaseAccess first');
|
|
2304
1630
|
const v = { ...update };
|
|
2305
|
-
|
|
2306
|
-
v.created_at = this.validateEntityDate(v.created_at);
|
|
2307
|
-
if (v.updated_at)
|
|
2308
|
-
v.updated_at = this.validateEntityDate(v.updated_at);
|
|
1631
|
+
v.created_at = v.created_at ? this.validateEntityDate(v.created_at) : undefined;
|
|
2309
1632
|
if (!v.created_at)
|
|
2310
1633
|
delete v.created_at;
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
1634
|
+
v.updated_at = v.updated_at ? this.validateEntityDate(v.updated_at) : this.validateEntityDate(new Date());
|
|
1635
|
+
this.applyOptionalDateFields(v, dateFields);
|
|
1636
|
+
this.applyIntegerBooleanFields(update, booleanFields);
|
|
1637
|
+
this.normalizeForStorage(v);
|
|
1638
|
+
this.isDirty = true;
|
|
1639
|
+
return v;
|
|
1640
|
+
}
|
|
1641
|
+
applyOptionalDateFields(v, dateFields) {
|
|
1642
|
+
if (dateFields == null)
|
|
1643
|
+
return;
|
|
1644
|
+
for (const df of dateFields) {
|
|
1645
|
+
if (v[df])
|
|
1646
|
+
v[df] = this.validateOptionalEntityDate(v[df]);
|
|
2318
1647
|
}
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
1648
|
+
}
|
|
1649
|
+
applyIntegerBooleanFields(update, booleanFields) {
|
|
1650
|
+
if (booleanFields == null)
|
|
1651
|
+
return;
|
|
1652
|
+
for (const df of booleanFields) {
|
|
1653
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1654
|
+
const u = update;
|
|
1655
|
+
if (u[df] !== undefined)
|
|
1656
|
+
u[df] = u[df] ? 1 : 0;
|
|
2324
1657
|
}
|
|
1658
|
+
}
|
|
1659
|
+
normalizeForStorage(v) {
|
|
2325
1660
|
for (const key of Object.keys(v)) {
|
|
2326
1661
|
const val = v[key];
|
|
2327
1662
|
if (Array.isArray(val) && (val.length === 0 || Number.isInteger(val[0]))) {
|
|
@@ -2331,8 +1666,6 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
2331
1666
|
v[key] = undefined;
|
|
2332
1667
|
}
|
|
2333
1668
|
}
|
|
2334
|
-
this.isDirty = true;
|
|
2335
|
-
return v;
|
|
2336
1669
|
}
|
|
2337
1670
|
/**
|
|
2338
1671
|
* Helper to force uniform behavior across database engines.
|
|
@@ -2347,27 +1680,9 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
2347
1680
|
delete v.created_at;
|
|
2348
1681
|
if (!v.updated_at)
|
|
2349
1682
|
delete v.updated_at;
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
v[df] = this.validateOptionalEntityDate(v[df]);
|
|
2354
|
-
}
|
|
2355
|
-
}
|
|
2356
|
-
if (booleanFields) {
|
|
2357
|
-
for (const df of booleanFields) {
|
|
2358
|
-
if (entity[df] !== undefined)
|
|
2359
|
-
entity[df] = !!entity[df] ? 1 : 0;
|
|
2360
|
-
}
|
|
2361
|
-
}
|
|
2362
|
-
for (const key of Object.keys(v)) {
|
|
2363
|
-
const val = v[key];
|
|
2364
|
-
if (Array.isArray(val) && (val.length === 0 || Number.isInteger(val[0]))) {
|
|
2365
|
-
v[key] = Uint8Array.from(val);
|
|
2366
|
-
}
|
|
2367
|
-
else if (val === null) {
|
|
2368
|
-
v[key] = undefined;
|
|
2369
|
-
}
|
|
2370
|
-
}
|
|
1683
|
+
this.applyOptionalDateFields(v, dateFields);
|
|
1684
|
+
this.applyIntegerBooleanFields(entity, booleanFields);
|
|
1685
|
+
this.normalizeForStorage(v);
|
|
2371
1686
|
this.isDirty = true;
|
|
2372
1687
|
return v;
|
|
2373
1688
|
}
|
|
@@ -2377,7 +1692,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
2377
1692
|
return;
|
|
2378
1693
|
// rawTransaction is missing, see if we moved it ...
|
|
2379
1694
|
const rawTx = await this.getRawTxOfKnownValidTransaction(t.txid, undefined, undefined, trx);
|
|
2380
|
-
if (
|
|
1695
|
+
if (rawTx == null)
|
|
2381
1696
|
return;
|
|
2382
1697
|
t.rawTx = rawTx;
|
|
2383
1698
|
}
|