feat: allows trackLogs to decode ABIs if inputs are included in the func call
This commit is contained in:
parent
e0f0d13cea
commit
40a8588758
|
@ -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);
|
||||
|
|
|
@ -62,8 +62,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