aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-04-03 07:28:33 +0800
committerkumavis <aaron@kumavis.me>2018-04-03 07:28:33 +0800
commit655593ea62b04a47cde18b785d1a88d0d0d0f726 (patch)
tree37cdbef5ef0f042c1ce3713e3b11efdec3a315b8 /app/scripts/lib
parentbd6f5547667bdae00e8990551f3a0ea39ab8d971 (diff)
parentc14ec4191741c444dcf5b7c3e177c17a10374c16 (diff)
downloadtangerine-wallet-browser-655593ea62b04a47cde18b785d1a88d0d0d0f726.tar
tangerine-wallet-browser-655593ea62b04a47cde18b785d1a88d0d0d0f726.tar.gz
tangerine-wallet-browser-655593ea62b04a47cde18b785d1a88d0d0d0f726.tar.bz2
tangerine-wallet-browser-655593ea62b04a47cde18b785d1a88d0d0d0f726.tar.lz
tangerine-wallet-browser-655593ea62b04a47cde18b785d1a88d0d0d0f726.tar.xz
tangerine-wallet-browser-655593ea62b04a47cde18b785d1a88d0d0d0f726.tar.zst
tangerine-wallet-browser-655593ea62b04a47cde18b785d1a88d0d0d0f726.zip
Merge branch 'master' of github.com:MetaMask/metamask-extension into build-perf
Diffstat (limited to 'app/scripts/lib')
-rw-r--r--app/scripts/lib/tx-gas-utils.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/app/scripts/lib/tx-gas-utils.js b/app/scripts/lib/tx-gas-utils.js
index 0fa9dd8d4..829b4c421 100644
--- a/app/scripts/lib/tx-gas-utils.js
+++ b/app/scripts/lib/tx-gas-utils.js
@@ -52,7 +52,9 @@ module.exports = class TxGasUtil {
// if recipient has no code, gas is 21k max:
const recipient = txParams.to
const hasRecipient = Boolean(recipient)
- const code = await this.query.getCode(recipient)
+ let code
+ if (recipient) code = await this.query.getCode(recipient)
+
if (hasRecipient && (!code || code === '0x')) {
txParams.gas = SIMPLE_GAS_COST
txMeta.simpleSend = true // Prevents buffer addition
@@ -100,6 +102,7 @@ module.exports = class TxGasUtil {
}
async validateTxParams (txParams) {
+ this.validateFrom(txParams)
this.validateRecipient(txParams)
if ('value' in txParams) {
const value = txParams.value.toString()
@@ -112,6 +115,12 @@ module.exports = class TxGasUtil {
}
}
}
+
+ validateFrom (txParams) {
+ if ( !(typeof txParams.from === 'string') ) throw new Error(`Invalid from address ${txParams.from} not a string`)
+ if (!isValidAddress(txParams.from)) throw new Error('Invalid from address')
+ }
+
validateRecipient (txParams) {
if (txParams.to === '0x' || txParams.to === null ) {
if (txParams.data) {
@@ -124,4 +133,4 @@ module.exports = class TxGasUtil {
}
return txParams
}
-}
+} \ No newline at end of file