diff --git a/ui/ducks/ens.js b/ui/ducks/ens.js index de72739e6..d2786f1d7 100644 --- a/ui/ducks/ens.js +++ b/ui/ducks/ens.js @@ -92,18 +92,20 @@ const slice = createSlice({ }, disableEnsLookup: (state) => { state.stage = 'NO_NETWORK_SUPPORT'; - state.error = ENS_NOT_SUPPORTED_ON_NETWORK; + state.error = null; state.warning = null; state.resolution = null; state.network = null; }, - resetResolution: (state) => { + ensNotSupported: (state) => { state.resolution = null; state.warning = null; - state.error = - state.stage === 'NO_NETWORK_SUPPORT' - ? ENS_NOT_SUPPORTED_ON_NETWORK - : null; + state.error = ENS_NOT_SUPPORTED_ON_NETWORK; + }, + resetEnsResolution: (state) => { + state.resolution = null; + state.warning = null; + state.error = null; }, }, extraReducers: (builder) => { @@ -123,9 +125,10 @@ const { disableEnsLookup, ensLookup, enableEnsLookup, - resetResolution, + ensNotSupported, + resetEnsResolution, } = actions; -export { resetResolution }; +export { resetEnsResolution }; export function initializeEnsSlice() { return (dispatch, getState) => { @@ -159,7 +162,7 @@ export function lookupEnsName(ensName) { ) && !isHexString(trimmedEnsName) ) { - await dispatch(resetResolution()); + await dispatch(ensNotSupported()); } else { log.info(`ENS attempting to resolve name: ${trimmedEnsName}`); let address; diff --git a/ui/ducks/send/send.js b/ui/ducks/send/send.js index a7a98072e..a7e224175 100644 --- a/ui/ducks/send/send.js +++ b/ui/ducks/send/send.js @@ -78,7 +78,7 @@ import { isValidDomainName, } from '../../helpers/utils/util'; import { getTokens, getUnapprovedTxs } from '../metamask/metamask'; -import { resetResolution } from '../ens'; +import { resetEnsResolution } from '../ens'; import { isBurnAddress, isValidHexAddress, @@ -1284,7 +1284,7 @@ export function resetRecipientInput() { return async (dispatch) => { await dispatch(updateRecipientUserInput('')); await dispatch(updateRecipient({ address: '', nickname: '' })); - await dispatch(resetResolution()); + await dispatch(resetEnsResolution()); await dispatch(validateRecipientUserInput()); }; } diff --git a/ui/ducks/send/send.test.js b/ui/ducks/send/send.test.js index 4b96e7a24..0f72349a9 100644 --- a/ui/ducks/send/send.test.js +++ b/ui/ducks/send/send.test.js @@ -1457,7 +1457,7 @@ describe('Send Slice', () => { ); expect(actionResult[0].payload).toStrictEqual(''); expect(actionResult[1].type).toStrictEqual('send/updateRecipient'); - expect(actionResult[2].type).toStrictEqual('ENS/resetResolution'); + expect(actionResult[2].type).toStrictEqual('ENS/resetEnsResolution'); expect(actionResult[3].type).toStrictEqual( 'send/validateRecipientUserInput', ); diff --git a/ui/pages/send/send-content/add-recipient/ens-input.component.js b/ui/pages/send/send-content/add-recipient/ens-input.component.js index bb1c7f3e7..47d641013 100644 --- a/ui/pages/send/send-content/add-recipient/ens-input.component.js +++ b/ui/pages/send/send-content/add-recipient/ens-input.component.js @@ -62,18 +62,19 @@ export default class EnsInput extends Component { } // Empty ENS state if input is empty // maybe scan ENS - if (isValidDomainName(input)) { lookupEnsName(input); - } else if ( - onValidAddressTyped && - !isBurnAddress(input) && - isValidHexAddress(input, { mixedCaseUseChecksum: true }) - ) { - onValidAddressTyped(input); } else { resetEnsResolution(); + if ( + onValidAddressTyped && + !isBurnAddress(input) && + isValidHexAddress(input, { mixedCaseUseChecksum: true }) + ) { + onValidAddressTyped(input); + } } + return null; }; diff --git a/ui/pages/send/send-content/add-recipient/ens-input.container.js b/ui/pages/send/send-content/add-recipient/ens-input.container.js index ef61fce85..bf0650b0e 100644 --- a/ui/pages/send/send-content/add-recipient/ens-input.container.js +++ b/ui/pages/send/send-content/add-recipient/ens-input.container.js @@ -3,7 +3,7 @@ import { connect } from 'react-redux'; import { lookupEnsName, initializeEnsSlice, - resetResolution, + resetEnsResolution, } from '../../../../ducks/ens'; import EnsInput from './ens-input.component'; @@ -11,7 +11,7 @@ function mapDispatchToProps(dispatch) { return { lookupEnsName: debounce((ensName) => dispatch(lookupEnsName(ensName)), 150), initializeEnsSlice: () => dispatch(initializeEnsSlice()), - resetEnsResolution: debounce(() => dispatch(resetResolution()), 300), + resetEnsResolution: debounce(() => dispatch(resetEnsResolution()), 300), }; } diff --git a/ui/pages/settings/contact-list-tab/add-contact/add-contact.component.js b/ui/pages/settings/contact-list-tab/add-contact/add-contact.component.js index 64e076973..6ce7f06f0 100644 --- a/ui/pages/settings/contact-list-tab/add-contact/add-contact.component.js +++ b/ui/pages/settings/contact-list-tab/add-contact/add-contact.component.js @@ -27,7 +27,7 @@ export default class AddContact extends PureComponent { qrCodeDetected: PropTypes.func, ensResolution: PropTypes.string, ensError: PropTypes.string, - resetResolution: PropTypes.func, + resetEnsResolution: PropTypes.func, }; state = { @@ -88,7 +88,7 @@ export default class AddContact extends PureComponent { this.validate(text); }} onReset={() => { - this.props.resetResolution(); + this.props.resetEnsResolution(); this.setState({ ethAddress: '', input: '' }); }} userInput={this.state.input} diff --git a/ui/pages/settings/contact-list-tab/add-contact/add-contact.container.js b/ui/pages/settings/contact-list-tab/add-contact/add-contact.container.js index 49f4deb70..604b10fee 100644 --- a/ui/pages/settings/contact-list-tab/add-contact/add-contact.container.js +++ b/ui/pages/settings/contact-list-tab/add-contact/add-contact.container.js @@ -10,7 +10,7 @@ import { getQrCodeData } from '../../../../ducks/app/app'; import { getEnsError, getEnsResolution, - resetResolution, + resetEnsResolution, } from '../../../../ducks/ens'; import AddContact from './add-contact.component'; @@ -28,7 +28,7 @@ const mapDispatchToProps = (dispatch) => { dispatch(addToAddressBook(recipient, nickname)), scanQrCode: () => dispatch(showQrScanner()), qrCodeDetected: (data) => dispatch(qrCodeDetected(data)), - resetResolution: () => dispatch(resetResolution()), + resetEnsResolution: () => dispatch(resetEnsResolution()), }; };