Skip to content
This repository has been archived by the owner on Sep 27, 2019. It is now read-only.

Commit

Permalink
Merge pull request #56 from protolambda/address-lowercase-fix
Browse files Browse the repository at this point in the history
Bugfix for TX processing problem introduced in 1.1.5
  • Loading branch information
OnlyOneJMJQ authored May 29, 2018
2 parents 71f37bb + 42afc30 commit ecb9ee1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/blocks/blocksSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,23 @@ function* processBlock({block, contracts, contractAddresses, contractNames, web3

if (txs.length > 0)
{
// Loop through txs looking for contract address
// Loop through txs looking for any contract address of interest
for (var i = 0; i < txs.length; i++)
{
if (contractAddresses.indexOf(txs[i].from.toLowerCase()) !== -1 || contractAddresses.indexOf(txs[i].to.toLowerCase()) !== -1)
const fromAddr = txs[i].from
const toAddr = txs[i].to

// Some txs are special cases (e.g. undefined "to" when it is a contract deploy TX)
// Prevent the toLowerCase call when it is undefined.
const fromTxIndex = fromAddr ? contractAddresses.indexOf(fromAddr.toLowerCase()) : -1
const toTxIndex = toAddr ? contractAddresses.indexOf(toAddr.toLowerCase()) : -1

const index = fromTxIndex !== -1 ? fromTxIndex : toTxIndex

if (index !== -1)
{
const index = contractAddresses.indexOf(txs[i].from.toLowerCase()) !== -1 ? contractAddresses.indexOf(txs[i].from.toLowerCase()) : contractAddresses.indexOf(txs[i].to.toLowerCase())
const contractName = contractNames[index]

yield put({type: 'CONTRACT_SYNCING', contract: contracts[contractName]})
}
}
Expand Down

0 comments on commit ecb9ee1

Please sign in to comment.