From 5a2153063cda4d7793b706f3ffd8a11cd72801db Mon Sep 17 00:00:00 2001 From: Fabian Date: Fri, 20 Mar 2020 10:32:46 -0500 Subject: [PATCH] Fabo/fix failed txs parsing (#486) * publish v2 txs and fix failed txs parsing * linted --- .../cosmos-node-subscription.js | 20 ++----------------- lib/reducers/cosmosV0-reducers.js | 5 ++++- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/lib/block-listeners/cosmos-node-subscription.js b/lib/block-listeners/cosmos-node-subscription.js index 4ad7fe8883..e4c3a4a3f3 100644 --- a/lib/block-listeners/cosmos-node-subscription.js +++ b/lib/block-listeners/cosmos-node-subscription.js @@ -1,7 +1,6 @@ const _ = require('lodash') const { publishBlockAdded, - publishUserTransactionAdded, publishUserTransactionAddedV2, publishEvent: publishEvent } = require('../subscriptions') @@ -27,9 +26,6 @@ class CosmosNodeSubscription { this.db = new database(config)(networkSchemaName) this.chainHangup = undefined this.height = undefined - this.cosmosAPI - .getStakingDenom() - .then(stakingDenom => (this.stakingDenom = stakingDenom)) this.pollForNewBlock() } @@ -38,7 +34,7 @@ class CosmosNodeSubscription { this.pollingTimeout = setTimeout(async () => { let block try { - block = await this.cosmosAPI.getBlockByHeight() + block = await this.cosmosAPI.getBlockByHeightV2() } catch (error) { console.error('Failed to fetch block', error) Sentry.captureException(error) @@ -94,14 +90,6 @@ class CosmosNodeSubscription { // transaction to each subscribed user. // TODO doesn't handle failing txs as it doesn't extract addresses from those txs (they are not tagged) block.transactions.forEach(tx => { - // update tx to v2 - let txV2 = this.cosmosAPI.reducers.transactionReducerV2( - { - ...tx.raw - }, - this.cosmosAPI.reducers, - this.stakingDenom - ) let addresses = [] try { this.cosmosAPI.extractInvolvedAddresses(tx.raw).forEach(address => { @@ -115,11 +103,7 @@ class CosmosNodeSubscription { } addresses = _.uniq(addresses) addresses.forEach(address => { - publishUserTransactionAdded(this.network.id, address, tx) - // txv2 returns array, so its zero element could not be set for some reasons - txV2.map(txMsg => - publishUserTransactionAddedV2(this.network.id, address, txMsg) - ) + publishUserTransactionAddedV2(this.network.id, address, tx) publishEvent(this.network.id, 'transaction', address, tx) }) }) diff --git a/lib/reducers/cosmosV0-reducers.js b/lib/reducers/cosmosV0-reducers.js index db44b9868f..2ea23caa27 100644 --- a/lib/reducers/cosmosV0-reducers.js +++ b/lib/reducers/cosmosV0-reducers.js @@ -550,7 +550,10 @@ function transactionReducerV2(transaction, reducers, stakingDenom) { timestamp: transaction.timestamp, memo: transaction.tx.value.memo, fees, - success: transaction.logs ? transaction.logs[index].success || false : false + success: + transaction.logs && transaction.logs[index] + ? transaction.logs[index].success || false + : false })) return returnedMessages }