mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
ganache-core merged my PR, so I changed some comments to clarify that ganache-core v2.2.1 and below will return the non-standard '0x0'
This commit is contained in:
parent
222e62d7f1
commit
4cc0b1ef01
@ -63,14 +63,15 @@ class TxGasUtil {
|
||||
const hasRecipient = Boolean(recipient)
|
||||
|
||||
if (hasRecipient) {
|
||||
let code = await this.query.getCode(recipient)
|
||||
const code = await this.query.getCode(recipient)
|
||||
|
||||
// If there's data in the params, but there's no code, it's not a valid contract
|
||||
// For no code, Infura will return '0x', and Ganache will return '0x0'
|
||||
// For no code, Infura will return '0x', and ganache-core v2.2.1 will return '0x0'
|
||||
if (txParams.data && (!code || code === '0x' || code === '0x0')) {
|
||||
throw {errorKey: TRANSACTION_NO_CONTRACT_ERROR_KEY}
|
||||
}
|
||||
else if (!code) {
|
||||
const err = new Error()
|
||||
err.errorKey = TRANSACTION_NO_CONTRACT_ERROR_KEY
|
||||
throw err
|
||||
} else if (!code) {
|
||||
txParams.gas = SIMPLE_GAS_COST // For a standard ETH send, gas is 21k max
|
||||
txMeta.simpleSend = true // Prevents buffer addition
|
||||
return SIMPLE_GAS_COST
|
||||
|
@ -489,7 +489,7 @@ PendingTx.prototype.verifyGasParams = function () {
|
||||
}
|
||||
|
||||
PendingTx.prototype._notZeroOrEmptyString = function (obj) {
|
||||
return obj !== '' && obj !== '0x0' && obj !== '0x' // The '0x' case might not ever happen, but it seems safest to protect against it
|
||||
return obj !== '' && obj !== '0x0' && obj !== '0x' // '0x' means null
|
||||
}
|
||||
|
||||
PendingTx.prototype.bnMultiplyByFraction = function (targetBN, numerator, denominator) {
|
||||
|
@ -215,7 +215,7 @@ async function estimateGas ({
|
||||
// if recipient has no code, gas is 21k max:
|
||||
if (!selectedToken && !data) {
|
||||
const code = Boolean(to) && await global.eth.getCode(to)
|
||||
if (!code || code === '0x' || code === '0x0') { // Infura will return '0x', and Ganache will return '0x0'
|
||||
if (!code || code === '0x' || code === '0x0') { // Infura will return '0x', and ganache-core v2.2.1 will return '0x0'
|
||||
return SIMPLE_GAS_COST
|
||||
}
|
||||
} else if (selectedToken && !to) {
|
||||
|
@ -114,7 +114,7 @@ export function getLatestSubmittedTxWithNonce (transactions = [], nonce = '0x0')
|
||||
|
||||
export async function isSmartContractAddress (address) {
|
||||
const code = await global.eth.getCode(address)
|
||||
return code && code !== '0x' && code !== '0x0'; // Infura will return '0x', and Ganache will return '0x0'
|
||||
return code && code !== '0x' && code !== '0x0' // Infura will return '0x', and ganache-core v2.2.1 will return '0x0'
|
||||
}
|
||||
|
||||
export function sumHexes (...args) {
|
||||
|
Loading…
Reference in New Issue
Block a user