Merge pull request #46 from status-im/feat/trackLogs-decode
feat: allows trackLogs to decode ABIs if inputs are included in the func call
This commit is contained in:
commit
a12f00f465
|
@ -10,7 +10,7 @@ class LogSyncer {
|
|||
this.subscriptions = [];
|
||||
}
|
||||
|
||||
track(options, gteBlockNum){
|
||||
track(options, inputsABI, gteBlockNum){
|
||||
const eventKey = 'logs-' + hash(options || {});
|
||||
const filterConditions = Object.assign({fromBlock: 0, toBlock: "latest"}, options || {});
|
||||
|
||||
|
@ -34,9 +34,16 @@ class LogSyncer {
|
|||
removed: e.removed
|
||||
}
|
||||
|
||||
const obsData = {blockNumber: e.blockNumber, data: e.data, address: e.address, topics: e.topics};
|
||||
|
||||
if(inputsABI){
|
||||
eventData.returnValues = web3.eth.abi.decodeLog(inputsABI, e.data, e.topics.slice(1));
|
||||
obsData.returnValues = eventData.returnValues;
|
||||
}
|
||||
|
||||
// TODO: test reorgs
|
||||
|
||||
sub.next({blockNumber: e.blockNumber, data: e.data, address: e.address, topics: e.topics});
|
||||
sub.next(obsData);
|
||||
|
||||
if(e.removed){
|
||||
this.db.deleteEvent(eventKey, id);
|
||||
|
|
|
@ -111,8 +111,8 @@ export default class Subspace {
|
|||
}
|
||||
}
|
||||
|
||||
trackLogs(options) {
|
||||
return this.logSyncer.track(options);
|
||||
trackLogs(options, inputsABI) {
|
||||
return this.logSyncer.track(options, inputsABI, this.latestBlockNumber - this.options.refreshLastNBlocks);
|
||||
}
|
||||
|
||||
_initNewBlocksSubscription() {
|
||||
|
|
Loading…
Reference in New Issue