aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
authorAlexander Tseung <alextsg@gmail.com>2018-04-03 16:03:31 +0800
committerAlexander Tseung <alextsg@gmail.com>2018-04-03 16:03:31 +0800
commit35875863d2feafc1f653e17e0f58efc2f18ddc46 (patch)
tree5d40581a08201b3f37c7b31fe2aab4675d827f6b /app/scripts/lib
parent516c1869b0f366a42282a66e14185ce630f883dd (diff)
parentc14ec4191741c444dcf5b7c3e177c17a10374c16 (diff)
downloadtangerine-wallet-browser-35875863d2feafc1f653e17e0f58efc2f18ddc46.tar
tangerine-wallet-browser-35875863d2feafc1f653e17e0f58efc2f18ddc46.tar.gz
tangerine-wallet-browser-35875863d2feafc1f653e17e0f58efc2f18ddc46.tar.bz2
tangerine-wallet-browser-35875863d2feafc1f653e17e0f58efc2f18ddc46.tar.lz
tangerine-wallet-browser-35875863d2feafc1f653e17e0f58efc2f18ddc46.tar.xz
tangerine-wallet-browser-35875863d2feafc1f653e17e0f58efc2f18ddc46.tar.zst
tangerine-wallet-browser-35875863d2feafc1f653e17e0f58efc2f18ddc46.zip
Fix merge conflicts. Modify send workflow
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