@bsv/wallet-toolbox-client 2.1.24 → 3.0.0-alpha.0
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/LeasedMonitorTask.d.ts +43 -0
- package/out/src/monitor/LeasedMonitorTask.d.ts.map +1 -0
- package/out/src/monitor/LeasedMonitorTask.js +89 -0
- package/out/src/monitor/LeasedMonitorTask.js.map +1 -0
- package/out/src/monitor/Monitor.d.ts +24 -0
- package/out/src/monitor/Monitor.d.ts.map +1 -1
- package/out/src/monitor/Monitor.js +63 -75
- package/out/src/monitor/Monitor.js.map +1 -1
- package/out/src/monitor/V7LeasedTask.d.ts +43 -0
- package/out/src/monitor/V7LeasedTask.d.ts.map +1 -0
- package/out/src/monitor/V7LeasedTask.js +89 -0
- package/out/src/monitor/V7LeasedTask.js.map +1 -0
- 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 +4 -2
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.js +83 -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/WalletStorage.interfaces.d.ts +59 -59
- package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
- package/out/src/sdk/types.d.ts +36 -4
- package/out/src/sdk/types.d.ts.map +1 -1
- package/out/src/sdk/types.js +53 -4
- 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/createDefaultIdbChaintracksOptions.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createDefaultIdbChaintracksOptions.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createDefaultNoDbChaintracksOptions.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createIdbChaintracks.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/createNoDbChaintracks.js.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 +544 -1224
- package/out/src/storage/StorageIdb.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts +124 -1
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +316 -186
- 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 +47 -0
- package/out/src/storage/idbHelpers.d.ts.map +1 -0
- package/out/src/storage/idbHelpers.js +417 -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 +338 -63
- 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 +251 -274
- 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.d.ts.map +1 -1
- package/out/src/storage/methods/internalizeAction.js +213 -56
- 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 +168 -93
- 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 +43 -2
- 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/monitorLease.d.ts +57 -0
- package/out/src/storage/schema/monitorLease.d.ts.map +1 -0
- package/out/src/storage/schema/monitorLease.js +101 -0
- package/out/src/storage/schema/monitorLease.js.map +1 -0
- package/out/src/storage/schema/processingFsm.d.ts +27 -0
- package/out/src/storage/schema/processingFsm.d.ts.map +1 -0
- package/out/src/storage/schema/processingFsm.js +132 -0
- package/out/src/storage/schema/processingFsm.js.map +1 -0
- package/out/src/storage/schema/tables/TableAction.d.ts +38 -0
- package/out/src/storage/schema/tables/TableAction.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableAction.js +3 -0
- package/out/src/storage/schema/tables/TableAction.js.map +1 -0
- 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/TableChainTip.d.ts +17 -0
- package/out/src/storage/schema/tables/TableChainTip.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableChainTip.js +3 -0
- package/out/src/storage/schema/tables/TableChainTip.js.map +1 -0
- 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/TableMonitorLease.d.ts +23 -0
- package/out/src/storage/schema/tables/TableMonitorLease.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableMonitorLease.js +3 -0
- package/out/src/storage/schema/tables/TableMonitorLease.js.map +1 -0
- package/out/src/storage/schema/tables/TableOutput.d.ts +10 -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/TableTransactionNew.d.ts +50 -0
- package/out/src/storage/schema/tables/TableTransactionNew.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableTransactionNew.js +3 -0
- package/out/src/storage/schema/tables/TableTransactionNew.js.map +1 -0
- package/out/src/storage/schema/tables/TableTransactionV7.d.ts +50 -0
- package/out/src/storage/schema/tables/TableTransactionV7.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableTransactionV7.js +3 -0
- package/out/src/storage/schema/tables/TableTransactionV7.js.map +1 -0
- package/out/src/storage/schema/tables/TableTxAudit.d.ts +26 -0
- package/out/src/storage/schema/tables/TableTxAudit.d.ts.map +1 -0
- package/out/src/storage/schema/tables/TableTxAudit.js +3 -0
- package/out/src/storage/schema/tables/TableTxAudit.js.map +1 -0
- 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/schema/tables/index.d.ts +5 -0
- package/out/src/storage/schema/tables/index.d.ts.map +1 -1
- package/out/src/storage/schema/tables/index.js +5 -0
- package/out/src/storage/schema/tables/index.js.map +1 -1
- package/out/src/storage/schema/transactionCrud.d.ts +41 -0
- package/out/src/storage/schema/transactionCrud.d.ts.map +1 -0
- package/out/src/storage/schema/transactionCrud.js +205 -0
- package/out/src/storage/schema/transactionCrud.js.map +1 -0
- package/out/src/storage/schema/transactionService.d.ts +315 -0
- package/out/src/storage/schema/transactionService.d.ts.map +1 -0
- package/out/src/storage/schema/transactionService.js +783 -0
- package/out/src/storage/schema/transactionService.js.map +1 -0
- package/out/src/storage/schema/txAudit.d.ts +33 -0
- package/out/src/storage/schema/txAudit.d.ts.map +1 -0
- package/out/src/storage/schema/txAudit.js +64 -0
- package/out/src/storage/schema/txAudit.js.map +1 -0
- package/out/src/storage/schema/v7Crud.d.ts +41 -0
- package/out/src/storage/schema/v7Crud.d.ts.map +1 -0
- package/out/src/storage/schema/v7Crud.js +205 -0
- package/out/src/storage/schema/v7Crud.js.map +1 -0
- package/out/src/storage/schema/v7Fsm.d.ts +27 -0
- package/out/src/storage/schema/v7Fsm.d.ts.map +1 -0
- package/out/src/storage/schema/v7Fsm.js +124 -0
- package/out/src/storage/schema/v7Fsm.js.map +1 -0
- package/out/src/storage/schema/v7MonitorLease.d.ts +57 -0
- package/out/src/storage/schema/v7MonitorLease.d.ts.map +1 -0
- package/out/src/storage/schema/v7MonitorLease.js +101 -0
- package/out/src/storage/schema/v7MonitorLease.js.map +1 -0
- package/out/src/storage/schema/v7Service.d.ts +305 -0
- package/out/src/storage/schema/v7Service.d.ts.map +1 -0
- package/out/src/storage/schema/v7Service.js +757 -0
- package/out/src/storage/schema/v7Service.js.map +1 -0
- package/out/src/storage/schema/v7TxAudit.d.ts +33 -0
- package/out/src/storage/schema/v7TxAudit.d.ts.map +1 -0
- package/out/src/storage/schema/v7TxAudit.js +64 -0
- package/out/src/storage/schema/v7TxAudit.js.map +1 -0
- 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/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`.
|
|
@@ -35,6 +69,9 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
35
69
|
];
|
|
36
70
|
this.dbName = `wallet-toolbox-${this.chain}net`;
|
|
37
71
|
}
|
|
72
|
+
// TODO(new-schema-idb): StorageIdb does not yet support the the new schema.
|
|
73
|
+
// getTransactionService() inherits the default `return undefined` from StorageProvider.
|
|
74
|
+
// A future implementation would wrap an IndexedDB-backed the transaction service here.
|
|
38
75
|
/**
|
|
39
76
|
* This method must be called at least once before any other method accesses the database,
|
|
40
77
|
* and each time the schema may have updated.
|
|
@@ -61,7 +98,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
61
98
|
* @returns
|
|
62
99
|
*/
|
|
63
100
|
async verifyDB(storageName, storageIdentityKey) {
|
|
64
|
-
if (this.db)
|
|
101
|
+
if (this.db != null)
|
|
65
102
|
return this.db;
|
|
66
103
|
this.db = await this.initDB(storageName, storageIdentityKey);
|
|
67
104
|
this._settings = (await this.db.getAll('settings'))[0];
|
|
@@ -73,12 +110,12 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
73
110
|
* or a Knex.Transaction as appropriate.
|
|
74
111
|
*/
|
|
75
112
|
toDbTrx(stores, mode, trx) {
|
|
76
|
-
if (trx) {
|
|
113
|
+
if (trx != null) {
|
|
77
114
|
const t = trx;
|
|
78
115
|
return t;
|
|
79
116
|
}
|
|
80
117
|
else {
|
|
81
|
-
if (
|
|
118
|
+
if (this.db == null)
|
|
82
119
|
throw new Error('not initialized');
|
|
83
120
|
const db = this.db;
|
|
84
121
|
const trx = db.transaction(stores || this.allStores, mode || 'readwrite');
|
|
@@ -103,150 +140,13 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
103
140
|
const chain = this.chain;
|
|
104
141
|
const maxOutputScript = 1024;
|
|
105
142
|
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
|
-
}
|
|
143
|
+
upgrade(db) {
|
|
144
|
+
(0, idbHelpers_1.upgradeAllStoresV1)(db);
|
|
243
145
|
if (!db.objectStoreNames.contains('settings')) {
|
|
244
146
|
if (!storageName || !storageIdentityKey) {
|
|
245
147
|
throw new WERR_errors_1.WERR_INVALID_OPERATION('migrate must be called before first access');
|
|
246
148
|
}
|
|
247
|
-
const settings = db.createObjectStore('settings', {
|
|
248
|
-
keyPath: 'storageIdentityKey'
|
|
249
|
-
});
|
|
149
|
+
const settings = db.createObjectStore('settings', { keyPath: 'storageIdentityKey' });
|
|
250
150
|
const s = {
|
|
251
151
|
created_at: new Date(),
|
|
252
152
|
updated_at: new Date(),
|
|
@@ -315,25 +215,25 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
315
215
|
const score = o.satoshis - targetSatoshis;
|
|
316
216
|
scores.push({ output: o, score });
|
|
317
217
|
}
|
|
318
|
-
if (
|
|
218
|
+
if (output == null) {
|
|
319
219
|
// sort scores increasing by score property
|
|
320
220
|
scores = scores.sort((a, b) => a.score - b.score);
|
|
321
221
|
// find the first score that is greater than or equal to 0
|
|
322
222
|
const o = scores.find(s => s.score >= 0);
|
|
323
|
-
if (o) {
|
|
223
|
+
if (o != null) {
|
|
324
224
|
// stage 2 satisfied (minimally funded)
|
|
325
225
|
output = o.output;
|
|
326
226
|
}
|
|
327
227
|
else if (scores.length > 0) {
|
|
328
228
|
// stage 3 satisfied (minimally under-funded)
|
|
329
|
-
output = scores.
|
|
229
|
+
output = scores.at(-1).output;
|
|
330
230
|
}
|
|
331
231
|
else {
|
|
332
232
|
// no available funding outputs
|
|
333
233
|
output = undefined;
|
|
334
234
|
}
|
|
335
235
|
}
|
|
336
|
-
if (output) {
|
|
236
|
+
if (output != null) {
|
|
337
237
|
// mark output as spent by transactionId
|
|
338
238
|
await this.updateOutput(output.outputId, { spendable: false, spentBy: transactionId }, dbTrx);
|
|
339
239
|
// Hydrate the locking script for the chosen output. Identical to Knex canon at
|
|
@@ -353,10 +253,10 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
353
253
|
rawTx: undefined,
|
|
354
254
|
inputBEEF: undefined
|
|
355
255
|
};
|
|
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)) {
|
|
256
|
+
r.proven = (0, utilityHelpers_1.verifyOneOrNone)(await this.findProvenTxs({ partial: { txid }, trx }));
|
|
257
|
+
if (r.proven == null) {
|
|
258
|
+
const req = (0, utilityHelpers_1.verifyOneOrNone)(await this.findProvenTxReqs({ partial: { txid }, trx }));
|
|
259
|
+
if ((req != null) && ['unsent', 'unmined', 'unconfirmed', 'sending', 'nosend', 'completed'].includes(req.status)) {
|
|
360
260
|
r.rawTx = req.rawTx;
|
|
361
261
|
r.inputBEEF = req.inputBEEF;
|
|
362
262
|
}
|
|
@@ -368,35 +268,32 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
368
268
|
return undefined;
|
|
369
269
|
if (!this.isAvailable())
|
|
370
270
|
await this.makeAvailable();
|
|
371
|
-
let rawTx = undefined;
|
|
372
271
|
const sliceRequested = offset !== undefined && length !== undefined && Number.isInteger(offset) && Number.isInteger(length);
|
|
373
272
|
// Slice path uses an extended status set that includes 'unfail' — matches Knex
|
|
374
273
|
// canon at StorageKnex.ts:131. The non-slice path continues to delegate to
|
|
375
274
|
// 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);
|
|
275
|
+
const rawTx = sliceRequested
|
|
276
|
+
? await this.getRawTxForSlice(txid, trx)
|
|
277
|
+
: await this.getRawTxFull(txid, trx);
|
|
278
|
+
if (rawTx != null && sliceRequested) {
|
|
279
|
+
return rawTx.slice(offset, (offset) + (length));
|
|
397
280
|
}
|
|
398
281
|
return rawTx;
|
|
399
282
|
}
|
|
283
|
+
async getRawTxForSlice(txid, trx) {
|
|
284
|
+
const proven = (0, utilityHelpers_1.verifyOneOrNone)(await this.findProvenTxs({ partial: { txid }, trx }));
|
|
285
|
+
if (proven != null)
|
|
286
|
+
return proven.rawTx;
|
|
287
|
+
const req = (0, utilityHelpers_1.verifyOneOrNone)(await this.findProvenTxReqs({ partial: { txid }, trx }));
|
|
288
|
+
const validStatuses = ['unsent', 'nosend', 'sending', 'unmined', 'completed', 'unfail'];
|
|
289
|
+
if (req != null && validStatuses.includes(req.status))
|
|
290
|
+
return req.rawTx;
|
|
291
|
+
return undefined;
|
|
292
|
+
}
|
|
293
|
+
async getRawTxFull(txid, trx) {
|
|
294
|
+
const r = await this.getProvenOrRawTx(txid, trx);
|
|
295
|
+
return r.proven != null ? r.proven.rawTx : r.rawTx;
|
|
296
|
+
}
|
|
400
297
|
async getLabelsForTransactionId(transactionId, trx) {
|
|
401
298
|
const maps = await this.findTxLabelMaps({ partial: { transactionId, isDeleted: false }, trx });
|
|
402
299
|
const labelIds = maps.map(m => m.txLabelId);
|
|
@@ -406,10 +303,11 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
406
303
|
// Knex/Bun drop it via JOIN; we must do the same silently or we'd break the whole
|
|
407
304
|
// listActions response. Skip + log so persistent orphans still produce a signal.
|
|
408
305
|
const label = (0, utilityHelpers_1.verifyOneOrNone)(await this.findTxLabels({ partial: { txLabelId, isDeleted: false }, trx }));
|
|
409
|
-
if (label)
|
|
306
|
+
if (label != null)
|
|
410
307
|
labels.push(label);
|
|
411
|
-
else
|
|
308
|
+
else {
|
|
412
309
|
console.debug(`[StorageIdb] orphan tx_labels_map row skipped: transactionId=${transactionId} txLabelId=${txLabelId}`);
|
|
310
|
+
}
|
|
413
311
|
}
|
|
414
312
|
return labels;
|
|
415
313
|
}
|
|
@@ -419,10 +317,11 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
419
317
|
const tags = [];
|
|
420
318
|
for (const outputTagId of tagIds) {
|
|
421
319
|
const tag = (0, utilityHelpers_1.verifyOneOrNone)(await this.findOutputTags({ partial: { outputTagId, isDeleted: false }, trx }));
|
|
422
|
-
if (tag)
|
|
320
|
+
if (tag != null)
|
|
423
321
|
tags.push(tag);
|
|
424
|
-
else
|
|
322
|
+
else {
|
|
425
323
|
console.debug(`[StorageIdb] orphan output_tags_map row skipped: outputId=${outputId} outputTagId=${outputTagId}`);
|
|
324
|
+
}
|
|
426
325
|
}
|
|
427
326
|
return tags;
|
|
428
327
|
}
|
|
@@ -485,70 +384,43 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
485
384
|
* you need IS NULL semantics (only meaningful for nullable columns).
|
|
486
385
|
*/
|
|
487
386
|
assertNoUndefinedInPartial(partial) {
|
|
488
|
-
if (
|
|
387
|
+
if (partial == null)
|
|
489
388
|
return;
|
|
490
389
|
for (const k of Object.keys(partial)) {
|
|
491
390
|
if (partial[k] === undefined) {
|
|
492
|
-
throw new WERR_errors_1.WERR_INVALID_PARAMETER(`args.partial.${k}`,
|
|
391
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER(`args.partial.${k}`, 'not undefined. Passing undefined as a filter value is not supported — omit the key to skip filtering. Matches Knex semantics.');
|
|
493
392
|
}
|
|
494
393
|
}
|
|
495
394
|
}
|
|
496
395
|
async filterOutputTagMaps(args, filtered, userId) {
|
|
497
396
|
var _a, _b, _c, _d;
|
|
498
397
|
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
398
|
const dbTrx = this.toDbTrx(['output_tags_map', 'output_tags'], 'readonly', args.trx);
|
|
399
|
+
const store = dbTrx.objectStore('output_tags_map');
|
|
400
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
503
401
|
let cursor;
|
|
504
|
-
if (((
|
|
505
|
-
cursor = await
|
|
402
|
+
if (((_a = args.partial) === null || _a === void 0 ? void 0 : _a.outputTagId) !== undefined) {
|
|
403
|
+
cursor = await store.index('outputTagId').openCursor(args.partial.outputTagId);
|
|
506
404
|
}
|
|
507
|
-
else if (((
|
|
508
|
-
cursor = await
|
|
405
|
+
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.outputId) !== undefined) {
|
|
406
|
+
cursor = await store.index('outputId').openCursor(args.partial.outputId);
|
|
509
407
|
}
|
|
510
408
|
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
|
-
}
|
|
409
|
+
cursor = await store.openCursor();
|
|
410
|
+
}
|
|
411
|
+
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) => {
|
|
412
|
+
if (args.tagIds != null && !args.tagIds.includes(r.outputTagId))
|
|
413
|
+
return false;
|
|
414
|
+
if (!(0, idbHelpers_1.matchesOutputTagMapPartial)(r, args.partial))
|
|
415
|
+
return false;
|
|
537
416
|
if (userId !== undefined) {
|
|
538
417
|
const tagsForUser = await this.countOutputTags({ partial: { userId, outputTagId: r.outputTagId }, trx: dbTrx });
|
|
539
418
|
if (tagsForUser === 0)
|
|
540
|
-
|
|
419
|
+
return false;
|
|
541
420
|
}
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
}
|
|
546
|
-
filtered(r);
|
|
547
|
-
count++;
|
|
548
|
-
if (((_d = args.paged) === null || _d === void 0 ? void 0 : _d.limit) && count >= args.paged.limit)
|
|
549
|
-
break;
|
|
550
|
-
}
|
|
551
|
-
if (!args.trx)
|
|
421
|
+
return true;
|
|
422
|
+
}, filtered);
|
|
423
|
+
if (args.trx == null)
|
|
552
424
|
await dbTrx.done;
|
|
553
425
|
}
|
|
554
426
|
async findOutputTagMaps(args) {
|
|
@@ -558,93 +430,54 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
558
430
|
});
|
|
559
431
|
return results;
|
|
560
432
|
}
|
|
433
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
434
|
+
async openProvenTxReqsCursor(
|
|
435
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
436
|
+
store,
|
|
437
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
438
|
+
partial, direction
|
|
439
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
440
|
+
) {
|
|
441
|
+
if (partial === null || partial === void 0 ? void 0 : partial.provenTxReqId)
|
|
442
|
+
return store.openCursor(partial.provenTxReqId, direction);
|
|
443
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.provenTxId) !== undefined)
|
|
444
|
+
return store.index('provenTxId').openCursor(partial.provenTxId, direction);
|
|
445
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.txid) !== undefined)
|
|
446
|
+
return store.index('txid').openCursor(partial.txid, direction);
|
|
447
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.status) !== undefined)
|
|
448
|
+
return store.index('status').openCursor(partial.status, direction);
|
|
449
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.batch) !== undefined)
|
|
450
|
+
return store.index('batch').openCursor(partial.batch, direction);
|
|
451
|
+
return store.openCursor(null, direction);
|
|
452
|
+
}
|
|
561
453
|
async filterProvenTxReqs(args, filtered, userId) {
|
|
562
|
-
var _a, _b
|
|
454
|
+
var _a, _b;
|
|
563
455
|
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);
|
|
456
|
+
if (args.partial.rawTx != null) {
|
|
457
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.rawTx', 'undefined. ProvenTxReqs may not be found by rawTx value.');
|
|
582
458
|
}
|
|
583
|
-
|
|
584
|
-
|
|
459
|
+
if (args.partial.inputBEEF != null) {
|
|
460
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.inputBEEF', 'undefined. ProvenTxReqs may not be found by inputBEEF value.');
|
|
585
461
|
}
|
|
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;
|
|
462
|
+
const dbTrx = this.toDbTrx(['proven_tx_reqs', 'transactions'], 'readonly', args.trx);
|
|
463
|
+
const direction = args.orderDescending ? 'prev' : 'next';
|
|
464
|
+
const store = dbTrx.objectStore('proven_tx_reqs');
|
|
465
|
+
const cursor = await this.openProvenTxReqsCursor(store, args.partial, direction);
|
|
466
|
+
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) => {
|
|
467
|
+
if (!(0, idbHelpers_1.matchesProvenTxReqPartial)(r, args.partial))
|
|
468
|
+
return false;
|
|
469
|
+
if (args.status != null && args.status.length > 0 && !args.status.includes(r.status))
|
|
470
|
+
return false;
|
|
471
|
+
if (args.txids != null && args.txids.length > 0 && !args.txids.includes(r.txid))
|
|
472
|
+
return false;
|
|
633
473
|
if (userId !== undefined) {
|
|
634
474
|
const txsForUser = await this.countTransactions({ partial: { userId, txid: r.txid }, trx: dbTrx });
|
|
635
475
|
if (txsForUser === 0)
|
|
636
|
-
|
|
637
|
-
}
|
|
638
|
-
if (skipped < offset) {
|
|
639
|
-
skipped++;
|
|
640
|
-
continue;
|
|
476
|
+
return false;
|
|
641
477
|
}
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
break;
|
|
646
|
-
}
|
|
647
|
-
if (!args.trx)
|
|
478
|
+
return true;
|
|
479
|
+
}, filtered);
|
|
480
|
+
if (args.trx == null)
|
|
648
481
|
await dbTrx.done;
|
|
649
482
|
}
|
|
650
483
|
async findProvenTxReqs(args) {
|
|
@@ -657,68 +490,37 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
657
490
|
async filterProvenTxs(args, filtered, userId) {
|
|
658
491
|
var _a, _b, _c, _d;
|
|
659
492
|
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;
|
|
493
|
+
if (args.partial.rawTx != null) {
|
|
494
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.rawTx', 'undefined. ProvenTxs may not be found by rawTx value.');
|
|
495
|
+
}
|
|
496
|
+
if (args.partial.merklePath != null) {
|
|
497
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.merklePath', 'undefined. ProvenTxs may not be found by merklePath value.');
|
|
498
|
+
}
|
|
667
499
|
const dbTrx = this.toDbTrx(['proven_txs', 'transactions'], 'readonly', args.trx);
|
|
668
500
|
const direction = args.orderDescending ? 'prev' : 'next';
|
|
501
|
+
const store = dbTrx.objectStore('proven_txs');
|
|
502
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
669
503
|
let cursor;
|
|
670
|
-
if ((
|
|
671
|
-
cursor = await
|
|
504
|
+
if ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.provenTxId) {
|
|
505
|
+
cursor = await store.openCursor(args.partial.provenTxId, direction);
|
|
672
506
|
}
|
|
673
|
-
else if (((
|
|
674
|
-
cursor = await
|
|
507
|
+
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.txid) !== undefined) {
|
|
508
|
+
cursor = await store.index('txid').openCursor(args.partial.txid, direction);
|
|
675
509
|
}
|
|
676
510
|
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
|
-
}
|
|
511
|
+
cursor = await store.openCursor(null, direction);
|
|
512
|
+
}
|
|
513
|
+
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) => {
|
|
514
|
+
if (!(0, idbHelpers_1.matchesProvenTxPartial)(r, args.partial))
|
|
515
|
+
return false;
|
|
707
516
|
if (userId !== undefined) {
|
|
708
|
-
const
|
|
709
|
-
if (
|
|
710
|
-
|
|
711
|
-
}
|
|
712
|
-
if (skipped < offset) {
|
|
713
|
-
skipped++;
|
|
714
|
-
continue;
|
|
517
|
+
const txCount = await this.countTransactions({ partial: { userId, provenTxId: r.provenTxId }, trx: dbTrx });
|
|
518
|
+
if (txCount === 0)
|
|
519
|
+
return false;
|
|
715
520
|
}
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
break;
|
|
720
|
-
}
|
|
721
|
-
if (!args.trx)
|
|
521
|
+
return true;
|
|
522
|
+
}, filtered);
|
|
523
|
+
if (args.trx == null)
|
|
722
524
|
await dbTrx.done;
|
|
723
525
|
}
|
|
724
526
|
async findProvenTxs(args) {
|
|
@@ -731,57 +533,30 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
731
533
|
async filterTxLabelMaps(args, filtered, userId) {
|
|
732
534
|
var _a, _b, _c, _d;
|
|
733
535
|
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
536
|
const dbTrx = this.toDbTrx(['tx_labels_map', 'tx_labels'], 'readonly', args.trx);
|
|
537
|
+
const store = dbTrx.objectStore('tx_labels_map');
|
|
538
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
738
539
|
let cursor;
|
|
739
|
-
if (((
|
|
740
|
-
cursor = await
|
|
540
|
+
if (((_a = args.partial) === null || _a === void 0 ? void 0 : _a.transactionId) !== undefined) {
|
|
541
|
+
cursor = await store.index('transactionId').openCursor(args.partial.transactionId);
|
|
741
542
|
}
|
|
742
|
-
else if (((
|
|
743
|
-
cursor = await
|
|
543
|
+
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.txLabelId) !== undefined) {
|
|
544
|
+
cursor = await store.index('txLabelId').openCursor(args.partial.txLabelId);
|
|
744
545
|
}
|
|
745
546
|
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
|
-
}
|
|
547
|
+
cursor = await store.openCursor();
|
|
548
|
+
}
|
|
549
|
+
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) => {
|
|
550
|
+
if (!(0, idbHelpers_1.matchesTxLabelMapPartial)(r, args.partial))
|
|
551
|
+
return false;
|
|
770
552
|
if (userId !== undefined) {
|
|
771
|
-
const
|
|
772
|
-
if (
|
|
773
|
-
|
|
774
|
-
}
|
|
775
|
-
if (skipped < offset) {
|
|
776
|
-
skipped++;
|
|
777
|
-
continue;
|
|
553
|
+
const labelCount = await this.countTxLabels({ partial: { userId, txLabelId: r.txLabelId }, trx: dbTrx });
|
|
554
|
+
if (labelCount === 0)
|
|
555
|
+
return false;
|
|
778
556
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
break;
|
|
783
|
-
}
|
|
784
|
-
if (!args.trx)
|
|
557
|
+
return true;
|
|
558
|
+
}, filtered);
|
|
559
|
+
if (args.trx == null)
|
|
785
560
|
await dbTrx.done;
|
|
786
561
|
}
|
|
787
562
|
async findTxLabelMaps(args) {
|
|
@@ -843,7 +618,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
843
618
|
}
|
|
844
619
|
}
|
|
845
620
|
finally {
|
|
846
|
-
if (
|
|
621
|
+
if (trx == null)
|
|
847
622
|
await dbTrx.done;
|
|
848
623
|
}
|
|
849
624
|
return certificate.certificateId;
|
|
@@ -856,7 +631,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
856
631
|
await store.add(e);
|
|
857
632
|
}
|
|
858
633
|
finally {
|
|
859
|
-
if (
|
|
634
|
+
if (trx == null)
|
|
860
635
|
await dbTrx.done;
|
|
861
636
|
}
|
|
862
637
|
}
|
|
@@ -871,7 +646,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
871
646
|
commission.commissionId = id;
|
|
872
647
|
}
|
|
873
648
|
finally {
|
|
874
|
-
if (
|
|
649
|
+
if (trx == null)
|
|
875
650
|
await dbTrx.done;
|
|
876
651
|
}
|
|
877
652
|
return commission.commissionId;
|
|
@@ -887,7 +662,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
887
662
|
event.id = id;
|
|
888
663
|
}
|
|
889
664
|
finally {
|
|
890
|
-
if (
|
|
665
|
+
if (trx == null)
|
|
891
666
|
await dbTrx.done;
|
|
892
667
|
}
|
|
893
668
|
return event.id;
|
|
@@ -903,7 +678,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
903
678
|
output.outputId = id;
|
|
904
679
|
}
|
|
905
680
|
finally {
|
|
906
|
-
if (
|
|
681
|
+
if (trx == null)
|
|
907
682
|
await dbTrx.done;
|
|
908
683
|
}
|
|
909
684
|
return output.outputId;
|
|
@@ -919,7 +694,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
919
694
|
basket.basketId = id;
|
|
920
695
|
}
|
|
921
696
|
finally {
|
|
922
|
-
if (
|
|
697
|
+
if (trx == null)
|
|
923
698
|
await dbTrx.done;
|
|
924
699
|
}
|
|
925
700
|
return basket.basketId;
|
|
@@ -935,7 +710,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
935
710
|
tag.outputTagId = id;
|
|
936
711
|
}
|
|
937
712
|
finally {
|
|
938
|
-
if (
|
|
713
|
+
if (trx == null)
|
|
939
714
|
await dbTrx.done;
|
|
940
715
|
}
|
|
941
716
|
return tag.outputTagId;
|
|
@@ -948,7 +723,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
948
723
|
await store.add(e);
|
|
949
724
|
}
|
|
950
725
|
finally {
|
|
951
|
-
if (
|
|
726
|
+
if (trx == null)
|
|
952
727
|
await dbTrx.done;
|
|
953
728
|
}
|
|
954
729
|
}
|
|
@@ -963,7 +738,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
963
738
|
tx.provenTxId = id;
|
|
964
739
|
}
|
|
965
740
|
finally {
|
|
966
|
-
if (
|
|
741
|
+
if (trx == null)
|
|
967
742
|
await dbTrx.done;
|
|
968
743
|
}
|
|
969
744
|
return tx.provenTxId;
|
|
@@ -979,7 +754,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
979
754
|
tx.provenTxReqId = id;
|
|
980
755
|
}
|
|
981
756
|
finally {
|
|
982
|
-
if (
|
|
757
|
+
if (trx == null)
|
|
983
758
|
await dbTrx.done;
|
|
984
759
|
}
|
|
985
760
|
return tx.provenTxReqId;
|
|
@@ -995,7 +770,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
995
770
|
syncState.syncStateId = id;
|
|
996
771
|
}
|
|
997
772
|
finally {
|
|
998
|
-
if (
|
|
773
|
+
if (trx == null)
|
|
999
774
|
await dbTrx.done;
|
|
1000
775
|
}
|
|
1001
776
|
return syncState.syncStateId;
|
|
@@ -1011,7 +786,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1011
786
|
tx.transactionId = id;
|
|
1012
787
|
}
|
|
1013
788
|
finally {
|
|
1014
|
-
if (
|
|
789
|
+
if (trx == null)
|
|
1015
790
|
await dbTrx.done;
|
|
1016
791
|
}
|
|
1017
792
|
return tx.transactionId;
|
|
@@ -1027,7 +802,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1027
802
|
label.txLabelId = id;
|
|
1028
803
|
}
|
|
1029
804
|
finally {
|
|
1030
|
-
if (
|
|
805
|
+
if (trx == null)
|
|
1031
806
|
await dbTrx.done;
|
|
1032
807
|
}
|
|
1033
808
|
return label.txLabelId;
|
|
@@ -1040,7 +815,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1040
815
|
await store.add(e);
|
|
1041
816
|
}
|
|
1042
817
|
finally {
|
|
1043
|
-
if (
|
|
818
|
+
if (trx == null)
|
|
1044
819
|
await dbTrx.done;
|
|
1045
820
|
}
|
|
1046
821
|
}
|
|
@@ -1055,14 +830,14 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1055
830
|
user.userId = id;
|
|
1056
831
|
}
|
|
1057
832
|
finally {
|
|
1058
|
-
if (
|
|
833
|
+
if (trx == null)
|
|
1059
834
|
await dbTrx.done;
|
|
1060
835
|
}
|
|
1061
836
|
return user.userId;
|
|
1062
837
|
}
|
|
1063
838
|
async updateIdb(id, update, keyProp, storeName, trx) {
|
|
1064
839
|
if (update[keyProp] !== undefined && (Array.isArray(id) || update[keyProp] !== id)) {
|
|
1065
|
-
throw new WERR_errors_1.WERR_INVALID_PARAMETER(`update.${keyProp}`,
|
|
840
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER(`update.${keyProp}`, 'undefined');
|
|
1066
841
|
}
|
|
1067
842
|
const u = this.validatePartialForUpdate(update);
|
|
1068
843
|
const dbTrx = this.toDbTrx([storeName], 'readwrite', trx);
|
|
@@ -1082,22 +857,23 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1082
857
|
};
|
|
1083
858
|
const uid = await store.put(v);
|
|
1084
859
|
if (uid !== i)
|
|
1085
|
-
throw new WERR_errors_1.WERR_INTERNAL(`updated id ${uid} does not match original ${id}`);
|
|
860
|
+
throw new WERR_errors_1.WERR_INTERNAL(`updated id ${String(uid)} does not match original ${String(id)}`);
|
|
1086
861
|
updated++;
|
|
1087
862
|
}
|
|
1088
863
|
}
|
|
1089
864
|
finally {
|
|
1090
|
-
if (
|
|
865
|
+
if (trx == null)
|
|
1091
866
|
await dbTrx.done;
|
|
1092
867
|
}
|
|
1093
868
|
return updated;
|
|
1094
869
|
}
|
|
1095
870
|
async updateIdbKey(key, update, keyProps, storeName, trx) {
|
|
1096
|
-
if (key.length !== keyProps.length)
|
|
871
|
+
if (key.length !== keyProps.length) {
|
|
1097
872
|
throw new WERR_errors_1.WERR_INTERNAL(`key.length ${key.length} !== keyProps.length ${keyProps.length}`);
|
|
873
|
+
}
|
|
1098
874
|
for (let i = 0; i < key.length; i++) {
|
|
1099
875
|
if (update[keyProps[i]] !== undefined && update[keyProps[i]] !== key[i]) {
|
|
1100
|
-
throw new WERR_errors_1.WERR_INVALID_PARAMETER(`update.${keyProps[i]}`,
|
|
876
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER(`update.${keyProps[i]}`, 'undefined');
|
|
1101
877
|
}
|
|
1102
878
|
}
|
|
1103
879
|
const u = this.validatePartialForUpdate(update);
|
|
@@ -1105,8 +881,9 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1105
881
|
const store = dbTrx.objectStore(storeName);
|
|
1106
882
|
try {
|
|
1107
883
|
const e = await store.get(key);
|
|
1108
|
-
if (!e)
|
|
884
|
+
if (!e) {
|
|
1109
885
|
throw new WERR_errors_1.WERR_INVALID_PARAMETER('key', `an existing record to update ${keyProps.join(',')} ${key.join(',')} not found`);
|
|
886
|
+
}
|
|
1110
887
|
const v = {
|
|
1111
888
|
...e,
|
|
1112
889
|
...u
|
|
@@ -1118,61 +895,61 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1118
895
|
}
|
|
1119
896
|
}
|
|
1120
897
|
finally {
|
|
1121
|
-
if (
|
|
898
|
+
if (trx == null)
|
|
1122
899
|
await dbTrx.done;
|
|
1123
900
|
}
|
|
1124
901
|
return 1;
|
|
1125
902
|
}
|
|
1126
903
|
async updateCertificate(id, update, trx) {
|
|
1127
|
-
return this.updateIdb(id, update, 'certificateId', 'certificates', trx);
|
|
904
|
+
return await this.updateIdb(id, update, 'certificateId', 'certificates', trx);
|
|
1128
905
|
}
|
|
1129
906
|
async updateCertificateField(certificateId, fieldName, update, trx) {
|
|
1130
|
-
return this.updateIdbKey([certificateId, fieldName], update, ['certificateId', 'fieldName'], 'certificate_fields', trx);
|
|
907
|
+
return await this.updateIdbKey([certificateId, fieldName], update, ['certificateId', 'fieldName'], 'certificate_fields', trx);
|
|
1131
908
|
}
|
|
1132
909
|
async updateCommission(id, update, trx) {
|
|
1133
|
-
return this.updateIdb(id, update, 'commissionId', 'commissions', trx);
|
|
910
|
+
return await this.updateIdb(id, update, 'commissionId', 'commissions', trx);
|
|
1134
911
|
}
|
|
1135
912
|
async updateMonitorEvent(id, update, trx) {
|
|
1136
|
-
return this.updateIdb(id, update, 'id', 'monitor_events', trx);
|
|
913
|
+
return await this.updateIdb(id, update, 'id', 'monitor_events', trx);
|
|
1137
914
|
}
|
|
1138
915
|
async updateOutput(id, update, trx) {
|
|
1139
|
-
return this.updateIdb(id, update, 'outputId', 'outputs', trx);
|
|
916
|
+
return await this.updateIdb(id, update, 'outputId', 'outputs', trx);
|
|
1140
917
|
}
|
|
1141
918
|
async updateOutputBasket(id, update, trx) {
|
|
1142
|
-
return this.updateIdb(id, update, 'basketId', 'output_baskets', trx);
|
|
919
|
+
return await this.updateIdb(id, update, 'basketId', 'output_baskets', trx);
|
|
1143
920
|
}
|
|
1144
921
|
async updateOutputTag(id, update, trx) {
|
|
1145
|
-
return this.updateIdb(id, update, 'outputTagId', 'output_tags', trx);
|
|
922
|
+
return await this.updateIdb(id, update, 'outputTagId', 'output_tags', trx);
|
|
1146
923
|
}
|
|
1147
924
|
async updateProvenTx(id, update, trx) {
|
|
1148
|
-
return this.updateIdb(id, update, 'provenTxId', 'proven_txs', trx);
|
|
925
|
+
return await this.updateIdb(id, update, 'provenTxId', 'proven_txs', trx);
|
|
1149
926
|
}
|
|
1150
927
|
async updateProvenTxReq(id, update, trx) {
|
|
1151
|
-
return this.updateIdb(id, update, 'provenTxReqId', 'proven_tx_reqs', trx);
|
|
928
|
+
return await this.updateIdb(id, update, 'provenTxReqId', 'proven_tx_reqs', trx);
|
|
1152
929
|
}
|
|
1153
930
|
async updateSyncState(id, update, trx) {
|
|
1154
|
-
return this.updateIdb(id, update, 'syncStateId', 'sync_states', trx);
|
|
931
|
+
return await this.updateIdb(id, update, 'syncStateId', 'sync_states', trx);
|
|
1155
932
|
}
|
|
1156
933
|
async updateTransaction(id, update, trx) {
|
|
1157
|
-
return this.updateIdb(id, update, 'transactionId', 'transactions', trx);
|
|
934
|
+
return await this.updateIdb(id, update, 'transactionId', 'transactions', trx);
|
|
1158
935
|
}
|
|
1159
936
|
async updateTxLabel(id, update, trx) {
|
|
1160
|
-
return this.updateIdb(id, update, 'txLabelId', 'tx_labels', trx);
|
|
937
|
+
return await this.updateIdb(id, update, 'txLabelId', 'tx_labels', trx);
|
|
1161
938
|
}
|
|
1162
939
|
async updateUser(id, update, trx) {
|
|
1163
|
-
return this.updateIdb(id, update, 'userId', 'users', trx);
|
|
940
|
+
return await this.updateIdb(id, update, 'userId', 'users', trx);
|
|
1164
941
|
}
|
|
1165
942
|
async updateOutputTagMap(outputId, tagId, update, trx) {
|
|
1166
|
-
return this.updateIdbKey([tagId, outputId], update, ['outputTagId', 'outputId'], 'output_tags_map', trx);
|
|
943
|
+
return await this.updateIdbKey([tagId, outputId], update, ['outputTagId', 'outputId'], 'output_tags_map', trx);
|
|
1167
944
|
}
|
|
1168
945
|
async updateTxLabelMap(transactionId, txLabelId, update, trx) {
|
|
1169
|
-
return this.updateIdbKey([txLabelId, transactionId], update, ['txLabelId', 'transactionId'], 'tx_labels_map', trx);
|
|
946
|
+
return await this.updateIdbKey([txLabelId, transactionId], update, ['txLabelId', 'transactionId'], 'tx_labels_map', trx);
|
|
1170
947
|
}
|
|
1171
948
|
//
|
|
1172
949
|
// StorageReader abstract methods
|
|
1173
950
|
//
|
|
1174
951
|
async destroy() {
|
|
1175
|
-
if (this.db) {
|
|
952
|
+
if (this.db != null) {
|
|
1176
953
|
this.db.close();
|
|
1177
954
|
}
|
|
1178
955
|
this.db = undefined;
|
|
@@ -1184,7 +961,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1184
961
|
* @returns
|
|
1185
962
|
*/
|
|
1186
963
|
async transaction(scope, trx) {
|
|
1187
|
-
if (trx)
|
|
964
|
+
if (trx != null)
|
|
1188
965
|
return await scope(trx);
|
|
1189
966
|
const stores = this.allStores;
|
|
1190
967
|
const db = await this.verifyDB();
|
|
@@ -1203,59 +980,21 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1203
980
|
async filterCertificateFields(args, filtered) {
|
|
1204
981
|
var _a, _b, _c, _d;
|
|
1205
982
|
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
983
|
const dbTrx = this.toDbTrx(['certificate_fields'], 'readonly', args.trx);
|
|
984
|
+
const store = dbTrx.objectStore('certificate_fields');
|
|
985
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1210
986
|
let cursor;
|
|
1211
|
-
if (((
|
|
1212
|
-
cursor = await
|
|
1213
|
-
.objectStore('certificate_fields')
|
|
1214
|
-
.index('certificateId')
|
|
1215
|
-
.openCursor(args.partial.certificateId);
|
|
987
|
+
if (((_a = args.partial) === null || _a === void 0 ? void 0 : _a.certificateId) !== undefined) {
|
|
988
|
+
cursor = await store.index('certificateId').openCursor(args.partial.certificateId);
|
|
1216
989
|
}
|
|
1217
|
-
else if (((
|
|
1218
|
-
cursor = await
|
|
990
|
+
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.userId) !== undefined) {
|
|
991
|
+
cursor = await store.index('userId').openCursor(args.partial.userId);
|
|
1219
992
|
}
|
|
1220
993
|
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;
|
|
994
|
+
cursor = await store.openCursor();
|
|
1257
995
|
}
|
|
1258
|
-
|
|
996
|
+
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);
|
|
997
|
+
if (args.trx == null)
|
|
1259
998
|
await dbTrx.done;
|
|
1260
999
|
}
|
|
1261
1000
|
async findCertificateFields(args) {
|
|
@@ -1265,81 +1004,40 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1265
1004
|
});
|
|
1266
1005
|
return result;
|
|
1267
1006
|
}
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
if (
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
cursor = await dbTrx
|
|
1282
|
-
.objectStore('certificates')
|
|
1007
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1008
|
+
async openCertificatesCursor(
|
|
1009
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1010
|
+
store,
|
|
1011
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1012
|
+
partial
|
|
1013
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1014
|
+
) {
|
|
1015
|
+
if (partial === null || partial === void 0 ? void 0 : partial.certificateId)
|
|
1016
|
+
return store.openCursor(partial.certificateId);
|
|
1017
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.userId) !== undefined) {
|
|
1018
|
+
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)) {
|
|
1019
|
+
return store
|
|
1283
1020
|
.index('userId_type_certifier_serialNumber')
|
|
1284
|
-
.openCursor([
|
|
1285
|
-
}
|
|
1286
|
-
else {
|
|
1287
|
-
cursor = await dbTrx.objectStore('certificates').index('userId').openCursor(args.partial.userId);
|
|
1021
|
+
.openCursor([partial.userId, partial.type, partial.certifier, partial.serialNumber]);
|
|
1288
1022
|
}
|
|
1023
|
+
return store.index('userId').openCursor(partial.userId);
|
|
1289
1024
|
}
|
|
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)
|
|
1025
|
+
return store.openCursor();
|
|
1026
|
+
}
|
|
1027
|
+
async filterCertificates(args, filtered) {
|
|
1028
|
+
var _a, _b;
|
|
1029
|
+
this.assertNoUndefinedInPartial(args.partial);
|
|
1030
|
+
const dbTrx = this.toDbTrx(['certificates'], 'readonly', args.trx);
|
|
1031
|
+
const store = dbTrx.objectStore('certificates');
|
|
1032
|
+
const cursor = await this.openCertificatesCursor(store, args.partial);
|
|
1033
|
+
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 => {
|
|
1034
|
+
if (args.certifiers != null && !args.certifiers.includes(r.certifier))
|
|
1035
|
+
return false;
|
|
1036
|
+
if (args.types != null && !args.types.includes(r.type))
|
|
1037
|
+
return false;
|
|
1038
|
+
return (0, idbHelpers_1.matchesCertificatePartial)(r, args.partial);
|
|
1039
|
+
}, filtered);
|
|
1040
|
+
if (args.trx == null)
|
|
1343
1041
|
await dbTrx.done;
|
|
1344
1042
|
}
|
|
1345
1043
|
async findCertificates(args) {
|
|
@@ -1358,63 +1056,27 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1358
1056
|
async filterCommissions(args, filtered) {
|
|
1359
1057
|
var _a, _b, _c, _d, _e;
|
|
1360
1058
|
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;
|
|
1059
|
+
if (args.partial.lockingScript != null) {
|
|
1060
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('partial.lockingScript', 'undefined. Commissions may not be found by lockingScript value.');
|
|
1061
|
+
}
|
|
1366
1062
|
const dbTrx = this.toDbTrx(['commissions'], 'readonly', args.trx);
|
|
1063
|
+
const store = dbTrx.objectStore('commissions');
|
|
1064
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1367
1065
|
let cursor;
|
|
1368
|
-
if ((
|
|
1369
|
-
cursor = await
|
|
1066
|
+
if ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.commissionId) {
|
|
1067
|
+
cursor = await store.openCursor(args.partial.commissionId);
|
|
1370
1068
|
}
|
|
1371
|
-
else if (((
|
|
1372
|
-
cursor = await
|
|
1069
|
+
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.userId) !== undefined) {
|
|
1070
|
+
cursor = await store.index('userId').openCursor(args.partial.userId);
|
|
1373
1071
|
}
|
|
1374
|
-
else if (((
|
|
1375
|
-
cursor = await
|
|
1072
|
+
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.transactionId) !== undefined) {
|
|
1073
|
+
cursor = await store.index('transactionId').openCursor(args.partial.transactionId);
|
|
1376
1074
|
}
|
|
1377
1075
|
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;
|
|
1076
|
+
cursor = await store.openCursor();
|
|
1416
1077
|
}
|
|
1417
|
-
|
|
1078
|
+
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);
|
|
1079
|
+
if (args.trx == null)
|
|
1418
1080
|
await dbTrx.done;
|
|
1419
1081
|
}
|
|
1420
1082
|
async findCommissions(args) {
|
|
@@ -1427,49 +1089,11 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1427
1089
|
async filterMonitorEvents(args, filtered) {
|
|
1428
1090
|
var _a, _b, _c;
|
|
1429
1091
|
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
1092
|
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)
|
|
1093
|
+
const store = dbTrx.objectStore('monitor_events');
|
|
1094
|
+
const cursor = ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.id) ? await store.openCursor(args.partial.id) : await store.openCursor();
|
|
1095
|
+
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);
|
|
1096
|
+
if (args.trx == null)
|
|
1473
1097
|
await dbTrx.done;
|
|
1474
1098
|
}
|
|
1475
1099
|
async findMonitorEvents(args) {
|
|
@@ -1480,70 +1104,26 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1480
1104
|
return result;
|
|
1481
1105
|
}
|
|
1482
1106
|
async filterOutputBaskets(args, filtered) {
|
|
1483
|
-
var _a, _b, _c, _d, _e;
|
|
1107
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1484
1108
|
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
1109
|
const dbTrx = this.toDbTrx(['output_baskets'], 'readonly', args.trx);
|
|
1110
|
+
const store = dbTrx.objectStore('output_baskets');
|
|
1111
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1489
1112
|
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
|
-
}
|
|
1113
|
+
if ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.basketId) {
|
|
1114
|
+
cursor = await store.openCursor(args.partial.basketId);
|
|
1115
|
+
}
|
|
1116
|
+
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) {
|
|
1117
|
+
cursor = await store.index('name_userId').openCursor([args.partial.name, args.partial.userId]);
|
|
1118
|
+
}
|
|
1119
|
+
else if (((_d = args.partial) === null || _d === void 0 ? void 0 : _d.userId) !== undefined) {
|
|
1120
|
+
cursor = await store.index('userId').openCursor(args.partial.userId);
|
|
1503
1121
|
}
|
|
1504
1122
|
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;
|
|
1123
|
+
cursor = await store.openCursor();
|
|
1545
1124
|
}
|
|
1546
|
-
|
|
1125
|
+
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);
|
|
1126
|
+
if (args.trx == null)
|
|
1547
1127
|
await dbTrx.done;
|
|
1548
1128
|
}
|
|
1549
1129
|
async findOutputBaskets(args) {
|
|
@@ -1553,227 +1133,121 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1553
1133
|
});
|
|
1554
1134
|
return result;
|
|
1555
1135
|
}
|
|
1136
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1137
|
+
async openOutputsCursor(
|
|
1138
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1139
|
+
store,
|
|
1140
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1141
|
+
partial, direction
|
|
1142
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1143
|
+
) {
|
|
1144
|
+
if (partial === null || partial === void 0 ? void 0 : partial.outputId)
|
|
1145
|
+
return store.openCursor(partial.outputId, direction);
|
|
1146
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.userId) !== undefined) {
|
|
1147
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.transactionId) && (partial === null || partial === void 0 ? void 0 : partial.vout) !== undefined) {
|
|
1148
|
+
return store.index('transactionId_vout_userId').openCursor([partial.transactionId, partial.vout, partial.userId], direction);
|
|
1149
|
+
}
|
|
1150
|
+
return store.index('userId').openCursor(partial.userId, direction);
|
|
1151
|
+
}
|
|
1152
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.transactionId) !== undefined)
|
|
1153
|
+
return store.index('transactionId').openCursor(partial.transactionId, direction);
|
|
1154
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.basketId) !== undefined)
|
|
1155
|
+
return store.index('basketId').openCursor(partial.basketId, direction);
|
|
1156
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.spentBy) !== undefined)
|
|
1157
|
+
return store.index('spentBy').openCursor(partial.spentBy, direction);
|
|
1158
|
+
return store.openCursor(null, direction);
|
|
1159
|
+
}
|
|
1556
1160
|
async filterOutputs(args, filtered, tagIds, isQueryModeAll) {
|
|
1557
|
-
var _a, _b
|
|
1161
|
+
var _a, _b;
|
|
1558
1162
|
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;
|
|
1163
|
+
if (args.partial.lockingScript != null) {
|
|
1164
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.lockingScript', 'undefined. Outputs may not be found by lockingScript value.');
|
|
1165
|
+
}
|
|
1566
1166
|
const stores = ['outputs'];
|
|
1567
|
-
if (tagIds && tagIds.length > 0)
|
|
1167
|
+
if (tagIds != null && tagIds.length > 0)
|
|
1568
1168
|
stores.push('output_tags_map');
|
|
1569
|
-
|
|
1570
|
-
if (args.txStatus) {
|
|
1169
|
+
if (args.txStatus != null)
|
|
1571
1170
|
stores.push('transactions');
|
|
1572
|
-
}
|
|
1573
1171
|
const dbTrx = this.toDbTrx(stores, 'readonly', args.trx);
|
|
1574
1172
|
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({
|
|
1173
|
+
const store = dbTrx.objectStore('outputs');
|
|
1174
|
+
const cursor = await this.openOutputsCursor(store, args.partial, direction);
|
|
1175
|
+
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) => {
|
|
1176
|
+
if (!(0, idbHelpers_1.matchesOutputPartial)(r, args.partial))
|
|
1177
|
+
return false;
|
|
1178
|
+
if (args.txStatus !== undefined) {
|
|
1179
|
+
const txCount = await this.countTransactions({
|
|
1665
1180
|
partial: { transactionId: r.transactionId },
|
|
1666
1181
|
status: args.txStatus,
|
|
1667
1182
|
trx: dbTrx
|
|
1668
1183
|
});
|
|
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) {
|
|
1184
|
+
if (txCount === 0)
|
|
1185
|
+
return false;
|
|
1186
|
+
}
|
|
1187
|
+
if (tagIds != null && tagIds.length > 0 && !await this.outputMatchesTags(r.outputId, tagIds, isQueryModeAll, dbTrx))
|
|
1188
|
+
return false;
|
|
1189
|
+
return true;
|
|
1190
|
+
}, r => {
|
|
1191
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1192
|
+
if (args.noScript === true)
|
|
1695
1193
|
r.script = undefined;
|
|
1696
|
-
}
|
|
1697
1194
|
filtered(r);
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
break;
|
|
1701
|
-
}
|
|
1702
|
-
if (!args.trx)
|
|
1195
|
+
});
|
|
1196
|
+
if (args.trx == null)
|
|
1703
1197
|
await dbTrx.done;
|
|
1704
1198
|
}
|
|
1199
|
+
async outputMatchesTags(outputId, tagIds, isQueryModeAll, dbTrx) {
|
|
1200
|
+
let ids = [...tagIds];
|
|
1201
|
+
await this.filterOutputTagMaps({ partial: { outputId }, trx: dbTrx }, tm => {
|
|
1202
|
+
if (ids.length > 0) {
|
|
1203
|
+
const i = ids.indexOf(tm.outputTagId);
|
|
1204
|
+
if (i >= 0) {
|
|
1205
|
+
if (isQueryModeAll) {
|
|
1206
|
+
ids.splice(i, 1);
|
|
1207
|
+
}
|
|
1208
|
+
else {
|
|
1209
|
+
ids = [];
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
});
|
|
1214
|
+
return ids.length === 0;
|
|
1215
|
+
}
|
|
1705
1216
|
async findOutputs(args, tagIds, isQueryModeAll) {
|
|
1706
1217
|
const results = [];
|
|
1707
1218
|
await this.filterOutputs(args, r => {
|
|
1708
1219
|
results.push(this.validateEntity(r));
|
|
1709
1220
|
}, tagIds, isQueryModeAll);
|
|
1710
1221
|
for (const o of results) {
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1222
|
+
if (args.noScript) {
|
|
1223
|
+
o.lockingScript = undefined;
|
|
1224
|
+
}
|
|
1225
|
+
else {
|
|
1714
1226
|
await this.validateOutputScript(o, args.trx);
|
|
1227
|
+
}
|
|
1715
1228
|
}
|
|
1716
1229
|
return results;
|
|
1717
1230
|
}
|
|
1718
1231
|
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;
|
|
1232
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1724
1233
|
const dbTrx = this.toDbTrx(['output_tags'], 'readonly', args.trx);
|
|
1234
|
+
const store = dbTrx.objectStore('output_tags');
|
|
1235
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1725
1236
|
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
|
-
}
|
|
1237
|
+
if ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.outputTagId) {
|
|
1238
|
+
cursor = await store.openCursor(args.partial.outputTagId);
|
|
1239
|
+
}
|
|
1240
|
+
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) {
|
|
1241
|
+
cursor = await store.index('tag_userId').openCursor([args.partial.tag, args.partial.userId]);
|
|
1242
|
+
}
|
|
1243
|
+
else if (((_d = args.partial) === null || _d === void 0 ? void 0 : _d.userId) !== undefined) {
|
|
1244
|
+
cursor = await store.index('userId').openCursor(args.partial.userId);
|
|
1739
1245
|
}
|
|
1740
1246
|
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;
|
|
1247
|
+
cursor = await store.openCursor();
|
|
1775
1248
|
}
|
|
1776
|
-
|
|
1249
|
+
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);
|
|
1250
|
+
if (args.trx == null)
|
|
1777
1251
|
await dbTrx.done;
|
|
1778
1252
|
}
|
|
1779
1253
|
async findOutputTags(args) {
|
|
@@ -1784,78 +1258,31 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1784
1258
|
return result;
|
|
1785
1259
|
}
|
|
1786
1260
|
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;
|
|
1261
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1262
|
+
if (args.partial.syncMap) {
|
|
1263
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.syncMap', 'undefined. SyncStates may not be found by syncMap value.');
|
|
1264
|
+
}
|
|
1794
1265
|
const dbTrx = this.toDbTrx(['sync_states'], 'readonly', args.trx);
|
|
1266
|
+
const store = dbTrx.objectStore('sync_states');
|
|
1267
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1795
1268
|
let cursor;
|
|
1796
|
-
if ((
|
|
1797
|
-
cursor = await
|
|
1269
|
+
if ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.syncStateId) {
|
|
1270
|
+
cursor = await store.openCursor(args.partial.syncStateId);
|
|
1798
1271
|
}
|
|
1799
|
-
else if (((
|
|
1800
|
-
cursor = await
|
|
1272
|
+
else if (((_b = args.partial) === null || _b === void 0 ? void 0 : _b.userId) !== undefined) {
|
|
1273
|
+
cursor = await store.index('userId').openCursor(args.partial.userId);
|
|
1801
1274
|
}
|
|
1802
|
-
else if (((
|
|
1803
|
-
cursor = await
|
|
1275
|
+
else if (((_c = args.partial) === null || _c === void 0 ? void 0 : _c.refNum) !== undefined) {
|
|
1276
|
+
cursor = await store.index('refNum').openCursor(args.partial.refNum);
|
|
1804
1277
|
}
|
|
1805
|
-
else if (((
|
|
1806
|
-
cursor = await
|
|
1278
|
+
else if (((_d = args.partial) === null || _d === void 0 ? void 0 : _d.status) !== undefined) {
|
|
1279
|
+
cursor = await store.index('status').openCursor(args.partial.status);
|
|
1807
1280
|
}
|
|
1808
1281
|
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;
|
|
1282
|
+
cursor = await store.openCursor();
|
|
1857
1283
|
}
|
|
1858
|
-
|
|
1284
|
+
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);
|
|
1285
|
+
if (args.trx == null)
|
|
1859
1286
|
await dbTrx.done;
|
|
1860
1287
|
}
|
|
1861
1288
|
async findSyncStates(args) {
|
|
@@ -1865,125 +1292,77 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1865
1292
|
});
|
|
1866
1293
|
return result;
|
|
1867
1294
|
}
|
|
1295
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1296
|
+
async openTransactionsCursor(
|
|
1297
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1298
|
+
store,
|
|
1299
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1300
|
+
partial, direction
|
|
1301
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1302
|
+
) {
|
|
1303
|
+
if (partial === null || partial === void 0 ? void 0 : partial.transactionId)
|
|
1304
|
+
return store.openCursor(partial.transactionId, direction);
|
|
1305
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.userId) !== undefined) {
|
|
1306
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.status) !== undefined) {
|
|
1307
|
+
return store.index('status_userId').openCursor([partial.status, partial.userId], direction);
|
|
1308
|
+
}
|
|
1309
|
+
return store.index('userId').openCursor(partial.userId, direction);
|
|
1310
|
+
}
|
|
1311
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.status) !== undefined)
|
|
1312
|
+
return store.index('status').openCursor(partial.status, direction);
|
|
1313
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.provenTxId) !== undefined)
|
|
1314
|
+
return store.index('provenTxId').openCursor(partial.provenTxId, direction);
|
|
1315
|
+
if ((partial === null || partial === void 0 ? void 0 : partial.reference) !== undefined)
|
|
1316
|
+
return store.index('reference').openCursor(partial.reference, direction);
|
|
1317
|
+
return store.openCursor(null, direction);
|
|
1318
|
+
}
|
|
1868
1319
|
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;
|
|
1320
|
+
var _a, _b;
|
|
1321
|
+
if (args.partial.rawTx != null) {
|
|
1322
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.rawTx', 'undefined. Transactions may not be found by rawTx value.');
|
|
1323
|
+
}
|
|
1324
|
+
if (args.partial.inputBEEF != null) {
|
|
1325
|
+
throw new WERR_errors_1.WERR_INVALID_PARAMETER('args.partial.inputBEEF', 'undefined. Transactions may not be found by inputBEEF value.');
|
|
1326
|
+
}
|
|
1878
1327
|
const stores = ['transactions'];
|
|
1879
|
-
if (labelIds && labelIds.length > 0)
|
|
1328
|
+
if (labelIds != null && labelIds.length > 0)
|
|
1880
1329
|
stores.push('tx_labels_map');
|
|
1881
|
-
}
|
|
1882
1330
|
const dbTrx = this.toDbTrx(stores, 'readonly', args.trx);
|
|
1883
1331
|
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
|
-
}
|
|
1332
|
+
const store = dbTrx.objectStore('transactions');
|
|
1333
|
+
const cursor = await this.openTransactionsCursor(store, args.partial, direction);
|
|
1334
|
+
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) => {
|
|
1335
|
+
if (args.from != null && r.created_at.getTime() < args.from.getTime())
|
|
1336
|
+
return false;
|
|
1337
|
+
if (args.to != null && r.created_at.getTime() >= args.to.getTime())
|
|
1338
|
+
return false;
|
|
1339
|
+
if (args.status != null && !args.status.includes(r.status))
|
|
1340
|
+
return false;
|
|
1341
|
+
if (!(0, idbHelpers_1.matchesTransactionPartial)(r, args.partial))
|
|
1342
|
+
return false;
|
|
1343
|
+
if (labelIds != null && labelIds.length > 0 && !await this.transactionMatchesLabels(r.transactionId, labelIds, isQueryModeAll, dbTrx))
|
|
1344
|
+
return false;
|
|
1345
|
+
return true;
|
|
1346
|
+
}, filtered);
|
|
1347
|
+
if (args.trx == null)
|
|
1348
|
+
await dbTrx.done;
|
|
1349
|
+
}
|
|
1350
|
+
async transactionMatchesLabels(transactionId, labelIds, isQueryModeAll, dbTrx) {
|
|
1351
|
+
let ids = [...labelIds];
|
|
1352
|
+
await this.filterTxLabelMaps({ partial: { transactionId }, trx: dbTrx }, lm => {
|
|
1353
|
+
if (ids.length > 0) {
|
|
1354
|
+
const i = ids.indexOf(lm.txLabelId);
|
|
1355
|
+
if (i >= 0) {
|
|
1356
|
+
if (isQueryModeAll) {
|
|
1357
|
+
ids.splice(i, 1);
|
|
1971
1358
|
}
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
if (skipped < offset) {
|
|
1977
|
-
skipped++;
|
|
1978
|
-
continue;
|
|
1359
|
+
else {
|
|
1360
|
+
ids = [];
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1979
1363
|
}
|
|
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;
|
|
1364
|
+
});
|
|
1365
|
+
return ids.length === 0;
|
|
1987
1366
|
}
|
|
1988
1367
|
async findTransactions(args, labelIds, isQueryModeAll) {
|
|
1989
1368
|
const results = [];
|
|
@@ -1991,75 +1370,36 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
1991
1370
|
results.push(this.validateEntity(r));
|
|
1992
1371
|
}, labelIds, isQueryModeAll);
|
|
1993
1372
|
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
|
|
1373
|
+
if (args.noRawTx) {
|
|
2000
1374
|
t.rawTx = undefined;
|
|
1375
|
+
t.inputBEEF = undefined;
|
|
1376
|
+
}
|
|
1377
|
+
else {
|
|
1378
|
+
await this.validateRawTransaction(t, args.trx);
|
|
1379
|
+
}
|
|
2001
1380
|
}
|
|
2002
1381
|
return results;
|
|
2003
1382
|
}
|
|
2004
1383
|
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;
|
|
1384
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2010
1385
|
const dbTrx = this.toDbTrx(['tx_labels'], 'readonly', args.trx);
|
|
1386
|
+
const store = dbTrx.objectStore('tx_labels');
|
|
1387
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2011
1388
|
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
|
-
}
|
|
1389
|
+
if ((_a = args.partial) === null || _a === void 0 ? void 0 : _a.txLabelId) {
|
|
1390
|
+
cursor = await store.openCursor(args.partial.txLabelId);
|
|
1391
|
+
}
|
|
1392
|
+
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) {
|
|
1393
|
+
cursor = await store.index('label_userId').openCursor([args.partial.label, args.partial.userId]);
|
|
1394
|
+
}
|
|
1395
|
+
else if (((_d = args.partial) === null || _d === void 0 ? void 0 : _d.userId) !== undefined) {
|
|
1396
|
+
cursor = await store.index('userId').openCursor(args.partial.userId);
|
|
2025
1397
|
}
|
|
2026
1398
|
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;
|
|
1399
|
+
cursor = await store.openCursor();
|
|
2061
1400
|
}
|
|
2062
|
-
|
|
1401
|
+
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);
|
|
1402
|
+
if (args.trx == null)
|
|
2063
1403
|
await dbTrx.done;
|
|
2064
1404
|
}
|
|
2065
1405
|
async findTxLabels(args) {
|
|
@@ -2069,46 +1409,27 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
2069
1409
|
});
|
|
2070
1410
|
return result;
|
|
2071
1411
|
}
|
|
1412
|
+
matchesUserPartial(r, partial) {
|
|
1413
|
+
if (!partial)
|
|
1414
|
+
return true;
|
|
1415
|
+
if (partial.userId && r.userId !== partial.userId)
|
|
1416
|
+
return false;
|
|
1417
|
+
if ((partial.created_at != null) && r.created_at.getTime() !== partial.created_at.getTime())
|
|
1418
|
+
return false;
|
|
1419
|
+
if ((partial.updated_at != null) && r.updated_at.getTime() !== partial.updated_at.getTime())
|
|
1420
|
+
return false;
|
|
1421
|
+
if (partial.identityKey && r.identityKey !== partial.identityKey)
|
|
1422
|
+
return false;
|
|
1423
|
+
if (partial.activeStorage && r.activeStorage !== partial.activeStorage)
|
|
1424
|
+
return false;
|
|
1425
|
+
return true;
|
|
1426
|
+
}
|
|
2072
1427
|
async filterUsers(args, filtered) {
|
|
2073
1428
|
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
1429
|
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)
|
|
1430
|
+
const cursor = await dbTrx.objectStore('users').openCursor();
|
|
1431
|
+
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);
|
|
1432
|
+
if (args.trx == null)
|
|
2112
1433
|
await dbTrx.done;
|
|
2113
1434
|
}
|
|
2114
1435
|
async findUsers(args) {
|
|
@@ -2248,9 +1569,8 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
2248
1569
|
return results;
|
|
2249
1570
|
}
|
|
2250
1571
|
async verifyReadyForDatabaseAccess(trx) {
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
}
|
|
1572
|
+
var _a;
|
|
1573
|
+
(_a = this._settings) !== null && _a !== void 0 ? _a : (this._settings = await this.readSettings());
|
|
2254
1574
|
return this._settings.dbtype;
|
|
2255
1575
|
}
|
|
2256
1576
|
/**
|
|
@@ -2260,18 +1580,30 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
2260
1580
|
validateEntity(entity, dateFields, booleanFields) {
|
|
2261
1581
|
entity.created_at = this.validateDate(entity.created_at);
|
|
2262
1582
|
entity.updated_at = this.validateDate(entity.updated_at);
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
1583
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1584
|
+
const e = entity;
|
|
1585
|
+
this.applyDateFields(e, dateFields);
|
|
1586
|
+
this.applyBooleanFields(e, booleanFields);
|
|
1587
|
+
this.normalizeEntityValues(e);
|
|
1588
|
+
return entity;
|
|
1589
|
+
}
|
|
1590
|
+
applyDateFields(entity, dateFields) {
|
|
1591
|
+
if (dateFields == null)
|
|
1592
|
+
return;
|
|
1593
|
+
for (const df of dateFields) {
|
|
1594
|
+
if (entity[df])
|
|
1595
|
+
entity[df] = this.validateDate(entity[df]);
|
|
2268
1596
|
}
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
1597
|
+
}
|
|
1598
|
+
applyBooleanFields(entity, booleanFields) {
|
|
1599
|
+
if (booleanFields == null)
|
|
1600
|
+
return;
|
|
1601
|
+
for (const df of booleanFields) {
|
|
1602
|
+
if (entity[df] !== undefined)
|
|
1603
|
+
entity[df] = Boolean(entity[df]);
|
|
2274
1604
|
}
|
|
1605
|
+
}
|
|
1606
|
+
normalizeEntityValues(entity) {
|
|
2275
1607
|
for (const key of Object.keys(entity)) {
|
|
2276
1608
|
const val = entity[key];
|
|
2277
1609
|
if (val === null) {
|
|
@@ -2281,7 +1613,6 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
2281
1613
|
entity[key] = Array.from(val);
|
|
2282
1614
|
}
|
|
2283
1615
|
}
|
|
2284
|
-
return entity;
|
|
2285
1616
|
}
|
|
2286
1617
|
/**
|
|
2287
1618
|
* Helper to force uniform behavior across database engines.
|
|
@@ -2302,26 +1633,35 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
2302
1633
|
if (!this.dbtype)
|
|
2303
1634
|
throw new WERR_errors_1.WERR_INTERNAL('must call verifyReadyForDatabaseAccess first');
|
|
2304
1635
|
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);
|
|
1636
|
+
v.created_at = v.created_at ? this.validateEntityDate(v.created_at) : undefined;
|
|
2309
1637
|
if (!v.created_at)
|
|
2310
1638
|
delete v.created_at;
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
1639
|
+
v.updated_at = v.updated_at ? this.validateEntityDate(v.updated_at) : this.validateEntityDate(new Date());
|
|
1640
|
+
this.applyOptionalDateFields(v, dateFields);
|
|
1641
|
+
this.applyIntegerBooleanFields(update, booleanFields);
|
|
1642
|
+
this.normalizeForStorage(v);
|
|
1643
|
+
this.isDirty = true;
|
|
1644
|
+
return v;
|
|
1645
|
+
}
|
|
1646
|
+
applyOptionalDateFields(v, dateFields) {
|
|
1647
|
+
if (dateFields == null)
|
|
1648
|
+
return;
|
|
1649
|
+
for (const df of dateFields) {
|
|
1650
|
+
if (v[df])
|
|
1651
|
+
v[df] = this.validateOptionalEntityDate(v[df]);
|
|
2318
1652
|
}
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
1653
|
+
}
|
|
1654
|
+
applyIntegerBooleanFields(update, booleanFields) {
|
|
1655
|
+
if (booleanFields == null)
|
|
1656
|
+
return;
|
|
1657
|
+
for (const df of booleanFields) {
|
|
1658
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1659
|
+
const u = update;
|
|
1660
|
+
if (u[df] !== undefined)
|
|
1661
|
+
u[df] = u[df] ? 1 : 0;
|
|
2324
1662
|
}
|
|
1663
|
+
}
|
|
1664
|
+
normalizeForStorage(v) {
|
|
2325
1665
|
for (const key of Object.keys(v)) {
|
|
2326
1666
|
const val = v[key];
|
|
2327
1667
|
if (Array.isArray(val) && (val.length === 0 || Number.isInteger(val[0]))) {
|
|
@@ -2331,8 +1671,6 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
2331
1671
|
v[key] = undefined;
|
|
2332
1672
|
}
|
|
2333
1673
|
}
|
|
2334
|
-
this.isDirty = true;
|
|
2335
|
-
return v;
|
|
2336
1674
|
}
|
|
2337
1675
|
/**
|
|
2338
1676
|
* Helper to force uniform behavior across database engines.
|
|
@@ -2347,27 +1685,9 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
2347
1685
|
delete v.created_at;
|
|
2348
1686
|
if (!v.updated_at)
|
|
2349
1687
|
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
|
-
}
|
|
1688
|
+
this.applyOptionalDateFields(v, dateFields);
|
|
1689
|
+
this.applyIntegerBooleanFields(entity, booleanFields);
|
|
1690
|
+
this.normalizeForStorage(v);
|
|
2371
1691
|
this.isDirty = true;
|
|
2372
1692
|
return v;
|
|
2373
1693
|
}
|
|
@@ -2377,7 +1697,7 @@ class StorageIdb extends StorageProvider_1.StorageProvider {
|
|
|
2377
1697
|
return;
|
|
2378
1698
|
// rawTransaction is missing, see if we moved it ...
|
|
2379
1699
|
const rawTx = await this.getRawTxOfKnownValidTransaction(t.txid, undefined, undefined, trx);
|
|
2380
|
-
if (
|
|
1700
|
+
if (rawTx == null)
|
|
2381
1701
|
return;
|
|
2382
1702
|
t.rawTx = rawTx;
|
|
2383
1703
|
}
|