mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix 9649 - Ensure QR codes work properly when adding contact
This commit is contained in:
parent
51187179bb
commit
4892a3e0e1
@ -33,6 +33,7 @@ export default class EnsInput extends Component {
|
|||||||
onReset: PropTypes.func,
|
onReset: PropTypes.func,
|
||||||
onValidAddressTyped: PropTypes.func,
|
onValidAddressTyped: PropTypes.func,
|
||||||
contact: PropTypes.object,
|
contact: PropTypes.object,
|
||||||
|
value: PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
@ -53,16 +54,22 @@ export default class EnsInput extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If an address is sent without a nickname, meaning not from ENS or from
|
|
||||||
// the user's own accounts, a default of a one-space string is used.
|
|
||||||
componentDidUpdate (prevProps) {
|
componentDidUpdate (prevProps) {
|
||||||
const {
|
const {
|
||||||
input,
|
input,
|
||||||
} = this.state
|
} = this.state
|
||||||
const {
|
const {
|
||||||
network,
|
network,
|
||||||
|
value,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
|
// Update the value in state if its prop value changes
|
||||||
|
if (input !== value) {
|
||||||
|
this.setState({ input: value })
|
||||||
|
}
|
||||||
|
|
||||||
|
// If an address is sent without a nickname, meaning not from ENS or from
|
||||||
|
// the user's own accounts, a default of a one-space string is used.
|
||||||
if (prevProps.network !== network) {
|
if (prevProps.network !== network) {
|
||||||
const provider = global.ethereumProvider
|
const provider = global.ethereumProvider
|
||||||
this.ens = new ENS({ provider, network })
|
this.ens = new ENS({ provider, network })
|
||||||
|
@ -52,6 +52,7 @@ export default class AddContact extends PureComponent {
|
|||||||
validate = (address) => {
|
validate = (address) => {
|
||||||
const valid = isValidAddress(address)
|
const valid = isValidAddress(address)
|
||||||
const validEnsAddress = isValidDomainName(address)
|
const validEnsAddress = isValidDomainName(address)
|
||||||
|
|
||||||
if (valid || validEnsAddress || address === '') {
|
if (valid || validEnsAddress || address === '') {
|
||||||
this.setState({ error: '', ethAddress: address })
|
this.setState({ error: '', ethAddress: address })
|
||||||
} else {
|
} else {
|
||||||
@ -73,6 +74,7 @@ export default class AddContact extends PureComponent {
|
|||||||
this.setState({ ensAddress: address, error: '', ensError: '' })
|
this.setState({ ensAddress: address, error: '', ensError: '' })
|
||||||
}}
|
}}
|
||||||
updateEnsResolutionError={(message) => this.setState({ ensError: message })}
|
updateEnsResolutionError={(message) => this.setState({ ensError: message })}
|
||||||
|
value={this.state.ethAddress || ''}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user