aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2018-06-19 00:25:20 +0800
committerDan <danjm.com@gmail.com>2018-06-19 00:25:20 +0800
commit70abe54c94d8c08aa1b73fd63f34b65bc3dff117 (patch)
treed4ee5d2aafcd2e1a5d9b0ce0448570bdd5f0a4dc /ui
parent6c9302f9853d931ecf2f4385fa77b78d367f89e2 (diff)
downloadtangerine-wallet-browser-70abe54c94d8c08aa1b73fd63f34b65bc3dff117.tar
tangerine-wallet-browser-70abe54c94d8c08aa1b73fd63f34b65bc3dff117.tar.gz
tangerine-wallet-browser-70abe54c94d8c08aa1b73fd63f34b65bc3dff117.tar.bz2
tangerine-wallet-browser-70abe54c94d8c08aa1b73fd63f34b65bc3dff117.tar.lz
tangerine-wallet-browser-70abe54c94d8c08aa1b73fd63f34b65bc3dff117.tar.xz
tangerine-wallet-browser-70abe54c94d8c08aa1b73fd63f34b65bc3dff117.tar.zst
tangerine-wallet-browser-70abe54c94d8c08aa1b73fd63f34b65bc3dff117.zip
Send screen returns simple gas cost if no to address specified when not sending token.
Diffstat (limited to 'ui')
-rw-r--r--ui/app/components/send_/send.utils.js5
-rw-r--r--ui/app/components/send_/tests/send-utils.test.js6
2 files changed, 8 insertions, 3 deletions
diff --git a/ui/app/components/send_/send.utils.js b/ui/app/components/send_/send.utils.js
index 3d8e1a882..9b26b4e32 100644
--- a/ui/app/components/send_/send.utils.js
+++ b/ui/app/components/send_/send.utils.js
@@ -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
}
diff --git a/ui/app/components/send_/tests/send-utils.test.js b/ui/app/components/send_/tests/send-utils.test.js
index 00804d074..facc0e518 100644
--- a/ui/app/components/send_/tests/send-utils.test.js
+++ b/ui/app/components/send_/tests/send-utils.test.js
@@ -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: '' } }))