mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
transactions move validation of the to field to validateRecipient
This commit is contained in:
parent
a2c14ad02b
commit
e5a83d3f1a
@ -101,12 +101,6 @@ module.exports = class TxGasUtil {
|
|||||||
|
|
||||||
async validateTxParams (txParams) {
|
async validateTxParams (txParams) {
|
||||||
this.validateRecipient(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) {
|
if ('value' in txParams) {
|
||||||
const value = txParams.value.toString()
|
const value = txParams.value.toString()
|
||||||
if (value.includes('-')) {
|
if (value.includes('-')) {
|
||||||
@ -119,12 +113,14 @@ module.exports = class TxGasUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
validateRecipient (txParams) {
|
validateRecipient (txParams) {
|
||||||
if (txParams.to === '0x') {
|
if (txParams.to === '0x' || txParams.to === null ) {
|
||||||
if (txParams.data) {
|
if (txParams.data) {
|
||||||
delete txParams.to
|
delete txParams.to
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Invalid recipient address')
|
throw new Error('Invalid recipient address')
|
||||||
}
|
}
|
||||||
|
} else if ( txParams.to !== undefined && !isValidAddress(txParams.to) ) {
|
||||||
|
throw new Error('Invalid recipient address')
|
||||||
}
|
}
|
||||||
return txParams
|
return txParams
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user