From 3ba72133813ce270d927c48fa815bb95bacf47f0 Mon Sep 17 00:00:00 2001 From: "markin.io" Date: Tue, 1 Mar 2022 18:16:43 +0300 Subject: [PATCH] Fixes getTransactionHistory.js and Identity.spec.js --- .../test/functional/platform/Identity.spec.js | 13 +++++++------ .../types/Account/methods/getTransactionHistory.js | 10 +++++++++- .../types/Account/methods/getTransactions.spec.js | 7 ++----- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/packages/platform-test-suite/test/functional/platform/Identity.spec.js b/packages/platform-test-suite/test/functional/platform/Identity.spec.js index 450a176797..30ddd81656 100644 --- a/packages/platform-test-suite/test/functional/platform/Identity.spec.js +++ b/packages/platform-test-suite/test/functional/platform/Identity.spec.js @@ -15,10 +15,10 @@ const BalanceIsNotEnoughError = require('@dashevo/dpp/lib/errors/consensus/fee/B const DAPIClient = require('@dashevo/dapi-client/lib/DAPIClient'); const { hash } = require('@dashevo/dpp/lib/util/hash'); const Identifier = require('@dashevo/dpp/lib/identifier/Identifier'); +const Transaction = require('@dashevo/dashcore-lib/lib/transaction'); const createClientWithFundedWallet = require('../../../lib/test/createClientWithFundedWallet'); const wait = require('../../../lib/wait'); const getDAPISeeds = require('../../../lib/test/getDAPISeeds'); -const Transaction = require('@dashevo/dashcore-lib/lib/transaction'); describe('Platform', () => { describe('Identity', () => { @@ -114,11 +114,12 @@ describe('Platform', () => { await wait(5000); } - walletAccount.storage.insertIdentityIdAtIndex( - walletAccount.walletId, - identityOne.getId().toString(), - identityOneIndex, - ); + walletAccount.storage + .getWalletStore(walletAccount.walletId) + .insertIdentityIdAtIndex( + identityOne.getId().toString(), + identityOneIndex, + ); // Creating transition that tries to spend the same transaction const { diff --git a/packages/wallet-lib/src/types/Account/methods/getTransactionHistory.js b/packages/wallet-lib/src/types/Account/methods/getTransactionHistory.js index 3dce856d09..f2cbdca2c6 100644 --- a/packages/wallet-lib/src/types/Account/methods/getTransactionHistory.js +++ b/packages/wallet-lib/src/types/Account/methods/getTransactionHistory.js @@ -22,9 +22,17 @@ function getTransactionHistory() { network, } = this; - const transactionsWithMetadata = this.getTransactions(); + const transactions = this.getTransactions(); + const walletStore = storage.getWalletStore(walletId); const chainStore = storage.getChainStore(network); + + const transactionsWithMetadata = Object.keys(transactions).reduce((acc, hash) => { + const { metadata } = chainStore.getTransaction(hash); + acc.push([transactions[hash], metadata]); + return acc; + }, []); + const { blockHeaders } = chainStore.state; const categorizedTransactions = categorizeTransactions( diff --git a/packages/wallet-lib/src/types/Account/methods/getTransactions.spec.js b/packages/wallet-lib/src/types/Account/methods/getTransactions.spec.js index fa4ac06921..defa1d5922 100644 --- a/packages/wallet-lib/src/types/Account/methods/getTransactions.spec.js +++ b/packages/wallet-lib/src/types/Account/methods/getTransactions.spec.js @@ -11,11 +11,8 @@ mockedHDSelf.getTransactions = getTransactions; describe('Account - getTransactions', function suite() { this.timeout(10000); it('should get the transactions', () => { - const transactionsWithMetadata = getTransactions.call(mockedHDSelf); - const transactionsHash = transactionsWithMetadata.reduce((acc, el)=>{ - acc.push(el[0].hash); - return acc; - },[]); + const transactions = getTransactions.call(mockedHDSelf); + const transactionsHash = Object.keys(transactions); expect(transactionsHash).to.deep.equal([ 'a43845e580ad01f31bc06ce47ab39674e40316c4c6b765b6e54d6d35777ef456',