-
Notifications
You must be signed in to change notification settings - Fork 1.7k
reverse call data decoding given transaction data & method #2312
Conversation
It looks like this contributor signed our Contributor License Agreement. 👍 Many thanks, Ethcore CLA Bot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except the methodToAbi
thing, minor grumbles.
const CREATE_METHOD = '60606040'; | ||
|
||
export function decodeCallData (data) { | ||
if (!data || !data.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd let it fail/throw here actually, to encourage consumers of this function to use it properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 (Actually does do so later on when no signature + data, removed)
export function decodeMethodInput (methodAbi, paramdata) { | ||
if (!methodAbi) { | ||
throw new Error('decodeMethodInput should receive valid method-specific ABI'); | ||
} else if (!paramdata) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those checks don't have an AND
relation, so it should be else if
-> if
. Every single failed check is a reason for decodeMethodInput
to fail, but multiple can fail at once.
I that with throw
, it doesn't make a big difference, but it's more robust.
} | ||
|
||
// takes a method in form name(..., types) and returns the interred abi definition | ||
export function methodToAbi (method) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indexOf
feels too brittle. This function should validate the syntax of method
properly (right now, it will already give a false positive with spaces inside method
).
If this is a standard format, as @jacogr told me, there should be an independent module for validating!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type checking to be done, as discussed.
api.util.* -
Allows decoding of values for https://github.com/ethcore/parity/issues/2208 & https://github.com/ethcore/parity/issues/2280