aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2018-03-14 06:32:03 +0800
committerfrankiebee <frankie.diamond@gmail.com>2018-03-14 06:32:03 +0800
commite5a83d3f1a3ebe9115c07e162ee4bca0f157b8b1 (patch)
treedb18d48f38dfb4396e0bbd8cbebdfe1e4184ae18 /app/scripts/lib
parenta2c14ad02b6f080efe18535d64efe4acdaa5f310 (diff)
downloadtangerine-wallet-browser-e5a83d3f1a3ebe9115c07e162ee4bca0f157b8b1.tar
tangerine-wallet-browser-e5a83d3f1a3ebe9115c07e162ee4bca0f157b8b1.tar.gz
tangerine-wallet-browser-e5a83d3f1a3ebe9115c07e162ee4bca0f157b8b1.tar.bz2
tangerine-wallet-browser-e5a83d3f1a3ebe9115c07e162ee4bca0f157b8b1.tar.lz
tangerine-wallet-browser-e5a83d3f1a3ebe9115c07e162ee4bca0f157b8b1.tar.xz
tangerine-wallet-browser-e5a83d3f1a3ebe9115c07e162ee4bca0f157b8b1.tar.zst
tangerine-wallet-browser-e5a83d3f1a3ebe9115c07e162ee4bca0f157b8b1.zip
transactions move validation of the to field to validateRecipient
Diffstat (limited to 'app/scripts/lib')
-rw-r--r--app/scripts/lib/tx-gas-utils.js10
1 files changed, 3 insertions, 7 deletions
diff --git a/app/scripts/lib/tx-gas-utils.js b/app/scripts/lib/tx-gas-utils.js
index 3b0494e04..a8f473a88 100644
--- a/app/scripts/lib/tx-gas-utils.js
+++ b/app/scripts/lib/tx-gas-utils.js
@@ -101,12 +101,6 @@ module.exports = class TxGasUtil {
async validateTxParams (txParams) {
this.validateRecipient(txParams)
- if ('to' in txParams) {
- if ( txParams.to === null ) delete txParams.to
- else if ( txParams.to !== undefined && !isValidAddress(txParams.to) ) {
- throw new Error(`Invalid recipient address`)
- }
- }
if ('value' in txParams) {
const value = txParams.value.toString()
if (value.includes('-')) {
@@ -119,12 +113,14 @@ module.exports = class TxGasUtil {
}
}
validateRecipient (txParams) {
- if (txParams.to === '0x') {
+ if (txParams.to === '0x' || txParams.to === null ) {
if (txParams.data) {
delete txParams.to
} else {
throw new Error('Invalid recipient address')
}
+ } else if ( txParams.to !== undefined && !isValidAddress(txParams.to) ) {
+ throw new Error('Invalid recipient address')
}
return txParams
}