diff --git a/ui/app/components/send/send-footer/send-footer.container.js b/ui/app/components/send/send-footer/send-footer.container.js index 60de4d0303d8..31d6c0c600ff 100644 --- a/ui/app/components/send/send-footer/send-footer.container.js +++ b/ui/app/components/send/send-footer/send-footer.container.js @@ -66,7 +66,7 @@ function mapDispatchToProps (dispatch) { }) selectedToken - ? dispatch(signTokenTx(selectedToken.address, to, amount, txParams)) + ? dispatch(signTokenTx(selectedToken.address, to, txParams.amount, txParams)) : dispatch(signTx(txParams)) }, update: ({ diff --git a/ui/app/components/send/send-footer/tests/send-footer-container.test.js b/ui/app/components/send/send-footer/tests/send-footer-container.test.js index cf4c893ee3fe..762c6d0a7bfe 100644 --- a/ui/app/components/send/send-footer/tests/send-footer-container.test.js +++ b/ui/app/components/send/send-footer/tests/send-footer-container.test.js @@ -14,7 +14,9 @@ const actionSpies = { } const utilsStubs = { addressIsNew: sinon.stub().returns(true), - constructTxParams: sinon.stub().returns('mockConstructedTxParams'), + constructTxParams: sinon.stub().returns({ + amount: 'mockConstructedAmount', + }), constructUpdatedTx: sinon.stub().returns('mockConstructedUpdatedTxParams'), } @@ -115,7 +117,7 @@ describe('send-footer container', () => { ) assert.deepEqual( actionSpies.signTokenTx.getCall(0).args, - [ '0xabc', 'mockTo', 'mockAmount', 'mockConstructedTxParams' ] + [ '0xabc', 'mockTo', 'mockConstructedAmount', { amount: 'mockConstructedAmount' } ] ) }) @@ -143,7 +145,7 @@ describe('send-footer container', () => { ) assert.deepEqual( actionSpies.signTx.getCall(0).args, - [ 'mockConstructedTxParams' ] + [ { amount: 'mockConstructedAmount' } ] ) }) }) diff --git a/ui/app/components/send/send.utils.js b/ui/app/components/send/send.utils.js index b2ac41e9cb27..d78b7736f5c4 100644 --- a/ui/app/components/send/send.utils.js +++ b/ui/app/components/send/send.utils.js @@ -234,10 +234,14 @@ async function estimateGas ({ if (to) { paramsForGasEstimate.to = to } + + if (!value || value === '0') { + paramsForGasEstimate.value = '0xff' + } } // if not, fall back to block gasLimit - paramsForGasEstimate.gas = ethUtil.addHexPrefix(multiplyCurrencies(blockGasLimit, 0.95, { + paramsForGasEstimate.gas = ethUtil.addHexPrefix(multiplyCurrencies(blockGasLimit || '0x5208', 0.95, { multiplicandBase: 16, multiplierBase: 10, roundDown: '0', diff --git a/ui/app/components/send/tests/send-utils.test.js b/ui/app/components/send/tests/send-utils.test.js index f31e1221b58a..48fa09392567 100644 --- a/ui/app/components/send/tests/send-utils.test.js +++ b/ui/app/components/send/tests/send-utils.test.js @@ -316,6 +316,7 @@ describe('send utils', () => { from: 'mockAddress', gas: '0x64x0.95', to: '0xisContract', + value: '0xff', } beforeEach(() => { @@ -373,7 +374,7 @@ describe('send utils', () => { assert.equal(baseMockParams.estimateGasMethod.callCount, 1) assert.deepEqual( baseMockParams.estimateGasMethod.getCall(0).args[0], - { gasPrice: undefined, value: undefined, data, from: baseExpectedCall.from, gas: baseExpectedCall.gas}, + { gasPrice: undefined, value: '0xff', data, from: baseExpectedCall.from, gas: baseExpectedCall.gas}, ) assert.equal(result, '0xabc16') }) diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js index 5a08f2d09b17..0de56ddbb816 100644 --- a/ui/app/reducers/metamask.js +++ b/ui/app/reducers/metamask.js @@ -36,7 +36,7 @@ function reduceMetamask (state, action) { tokenBalance: '0x0', from: '', to: '', - amount: '0x0', + amount: '0', memo: '', errors: {}, maxModeOn: false,