tx-state-manager - validateTxParams - validate chainId is Number

feature/default_network_editable
kumavis 7 years ago
parent 3b1e4c74f5
commit 83df8b58ba
  1. 12
      app/scripts/lib/tx-state-manager.js

@ -140,8 +140,16 @@ module.exports = class TransactionStateManager extends EventEmitter {
validateTxParams(txParams) {
Object.keys(txParams).forEach((key) => {
const value = txParams[key]
if (typeof value !== 'string' && key !== 'chainId') throw new Error(`${key}: ${value} in txParams is not a string`)
if (!ethUtil.isHexPrefixed(value) && key !== 'chainId') throw new Error('is not hex prefixed, everything on txParams must be hex prefixed')
// validate types
switch (key) {
case 'chainId':
if (typeof value !== 'number') throw new Error(`${key} in txParams is not a Number. got: (${value})`)
break
default:
if (typeof value !== 'string') throw new Error(`${key} in txParams is not a string. got: (${value})`)
if (!ethUtil.isHexPrefixed(value)) throw new Error(`${key} in txParams is not hex prefixed. got: (${value})`)
break
}
})
}

Loading…
Cancel
Save