Filter tokens logs from current block, not genesis (#6128)

* Filter tokens logs from current block, not genesis

* Fix linting
This commit is contained in:
Nicolas Gotchac 2017-07-25 08:39:41 +02:00 committed by Gav Wood
parent 78fab4e471
commit 58fec9181f

View File

@ -144,13 +144,16 @@ export function updateTokensFilter (_addresses, _tokens, options = {}) {
promises.push(api.eth.uninstallFilter(tokensFilter.filterToId)); promises.push(api.eth.uninstallFilter(tokensFilter.filterToId));
} }
const promise = Promise.all(promises); Promise
.all([
api.eth.blockNumber()
].concat(promises))
.then(([ block ]) => {
const topicsFrom = [ TRANSFER_SIGNATURE, addresses, null ]; const topicsFrom = [ TRANSFER_SIGNATURE, addresses, null ];
const topicsTo = [ TRANSFER_SIGNATURE, null, addresses ]; const topicsTo = [ TRANSFER_SIGNATURE, null, addresses ];
const filterOptions = { const filterOptions = {
fromBlock: 0, fromBlock: block,
toBlock: 'pending', toBlock: 'pending',
address: tokenAddresses address: tokenAddresses
}; };
@ -170,8 +173,8 @@ export function updateTokensFilter (_addresses, _tokens, options = {}) {
api.eth.newFilter(optionsTo) api.eth.newFilter(optionsTo)
]); ]);
promise return newFilters;
.then(() => newFilters) })
.then(([ filterFromId, filterToId ]) => { .then(([ filterFromId, filterToId ]) => {
const nextTokensFilter = { const nextTokensFilter = {
filterFromId, filterToId, filterFromId, filterToId,