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,34 +144,37 @@ 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 topicsTo = [ TRANSFER_SIGNATURE, null, addresses ];
const topicsFrom = [ TRANSFER_SIGNATURE, addresses, null ]; const filterOptions = {
const topicsTo = [ TRANSFER_SIGNATURE, null, addresses ]; fromBlock: block,
toBlock: 'pending',
address: tokenAddresses
};
const filterOptions = { const optionsFrom = {
fromBlock: 0, ...filterOptions,
toBlock: 'pending', topics: topicsFrom
address: tokenAddresses };
};
const optionsFrom = { const optionsTo = {
...filterOptions, ...filterOptions,
topics: topicsFrom topics: topicsTo
}; };
const optionsTo = { const newFilters = Promise.all([
...filterOptions, api.eth.newFilter(optionsFrom),
topics: topicsTo api.eth.newFilter(optionsTo)
}; ]);
const newFilters = Promise.all([ return newFilters;
api.eth.newFilter(optionsFrom), })
api.eth.newFilter(optionsTo)
]);
promise
.then(() => newFilters)
.then(([ filterFromId, filterToId ]) => { .then(([ filterFromId, filterToId ]) => {
const nextTokensFilter = { const nextTokensFilter = {
filterFromId, filterToId, filterFromId, filterToId,