aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
authorThomas <tmashuang@gmail.com>2018-01-08 19:16:20 +0800
committerThomas <tmashuang@gmail.com>2018-01-08 19:16:20 +0800
commit39b700bf87f213d2fb06dcde85f4e6173a6ce70c (patch)
treed12b46142c077acbf1fe2e1ff3aae6e948e6ff44 /app/scripts/lib
parent313b3c087a09bcc4462da15ff3caeac515967cf5 (diff)
downloadtangerine-wallet-browser-39b700bf87f213d2fb06dcde85f4e6173a6ce70c.tar
tangerine-wallet-browser-39b700bf87f213d2fb06dcde85f4e6173a6ce70c.tar.gz
tangerine-wallet-browser-39b700bf87f213d2fb06dcde85f4e6173a6ce70c.tar.bz2
tangerine-wallet-browser-39b700bf87f213d2fb06dcde85f4e6173a6ce70c.tar.lz
tangerine-wallet-browser-39b700bf87f213d2fb06dcde85f4e6173a6ce70c.tar.xz
tangerine-wallet-browser-39b700bf87f213d2fb06dcde85f4e6173a6ce70c.tar.zst
tangerine-wallet-browser-39b700bf87f213d2fb06dcde85f4e6173a6ce70c.zip
Account for 0x/empty string address and contract creation
Diffstat (limited to 'app/scripts/lib')
-rw-r--r--app/scripts/lib/tx-gas-utils.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/scripts/lib/tx-gas-utils.js b/app/scripts/lib/tx-gas-utils.js
index ccf8bb1b1..5e49fdb22 100644
--- a/app/scripts/lib/tx-gas-utils.js
+++ b/app/scripts/lib/tx-gas-utils.js
@@ -81,6 +81,7 @@ module.exports = class txProvideUtil {
}
async validateTxParams (txParams) {
+ this.validateRecipient(txParams)
if ('value' in txParams) {
const value = txParams.value.toString()
if (value.includes('-')) {
@@ -92,4 +93,14 @@ module.exports = class txProvideUtil {
}
}
}
+ validateRecipient (txParams) {
+ if (txParams.to === '0x') {
+ if (txParams.data) {
+ delete txParams.to
+ } else {
+ throw new Error('Invalid recipient address')
+ }
+ }
+ return txParams
+ }
}