Skip to content

Commit

Permalink
Fix calculating of balance sufficiency and tx params when sending tok…
Browse files Browse the repository at this point in the history
…en transaction.
  • Loading branch information
danjm committed Feb 25, 2019
1 parent b6e154d commit a599ccd
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
} from '../../../../ducks/gas.duck'
import { getGasLoadingError, gasFeeIsInError, getGasButtonGroupShown } from './send-gas-row.selectors.js'
import { showModal, setGasPrice, setGasLimit, setGasTotal } from '../../../../actions'
import { getAdvancedInlineGasShown, getCurrentEthBalance } from '../../../../selectors'
import { getAdvancedInlineGasShown, getCurrentEthBalance, getSelectedToken } from '../../../../selectors'
import SendGasRow from './send-gas-row.component'

export default connect(mapStateToProps, mapDispatchToProps, mergeProps)(SendGasRow)
Expand All @@ -42,7 +42,7 @@ function mapStateToProps (state) {
const balance = getCurrentEthBalance(state)

const insufficientBalance = !isBalanceSufficient({
amount: getSendAmount(state),
amount: getSelectedToken(state) ? '0x0' : getSendAmount(state),
gasTotal,
balance,
conversionRate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ proxyquire('../send-gas-row.container.js', {
'../../../../selectors': {
getCurrentEthBalance: (s) => `mockCurrentEthBalance:${s}`,
getAdvancedInlineGasShown: (s) => `mockAdvancedInlineGasShown:${s}`,
getSelectedToken: () => false,
},
'../../send.selectors.js': {
getConversionRate: (s) => `mockConversionRate:${s}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function mapDispatchToProps (dispatch) {
})

selectedToken
? dispatch(signTokenTx(selectedToken.address, to, txParams.amount, txParams))
? dispatch(signTokenTx(selectedToken.address, to, amount, txParams))
: dispatch(signTx(txParams))
},
update: ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const actionSpies = {
const utilsStubs = {
addressIsNew: sinon.stub().returns(true),
constructTxParams: sinon.stub().returns({
amount: 'mockConstructedAmount',
value: 'mockAmount',
}),
constructUpdatedTx: sinon.stub().returns('mockConstructedUpdatedTxParams'),
}
Expand Down Expand Up @@ -117,7 +117,7 @@ describe('send-footer container', () => {
)
assert.deepEqual(
actionSpies.signTokenTx.getCall(0).args,
[ '0xabc', 'mockTo', 'mockConstructedAmount', { amount: 'mockConstructedAmount' } ]
[ '0xabc', 'mockTo', 'mockAmount', { value: 'mockAmount' } ]
)
})

Expand Down Expand Up @@ -145,7 +145,7 @@ describe('send-footer container', () => {
)
assert.deepEqual(
actionSpies.signTx.getCall(0).args,
[ { amount: 'mockConstructedAmount' } ]
[ { value: 'mockAmount' } ]
)
})
})
Expand Down

0 comments on commit a599ccd

Please sign in to comment.