aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/pages/send/send-content/send-to-row
diff options
context:
space:
mode:
authorDan Finlay <542863+danfinlay@users.noreply.github.com>2019-08-07 05:53:50 +0800
committerGitHub <noreply@github.com>2019-08-07 05:53:50 +0800
commitdb08881d4527e8a037f401ef22b849e52152864f (patch)
tree6032d7a4ae67371889eece1d8490c26d5a119dd5 /ui/app/pages/send/send-content/send-to-row
parent4139019d0f4dd83f56da400ca7e0e6d1976d1716 (diff)
parent86ad9564a064fd6158dab6a3c9e5b10614ef6e68 (diff)
downloadtangerine-wallet-browser-db08881d4527e8a037f401ef22b849e52152864f.tar.gz
tangerine-wallet-browser-db08881d4527e8a037f401ef22b849e52152864f.tar.zst
tangerine-wallet-browser-db08881d4527e8a037f401ef22b849e52152864f.zip
Merge pull request #6969 from MetaMask/developv7.0.0
Master Version Bump
Diffstat (limited to 'ui/app/pages/send/send-content/send-to-row')
-rw-r--r--ui/app/pages/send/send-content/send-to-row/index.js1
-rw-r--r--ui/app/pages/send/send-content/send-to-row/send-to-row-README.md0
-rw-r--r--ui/app/pages/send/send-content/send-to-row/send-to-row.component.js91
-rw-r--r--ui/app/pages/send/send-content/send-to-row/send-to-row.container.js54
-rw-r--r--ui/app/pages/send/send-content/send-to-row/send-to-row.selectors.js24
-rw-r--r--ui/app/pages/send/send-content/send-to-row/send-to-row.utils.js35
-rw-r--r--ui/app/pages/send/send-content/send-to-row/tests/send-to-row-component.test.js166
-rw-r--r--ui/app/pages/send/send-content/send-to-row/tests/send-to-row-container.test.js134
-rw-r--r--ui/app/pages/send/send-content/send-to-row/tests/send-to-row-selectors.test.js59
-rw-r--r--ui/app/pages/send/send-content/send-to-row/tests/send-to-row-utils.test.js107
10 files changed, 0 insertions, 671 deletions
diff --git a/ui/app/pages/send/send-content/send-to-row/index.js b/ui/app/pages/send/send-content/send-to-row/index.js
deleted file mode 100644
index 121f15148..000000000
--- a/ui/app/pages/send/send-content/send-to-row/index.js
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from './send-to-row.container'
diff --git a/ui/app/pages/send/send-content/send-to-row/send-to-row-README.md b/ui/app/pages/send/send-content/send-to-row/send-to-row-README.md
deleted file mode 100644
index e69de29bb..000000000
--- a/ui/app/pages/send/send-content/send-to-row/send-to-row-README.md
+++ /dev/null
diff --git a/ui/app/pages/send/send-content/send-to-row/send-to-row.component.js b/ui/app/pages/send/send-content/send-to-row/send-to-row.component.js
deleted file mode 100644
index 9baf327c1..000000000
--- a/ui/app/pages/send/send-content/send-to-row/send-to-row.component.js
+++ /dev/null
@@ -1,91 +0,0 @@
-import React, { Component } from 'react'
-import PropTypes from 'prop-types'
-import SendRowWrapper from '../send-row-wrapper'
-import EnsInput from '../../../../components/app/ens-input'
-import { getToErrorObject, getToWarningObject } from './send-to-row.utils.js'
-
-export default class SendToRow extends Component {
-
- static propTypes = {
- closeToDropdown: PropTypes.func,
- hasHexData: PropTypes.bool.isRequired,
- inError: PropTypes.bool,
- inWarning: PropTypes.bool,
- network: PropTypes.string,
- openToDropdown: PropTypes.func,
- selectedToken: PropTypes.object,
- to: PropTypes.string,
- toAccounts: PropTypes.array,
- toDropdownOpen: PropTypes.bool,
- tokens: PropTypes.array,
- updateGas: PropTypes.func,
- updateSendTo: PropTypes.func,
- updateSendToError: PropTypes.func,
- updateSendToWarning: PropTypes.func,
- scanQrCode: PropTypes.func,
- }
-
- static contextTypes = {
- t: PropTypes.func,
- metricsEvent: PropTypes.func,
- }
-
- handleToChange (to, nickname = '', toError, toWarning, network) {
- const { hasHexData, updateSendTo, updateSendToError, updateGas, tokens, selectedToken, updateSendToWarning } = this.props
- const toErrorObject = getToErrorObject(to, toError, hasHexData, tokens, selectedToken, network)
- const toWarningObject = getToWarningObject(to, toWarning, tokens, selectedToken)
- updateSendTo(to, nickname)
- updateSendToError(toErrorObject)
- updateSendToWarning(toWarningObject)
- if (toErrorObject.to === null) {
- updateGas({ to })
- }
- }
-
- render () {
- const {
- closeToDropdown,
- inError,
- inWarning,
- network,
- openToDropdown,
- to,
- toAccounts,
- toDropdownOpen,
- } = this.props
-
- return (
- <SendRowWrapper
- errorType={'to'}
- label={`${this.context.t('to')}: `}
- showError={inError}
- showWarning={inWarning}
- warningType={'to'}
- >
- <EnsInput
- scanQrCode={_ => {
- this.context.metricsEvent({
- eventOpts: {
- category: 'Transactions',
- action: 'Edit Screen',
- name: 'Used QR scanner',
- },
- })
- this.props.scanQrCode()
- }}
- accounts={toAccounts}
- closeDropdown={() => closeToDropdown()}
- dropdownOpen={toDropdownOpen}
- inError={inError}
- name={'address'}
- network={network}
- onChange={({ toAddress, nickname, toError, toWarning }) => this.handleToChange(toAddress, nickname, toError, toWarning, this.props.network)}
- openDropdown={() => openToDropdown()}
- placeholder={this.context.t('recipientAddress')}
- to={to}
- />
- </SendRowWrapper>
- )
- }
-
-}
diff --git a/ui/app/pages/send/send-content/send-to-row/send-to-row.container.js b/ui/app/pages/send/send-content/send-to-row/send-to-row.container.js
deleted file mode 100644
index 2cbe9fcd0..000000000
--- a/ui/app/pages/send/send-content/send-to-row/send-to-row.container.js
+++ /dev/null
@@ -1,54 +0,0 @@
-import { connect } from 'react-redux'
-import {
- getCurrentNetwork,
- getSelectedToken,
- getSendTo,
- getSendToAccounts,
- getSendHexData,
-} from '../../send.selectors.js'
-import {
- getToDropdownOpen,
- getTokens,
- sendToIsInError,
- sendToIsInWarning,
-} from './send-to-row.selectors.js'
-import {
- updateSendTo,
-} from '../../../../store/actions'
-import {
- updateSendErrors,
- updateSendWarnings,
- openToDropdown,
- closeToDropdown,
-} from '../../../../ducks/send/send.duck'
-import SendToRow from './send-to-row.component'
-
-export default connect(mapStateToProps, mapDispatchToProps)(SendToRow)
-
-function mapStateToProps (state) {
- return {
- hasHexData: Boolean(getSendHexData(state)),
- inError: sendToIsInError(state),
- inWarning: sendToIsInWarning(state),
- network: getCurrentNetwork(state),
- selectedToken: getSelectedToken(state),
- to: getSendTo(state),
- toAccounts: getSendToAccounts(state),
- toDropdownOpen: getToDropdownOpen(state),
- tokens: getTokens(state),
- }
-}
-
-function mapDispatchToProps (dispatch) {
- return {
- closeToDropdown: () => dispatch(closeToDropdown()),
- openToDropdown: () => dispatch(openToDropdown()),
- updateSendTo: (to, nickname) => dispatch(updateSendTo(to, nickname)),
- updateSendToError: (toErrorObject) => {
- dispatch(updateSendErrors(toErrorObject))
- },
- updateSendToWarning: (toWarningObject) => {
- dispatch(updateSendWarnings(toWarningObject))
- },
- }
-}
diff --git a/ui/app/pages/send/send-content/send-to-row/send-to-row.selectors.js b/ui/app/pages/send/send-content/send-to-row/send-to-row.selectors.js
deleted file mode 100644
index a6160d335..000000000
--- a/ui/app/pages/send/send-content/send-to-row/send-to-row.selectors.js
+++ /dev/null
@@ -1,24 +0,0 @@
-const selectors = {
- getToDropdownOpen,
- getTokens,
- sendToIsInError,
- sendToIsInWarning,
-}
-
-module.exports = selectors
-
-function getToDropdownOpen (state) {
- return state.send.toDropdownOpen
-}
-
-function sendToIsInError (state) {
- return Boolean(state.send.errors.to)
-}
-
-function sendToIsInWarning (state) {
- return Boolean(state.send.warnings.to)
-}
-
-function getTokens (state) {
- return state.metamask.tokens
-}
diff --git a/ui/app/pages/send/send-content/send-to-row/send-to-row.utils.js b/ui/app/pages/send/send-content/send-to-row/send-to-row.utils.js
deleted file mode 100644
index b3b0d2da3..000000000
--- a/ui/app/pages/send/send-content/send-to-row/send-to-row.utils.js
+++ /dev/null
@@ -1,35 +0,0 @@
-const {
- REQUIRED_ERROR,
- INVALID_RECIPIENT_ADDRESS_ERROR,
- KNOWN_RECIPIENT_ADDRESS_ERROR,
- INVALID_RECIPIENT_ADDRESS_NOT_ETH_NETWORK_ERROR,
-} = require('../../send.constants')
-const { isValidAddress, isEthNetwork } = require('../../../../helpers/utils/util')
-import { checkExistingAddresses } from '../../../add-token/util'
-
-const ethUtil = require('ethereumjs-util')
-const contractMap = require('eth-contract-metadata')
-
-function getToErrorObject (to, toError = null, hasHexData = false, _, __, network) {
- if (!to) {
- if (!hasHexData) {
- toError = REQUIRED_ERROR
- }
- } else if (!isValidAddress(to, network) && !toError) {
- toError = isEthNetwork(network) ? INVALID_RECIPIENT_ADDRESS_ERROR : INVALID_RECIPIENT_ADDRESS_NOT_ETH_NETWORK_ERROR
- }
-
- return { to: toError }
-}
-
-function getToWarningObject (to, toWarning = null, tokens = [], selectedToken = null) {
- if (selectedToken && (ethUtil.toChecksumAddress(to) in contractMap || checkExistingAddresses(to, tokens))) {
- toWarning = KNOWN_RECIPIENT_ADDRESS_ERROR
- }
- return { to: toWarning }
-}
-
-module.exports = {
- getToErrorObject,
- getToWarningObject,
-}
diff --git a/ui/app/pages/send/send-content/send-to-row/tests/send-to-row-component.test.js b/ui/app/pages/send/send-content/send-to-row/tests/send-to-row-component.test.js
deleted file mode 100644
index c180d97f1..000000000
--- a/ui/app/pages/send/send-content/send-to-row/tests/send-to-row-component.test.js
+++ /dev/null
@@ -1,166 +0,0 @@
-import React from 'react'
-import assert from 'assert'
-import { shallow } from 'enzyme'
-import sinon from 'sinon'
-import proxyquire from 'proxyquire'
-
-const SendToRow = proxyquire('../send-to-row.component.js', {
- './send-to-row.utils.js': {
- getToErrorObject: (to, toError) => ({
- to: to === false ? null : `mockToErrorObject:${to}${toError}`,
- }),
- getToWarningObject: (to, toWarning) => ({
- to: to === false ? null : `mockToWarningObject:${to}${toWarning}`,
- }),
- },
-}).default
-
-import SendRowWrapper from '../../send-row-wrapper/send-row-wrapper.component'
-import EnsInput from '../../../../../components/app/ens-input'
-
-const propsMethodSpies = {
- closeToDropdown: sinon.spy(),
- openToDropdown: sinon.spy(),
- updateGas: sinon.spy(),
- updateSendTo: sinon.spy(),
- updateSendToError: sinon.spy(),
- updateSendToWarning: sinon.spy(),
-}
-
-sinon.spy(SendToRow.prototype, 'handleToChange')
-
-describe('SendToRow Component', function () {
- let wrapper
- let instance
-
- beforeEach(() => {
- wrapper = shallow(<SendToRow
- closeToDropdown={propsMethodSpies.closeToDropdown}
- inError={false}
- inWarning={false}
- network={'mockNetwork'}
- openToDropdown={propsMethodSpies.openToDropdown}
- to={'mockTo'}
- toAccounts={['mockAccount']}
- toDropdownOpen={false}
- updateGas={propsMethodSpies.updateGas}
- updateSendTo={propsMethodSpies.updateSendTo}
- updateSendToError={propsMethodSpies.updateSendToError}
- updateSendToWarning={propsMethodSpies.updateSendToWarning}
- />, { context: { t: str => str + '_t' } })
- instance = wrapper.instance()
- })
-
- afterEach(() => {
- propsMethodSpies.closeToDropdown.resetHistory()
- propsMethodSpies.openToDropdown.resetHistory()
- propsMethodSpies.updateSendTo.resetHistory()
- propsMethodSpies.updateSendToError.resetHistory()
- propsMethodSpies.updateSendToWarning.resetHistory()
- SendToRow.prototype.handleToChange.resetHistory()
- })
-
- describe('handleToChange', () => {
-
- it('should call updateSendTo', () => {
- assert.equal(propsMethodSpies.updateSendTo.callCount, 0)
- instance.handleToChange('mockTo2', 'mockNickname')
- assert.equal(propsMethodSpies.updateSendTo.callCount, 1)
- assert.deepEqual(
- propsMethodSpies.updateSendTo.getCall(0).args,
- ['mockTo2', 'mockNickname']
- )
- })
-
- it('should call updateSendToError', () => {
- assert.equal(propsMethodSpies.updateSendToError.callCount, 0)
- instance.handleToChange('mockTo2', '', 'mockToError')
- assert.equal(propsMethodSpies.updateSendToError.callCount, 1)
- assert.deepEqual(
- propsMethodSpies.updateSendToError.getCall(0).args,
- [{ to: 'mockToErrorObject:mockTo2mockToError' }]
- )
- })
-
- it('should call updateSendToWarning', () => {
- assert.equal(propsMethodSpies.updateSendToWarning.callCount, 0)
- instance.handleToChange('mockTo2', '', '', 'mockToWarning')
- assert.equal(propsMethodSpies.updateSendToWarning.callCount, 1)
- assert.deepEqual(
- propsMethodSpies.updateSendToWarning.getCall(0).args,
- [{ to: 'mockToWarningObject:mockTo2mockToWarning' }]
- )
- })
-
- it('should not call updateGas if there is a to error', () => {
- assert.equal(propsMethodSpies.updateGas.callCount, 0)
- instance.handleToChange('mockTo2')
- assert.equal(propsMethodSpies.updateGas.callCount, 0)
- })
-
- it('should call updateGas if there is no to error', () => {
- assert.equal(propsMethodSpies.updateGas.callCount, 0)
- instance.handleToChange(false)
- assert.equal(propsMethodSpies.updateGas.callCount, 1)
- })
- })
-
- describe('render', () => {
- it('should render a SendRowWrapper component', () => {
- assert.equal(wrapper.find(SendRowWrapper).length, 1)
- })
-
- it('should pass the correct props to SendRowWrapper', () => {
- const {
- errorType,
- label,
- showError,
- } = wrapper.find(SendRowWrapper).props()
-
- assert.equal(errorType, 'to')
-
- assert.equal(label, 'to_t: ')
-
- assert.equal(showError, false)
- })
-
- it('should render an EnsInput as a child of the SendRowWrapper', () => {
- assert(wrapper.find(SendRowWrapper).childAt(0).is(EnsInput))
- })
-
- it('should render the EnsInput with the correct props', () => {
- const {
- accounts,
- closeDropdown,
- dropdownOpen,
- inError,
- name,
- network,
- onChange,
- openDropdown,
- placeholder,
- to,
- } = wrapper.find(SendRowWrapper).childAt(0).props()
- assert.deepEqual(accounts, ['mockAccount'])
- assert.equal(dropdownOpen, false)
- assert.equal(inError, false)
- assert.equal(name, 'address')
- assert.equal(network, 'mockNetwork')
- assert.equal(placeholder, 'recipientAddress_t')
- assert.equal(to, 'mockTo')
- assert.equal(propsMethodSpies.closeToDropdown.callCount, 0)
- closeDropdown()
- assert.equal(propsMethodSpies.closeToDropdown.callCount, 1)
- assert.equal(propsMethodSpies.openToDropdown.callCount, 0)
- openDropdown()
- assert.equal(propsMethodSpies.openToDropdown.callCount, 1)
- assert.equal(SendToRow.prototype.handleToChange.callCount, 0)
- onChange({ toAddress: 'mockNewTo', nickname: 'mockNewNickname', toError: 'mockToError', toWarning: 'mockToWarning' })
- assert.equal(SendToRow.prototype.handleToChange.callCount, 1)
- assert.deepEqual(
- SendToRow.prototype.handleToChange.getCall(0).args,
- ['mockNewTo', 'mockNewNickname', 'mockToError', 'mockToWarning', 'mockNetwork' ]
- )
- })
- })
-})
diff --git a/ui/app/pages/send/send-content/send-to-row/tests/send-to-row-container.test.js b/ui/app/pages/send/send-content/send-to-row/tests/send-to-row-container.test.js
deleted file mode 100644
index bb8702e9a..000000000
--- a/ui/app/pages/send/send-content/send-to-row/tests/send-to-row-container.test.js
+++ /dev/null
@@ -1,134 +0,0 @@
-import assert from 'assert'
-import proxyquire from 'proxyquire'
-import sinon from 'sinon'
-
-let mapStateToProps
-let mapDispatchToProps
-
-const actionSpies = {
- updateSendTo: sinon.spy(),
-}
-const duckActionSpies = {
- closeToDropdown: sinon.spy(),
- openToDropdown: sinon.spy(),
- updateSendErrors: sinon.spy(),
- updateSendWarnings: sinon.spy(),
-}
-
-proxyquire('../send-to-row.container.js', {
- 'react-redux': {
- connect: (ms, md) => {
- mapStateToProps = ms
- mapDispatchToProps = md
- return () => ({})
- },
- },
- '../../send.selectors.js': {
- getCurrentNetwork: (s) => `mockNetwork:${s}`,
- getSelectedToken: (s) => `mockSelectedToken:${s}`,
- getSendHexData: (s) => s,
- getSendTo: (s) => `mockTo:${s}`,
- getSendToAccounts: (s) => `mockToAccounts:${s}`,
- },
- './send-to-row.selectors.js': {
- getToDropdownOpen: (s) => `mockToDropdownOpen:${s}`,
- sendToIsInError: (s) => `mockInError:${s}`,
- sendToIsInWarning: (s) => `mockInWarning:${s}`,
- getTokens: (s) => `mockTokens:${s}`,
- },
- '../../../../store/actions': actionSpies,
- '../../../../ducks/send/send.duck': duckActionSpies,
-})
-
-describe('send-to-row container', () => {
-
- describe('mapStateToProps()', () => {
-
- it('should map the correct properties to props', () => {
- assert.deepEqual(mapStateToProps('mockState'), {
- hasHexData: true,
- inError: 'mockInError:mockState',
- inWarning: 'mockInWarning:mockState',
- network: 'mockNetwork:mockState',
- selectedToken: 'mockSelectedToken:mockState',
- to: 'mockTo:mockState',
- toAccounts: 'mockToAccounts:mockState',
- toDropdownOpen: 'mockToDropdownOpen:mockState',
- tokens: 'mockTokens:mockState',
- })
- })
-
- })
-
- describe('mapDispatchToProps()', () => {
- let dispatchSpy
- let mapDispatchToPropsObject
-
- beforeEach(() => {
- dispatchSpy = sinon.spy()
- mapDispatchToPropsObject = mapDispatchToProps(dispatchSpy)
- })
-
- describe('closeToDropdown()', () => {
- it('should dispatch an action', () => {
- mapDispatchToPropsObject.closeToDropdown()
- assert(dispatchSpy.calledOnce)
- assert(duckActionSpies.closeToDropdown.calledOnce)
- assert.equal(
- duckActionSpies.closeToDropdown.getCall(0).args[0],
- undefined
- )
- })
- })
-
- describe('openToDropdown()', () => {
- it('should dispatch an action', () => {
- mapDispatchToPropsObject.openToDropdown()
- assert(dispatchSpy.calledOnce)
- assert(duckActionSpies.openToDropdown.calledOnce)
- assert.equal(
- duckActionSpies.openToDropdown.getCall(0).args[0],
- undefined
- )
- })
- })
-
- describe('updateSendTo()', () => {
- it('should dispatch an action', () => {
- mapDispatchToPropsObject.updateSendTo('mockTo', 'mockNickname')
- assert(dispatchSpy.calledOnce)
- assert(actionSpies.updateSendTo.calledOnce)
- assert.deepEqual(
- actionSpies.updateSendTo.getCall(0).args,
- ['mockTo', 'mockNickname']
- )
- })
- })
-
- describe('updateSendToError()', () => {
- it('should dispatch an action', () => {
- mapDispatchToPropsObject.updateSendToError('mockToErrorObject')
- assert(dispatchSpy.calledOnce)
- assert(duckActionSpies.updateSendErrors.calledOnce)
- assert.equal(
- duckActionSpies.updateSendErrors.getCall(0).args[0],
- 'mockToErrorObject'
- )
- })
- })
-
- describe('updateSendToWarning()', () => {
- it('should dispatch an action', () => {
- mapDispatchToPropsObject.updateSendToWarning('mockToWarningObject')
- assert(dispatchSpy.calledOnce)
- assert(duckActionSpies.updateSendWarnings.calledOnce)
- assert.equal(
- duckActionSpies.updateSendWarnings.getCall(0).args[0],
- 'mockToWarningObject'
- )
- })
- })
-
- })
-
-})
diff --git a/ui/app/pages/send/send-content/send-to-row/tests/send-to-row-selectors.test.js b/ui/app/pages/send/send-content/send-to-row/tests/send-to-row-selectors.test.js
deleted file mode 100644
index 0fa342d1e..000000000
--- a/ui/app/pages/send/send-content/send-to-row/tests/send-to-row-selectors.test.js
+++ /dev/null
@@ -1,59 +0,0 @@
-import assert from 'assert'
-import {
- getToDropdownOpen,
- getTokens,
- sendToIsInError,
-} from '../send-to-row.selectors.js'
-
-describe('send-to-row selectors', () => {
-
- describe('getToDropdownOpen()', () => {
- it('should return send.getToDropdownOpen', () => {
- const state = {
- send: {
- toDropdownOpen: false,
- },
- }
-
- assert.equal(getToDropdownOpen(state), false)
- })
- })
-
- describe('sendToIsInError()', () => {
- it('should return true if send.errors.to is truthy', () => {
- const state = {
- send: {
- errors: {
- to: 'abc',
- },
- },
- }
-
- assert.equal(sendToIsInError(state), true)
- })
-
- it('should return false if send.errors.to is falsy', () => {
- const state = {
- send: {
- errors: {
- to: null,
- },
- },
- }
-
- assert.equal(sendToIsInError(state), false)
- })
- })
-
- describe('getTokens()', () => {
- it('should return empty array if no tokens in state', () => {
- const state = {
- metamask: {
- tokens: [],
- },
- }
-
- assert.deepStrictEqual(getTokens(state), [])
- })
- })
-})
diff --git a/ui/app/pages/send/send-content/send-to-row/tests/send-to-row-utils.test.js b/ui/app/pages/send/send-content/send-to-row/tests/send-to-row-utils.test.js
deleted file mode 100644
index f8a6dd96f..000000000
--- a/ui/app/pages/send/send-content/send-to-row/tests/send-to-row-utils.test.js
+++ /dev/null
@@ -1,107 +0,0 @@
-import assert from 'assert'
-import proxyquire from 'proxyquire'
-import sinon from 'sinon'
-
-import {
- REQUIRED_ERROR,
- INVALID_RECIPIENT_ADDRESS_ERROR,
- KNOWN_RECIPIENT_ADDRESS_ERROR,
-} from '../../../send.constants'
-
-const stubs = {
- isValidAddress: sinon.stub().callsFake(to => Boolean(to.match(/^[0xabcdef123456798]+$/))),
-}
-
-const toRowUtils = proxyquire('../send-to-row.utils.js', {
- '../../../../helpers/utils/util': {
- isValidAddress: stubs.isValidAddress,
- },
-})
-const {
- getToErrorObject,
- getToWarningObject,
-} = toRowUtils
-
-describe('send-to-row utils', () => {
-
- describe('getToErrorObject()', () => {
- it('should return a required error if to is falsy', () => {
- assert.deepEqual(getToErrorObject(null), {
- to: REQUIRED_ERROR,
- })
- })
-
- 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,
- })
- })
-
- it('should return null if to is truthy and valid', () => {
- assert.deepEqual(getToErrorObject('0xabc123'), {
- to: null,
- })
- })
-
- it('should return the passed error if to is truthy but invalid if to is truthy and valid', () => {
- assert.deepEqual(getToErrorObject('invalid #$ 345878', 'someExplicitError'), {
- to: 'someExplicitError',
- })
- })
-
- it('should return null if to is truthy but part of state tokens', () => {
- assert.deepEqual(getToErrorObject('0xabc123', undefined, false, [{'address': '0xabc123'}], {'address': '0xabc123'}), {
- to: null,
- })
- })
-
- it('should null if to is truthy part of tokens but selectedToken falsy', () => {
- assert.deepEqual(getToErrorObject('0xabc123', undefined, false, [{'address': '0xabc123'}]), {
- to: null,
- })
- })
-
- it('should return null if to is truthy but part of contract metadata', () => {
- assert.deepEqual(getToErrorObject('0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359', undefined, false, [{'address': '0xabc123'}], {'address': '0xabc123'}), {
- to: null,
- })
- })
- it('should null if to is truthy part of contract metadata but selectedToken falsy', () => {
- assert.deepEqual(getToErrorObject('0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359', undefined, false, [{'address': '0xabc123'}], {'address': '0xabc123'}), {
- to: null,
- })
- })
- })
-
- describe('getToWarningObject()', () => {
- it('should return a known address recipient if to is truthy but part of state tokens', () => {
- assert.deepEqual(getToWarningObject('0xabc123', undefined, [{'address': '0xabc123'}], {'address': '0xabc123'}), {
- to: KNOWN_RECIPIENT_ADDRESS_ERROR,
- })
- })
-
- it('should null if to is truthy part of tokens but selectedToken falsy', () => {
- assert.deepEqual(getToWarningObject('0xabc123', undefined, [{'address': '0xabc123'}]), {
- to: null,
- })
- })
-
- it('should return a known address recipient if to is truthy but part of contract metadata', () => {
- assert.deepEqual(getToWarningObject('0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359', undefined, [{'address': '0xabc123'}], {'address': '0xabc123'}), {
- to: KNOWN_RECIPIENT_ADDRESS_ERROR,
- })
- })
- it('should null if to is truthy part of contract metadata but selectedToken falsy', () => {
- assert.deepEqual(getToWarningObject('0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359', undefined, [{'address': '0xabc123'}], {'address': '0xabc123'}), {
- to: KNOWN_RECIPIENT_ADDRESS_ERROR,
- })
- })
- })
-
-})