@bsv/wallet-toolbox 1.1.59 → 1.1.61
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/.prettierrc +1 -1
- package/docs/client.md +39 -5
- package/docs/services.md +1 -0
- package/docs/setup.md +9 -26
- package/docs/storage.md +35 -0
- package/docs/wallet.md +39 -5
- package/out/src/Setup.d.ts.map +1 -1
- package/out/src/Setup.js +6 -16
- package/out/src/Setup.js.map +1 -1
- package/out/src/Wallet.d.ts.map +1 -1
- package/out/src/Wallet.js +4 -11
- package/out/src/Wallet.js.map +1 -1
- package/out/src/monitor/Monitor.d.ts.map +1 -1
- package/out/src/monitor/Monitor.js.map +1 -1
- package/out/src/monitor/MonitorDaemon.d.ts.map +1 -1
- package/out/src/monitor/MonitorDaemon.js +1 -3
- package/out/src/monitor/MonitorDaemon.js.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskCheckForProofs.js +2 -10
- package/out/src/monitor/tasks/TaskCheckForProofs.js.map +1 -1
- package/out/src/monitor/tasks/TaskClock.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskClock.js +1 -1
- package/out/src/monitor/tasks/TaskClock.js.map +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/TaskNewHeader.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskNewHeader.js +1 -2
- package/out/src/monitor/tasks/TaskNewHeader.js.map +1 -1
- package/out/src/monitor/tasks/TaskPurge.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskPurge.js +1 -2
- package/out/src/monitor/tasks/TaskPurge.js.map +1 -1
- package/out/src/monitor/tasks/TaskReviewStatus.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskReviewStatus.js +1 -2
- package/out/src/monitor/tasks/TaskReviewStatus.js.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.d.ts.map +1 -1
- package/out/src/monitor/tasks/TaskSendWaiting.js.map +1 -1
- package/out/src/sdk/CertOps.d.ts.map +1 -1
- package/out/src/sdk/CertOps.js +4 -12
- package/out/src/sdk/CertOps.js.map +1 -1
- package/out/src/sdk/PrivilegedKeyManager.d.ts.map +1 -1
- 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.map +1 -1
- package/out/src/sdk/WalletError.d.ts.map +1 -1
- package/out/src/sdk/WalletError.js +1 -4
- package/out/src/sdk/WalletError.js.map +1 -1
- package/out/src/sdk/WalletServices.interfaces.d.ts +2 -0
- package/out/src/sdk/WalletServices.interfaces.d.ts.map +1 -1
- package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
- package/out/src/sdk/__test/CertificateLifeCycle.test.js +1 -3
- package/out/src/sdk/__test/CertificateLifeCycle.test.js.map +1 -1
- package/out/src/sdk/__test/PrivilegedKeyManager.test.js +13 -26
- package/out/src/sdk/__test/PrivilegedKeyManager.test.js.map +1 -1
- package/out/src/sdk/types.d.ts.map +1 -1
- package/out/src/sdk/types.js +2 -10
- package/out/src/sdk/types.js.map +1 -1
- package/out/src/sdk/validationHelpers.d.ts.map +1 -1
- package/out/src/sdk/validationHelpers.js +5 -12
- package/out/src/sdk/validationHelpers.js.map +1 -1
- package/out/src/services/Services.d.ts +1 -0
- package/out/src/services/Services.d.ts.map +1 -1
- package/out/src/services/Services.js +29 -38
- package/out/src/services/Services.js.map +1 -1
- package/out/src/services/__tests/bitrails.test.js.map +1 -1
- package/out/src/services/__tests/getMerklePath.test.js.map +1 -1
- package/out/src/services/__tests/getRawTx.test.js.map +1 -1
- package/out/src/services/__tests/verifyBeef.test.js +2 -1
- package/out/src/services/__tests/verifyBeef.test.js.map +1 -1
- package/out/src/services/chaintracker/ChaintracksChainTracker.d.ts.map +1 -1
- package/out/src/services/chaintracker/ChaintracksChainTracker.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/BlockHeaderApi.js.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.d.ts.map +1 -1
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js +1 -3
- package/out/src/services/chaintracker/chaintracks/ChaintracksServiceClient.js.map +1 -1
- package/out/src/services/createDefaultWalletServicesOptions.d.ts.map +1 -1
- 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 +1 -2
- package/out/src/services/providers/ARC.js.map +1 -1
- package/out/src/services/providers/Bitails.d.ts.map +1 -1
- package/out/src/services/providers/Bitails.js +62 -134
- 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.map +1 -1
- package/out/src/services/providers/WhatsOnChain.js +6 -21
- package/out/src/services/providers/WhatsOnChain.js.map +1 -1
- package/out/src/services/providers/__tests/WhatsOnChain.test.js +1 -2
- package/out/src/services/providers/__tests/WhatsOnChain.test.js.map +1 -1
- package/out/src/services/providers/echangeRates.d.ts.map +1 -1
- package/out/src/services/providers/echangeRates.js.map +1 -1
- 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.d.ts.map +1 -1
- package/out/src/signer/methods/acquireDirectCertificate.js +1 -3
- 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 +3 -11
- package/out/src/signer/methods/buildSignableTransaction.js.map +1 -1
- package/out/src/signer/methods/createAction.d.ts.map +1 -1
- package/out/src/signer/methods/createAction.js +3 -10
- 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.map +1 -1
- package/out/src/signer/methods/proveCertificate.d.ts.map +1 -1
- package/out/src/signer/methods/proveCertificate.js.map +1 -1
- package/out/src/signer/methods/signAction.d.ts.map +1 -1
- package/out/src/signer/methods/signAction.js +2 -7
- package/out/src/signer/methods/signAction.js.map +1 -1
- package/out/src/storage/StorageKnex.d.ts.map +1 -1
- package/out/src/storage/StorageKnex.js +15 -44
- package/out/src/storage/StorageKnex.js.map +1 -1
- package/out/src/storage/StorageProvider.d.ts.map +1 -1
- package/out/src/storage/StorageProvider.js +9 -34
- 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.map +1 -1
- package/out/src/storage/StorageReaderWriter.d.ts.map +1 -1
- package/out/src/storage/StorageReaderWriter.js.map +1 -1
- package/out/src/storage/StorageSyncReader.d.ts.map +1 -1
- package/out/src/storage/StorageSyncReader.js.map +1 -1
- package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
- package/out/src/storage/WalletStorageManager.js +5 -10
- package/out/src/storage/WalletStorageManager.js.map +1 -1
- package/out/src/storage/__test/WalletStorageManager.test.js +2 -8
- package/out/src/storage/__test/WalletStorageManager.test.js.map +1 -1
- package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.js +10 -30
- package/out/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.js.map +1 -1
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.d.ts.map +1 -1
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.js +17 -28
- package/out/src/storage/methods/__test/GenerateChange/randomValsUsed1.js.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.d.ts.map +1 -1
- package/out/src/storage/methods/attemptToPostReqsToNetwork.js +6 -20
- 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 +4 -9
- 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 +7 -18
- package/out/src/storage/methods/generateChange.js.map +1 -1
- package/out/src/storage/methods/getBeefForTransaction.d.ts.map +1 -1
- package/out/src/storage/methods/getBeefForTransaction.js +1 -3
- package/out/src/storage/methods/getBeefForTransaction.js.map +1 -1
- package/out/src/storage/methods/getSyncChunk.d.ts.map +1 -1
- package/out/src/storage/methods/getSyncChunk.js.map +1 -1
- package/out/src/storage/methods/internalizeAction.d.ts.map +1 -1
- package/out/src/storage/methods/internalizeAction.js +2 -9
- package/out/src/storage/methods/internalizeAction.js.map +1 -1
- package/out/src/storage/methods/listActions.d.ts.map +1 -1
- package/out/src/storage/methods/listActions.js +3 -15
- package/out/src/storage/methods/listActions.js.map +1 -1
- package/out/src/storage/methods/listCertificates.d.ts.map +1 -1
- package/out/src/storage/methods/listCertificates.js.map +1 -1
- package/out/src/storage/methods/listOutputs.d.ts.map +1 -1
- package/out/src/storage/methods/listOutputs.js +4 -11
- package/out/src/storage/methods/listOutputs.js.map +1 -1
- package/out/src/storage/methods/processAction.d.ts.map +1 -1
- package/out/src/storage/methods/processAction.js +4 -10
- package/out/src/storage/methods/processAction.js.map +1 -1
- package/out/src/storage/methods/purgeData.d.ts.map +1 -1
- package/out/src/storage/methods/purgeData.js +8 -32
- package/out/src/storage/methods/purgeData.js.map +1 -1
- package/out/src/storage/methods/reviewStatus.d.ts.map +1 -1
- package/out/src/storage/methods/reviewStatus.js +1 -3
- package/out/src/storage/methods/reviewStatus.js.map +1 -1
- package/out/src/storage/remoting/StorageClient.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageClient.js +15 -41
- package/out/src/storage/remoting/StorageClient.js.map +1 -1
- package/out/src/storage/remoting/StorageServer.d.ts.map +1 -1
- package/out/src/storage/remoting/StorageServer.js +2 -5
- package/out/src/storage/remoting/StorageServer.js.map +1 -1
- package/out/src/storage/schema/KnexMigrations.d.ts.map +1 -1
- package/out/src/storage/schema/KnexMigrations.js +24 -130
- package/out/src/storage/schema/KnexMigrations.js.map +1 -1
- package/out/src/storage/schema/entities/Certificate.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Certificate.js +1 -1
- package/out/src/storage/schema/entities/Certificate.js.map +1 -1
- package/out/src/storage/schema/entities/CertificateField.d.ts.map +1 -1
- package/out/src/storage/schema/entities/CertificateField.js +2 -5
- package/out/src/storage/schema/entities/CertificateField.js.map +1 -1
- package/out/src/storage/schema/entities/Commission.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Commission.js +2 -5
- package/out/src/storage/schema/entities/Commission.js.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/MergeEntity.d.ts.map +1 -1
- package/out/src/storage/schema/entities/MergeEntity.js +14 -9
- package/out/src/storage/schema/entities/MergeEntity.js.map +1 -1
- package/out/src/storage/schema/entities/Output.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Output.js +8 -25
- package/out/src/storage/schema/entities/Output.js.map +1 -1
- package/out/src/storage/schema/entities/OutputBasket.d.ts.map +1 -1
- package/out/src/storage/schema/entities/OutputBasket.js +1 -1
- package/out/src/storage/schema/entities/OutputBasket.js.map +1 -1
- package/out/src/storage/schema/entities/OutputTag.d.ts.map +1 -1
- package/out/src/storage/schema/entities/OutputTag.js +1 -1
- package/out/src/storage/schema/entities/OutputTag.js.map +1 -1
- package/out/src/storage/schema/entities/OutputTagMap.d.ts.map +1 -1
- package/out/src/storage/schema/entities/OutputTagMap.js +3 -7
- package/out/src/storage/schema/entities/OutputTagMap.js.map +1 -1
- package/out/src/storage/schema/entities/ProvenTx.d.ts.map +1 -1
- package/out/src/storage/schema/entities/ProvenTx.js +10 -20
- package/out/src/storage/schema/entities/ProvenTx.js.map +1 -1
- package/out/src/storage/schema/entities/ProvenTxReq.d.ts.map +1 -1
- package/out/src/storage/schema/entities/ProvenTxReq.js +8 -18
- package/out/src/storage/schema/entities/ProvenTxReq.js.map +1 -1
- package/out/src/storage/schema/entities/SyncState.d.ts +1 -0
- package/out/src/storage/schema/entities/SyncState.d.ts.map +1 -1
- package/out/src/storage/schema/entities/SyncState.js +41 -6
- package/out/src/storage/schema/entities/SyncState.js.map +1 -1
- package/out/src/storage/schema/entities/Transaction.d.ts.map +1 -1
- package/out/src/storage/schema/entities/Transaction.js +4 -13
- package/out/src/storage/schema/entities/Transaction.js.map +1 -1
- package/out/src/storage/schema/entities/TxLabel.d.ts.map +1 -1
- package/out/src/storage/schema/entities/TxLabel.js +1 -1
- package/out/src/storage/schema/entities/TxLabel.js.map +1 -1
- package/out/src/storage/schema/entities/TxLabelMap.d.ts.map +1 -1
- package/out/src/storage/schema/entities/TxLabelMap.js +3 -9
- package/out/src/storage/schema/entities/TxLabelMap.js.map +1 -1
- package/out/src/storage/schema/entities/User.d.ts.map +1 -1
- package/out/src/storage/schema/entities/User.js +3 -5
- package/out/src/storage/schema/entities/User.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/CertificateFieldTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/CertificateTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/CommissionTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputBasketTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputTagMapTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputTagTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/OutputTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/ProvenTxReqTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js +1 -2
- package/out/src/storage/schema/entities/__tests/ProvenTxTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/SyncStateTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/TransactionTests.test.js +2 -2
- package/out/src/storage/schema/entities/__tests/TransactionTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/TxLabelMapTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/TxLabelTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/stampLogTests.test.js.map +1 -1
- package/out/src/storage/schema/entities/__tests/usersTests.test.js.map +1 -1
- package/out/src/storage/schema/tables/TableSettings.d.ts.map +1 -1
- package/out/src/storage/sync/StorageMySQLDojoReader.d.ts.map +1 -1
- package/out/src/storage/sync/StorageMySQLDojoReader.js +1 -3
- package/out/src/storage/sync/StorageMySQLDojoReader.js.map +1 -1
- package/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -1
- package/out/src/utility/ScriptTemplateBRC29.js +1 -2
- package/out/src/utility/ScriptTemplateBRC29.js.map +1 -1
- package/out/src/utility/stampLog.d.ts.map +1 -1
- 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.map +1 -1
- package/out/src/utility/utilityHelpers.buffer.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.buffer.js.map +1 -1
- package/out/src/utility/utilityHelpers.d.ts.map +1 -1
- package/out/src/utility/utilityHelpers.js +1 -3
- package/out/src/utility/utilityHelpers.js.map +1 -1
- package/out/test/Wallet/StorageClient/storageClient.man.test.js.map +1 -1
- package/out/test/Wallet/action/internalizeAction.a.test.js.map +1 -1
- package/out/test/Wallet/certificate/acquireCertificate.test.js.map +1 -1
- package/out/test/Wallet/certificate/listCertificates.test.js.map +1 -1
- package/out/test/Wallet/get/getHeaderForHeight.test.js +2 -6
- package/out/test/Wallet/get/getHeaderForHeight.test.js.map +1 -1
- package/out/test/Wallet/get/getHeight.test.js.map +1 -1
- package/out/test/Wallet/get/getKnownTxids.test.js.map +1 -1
- package/out/test/Wallet/get/getNetwork.test.js.map +1 -1
- package/out/test/Wallet/get/getVersion.test.js.map +1 -1
- package/out/test/Wallet/live/walletLive.man.test.d.ts.map +1 -1
- package/out/test/Wallet/live/walletLive.man.test.js +3 -9
- package/out/test/Wallet/live/walletLive.man.test.js.map +1 -1
- package/out/test/Wallet/local/localWallet.man.test.d.ts.map +1 -1
- package/out/test/Wallet/local/localWallet.man.test.js +15 -22
- package/out/test/Wallet/local/localWallet.man.test.js.map +1 -1
- package/out/test/Wallet/specOps/specOps.man.test.js +1 -4
- package/out/test/Wallet/specOps/specOps.man.test.js.map +1 -1
- package/out/test/Wallet/support/janitor.man.test.js.map +1 -1
- package/out/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.js.map +1 -1
- package/out/test/Wallet/sync/setActive.test.js +73 -50
- package/out/test/Wallet/sync/setActive.test.js.map +1 -1
- package/out/test/checkDB.d.ts.map +1 -1
- package/out/test/checkDB.js.map +1 -1
- package/out/test/examples/backup.man.test.d.ts.map +1 -1
- package/out/test/examples/backup.man.test.js.map +1 -1
- package/out/test/examples/pushdrop.test.d.ts.map +1 -1
- package/out/test/examples/pushdrop.test.js +5 -4
- package/out/test/examples/pushdrop.test.js.map +1 -1
- package/out/test/monitor/Monitor.test.js.map +1 -1
- package/out/test/services/Services.test.js.map +1 -1
- package/out/test/storage/KnexMigrations.test.js.map +1 -1
- package/out/test/storage/StorageMySQLDojoReader.man.test.js +1 -3
- package/out/test/storage/StorageMySQLDojoReader.man.test.js.map +1 -1
- package/out/test/storage/count.test.js.map +1 -1
- package/out/test/storage/find.test.js +5 -10
- package/out/test/storage/find.test.js.map +1 -1
- package/out/test/storage/findLegacy.test.js.map +1 -1
- package/out/test/storage/insert.test.js.map +1 -1
- package/out/test/storage/update.test.js +7 -19
- package/out/test/storage/update.test.js.map +1 -1
- package/out/test/storage/update2.test.js +22 -24
- package/out/test/storage/update2.test.js.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.d.ts +3 -1
- package/out/test/utils/TestUtilsWalletStorage.d.ts.map +1 -1
- package/out/test/utils/TestUtilsWalletStorage.js +52 -76
- package/out/test/utils/TestUtilsWalletStorage.js.map +1 -1
- package/out/test/wallet/action/abortAction.test.d.ts.map +1 -0
- package/out/test/wallet/action/abortAction.test.js.map +1 -0
- package/out/test/wallet/action/createAction.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/action/createAction.test.js +1 -2
- package/out/test/wallet/action/createAction.test.js.map +1 -0
- package/out/test/{Wallet → wallet}/action/createAction2.test.d.ts.map +1 -1
- package/out/test/{Wallet → wallet}/action/createAction2.test.js +6 -16
- package/out/test/wallet/action/createAction2.test.js.map +1 -0
- package/out/test/wallet/action/createActionToGenerateBeefs.man.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/action/createActionToGenerateBeefs.man.test.js.map +1 -1
- package/out/test/wallet/action/internalizeAction.test.d.ts.map +1 -0
- package/out/test/wallet/action/internalizeAction.test.js.map +1 -0
- package/out/test/wallet/action/relinquishOutput.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/action/relinquishOutput.test.js.map +1 -1
- package/out/test/wallet/construct/Wallet.constructor.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/construct/Wallet.constructor.test.js.map +1 -1
- package/out/test/wallet/list/listActions.test.d.ts.map +1 -0
- package/out/test/wallet/list/listActions.test.js.map +1 -0
- package/out/test/wallet/list/listActions2.test.d.ts.map +1 -0
- package/out/test/wallet/list/listActions2.test.js.map +1 -0
- package/out/test/wallet/list/listCertificates.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/list/listCertificates.test.js +2 -6
- package/out/test/wallet/list/listCertificates.test.js.map +1 -0
- package/out/test/wallet/list/listOutputs.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/list/listOutputs.test.js +2 -10
- package/out/test/wallet/list/listOutputs.test.js.map +1 -0
- package/out/test/wallet/sync/Wallet.sync.test.d.ts.map +1 -0
- package/out/test/{Wallet → wallet}/sync/Wallet.sync.test.js +4 -6
- package/out/test/wallet/sync/Wallet.sync.test.js.map +1 -0
- package/out/tsconfig.all.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/Setup.ts +15 -52
- package/src/Wallet.ts +58 -161
- package/src/monitor/Monitor.ts +7 -22
- package/src/monitor/MonitorDaemon.ts +6 -23
- package/src/monitor/tasks/TaskCheckForProofs.ts +4 -23
- package/src/monitor/tasks/TaskClock.ts +1 -3
- package/src/monitor/tasks/TaskFailAbandoned.ts +1 -3
- package/src/monitor/tasks/TaskNewHeader.ts +1 -4
- package/src/monitor/tasks/TaskPurge.ts +1 -2
- package/src/monitor/tasks/TaskReviewStatus.ts +1 -3
- package/src/monitor/tasks/TaskSendWaiting.ts +3 -10
- package/src/sdk/CertOps.ts +31 -103
- package/src/sdk/PrivilegedKeyManager.ts +18 -48
- package/src/sdk/WERR_errors.ts +6 -25
- package/src/sdk/WalletError.ts +5 -21
- package/src/sdk/WalletServices.interfaces.ts +11 -33
- package/src/sdk/WalletStorage.interfaces.ts +25 -91
- package/src/sdk/__test/CertificateLifeCycle.test.ts +9 -27
- package/src/sdk/__test/PrivilegedKeyManager.test.ts +29 -66
- package/src/sdk/types.ts +6 -26
- package/src/sdk/validationHelpers.ts +111 -402
- package/src/services/Services.ts +51 -114
- package/src/services/__tests/bitrails.test.ts +4 -15
- package/src/services/__tests/getMerklePath.test.ts +1 -2
- package/src/services/__tests/getRawTx.test.ts +1 -3
- package/src/services/__tests/verifyBeef.test.ts +2 -1
- package/src/services/chaintracker/ChaintracksChainTracker.ts +3 -13
- package/src/services/chaintracker/chaintracks/BlockHeaderApi.ts +4 -12
- package/src/services/chaintracker/chaintracks/ChaintracksServiceClient.ts +9 -27
- package/src/services/createDefaultWalletServicesOptions.ts +2 -5
- package/src/services/providers/ARC.ts +5 -24
- package/src/services/providers/Bitails.ts +61 -159
- package/src/services/providers/SdkWhatsOnChain.ts +4 -17
- package/src/services/providers/WhatsOnChain.ts +31 -100
- package/src/services/providers/__tests/WhatsOnChain.test.ts +5 -15
- package/src/services/providers/echangeRates.ts +7 -22
- package/src/signer/WalletSigner.ts +1 -5
- package/src/signer/methods/acquireDirectCertificate.ts +1 -4
- package/src/signer/methods/buildSignableTransaction.ts +5 -20
- package/src/signer/methods/createAction.ts +15 -54
- package/src/signer/methods/internalizeAction.ts +10 -39
- package/src/signer/methods/proveCertificate.ts +2 -5
- package/src/signer/methods/signAction.ts +9 -39
- package/src/storage/StorageKnex.ts +166 -499
- package/src/storage/StorageProvider.ts +75 -291
- package/src/storage/StorageReader.ts +20 -65
- package/src/storage/StorageReaderWriter.ts +67 -264
- package/src/storage/StorageSyncReader.ts +2 -5
- package/src/storage/WalletStorageManager.ts +33 -108
- package/src/storage/__test/WalletStorageManager.test.ts +6 -23
- package/src/storage/methods/__test/GenerateChange/generateChangeSdk.test.ts +53 -171
- package/src/storage/methods/__test/GenerateChange/randomValsUsed1.ts +17 -28
- package/src/storage/methods/attemptToPostReqsToNetwork.ts +9 -37
- package/src/storage/methods/createAction.ts +45 -181
- package/src/storage/methods/generateChange.ts +33 -114
- package/src/storage/methods/getBeefForTransaction.ts +7 -37
- package/src/storage/methods/getSyncChunk.ts +18 -69
- package/src/storage/methods/internalizeAction.ts +18 -70
- package/src/storage/methods/listActions.ts +6 -23
- package/src/storage/methods/listCertificates.ts +5 -14
- package/src/storage/methods/listOutputs.ts +14 -68
- package/src/storage/methods/processAction.ts +29 -104
- package/src/storage/methods/purgeData.ts +11 -45
- package/src/storage/methods/reviewStatus.ts +3 -9
- package/src/storage/remoting/StorageClient.ts +43 -146
- package/src/storage/remoting/StorageServer.ts +21 -59
- package/src/storage/schema/KnexMigrations.ts +34 -165
- package/src/storage/schema/entities/Certificate.ts +3 -14
- package/src/storage/schema/entities/CertificateField.ts +6 -28
- package/src/storage/schema/entities/Commission.ts +6 -23
- package/src/storage/schema/entities/EntityBase.ts +1 -6
- package/src/storage/schema/entities/MergeEntity.ts +14 -21
- package/src/storage/schema/entities/Output.ts +10 -39
- package/src/storage/schema/entities/OutputBasket.ts +4 -16
- package/src/storage/schema/entities/OutputTag.ts +4 -17
- package/src/storage/schema/entities/OutputTagMap.ts +7 -30
- package/src/storage/schema/entities/ProvenTx.ts +16 -57
- package/src/storage/schema/entities/ProvenTxReq.ts +29 -93
- package/src/storage/schema/entities/SyncState.ts +64 -116
- package/src/storage/schema/entities/Transaction.ts +10 -35
- package/src/storage/schema/entities/TxLabel.ts +4 -17
- package/src/storage/schema/entities/TxLabelMap.ts +6 -28
- package/src/storage/schema/entities/User.ts +8 -31
- package/src/storage/schema/entities/__tests/CertificateFieldTests.test.ts +23 -54
- package/src/storage/schema/entities/__tests/CertificateTests.test.ts +26 -59
- package/src/storage/schema/entities/__tests/CommissionTests.test.ts +2 -11
- package/src/storage/schema/entities/__tests/OutputBasketTests.test.ts +2 -10
- package/src/storage/schema/entities/__tests/OutputTagMapTests.test.ts +2 -10
- package/src/storage/schema/entities/__tests/OutputTagTests.test.ts +1 -4
- package/src/storage/schema/entities/__tests/OutputTests.test.ts +3 -14
- package/src/storage/schema/entities/__tests/ProvenTxReqTests.test.ts +4 -16
- package/src/storage/schema/entities/__tests/ProvenTxTests.test.ts +5 -18
- package/src/storage/schema/entities/__tests/SyncStateTests.test.ts +5 -26
- package/src/storage/schema/entities/__tests/TransactionTests.test.ts +12 -48
- package/src/storage/schema/entities/__tests/TxLabelMapTests.test.ts +4 -22
- package/src/storage/schema/entities/__tests/TxLabelTests.test.ts +2 -10
- package/src/storage/schema/entities/__tests/stampLogTests.test.ts +3 -10
- package/src/storage/schema/entities/__tests/usersTests.test.ts +4 -7
- package/src/storage/schema/tables/TableSettings.ts +1 -3
- package/src/storage/sync/StorageMySQLDojoReader.ts +47 -148
- package/src/utility/ScriptTemplateBRC29.ts +2 -11
- package/src/utility/stampLog.ts +2 -6
- package/src/utility/tscProofToMerklePath.ts +1 -4
- package/src/utility/utilityHelpers.buffer.ts +3 -12
- package/src/utility/utilityHelpers.ts +14 -49
- package/test/Wallet/StorageClient/storageClient.man.test.ts +2 -8
- package/test/Wallet/action/internalizeAction.a.test.ts +8 -23
- package/test/Wallet/certificate/acquireCertificate.test.ts +10 -24
- package/test/Wallet/certificate/listCertificates.test.ts +8 -18
- package/test/Wallet/get/getHeaderForHeight.test.ts +4 -15
- package/test/Wallet/get/getHeight.test.ts +2 -6
- package/test/Wallet/get/getKnownTxids.test.ts +1 -5
- package/test/Wallet/get/getNetwork.test.ts +1 -2
- package/test/Wallet/get/getVersion.test.ts +1 -2
- package/test/Wallet/live/walletLive.man.test.ts +14 -41
- package/test/Wallet/local/localWallet.man.test.ts +26 -99
- package/test/Wallet/specOps/specOps.man.test.ts +4 -13
- package/test/Wallet/support/janitor.man.test.ts +2 -7
- package/test/Wallet/sync/Wallet.updateWalletLegacyTestData.man.test.ts +11 -34
- package/test/Wallet/sync/setActive.test.ts +75 -61
- package/test/checkDB.ts +2 -8
- package/test/examples/backup.man.test.ts +2 -9
- package/test/examples/pushdrop.test.ts +7 -20
- package/test/monitor/Monitor.test.ts +33 -87
- package/test/services/Services.test.ts +8 -19
- package/test/storage/KnexMigrations.test.ts +3 -18
- package/test/storage/StorageMySQLDojoReader.man.test.ts +4 -15
- package/test/storage/count.test.ts +7 -24
- package/test/storage/find.test.ts +7 -29
- package/test/storage/findLegacy.test.ts +2 -5
- package/test/storage/insert.test.ts +3 -19
- package/test/storage/update.test.ts +47 -179
- package/test/storage/update2.test.ts +54 -176
- package/test/utils/TestUtilsWalletStorage.ts +139 -372
- package/test/{Wallet → wallet}/action/abortAction.test.ts +4 -12
- package/test/{Wallet → wallet}/action/createAction.test.ts +4 -14
- package/test/{Wallet → wallet}/action/createAction2.test.ts +74 -208
- package/test/{Wallet → wallet}/action/createActionToGenerateBeefs.man.test.ts +8 -11
- package/test/{Wallet → wallet}/action/internalizeAction.test.ts +20 -72
- package/test/{Wallet → wallet}/action/relinquishOutput.test.ts +3 -9
- package/test/{Wallet → wallet}/list/listActions.test.ts +2 -9
- package/test/{Wallet → wallet}/list/listActions2.test.ts +8 -34
- package/test/{Wallet → wallet}/list/listCertificates.test.ts +5 -16
- package/test/{Wallet → wallet}/list/listOutputs.test.ts +15 -54
- package/test/{Wallet → wallet}/sync/Wallet.sync.test.ts +18 -49
- package/out/src/sdk/StorageSyncReader.d.ts +0 -121
- package/out/src/sdk/StorageSyncReader.d.ts.map +0 -1
- package/out/src/sdk/StorageSyncReader.js +0 -3
- package/out/src/sdk/StorageSyncReader.js.map +0 -1
- package/out/src/sdk/StorageSyncReaderWriter.d.ts +0 -89
- package/out/src/sdk/StorageSyncReaderWriter.d.ts.map +0 -1
- package/out/src/sdk/StorageSyncReaderWriter.js +0 -3
- package/out/src/sdk/StorageSyncReaderWriter.js.map +0 -1
- package/out/test/Wallet/action/abortAction.test.d.ts.map +0 -1
- package/out/test/Wallet/action/abortAction.test.js.map +0 -1
- package/out/test/Wallet/action/createAction.test.d.ts.map +0 -1
- package/out/test/Wallet/action/createAction.test.js.map +0 -1
- package/out/test/Wallet/action/createAction2.test.js.map +0 -1
- package/out/test/Wallet/action/createActionToGenerateBeefs.man.test.d.ts.map +0 -1
- package/out/test/Wallet/action/internalizeAction.test.d.ts.map +0 -1
- package/out/test/Wallet/action/internalizeAction.test.js.map +0 -1
- package/out/test/Wallet/action/relinquishOutput.test.d.ts.map +0 -1
- package/out/test/Wallet/construct/Wallet.constructor.test.d.ts.map +0 -1
- package/out/test/Wallet/list/listActions.test.d.ts.map +0 -1
- package/out/test/Wallet/list/listActions.test.js.map +0 -1
- package/out/test/Wallet/list/listActions2.test.d.ts.map +0 -1
- package/out/test/Wallet/list/listActions2.test.js.map +0 -1
- package/out/test/Wallet/list/listCertificates.test.d.ts.map +0 -1
- package/out/test/Wallet/list/listCertificates.test.js.map +0 -1
- package/out/test/Wallet/list/listOutputs.test.d.ts.map +0 -1
- package/out/test/Wallet/list/listOutputs.test.js.map +0 -1
- package/out/test/Wallet/sync/Wallet.sync.test.d.ts.map +0 -1
- package/out/test/Wallet/sync/Wallet.sync.test.js.map +0 -1
- /package/out/test/{Wallet → wallet}/action/abortAction.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/action/abortAction.test.js +0 -0
- /package/out/test/{Wallet → wallet}/action/createAction.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/action/createAction2.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/action/createActionToGenerateBeefs.man.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/action/createActionToGenerateBeefs.man.test.js +0 -0
- /package/out/test/{Wallet → wallet}/action/internalizeAction.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/action/internalizeAction.test.js +0 -0
- /package/out/test/{Wallet → wallet}/action/relinquishOutput.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/action/relinquishOutput.test.js +0 -0
- /package/out/test/{Wallet → wallet}/construct/Wallet.constructor.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/construct/Wallet.constructor.test.js +0 -0
- /package/out/test/{Wallet → wallet}/list/listActions.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/list/listActions.test.js +0 -0
- /package/out/test/{Wallet → wallet}/list/listActions2.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/list/listActions2.test.js +0 -0
- /package/out/test/{Wallet → wallet}/list/listCertificates.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/list/listOutputs.test.d.ts +0 -0
- /package/out/test/{Wallet → wallet}/sync/Wallet.sync.test.d.ts +0 -0
- /package/test/{Wallet → wallet}/construct/Wallet.constructor.test.ts +0 -0
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { MerklePath } from '@bsv/sdk'
|
|
2
|
-
import {
|
|
3
|
-
arraysEqual,
|
|
4
|
-
sdk,
|
|
5
|
-
TableOutputBasket,
|
|
6
|
-
verifyId,
|
|
7
|
-
verifyOneOrNone
|
|
8
|
-
} from '../../../index.client'
|
|
2
|
+
import { arraysEqual, sdk, TableOutputBasket, verifyId, verifyOneOrNone } from '../../../index.client'
|
|
9
3
|
import { EntityBase, EntityStorage, SyncMap } from '.'
|
|
10
4
|
|
|
11
5
|
export class EntityOutputBasket extends EntityBase<TableOutputBasket> {
|
|
@@ -100,8 +94,7 @@ export class EntityOutputBasket extends EntityBase<TableOutputBasket> {
|
|
|
100
94
|
)
|
|
101
95
|
return false
|
|
102
96
|
if (syncMap) {
|
|
103
|
-
if (eo.basketId !== syncMap.outputBasket.idMap[verifyId(ei.basketId)])
|
|
104
|
-
return false
|
|
97
|
+
if (eo.basketId !== syncMap.outputBasket.idMap[verifyId(ei.basketId)]) return false
|
|
105
98
|
} else {
|
|
106
99
|
if (eo.basketId !== ei.basketId || eo.userId !== ei.userId) return false
|
|
107
100
|
}
|
|
@@ -129,12 +122,7 @@ export class EntityOutputBasket extends EntityBase<TableOutputBasket> {
|
|
|
129
122
|
}
|
|
130
123
|
|
|
131
124
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
132
|
-
override async mergeNew(
|
|
133
|
-
storage: EntityStorage,
|
|
134
|
-
userId: number,
|
|
135
|
-
syncMap: SyncMap,
|
|
136
|
-
trx?: sdk.TrxToken
|
|
137
|
-
): Promise<void> {
|
|
125
|
+
override async mergeNew(storage: EntityStorage, userId: number, syncMap: SyncMap, trx?: sdk.TrxToken): Promise<void> {
|
|
138
126
|
this.userId = userId
|
|
139
127
|
this.name ||= 'default'
|
|
140
128
|
this.basketId = 0
|
|
@@ -155,7 +143,7 @@ export class EntityOutputBasket extends EntityBase<TableOutputBasket> {
|
|
|
155
143
|
this.minimumDesiredUTXOValue = ei.minimumDesiredUTXOValue
|
|
156
144
|
this.numberOfDesiredUTXOs = ei.numberOfDesiredUTXOs
|
|
157
145
|
this.isDeleted = ei.isDeleted
|
|
158
|
-
this.updated_at = new Date()
|
|
146
|
+
this.updated_at = new Date(Math.max(ei.updated_at.getTime(), this.updated_at.getTime()))
|
|
159
147
|
await storage.updateOutputBasket(this.id, this.toApi(), trx)
|
|
160
148
|
wasMerged = true
|
|
161
149
|
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
import { MerklePath } from '@bsv/sdk'
|
|
3
|
-
import {
|
|
4
|
-
arraysEqual,
|
|
5
|
-
sdk,
|
|
6
|
-
TableOutputTag,
|
|
7
|
-
verifyId,
|
|
8
|
-
verifyOneOrNone
|
|
9
|
-
} from '../../../index.client'
|
|
3
|
+
import { arraysEqual, sdk, TableOutputTag, verifyId, verifyOneOrNone } from '../../../index.client'
|
|
10
4
|
import { EntityBase, EntityStorage, SyncMap } from '.'
|
|
11
5
|
|
|
12
6
|
export class EntityOutputTag extends EntityBase<TableOutputTag> {
|
|
@@ -94,9 +88,7 @@ export class EntityOutputTag extends EntityBase<TableOutputTag> {
|
|
|
94
88
|
syncMap: SyncMap,
|
|
95
89
|
trx?: sdk.TrxToken
|
|
96
90
|
): Promise<{ found: boolean; eo: EntityOutputTag; eiId: number }> {
|
|
97
|
-
const ef = verifyOneOrNone(
|
|
98
|
-
await storage.findOutputTags({ partial: { tag: ei.tag, userId }, trx })
|
|
99
|
-
)
|
|
91
|
+
const ef = verifyOneOrNone(await storage.findOutputTags({ partial: { tag: ei.tag, userId }, trx }))
|
|
100
92
|
return {
|
|
101
93
|
found: !!ef,
|
|
102
94
|
eo: new EntityOutputTag(ef || { ...ei }),
|
|
@@ -104,12 +96,7 @@ export class EntityOutputTag extends EntityBase<TableOutputTag> {
|
|
|
104
96
|
}
|
|
105
97
|
}
|
|
106
98
|
|
|
107
|
-
override async mergeNew(
|
|
108
|
-
storage: EntityStorage,
|
|
109
|
-
userId: number,
|
|
110
|
-
syncMap: SyncMap,
|
|
111
|
-
trx?: sdk.TrxToken
|
|
112
|
-
): Promise<void> {
|
|
99
|
+
override async mergeNew(storage: EntityStorage, userId: number, syncMap: SyncMap, trx?: sdk.TrxToken): Promise<void> {
|
|
113
100
|
this.userId = userId
|
|
114
101
|
this.outputTagId = 0
|
|
115
102
|
this.outputTagId = await storage.insertOutputTag(this.toApi(), trx)
|
|
@@ -125,7 +112,7 @@ export class EntityOutputTag extends EntityBase<TableOutputTag> {
|
|
|
125
112
|
let wasMerged = false
|
|
126
113
|
if (ei.updated_at > this.updated_at) {
|
|
127
114
|
this.isDeleted = ei.isDeleted
|
|
128
|
-
this.updated_at = new Date()
|
|
115
|
+
this.updated_at = new Date(Math.max(ei.updated_at.getTime(), this.updated_at.getTime()))
|
|
129
116
|
await storage.updateOutputTag(this.id, this.toApi(), trx)
|
|
130
117
|
wasMerged = true
|
|
131
118
|
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
import { MerklePath } from '@bsv/sdk'
|
|
3
|
-
import {
|
|
4
|
-
arraysEqual,
|
|
5
|
-
sdk,
|
|
6
|
-
TableOutputTagMap,
|
|
7
|
-
verifyId,
|
|
8
|
-
verifyOneOrNone
|
|
9
|
-
} from '../../../index.client'
|
|
3
|
+
import { arraysEqual, sdk, TableOutputTagMap, verifyId, verifyOneOrNone } from '../../../index.client'
|
|
10
4
|
import { EntityBase, EntityStorage, SyncMap } from '.'
|
|
11
5
|
|
|
12
6
|
export class EntityOutputTagMap extends EntityBase<TableOutputTagMap> {
|
|
@@ -68,19 +62,12 @@ export class EntityOutputTagMap extends EntityBase<TableOutputTagMap> {
|
|
|
68
62
|
return 'output_tags_map'
|
|
69
63
|
}
|
|
70
64
|
|
|
71
|
-
override equals(
|
|
72
|
-
ei: TableOutputTagMap,
|
|
73
|
-
syncMap?: SyncMap | undefined
|
|
74
|
-
): boolean {
|
|
65
|
+
override equals(ei: TableOutputTagMap, syncMap?: SyncMap | undefined): boolean {
|
|
75
66
|
const eo = this.toApi()
|
|
76
67
|
|
|
77
68
|
if (
|
|
78
|
-
eo.outputId !==
|
|
79
|
-
|
|
80
|
-
eo.outputTagId !==
|
|
81
|
-
(syncMap
|
|
82
|
-
? syncMap.outputTag.idMap[verifyId(ei.outputTagId)]
|
|
83
|
-
: ei.outputTagId) ||
|
|
69
|
+
eo.outputId !== (syncMap ? syncMap.output.idMap[verifyId(ei.outputId)] : ei.outputId) ||
|
|
70
|
+
eo.outputTagId !== (syncMap ? syncMap.outputTag.idMap[verifyId(ei.outputTagId)] : ei.outputTagId) ||
|
|
84
71
|
eo.isDeleted !== ei.isDeleted
|
|
85
72
|
)
|
|
86
73
|
return false
|
|
@@ -110,12 +97,7 @@ export class EntityOutputTagMap extends EntityBase<TableOutputTagMap> {
|
|
|
110
97
|
}
|
|
111
98
|
}
|
|
112
99
|
|
|
113
|
-
override async mergeNew(
|
|
114
|
-
storage: EntityStorage,
|
|
115
|
-
userId: number,
|
|
116
|
-
syncMap: SyncMap,
|
|
117
|
-
trx?: sdk.TrxToken
|
|
118
|
-
): Promise<void> {
|
|
100
|
+
override async mergeNew(storage: EntityStorage, userId: number, syncMap: SyncMap, trx?: sdk.TrxToken): Promise<void> {
|
|
119
101
|
this.outputId = syncMap.output.idMap[this.outputId]
|
|
120
102
|
this.outputTagId = syncMap.outputTag.idMap[this.outputTagId]
|
|
121
103
|
await storage.insertOutputTagMap(this.toApi(), trx)
|
|
@@ -131,13 +113,8 @@ export class EntityOutputTagMap extends EntityBase<TableOutputTagMap> {
|
|
|
131
113
|
let wasMerged = false
|
|
132
114
|
if (ei.updated_at > this.updated_at) {
|
|
133
115
|
this.isDeleted = ei.isDeleted
|
|
134
|
-
this.updated_at = new Date()
|
|
135
|
-
await storage.updateOutputTagMap(
|
|
136
|
-
this.outputId,
|
|
137
|
-
this.outputTagId,
|
|
138
|
-
this.toApi(),
|
|
139
|
-
trx
|
|
140
|
-
)
|
|
116
|
+
this.updated_at = new Date(Math.max(ei.updated_at.getTime(), this.updated_at.getTime()))
|
|
117
|
+
await storage.updateOutputTagMap(this.outputId, this.outputTagId, this.toApi(), trx)
|
|
141
118
|
wasMerged = true
|
|
142
119
|
}
|
|
143
120
|
return wasMerged
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { MerklePath } from '@bsv/sdk'
|
|
2
|
-
import {
|
|
3
|
-
arraysEqual,
|
|
4
|
-
sdk,
|
|
5
|
-
TableProvenTx,
|
|
6
|
-
verifyId,
|
|
7
|
-
verifyOneOrNone
|
|
8
|
-
} from '../../../index.client'
|
|
2
|
+
import { arraysEqual, sdk, TableProvenTx, verifyId, verifyOneOrNone } from '../../../index.client'
|
|
9
3
|
import { EntityBase, EntityProvenTxReq, EntityStorage, SyncMap } from '.'
|
|
10
4
|
|
|
11
5
|
export class EntityProvenTx extends EntityBase<TableProvenTx> {
|
|
@@ -25,11 +19,7 @@ export class EntityProvenTx extends EntityBase<TableProvenTx> {
|
|
|
25
19
|
* @param rawTx
|
|
26
20
|
* @returns
|
|
27
21
|
*/
|
|
28
|
-
static async fromTxid(
|
|
29
|
-
txid: string,
|
|
30
|
-
services: sdk.WalletServices,
|
|
31
|
-
rawTx?: number[]
|
|
32
|
-
): Promise<ProvenTxFromTxidResult> {
|
|
22
|
+
static async fromTxid(txid: string, services: sdk.WalletServices, rawTx?: number[]): Promise<ProvenTxFromTxidResult> {
|
|
33
23
|
const r: ProvenTxFromTxidResult = { proven: undefined, rawTx }
|
|
34
24
|
|
|
35
25
|
const chain = services.chain
|
|
@@ -200,9 +190,7 @@ export class EntityProvenTx extends EntityBase<TableProvenTx> {
|
|
|
200
190
|
syncMap: SyncMap,
|
|
201
191
|
trx?: sdk.TrxToken
|
|
202
192
|
): Promise<{ found: boolean; eo: EntityProvenTx; eiId: number }> {
|
|
203
|
-
const ef = verifyOneOrNone(
|
|
204
|
-
await storage.findProvenTxs({ partial: { txid: ei.txid }, trx })
|
|
205
|
-
)
|
|
193
|
+
const ef = verifyOneOrNone(await storage.findProvenTxs({ partial: { txid: ei.txid }, trx }))
|
|
206
194
|
return {
|
|
207
195
|
found: !!ef,
|
|
208
196
|
eo: new EntityProvenTx(ef || { ...ei }),
|
|
@@ -210,12 +198,7 @@ export class EntityProvenTx extends EntityBase<TableProvenTx> {
|
|
|
210
198
|
}
|
|
211
199
|
}
|
|
212
200
|
|
|
213
|
-
override async mergeNew(
|
|
214
|
-
storage: EntityStorage,
|
|
215
|
-
userId: number,
|
|
216
|
-
syncMap: SyncMap,
|
|
217
|
-
trx?: sdk.TrxToken
|
|
218
|
-
): Promise<void> {
|
|
201
|
+
override async mergeNew(storage: EntityStorage, userId: number, syncMap: SyncMap, trx?: sdk.TrxToken): Promise<void> {
|
|
219
202
|
this.provenTxId = 0
|
|
220
203
|
// TODO: Since these records are a shared resource, the record must be validated before accepting it...
|
|
221
204
|
this.provenTxId = await storage.insertProvenTx(this.toApi(), trx)
|
|
@@ -273,25 +256,14 @@ export class EntityProvenTx extends EntityBase<TableProvenTx> {
|
|
|
273
256
|
|
|
274
257
|
if (!gmpResult.merklePath) {
|
|
275
258
|
if (req.created_at) {
|
|
276
|
-
const
|
|
277
|
-
const
|
|
278
|
-
reqAgeInMsecs < 1 ? 0 : reqAgeInMsecs / (1000 * 60)
|
|
279
|
-
)
|
|
259
|
+
const ageInMsecs = Date.now() - req.created_at.getTime()
|
|
260
|
+
const ageInMinutes = Math.ceil(ageInMsecs < 1 ? 0 : ageInMsecs / (1000 * 60))
|
|
280
261
|
|
|
281
|
-
if (
|
|
282
|
-
req.attempts > EntityProvenTx.getProofAttemptsLimit &&
|
|
283
|
-
reqAgeInMinutes > EntityProvenTx.getProofMinutes
|
|
284
|
-
) {
|
|
262
|
+
if (req.attempts > EntityProvenTx.getProofAttemptsLimit && ageInMinutes > EntityProvenTx.getProofMinutes) {
|
|
285
263
|
// Start the process of setting transactions to 'failed'
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
attempts: req.attempts,
|
|
290
|
-
limit: EntityProvenTx.getProofAttemptsLimit,
|
|
291
|
-
ageInMinutes: reqAgeInMinutes
|
|
292
|
-
},
|
|
293
|
-
true
|
|
294
|
-
)
|
|
264
|
+
const limit = EntityProvenTx.getProofAttemptsLimit
|
|
265
|
+
const { attempts } = req
|
|
266
|
+
req.addHistoryNote({ what: 'getMerklePathGiveUp', attempts, limit, ageInMinutes }, true)
|
|
295
267
|
req.notified = false
|
|
296
268
|
req.status = 'invalid'
|
|
297
269
|
}
|
|
@@ -301,21 +273,15 @@ export class EntityProvenTx extends EntityBase<TableProvenTx> {
|
|
|
301
273
|
|
|
302
274
|
if (countsAsAttempt) req.attempts++
|
|
303
275
|
|
|
304
|
-
const merklePaths = Array.isArray(gmpResult.merklePath)
|
|
305
|
-
? gmpResult.merklePath
|
|
306
|
-
: [gmpResult.merklePath]
|
|
276
|
+
const merklePaths = Array.isArray(gmpResult.merklePath) ? gmpResult.merklePath : [gmpResult.merklePath]
|
|
307
277
|
|
|
308
278
|
for (const proof of merklePaths) {
|
|
309
279
|
try {
|
|
310
280
|
const now = new Date()
|
|
311
|
-
const leaf = proof.path[0].find(
|
|
312
|
-
leaf => leaf.txid === true && leaf.hash === req.txid
|
|
313
|
-
)
|
|
281
|
+
const leaf = proof.path[0].find(leaf => leaf.txid === true && leaf.hash === req.txid)
|
|
314
282
|
if (!leaf) {
|
|
315
283
|
req.addHistoryNote({ what: 'getMerklePathTxidNotFound' }, true)
|
|
316
|
-
throw new sdk.WERR_INTERNAL(
|
|
317
|
-
'merkle path does not contain leaf for txid'
|
|
318
|
-
)
|
|
284
|
+
throw new sdk.WERR_INTERNAL('merkle path does not contain leaf for txid')
|
|
319
285
|
}
|
|
320
286
|
|
|
321
287
|
const proven = new EntityProvenTx({
|
|
@@ -333,16 +299,9 @@ export class EntityProvenTx extends EntityBase<TableProvenTx> {
|
|
|
333
299
|
|
|
334
300
|
return proven
|
|
335
301
|
} catch (eu: unknown) {
|
|
336
|
-
const
|
|
337
|
-
req
|
|
338
|
-
|
|
339
|
-
what: 'getMerklePathProvenError',
|
|
340
|
-
attempts: req.attempts,
|
|
341
|
-
code: e.code,
|
|
342
|
-
description: e.description
|
|
343
|
-
},
|
|
344
|
-
true
|
|
345
|
-
)
|
|
302
|
+
const { code, description } = sdk.WalletError.fromUnknown(eu)
|
|
303
|
+
const { attempts } = req
|
|
304
|
+
req.addHistoryNote({ what: 'getMerklePathProvenError', attempts, code, description }, true)
|
|
346
305
|
}
|
|
347
306
|
}
|
|
348
307
|
}
|
|
@@ -22,31 +22,18 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
|
|
|
22
22
|
txid: string,
|
|
23
23
|
trx?: sdk.TrxToken
|
|
24
24
|
): Promise<EntityProvenTxReq | undefined> {
|
|
25
|
-
const reqApi = verifyOneOrNone(
|
|
26
|
-
await storage.findProvenTxReqs({ partial: { txid }, trx })
|
|
27
|
-
)
|
|
25
|
+
const reqApi = verifyOneOrNone(await storage.findProvenTxReqs({ partial: { txid }, trx }))
|
|
28
26
|
if (!reqApi) return undefined
|
|
29
27
|
return new EntityProvenTxReq(reqApi)
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
static async fromStorageId(
|
|
33
|
-
storage:
|
|
34
|
-
id
|
|
35
|
-
trx?: sdk.TrxToken
|
|
36
|
-
): Promise<EntityProvenTxReq> {
|
|
37
|
-
const reqApi = verifyOneOrNone(
|
|
38
|
-
await storage.findProvenTxReqs({ partial: { provenTxReqId: id }, trx })
|
|
39
|
-
)
|
|
40
|
-
if (!reqApi)
|
|
41
|
-
throw new sdk.WERR_INTERNAL(`proven_tx_reqs with id ${id} is missing.`)
|
|
30
|
+
static async fromStorageId(storage: EntityStorage, id: number, trx?: sdk.TrxToken): Promise<EntityProvenTxReq> {
|
|
31
|
+
const reqApi = verifyOneOrNone(await storage.findProvenTxReqs({ partial: { provenTxReqId: id }, trx }))
|
|
32
|
+
if (!reqApi) throw new sdk.WERR_INTERNAL(`proven_tx_reqs with id ${id} is missing.`)
|
|
42
33
|
return new EntityProvenTxReq(reqApi)
|
|
43
34
|
}
|
|
44
35
|
|
|
45
|
-
static fromTxid(
|
|
46
|
-
txid: string,
|
|
47
|
-
rawTx: number[],
|
|
48
|
-
inputBEEF?: number[]
|
|
49
|
-
): EntityProvenTxReq {
|
|
36
|
+
static fromTxid(txid: string, rawTx: number[], inputBEEF?: number[]): EntityProvenTxReq {
|
|
50
37
|
const now = new Date()
|
|
51
38
|
return new EntityProvenTxReq({
|
|
52
39
|
provenTxReqId: 0,
|
|
@@ -110,19 +97,14 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
|
|
|
110
97
|
// Cleanup null values and duplicates.
|
|
111
98
|
const transactionIds: number[] = []
|
|
112
99
|
for (const id of this.notify.transactionIds) {
|
|
113
|
-
if (Number.isInteger(id) && !transactionIds.some(txid => txid === id))
|
|
114
|
-
transactionIds.push(id)
|
|
100
|
+
if (Number.isInteger(id) && !transactionIds.some(txid => txid === id)) transactionIds.push(id)
|
|
115
101
|
}
|
|
116
102
|
this.notify.transactionIds = transactionIds
|
|
117
103
|
}
|
|
118
104
|
}
|
|
119
105
|
|
|
120
|
-
async refreshFromStorage(
|
|
121
|
-
storage:
|
|
122
|
-
): Promise<void> {
|
|
123
|
-
const newApi = verifyOne(
|
|
124
|
-
await storage.findProvenTxReqs({ partial: { provenTxReqId: this.id } })
|
|
125
|
-
)
|
|
106
|
+
async refreshFromStorage(storage: EntityStorage | WalletStorageManager): Promise<void> {
|
|
107
|
+
const newApi = verifyOne(await storage.findProvenTxReqs({ partial: { provenTxReqId: this.id } }))
|
|
126
108
|
this.api = newApi
|
|
127
109
|
this.unpackApi()
|
|
128
110
|
}
|
|
@@ -156,8 +138,7 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
|
|
|
156
138
|
const filter = since.toISOString()
|
|
157
139
|
const notes = this.history.notes
|
|
158
140
|
if (notes && fh.notes) {
|
|
159
|
-
for (const note of notes)
|
|
160
|
-
if (note.when && note.when > filter) fh.notes.push(note)
|
|
141
|
+
for (const note of notes) if (note.when && note.when > filter) fh.notes.push(note)
|
|
161
142
|
}
|
|
162
143
|
return fh
|
|
163
144
|
}
|
|
@@ -203,10 +184,7 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
|
|
|
203
184
|
return summary
|
|
204
185
|
}
|
|
205
186
|
|
|
206
|
-
parseHistoryNote(
|
|
207
|
-
note: sdk.ReqHistoryNote,
|
|
208
|
-
summary?: ProvenTxReqHistorySummaryApi
|
|
209
|
-
): string {
|
|
187
|
+
parseHistoryNote(note: sdk.ReqHistoryNote, summary?: ProvenTxReqHistorySummaryApi): string {
|
|
210
188
|
const c = summary || {
|
|
211
189
|
setToCompleted: false,
|
|
212
190
|
setToUnmined: false,
|
|
@@ -255,13 +233,10 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
|
|
|
255
233
|
}
|
|
256
234
|
|
|
257
235
|
addNotifyTransactionId(id: number) {
|
|
258
|
-
if (!Number.isInteger(id))
|
|
259
|
-
throw new sdk.WERR_INVALID_PARAMETER('id', 'integer')
|
|
236
|
+
if (!Number.isInteger(id)) throw new sdk.WERR_INVALID_PARAMETER('id', 'integer')
|
|
260
237
|
const s = new Set(this.notify.transactionIds || [])
|
|
261
238
|
s.add(id)
|
|
262
|
-
this.notify.transactionIds = [...s].sort((a, b) =>
|
|
263
|
-
a > b ? 1 : a < b ? -1 : 0
|
|
264
|
-
)
|
|
239
|
+
this.notify.transactionIds = [...s].sort((a, b) => (a > b ? 1 : a < b ? -1 : 0))
|
|
265
240
|
this.notified = false
|
|
266
241
|
}
|
|
267
242
|
|
|
@@ -276,9 +251,7 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
|
|
|
276
251
|
if (!note.when) note.when = new Date().toISOString()
|
|
277
252
|
if (noDupes) {
|
|
278
253
|
// Remove any existing notes with same 'what' value and either no 'when' or an earlier 'when'
|
|
279
|
-
this.history.notes = this.history.notes!.filter(
|
|
280
|
-
n => n.what !== note.what || (n.when && n.when > note.when!)
|
|
281
|
-
)
|
|
254
|
+
this.history.notes = this.history.notes!.filter(n => n.what !== note.what || (n.when && n.when > note.when!))
|
|
282
255
|
}
|
|
283
256
|
let addNote = true
|
|
284
257
|
for (const n of this.history.notes) {
|
|
@@ -297,9 +270,7 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
|
|
|
297
270
|
const k = (n: sdk.ReqHistoryNote): string => {
|
|
298
271
|
return `${n.when} ${n.what}`
|
|
299
272
|
}
|
|
300
|
-
this.history.notes.sort((a, b) =>
|
|
301
|
-
k(a) < k(b) ? -1 : k(a) > k(b) ? 1 : 0
|
|
302
|
-
)
|
|
273
|
+
this.history.notes.sort((a, b) => (k(a) < k(b) ? -1 : k(a) > k(b) ? 1 : 0))
|
|
303
274
|
}
|
|
304
275
|
}
|
|
305
276
|
|
|
@@ -333,10 +304,7 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
|
|
|
333
304
|
* @param storage
|
|
334
305
|
* @param trx
|
|
335
306
|
*/
|
|
336
|
-
async updateStorageDynamicProperties(
|
|
337
|
-
storage: WalletStorageManager | StorageProvider,
|
|
338
|
-
trx?: sdk.TrxToken
|
|
339
|
-
) {
|
|
307
|
+
async updateStorageDynamicProperties(storage: WalletStorageManager | StorageProvider, trx?: sdk.TrxToken) {
|
|
340
308
|
this.updated_at = new Date()
|
|
341
309
|
this.updateApi()
|
|
342
310
|
const update: Partial<TableProvenTxReqDynamics> = {
|
|
@@ -360,16 +328,10 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
|
|
|
360
328
|
}
|
|
361
329
|
}
|
|
362
330
|
|
|
363
|
-
async insertOrMerge(
|
|
364
|
-
storage: EntityStorage,
|
|
365
|
-
trx?: sdk.TrxToken
|
|
366
|
-
): Promise<EntityProvenTxReq> {
|
|
331
|
+
async insertOrMerge(storage: EntityStorage, trx?: sdk.TrxToken): Promise<EntityProvenTxReq> {
|
|
367
332
|
const req = await storage.transaction<EntityProvenTxReq>(async trx => {
|
|
368
333
|
let reqApi0 = this.toApi()
|
|
369
|
-
const { req: reqApi1, isNew } = await storage.findOrInsertProvenTxReq(
|
|
370
|
-
reqApi0,
|
|
371
|
-
trx
|
|
372
|
-
)
|
|
334
|
+
const { req: reqApi1, isNew } = await storage.findOrInsertProvenTxReq(reqApi0, trx)
|
|
373
335
|
if (isNew) {
|
|
374
336
|
return new EntityProvenTxReq(reqApi1)
|
|
375
337
|
} else {
|
|
@@ -391,11 +353,7 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
|
|
|
391
353
|
}
|
|
392
354
|
set status(v: sdk.ProvenTxReqStatus) {
|
|
393
355
|
if (v !== this.api.status) {
|
|
394
|
-
this.addHistoryNote({
|
|
395
|
-
what: 'status',
|
|
396
|
-
status_was: this.api.status,
|
|
397
|
-
status_now: v
|
|
398
|
-
})
|
|
356
|
+
this.addHistoryNote({ what: 'status', status_was: this.api.status, status_now: v })
|
|
399
357
|
this.api.status = v
|
|
400
358
|
}
|
|
401
359
|
}
|
|
@@ -476,19 +434,14 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
|
|
|
476
434
|
/**
|
|
477
435
|
* 'convergent' equality must satisfy (A sync B) equals (B sync A)
|
|
478
436
|
*/
|
|
479
|
-
override equals(
|
|
480
|
-
ei: TableProvenTxReq,
|
|
481
|
-
syncMap?: SyncMap | undefined
|
|
482
|
-
): boolean {
|
|
437
|
+
override equals(ei: TableProvenTxReq, syncMap?: SyncMap | undefined): boolean {
|
|
483
438
|
const eo = this.toApi()
|
|
484
439
|
if (
|
|
485
440
|
eo.txid != ei.txid ||
|
|
486
441
|
!arraysEqual(eo.rawTx, ei.rawTx) ||
|
|
487
442
|
(!eo.inputBEEF && ei.inputBEEF) ||
|
|
488
443
|
(eo.inputBEEF && !ei.inputBEEF) ||
|
|
489
|
-
(eo.inputBEEF &&
|
|
490
|
-
ei.inputBEEF &&
|
|
491
|
-
!arraysEqual(eo.inputBEEF, ei.inputBEEF)) ||
|
|
444
|
+
(eo.inputBEEF && ei.inputBEEF && !arraysEqual(eo.inputBEEF, ei.inputBEEF)) ||
|
|
492
445
|
eo.batch != ei.batch
|
|
493
446
|
)
|
|
494
447
|
return false
|
|
@@ -497,12 +450,10 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
|
|
|
497
450
|
// attempts doesn't matter for convergent equality
|
|
498
451
|
// history doesn't matter for convergent equality
|
|
499
452
|
// only local transactionIds matter, that cared about this txid in sorted order
|
|
500
|
-
eo.provenTxReqId !==
|
|
501
|
-
syncMap.provenTxReq.idMap[verifyId(ei.provenTxReqId)] ||
|
|
453
|
+
eo.provenTxReqId !== syncMap.provenTxReq.idMap[verifyId(ei.provenTxReqId)] ||
|
|
502
454
|
(!eo.provenTxId && ei.provenTxId) ||
|
|
503
455
|
(eo.provenTxId && !ei.provenTxId) ||
|
|
504
|
-
(ei.provenTxId &&
|
|
505
|
-
eo.provenTxId !== syncMap.provenTx.idMap[ei.provenTxId])
|
|
456
|
+
(ei.provenTxId && eo.provenTxId !== syncMap.provenTx.idMap[ei.provenTxId])
|
|
506
457
|
// || eo.created_at !== minDate(ei.created_at, eo.created_at)
|
|
507
458
|
// || eo.updated_at !== maxDate(ei.updated_at, eo.updated_at)
|
|
508
459
|
)
|
|
@@ -529,9 +480,7 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
|
|
|
529
480
|
syncMap: SyncMap,
|
|
530
481
|
trx?: sdk.TrxToken
|
|
531
482
|
): Promise<{ found: boolean; eo: EntityProvenTxReq; eiId: number }> {
|
|
532
|
-
const ef = verifyOneOrNone(
|
|
533
|
-
await storage.findProvenTxReqs({ partial: { txid: ei.txid }, trx })
|
|
534
|
-
)
|
|
483
|
+
const ef = verifyOneOrNone(await storage.findProvenTxReqs({ partial: { txid: ei.txid }, trx }))
|
|
535
484
|
return {
|
|
536
485
|
found: !!ef,
|
|
537
486
|
eo: new EntityProvenTxReq(ef || { ...ei }),
|
|
@@ -544,8 +493,7 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
|
|
|
544
493
|
const externalIds = this.notify.transactionIds || []
|
|
545
494
|
this.notify.transactionIds = []
|
|
546
495
|
for (const transactionId of externalIds) {
|
|
547
|
-
const localTxId: number | undefined =
|
|
548
|
-
syncMap.transaction.idMap[transactionId]
|
|
496
|
+
const localTxId: number | undefined = syncMap.transaction.idMap[transactionId]
|
|
549
497
|
if (localTxId) {
|
|
550
498
|
this.addNotifyTransactionId(localTxId)
|
|
551
499
|
}
|
|
@@ -558,9 +506,7 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
|
|
|
558
506
|
if (eie.notify.transactionIds) {
|
|
559
507
|
this.notify.transactionIds ||= []
|
|
560
508
|
for (const transactionId of eie.notify.transactionIds) {
|
|
561
|
-
const localTxId: number | undefined = syncMap
|
|
562
|
-
? syncMap.transaction.idMap[transactionId]
|
|
563
|
-
: transactionId
|
|
509
|
+
const localTxId: number | undefined = syncMap ? syncMap.transaction.idMap[transactionId] : transactionId
|
|
564
510
|
if (localTxId) {
|
|
565
511
|
this.addNotifyTransactionId(localTxId)
|
|
566
512
|
}
|
|
@@ -569,11 +515,7 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
|
|
|
569
515
|
}
|
|
570
516
|
|
|
571
517
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
572
|
-
mergeHistory(
|
|
573
|
-
ei: TableProvenTxReq,
|
|
574
|
-
syncMap?: SyncMap,
|
|
575
|
-
noDupes?: boolean
|
|
576
|
-
): void {
|
|
518
|
+
mergeHistory(ei: TableProvenTxReq, syncMap?: SyncMap, noDupes?: boolean): void {
|
|
577
519
|
const eie = new EntityProvenTxReq(ei)
|
|
578
520
|
if (eie.history.notes) {
|
|
579
521
|
for (const note of eie.history.notes) {
|
|
@@ -586,14 +528,8 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
|
|
|
586
528
|
return sdk.ProvenTxReqTerminalStatus.some(s => s === status)
|
|
587
529
|
}
|
|
588
530
|
|
|
589
|
-
override async mergeNew(
|
|
590
|
-
|
|
591
|
-
userId: number,
|
|
592
|
-
syncMap: SyncMap,
|
|
593
|
-
trx?: sdk.TrxToken
|
|
594
|
-
): Promise<void> {
|
|
595
|
-
if (this.provenTxId)
|
|
596
|
-
this.provenTxId = syncMap.provenTx.idMap[this.provenTxId]
|
|
531
|
+
override async mergeNew(storage: EntityStorage, userId: number, syncMap: SyncMap, trx?: sdk.TrxToken): Promise<void> {
|
|
532
|
+
if (this.provenTxId) this.provenTxId = syncMap.provenTx.idMap[this.provenTxId]
|
|
597
533
|
this.mapNotifyTransactionIds(syncMap)
|
|
598
534
|
this.provenTxReqId = 0
|
|
599
535
|
this.provenTxReqId = await storage.insertProvenTxReq(this.toApi(), trx)
|
|
@@ -625,7 +561,7 @@ export class EntityProvenTxReq extends EntityBase<TableProvenTxReq> {
|
|
|
625
561
|
this.mergeHistory(ei, syncMap, true)
|
|
626
562
|
this.mergeNotifyTransactionIds(ei, syncMap)
|
|
627
563
|
|
|
628
|
-
this.updated_at = new Date()
|
|
564
|
+
this.updated_at = new Date(Math.max(ei.updated_at.getTime(), this.updated_at.getTime()))
|
|
629
565
|
await storage.updateProvenTxReq(this.id, this.toApi(), trx)
|
|
630
566
|
return false
|
|
631
567
|
}
|