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