ethereumjs/ethrpc

Number validation

fanatid opened this issue · 4 comments

Number validation allow number to be null or undefined

if (number === null) return number;
if (number === undefined) return number;

transaction validator uses this validator for gas, gas price, value, nonce -- all this fields can be empty? (null/undefined)

The number validator is meant to be a fairly lenient so that it can be used in places that allow for null/missing numbers. Ideally, any place that calls it where null/undefined is not allowed should also check for that. If we disallowed null/undefined, then there would be a number of call sites that would get a bit uglier.

I understand, but this validator is used in tx validator which is used before send tx to node. Should tx validation be changed then?

If null/undefined are not allowed in that context, then yeah, they should verify that. Which number on the transaction specifically are you concerned with? I believe all of the ones you listed are optional (meaning they can be null/missing). See https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendtransaction for reference on optionality.

You are right, only from is required, did not known about this.