Fix naming
This commit is contained in:
parent
2fd52c2be3
commit
8cd3ccd5af
|
@ -134,7 +134,7 @@ export const messageListen = {
|
||||||
|
|
||||||
export const ENS_RECORD = createRequestTypes('ENS_RECORD');
|
export const ENS_RECORD = createRequestTypes('ENS_RECORD');
|
||||||
export const ensRecord = {
|
export const ensRecord = {
|
||||||
resolve: (subdomain) => action(ENS_RECORD[REQUEST], {subdomain}),
|
resolve: (name) => action(ENS_RECORD[REQUEST], {name}),
|
||||||
lookup: (address) => action(ENS_RECORD[REQUEST], {address}),
|
lookup: (address) => action(ENS_RECORD[REQUEST], {address}),
|
||||||
success: (record, payload) => action(ENS_RECORD[SUCCESS], {ensRecords: [Object.assign(payload, record)]}),
|
success: (record, payload) => action(ENS_RECORD[SUCCESS], {ensRecords: [Object.assign(payload, record)]}),
|
||||||
failure: (error) => action(ENS_RECORD[FAILURE], {error})
|
failure: (error) => action(ENS_RECORD[FAILURE], {error})
|
||||||
|
|
|
@ -85,7 +85,7 @@ export function fetchContractProfile(payload) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fetchEnsRecord(payload) {
|
export function fetchEnsRecord(payload) {
|
||||||
if (payload.subdomain) {
|
if (payload.name) {
|
||||||
return get('/ens/resolve', {params: payload});
|
return get('/ens/resolve', {params: payload});
|
||||||
} else {
|
} else {
|
||||||
return get('/ens/lookup', {params: payload});
|
return get('/ens/lookup', {params: payload});
|
||||||
|
|
|
@ -28,9 +28,9 @@ class EnsLookup extends Component {
|
||||||
showResult() {
|
showResult() {
|
||||||
let ensRecord = this.props.ensRecords.find((record) => record.address === this.state.address);
|
let ensRecord = this.props.ensRecords.find((record) => record.address === this.state.address);
|
||||||
if (ensRecord) {
|
if (ensRecord) {
|
||||||
return <Alert type="success">The subdomain is: {ensRecord.subdomain}</Alert>;
|
return <Alert type="success">The name is: {ensRecord.name}</Alert>;
|
||||||
} else {
|
} else {
|
||||||
return <Alert type="danger">We could not find a subdomain for this address</Alert>;
|
return <Alert type="danger">We could not find a name for this address</Alert>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,26 +11,26 @@ class EnsResolve extends Component {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
subdomain: '',
|
name: '',
|
||||||
showResult: false
|
showResult: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
handleChange(e) {
|
handleChange(e) {
|
||||||
this.setState({subdomain: e.target.value, showResult: false});
|
this.setState({name: e.target.value, showResult: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleResolve() {
|
handleResolve() {
|
||||||
this.setState({showResult: true});
|
this.setState({showResult: true});
|
||||||
this.props.resolve(this.state.subdomain);
|
this.props.resolve(this.state.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
showResult() {
|
showResult() {
|
||||||
let ensRecord = this.props.ensRecords.find((record) => record.subdomain === this.state.subdomain);
|
let ensRecord = this.props.ensRecords.find((record) => record.name === this.state.name);
|
||||||
if (ensRecord) {
|
if (ensRecord) {
|
||||||
return <Alert type="success">The address is: {ensRecord.address}</Alert>;
|
return <Alert type="success">The address is: {ensRecord.address}</Alert>;
|
||||||
} else {
|
} else {
|
||||||
return <Alert type="danger">We could not find an address for this subdomain</Alert>;
|
return <Alert type="danger">We could not find an address for this name</Alert>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class EnsResolve extends Component {
|
||||||
<h3>Resolve</h3>
|
<h3>Resolve</h3>
|
||||||
<Form.FieldSet>
|
<Form.FieldSet>
|
||||||
<Form.Group>
|
<Form.Group>
|
||||||
<Form.Input placeholder="Enter a subdomain" onChange={e => this.handleChange(e)}/>
|
<Form.Input placeholder="Enter a name" onChange={e => this.handleChange(e)}/>
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
<Button color="primary" onClick={() => this.handleResolve()}>Resolve</Button>
|
<Button color="primary" onClick={() => this.handleResolve()}>Resolve</Button>
|
||||||
{this.state.showResult && this.showResult()}
|
{this.state.showResult && this.showResult()}
|
||||||
|
|
|
@ -59,8 +59,8 @@ const filtrer = {
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
ensRecords: function(record, index, self) {
|
ensRecords: function(record, index, self) {
|
||||||
return record.subdomain && record.address && record.address !== voidAddress && index === self.findIndex((r) => (
|
return record.name && record.address && record.address !== voidAddress && index === self.findIndex((r) => (
|
||||||
r.address=== record.address && r.subdomain === record.subdomain
|
r.address=== record.address && r.name === record.name
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue