diff options
author | Frankie <frankie.diamond@gmail.com> | 2018-03-29 03:53:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-29 03:53:38 +0800 |
commit | 5a9aa153ecd0721be3a643afe1d23349f5b567eb (patch) | |
tree | bb863d2471840fa77adcac2443d3c61faa1fa5e1 /app/scripts/lib | |
parent | 871edfe12ad37545c596e2e926afc458c0efa559 (diff) | |
parent | 21fbaed97c84e75968cff1810999d0ec1aa5ef26 (diff) | |
download | tangerine-wallet-browser-5a9aa153ecd0721be3a643afe1d23349f5b567eb.tar tangerine-wallet-browser-5a9aa153ecd0721be3a643afe1d23349f5b567eb.tar.gz tangerine-wallet-browser-5a9aa153ecd0721be3a643afe1d23349f5b567eb.tar.bz2 tangerine-wallet-browser-5a9aa153ecd0721be3a643afe1d23349f5b567eb.tar.lz tangerine-wallet-browser-5a9aa153ecd0721be3a643afe1d23349f5b567eb.tar.xz tangerine-wallet-browser-5a9aa153ecd0721be3a643afe1d23349f5b567eb.tar.zst tangerine-wallet-browser-5a9aa153ecd0721be3a643afe1d23349f5b567eb.zip |
Merge pull request #3767 from MetaMask/tx-state-undefined-value
tx controller - stricter validation and other improvements
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/tx-state-manager.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/app/scripts/lib/tx-state-manager.js b/app/scripts/lib/tx-state-manager.js index ab344ae9b..23c915a61 100644 --- a/app/scripts/lib/tx-state-manager.js +++ b/app/scripts/lib/tx-state-manager.js @@ -106,12 +106,9 @@ module.exports = class TransactionStateManager extends EventEmitter { } updateTx (txMeta, note) { + // validate txParams if (txMeta.txParams) { - Object.keys(txMeta.txParams).forEach((key) => { - const value = txMeta.txParams[key] - if (typeof value !== 'string') console.error(`${key}: ${value} in txParams is not a string`) - if (!ethUtil.isHexPrefixed(value)) console.error('is not hex prefixed, anything on txParams must be hex prefixed') - }) + this.validateTxParams(txMeta.txParams) } // create txMeta snapshot for history @@ -139,6 +136,15 @@ module.exports = class TransactionStateManager extends EventEmitter { this.updateTx(txMeta, `txStateManager#updateTxParams`) } + // validates txParams members by type + validateTxParams(txParams) { + Object.keys(txParams).forEach((key) => { + const value = txParams[key] + if (typeof value !== 'string') throw new Error(`${key}: ${value} in txParams is not a string`) + if (!ethUtil.isHexPrefixed(value)) throw new Error('is not hex prefixed, everything on txParams must be hex prefixed') + }) + } + /* Takes an object of fields to search for eg: let thingsToLookFor = { |