|
|
@ -38,6 +38,7 @@ export default class EnsInput extends Component { |
|
|
|
onValidAddressTyped: PropTypes.func, |
|
|
|
onValidAddressTyped: PropTypes.func, |
|
|
|
contact: PropTypes.object, |
|
|
|
contact: PropTypes.object, |
|
|
|
value: PropTypes.string, |
|
|
|
value: PropTypes.string, |
|
|
|
|
|
|
|
internalSearch: PropTypes.bool, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
state = { |
|
|
|
state = { |
|
|
@ -47,11 +48,11 @@ export default class EnsInput extends Component { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
componentDidMount() { |
|
|
|
componentDidMount() { |
|
|
|
const { network } = this.props |
|
|
|
const { network, internalSearch } = this.props |
|
|
|
const networkHasEnsSupport = getNetworkEnsSupport(network) |
|
|
|
const networkHasEnsSupport = getNetworkEnsSupport(network) |
|
|
|
this.setState({ ensResolution: ZERO_ADDRESS }) |
|
|
|
this.setState({ ensResolution: ZERO_ADDRESS }) |
|
|
|
|
|
|
|
|
|
|
|
if (networkHasEnsSupport) { |
|
|
|
if (networkHasEnsSupport && !internalSearch) { |
|
|
|
const provider = global.ethereumProvider |
|
|
|
const provider = global.ethereumProvider |
|
|
|
this.ens = new ENS({ provider, network }) |
|
|
|
this.ens = new ENS({ provider, network }) |
|
|
|
this.checkName = debounce(this.lookupEnsName, 200) |
|
|
|
this.checkName = debounce(this.lookupEnsName, 200) |
|
|
@ -60,7 +61,7 @@ export default class EnsInput extends Component { |
|
|
|
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps) { |
|
|
|
componentDidUpdate(prevProps) { |
|
|
|
const { input } = this.state |
|
|
|
const { input } = this.state |
|
|
|
const { network, value } = this.props |
|
|
|
const { network, value, internalSearch } = this.props |
|
|
|
|
|
|
|
|
|
|
|
let newValue |
|
|
|
let newValue |
|
|
|
|
|
|
|
|
|
|
@ -81,6 +82,9 @@ export default class EnsInput extends Component { |
|
|
|
if (newValue !== undefined) { |
|
|
|
if (newValue !== undefined) { |
|
|
|
this.onChange({ target: { value: newValue } }) |
|
|
|
this.onChange({ target: { value: newValue } }) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!internalSearch && prevProps.internalSearch) { |
|
|
|
|
|
|
|
this.resetInput() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
resetInput = () => { |
|
|
|
resetInput = () => { |
|
|
@ -143,12 +147,15 @@ export default class EnsInput extends Component { |
|
|
|
updateEnsResolution, |
|
|
|
updateEnsResolution, |
|
|
|
updateEnsResolutionError, |
|
|
|
updateEnsResolutionError, |
|
|
|
onValidAddressTyped, |
|
|
|
onValidAddressTyped, |
|
|
|
|
|
|
|
internalSearch, |
|
|
|
} = this.props |
|
|
|
} = this.props |
|
|
|
const input = e.target.value |
|
|
|
const input = e.target.value |
|
|
|
const networkHasEnsSupport = getNetworkEnsSupport(network) |
|
|
|
const networkHasEnsSupport = getNetworkEnsSupport(network) |
|
|
|
|
|
|
|
|
|
|
|
this.setState({ input }, () => onChange(input)) |
|
|
|
this.setState({ input }, () => onChange(input)) |
|
|
|
|
|
|
|
if (internalSearch) { |
|
|
|
|
|
|
|
return null |
|
|
|
|
|
|
|
} |
|
|
|
// Empty ENS state if input is empty
|
|
|
|
// Empty ENS state if input is empty
|
|
|
|
// maybe scan ENS
|
|
|
|
// maybe scan ENS
|
|
|
|
|
|
|
|
|
|
|
@ -161,7 +168,7 @@ export default class EnsInput extends Component { |
|
|
|
updateEnsResolutionError( |
|
|
|
updateEnsResolutionError( |
|
|
|
networkHasEnsSupport ? '' : 'Network does not support ENS', |
|
|
|
networkHasEnsSupport ? '' : 'Network does not support ENS', |
|
|
|
) |
|
|
|
) |
|
|
|
return |
|
|
|
return null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isValidDomainName(input)) { |
|
|
|
if (isValidDomainName(input)) { |
|
|
@ -172,6 +179,7 @@ export default class EnsInput extends Component { |
|
|
|
updateEnsResolution('') |
|
|
|
updateEnsResolution('') |
|
|
|
updateEnsResolutionError('') |
|
|
|
updateEnsResolutionError('') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
render() { |
|
|
|
render() { |
|
|
|