mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Send screen returns simple gas cost if no to address specified when not sending token.
This commit is contained in:
parent
6c9302f985
commit
70abe54c94
@ -177,9 +177,8 @@ async function estimateGas ({ selectedAddress, selectedToken, blockGasLimit, to,
|
||||
}
|
||||
|
||||
// if recipient has no code, gas is 21k max:
|
||||
const hasRecipient = Boolean(to)
|
||||
if (hasRecipient && !selectedToken) {
|
||||
const code = await global.eth.getCode(to)
|
||||
if (!selectedToken) {
|
||||
const code = Boolean(to) && await global.eth.getCode(to)
|
||||
if (!code || code === '0x') {
|
||||
return SIMPLE_GAS_COST
|
||||
}
|
||||
|
@ -323,6 +323,12 @@ describe('send utils', () => {
|
||||
assert.equal(result, SIMPLE_GAS_COST)
|
||||
})
|
||||
|
||||
it(`should return ${SIMPLE_GAS_COST} if not passed a selectedToken or truthy to address`, async () => {
|
||||
assert.equal(baseMockParams.estimateGasMethod.callCount, 0)
|
||||
const result = await estimateGas(Object.assign({}, baseMockParams, { to: null }))
|
||||
assert.equal(result, SIMPLE_GAS_COST)
|
||||
})
|
||||
|
||||
it(`should not return ${SIMPLE_GAS_COST} if passed a selectedToken`, async () => {
|
||||
assert.equal(baseMockParams.estimateGasMethod.callCount, 0)
|
||||
const result = await estimateGas(Object.assign({}, baseMockParams, { to: '0x123', selectedToken: { address: '' } }))
|
||||
|
Loading…
Reference in New Issue
Block a user