diff options
Account for 0x/empty string address and contract creation
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/tx-gas-utils.js | 11 |
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 + } } |