1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Merge pull request #3848 from MetaMask/i#3841

transactions - dont throw if chain id is not a string
This commit is contained in:
kumavis 2018-04-03 14:06:10 -07:00 committed by GitHub
commit 6eff5944d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -140,8 +140,16 @@ module.exports = class TransactionStateManager extends EventEmitter {
validateTxParams(txParams) { validateTxParams(txParams) {
Object.keys(txParams).forEach((key) => { Object.keys(txParams).forEach((key) => {
const value = txParams[key] const value = txParams[key]
if (typeof value !== 'string') throw new Error(`${key}: ${value} in txParams is not a string`) // validate types
if (!ethUtil.isHexPrefixed(value)) throw new Error('is not hex prefixed, everything on txParams must be hex prefixed') 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
}
}) })
} }