Recipient not required on send screen when hex data present

feature/default_network_editable
Whymarrh Whitby 6 years ago
parent c9f22916dd
commit ce2e068b43
  1. 5
      ui/app/components/send/send-content/send-to-row/send-to-row.component.js
  2. 2
      ui/app/components/send/send-content/send-to-row/send-to-row.container.js
  3. 6
      ui/app/components/send/send-content/send-to-row/send-to-row.utils.js
  4. 2
      ui/app/components/send/send-content/send-to-row/tests/send-to-row-container.test.js
  5. 6
      ui/app/components/send/send-content/send-to-row/tests/send-to-row-utils.test.js

@ -8,6 +8,7 @@ export default class SendToRow extends Component {
static propTypes = {
closeToDropdown: PropTypes.func,
hasHexData: PropTypes.bool.isRequired,
inError: PropTypes.bool,
network: PropTypes.string,
openToDropdown: PropTypes.func,
@ -25,8 +26,8 @@ export default class SendToRow extends Component {
};
handleToChange (to, nickname = '', toError) {
const { updateSendTo, updateSendToError, updateGas } = this.props
const toErrorObject = getToErrorObject(to, toError)
const { hasHexData, updateSendTo, updateSendToError, updateGas } = this.props
const toErrorObject = getToErrorObject(to, toError, hasHexData)
updateSendTo(to, nickname)
updateSendToError(toErrorObject)
if (toErrorObject.to === null) {

@ -3,6 +3,7 @@ import {
getCurrentNetwork,
getSendTo,
getSendToAccounts,
getSendHexData,
} from '../../send.selectors.js'
import {
getToDropdownOpen,
@ -22,6 +23,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(SendToRow)
function mapStateToProps (state) {
return {
hasHexData: Boolean(getSendHexData(state)),
inError: sendToIsInError(state),
network: getCurrentNetwork(state),
to: getSendTo(state),

@ -4,9 +4,11 @@ const {
} = require('../../send.constants')
const { isValidAddress } = require('../../../../util')
function getToErrorObject (to, toError = null) {
function getToErrorObject (to, toError = null, hasHexData = false) {
if (!to) {
toError = REQUIRED_ERROR
if (!hasHexData) {
toError = REQUIRED_ERROR
}
} else if (!isValidAddress(to) && !toError) {
toError = INVALID_RECIPIENT_ADDRESS_ERROR
}

@ -24,6 +24,7 @@ proxyquire('../send-to-row.container.js', {
},
'../../send.selectors.js': {
getCurrentNetwork: (s) => `mockNetwork:${s}`,
getSendHexData: (s) => s,
getSendTo: (s) => `mockTo:${s}`,
getSendToAccounts: (s) => `mockToAccounts:${s}`,
},
@ -41,6 +42,7 @@ describe('send-to-row container', () => {
it('should map the correct properties to props', () => {
assert.deepEqual(mapStateToProps('mockState'), {
hasHexData: true,
inError: 'mockInError:mockState',
network: 'mockNetwork:mockState',
to: 'mockTo:mockState',

@ -29,6 +29,12 @@ describe('send-to-row utils', () => {
})
})
it('should return null if to is falsy and hexData is truthy', () => {
assert.deepEqual(getToErrorObject(null, undefined, true), {
to: null,
})
})
it('should return an invalid recipient error if to is truthy but invalid', () => {
assert.deepEqual(getToErrorObject('mockInvalidTo'), {
to: INVALID_RECIPIENT_ADDRESS_ERROR,

Loading…
Cancel
Save