Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashing when receiving token Transfer event #3

Open
danfinlay opened this issue Sep 20, 2017 · 4 comments
Open

Crashing when receiving token Transfer event #3

danfinlay opened this issue Sep 20, 2017 · 4 comments

Comments

@danfinlay
Copy link

Reproduced in repository here.

The problem seems to be in this code:

function decodeEvent(eventObject, data, topics) {
  var useNumberedParams = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;

  var nonIndexed = eventObject.inputs.filter(function (input) {
    return !input.indexed;
  });
  var nonIndexedNames = utils.getKeys(nonIndexed, 'name', true);
  var nonIndexedTypes = utils.getKeys(nonIndexed, 'type');
  var event = decodeParams(nonIndexedNames, nonIndexedTypes, utils.hexOrBuffer(data), useNumberedParams);
  var topicOffset = eventObject.anonymous ? 0 : 1;
  eventObject.inputs.filter(function (input) {
    return input.indexed;
  }).map(function (input, i) {
    var topic = new Buffer(topics[i + topicOffset].slice(2), 'hex');
    var coder = getParamCoder(input.type);
    event[input.name] = coder.decode(topic, 0).value;
  });
  event._eventName = eventObject.name;
  return event;
}

The event is anonymous, but only has one topic, so nothing is at index 1. I don't fully get how to read this code, so I'm not sure how to fix it.

@SilentCicero
Copy link
Member

@danfinlay can you provide more info on the event data itself, name, args, some more code on your end etc?

@kumavis
Copy link

kumavis commented Dec 21, 2017

@SilentCicero theres a whole repro repo

@SilentCicero
Copy link
Member

SilentCicero commented Dec 21, 2017

@kumavis I read through it, okay, it should be able to handle the anonymous portion:

var topicOffset = eventObject.anonymous ? 0 : 1;
  eventObject.inputs.filter(function (input) {
    return input.indexed;
  }).map(function (input, i) {
    var topic = new Buffer(topics[i + topicOffset].slice(2), 'hex');
    var coder = getParamCoder(input.type);
    event[input.name] = coder.decode(topic, 0).value;
  });

If the event is anonymous it sets the offset to zero. So that shouldn't be the problem. Are you getting a specific error or just no data? @danfinlay

@kumavis
Copy link

kumavis commented Dec 21, 2017

@danfinlay you say the event is anonymous but there are no anonymous events in human-standard-token-abi thats used in the repo
https://github.com/danfinlay/human-standard-token-abi/blob/master/index.js

legobeat added a commit to legobeat/ethjs-filter that referenced this issue Nov 9, 2023
check in package-lock.json

Generated using:
  - node v8.17.0
  - npm 6.13.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants