From e1043bf5f5420a27f09ec498db2471208948cb94 Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Tue, 14 Aug 2018 11:31:58 +0100 Subject: [PATCH] Use subdomain --- embark-ui/src/actions/index.js | 7 +++---- embark-ui/src/api/index.js | 2 +- embark-ui/src/components/EnsLookup.js | 4 ++-- embark-ui/src/components/EnsRegister.js | 8 ++++---- embark-ui/src/components/EnsResolve.js | 10 +++++----- embark-ui/src/reducers/index.js | 4 ++-- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/embark-ui/src/actions/index.js b/embark-ui/src/actions/index.js index 5871682d7..d4c4e61ab 100644 --- a/embark-ui/src/actions/index.js +++ b/embark-ui/src/actions/index.js @@ -134,7 +134,7 @@ export const messageListen = { export const ENS_RECORD = createRequestTypes('ENS_RECORD'); export const ensRecord = { - resolve: (name) => action(ENS_RECORD[REQUEST], {name}), + resolve: (subdomain) => action(ENS_RECORD[REQUEST], {subdomain}), lookup: (address) => action(ENS_RECORD[REQUEST], {address}), success: (record, payload) => action(ENS_RECORD[SUCCESS], {ensRecords: [Object.assign(payload, record)]}), failure: (error) => action(ENS_RECORD[FAILURE], {error}) @@ -142,12 +142,11 @@ export const ensRecord = { export const ENS_RECORDS = createRequestTypes('ENS_RECORDS'); export const ensRecords = { - post: (name, address) => action(ENS_RECORDS[REQUEST], {name, address}), - success: (_record, payload) => action(ENS_RECORDS[SUCCESS], {ensRecords: [{name: payload.name, address: payload.address}]}), + post: (subdomain, address) => action(ENS_RECORDS[REQUEST], {subdomain, address}), + success: (_record, payload) => action(ENS_RECORDS[SUCCESS], {ensRecords: [{subdomain: payload.subdomain, address: payload.address}]}), failure: (error) => action(ENS_RECORDS[FAILURE], {error}) }; - export const FIDDLE = createRequestTypes('FIDDLE'); export const fiddle = { request: (codeToCompile) => action(FIDDLE[REQUEST], {codeToCompile}), diff --git a/embark-ui/src/api/index.js b/embark-ui/src/api/index.js index 7bdc21e4a..58f65022b 100644 --- a/embark-ui/src/api/index.js +++ b/embark-ui/src/api/index.js @@ -85,7 +85,7 @@ export function fetchContractProfile(payload) { } export function fetchEnsRecord(payload) { - if (payload.name) { + if (payload.subdomain) { return get('/ens/resolve', {params: payload}); } else { return get('/ens/lookup', {params: payload}); diff --git a/embark-ui/src/components/EnsLookup.js b/embark-ui/src/components/EnsLookup.js index b8446b7f3..3cb48024b 100644 --- a/embark-ui/src/components/EnsLookup.js +++ b/embark-ui/src/components/EnsLookup.js @@ -28,9 +28,9 @@ class EnsLookup extends Component { showResult() { let ensRecord = this.props.ensRecords.find((record) => record.address === this.state.address); if (ensRecord) { - return The name is: {ensRecord.name}; + return The subdomain is: {ensRecord.subdomain}; } else { - return We could not find a name for this address; + return We could not find a subdomain for this address; } } diff --git a/embark-ui/src/components/EnsRegister.js b/embark-ui/src/components/EnsRegister.js index e9ce3858a..63a40ee71 100644 --- a/embark-ui/src/components/EnsRegister.js +++ b/embark-ui/src/components/EnsRegister.js @@ -11,7 +11,7 @@ class EnsRegister extends Component { super(props); this.state = { - name: '', + subdomain: '', address: '', showResult: false }; @@ -25,12 +25,12 @@ class EnsRegister extends Component { } handleRegister() { - this.props.register(this.state.name, this.state.address); + this.props.register(this.state.subdomain, this.state.address); this.setState({showResult: true}); } showResult() { - let ensRecord = this.props.ensRecords.find((record) => record.address === this.state.address && record.name === this.state.name); + let ensRecord = this.props.ensRecords.find((record) => record.address === this.state.address && record.subdomain === this.state.subdomain); if (ensRecord) { return Successfully registered; } else { @@ -46,7 +46,7 @@ class EnsRegister extends Component { - this.handleChange(e, "name")}/> + this.handleChange(e, "subdomain")}/> diff --git a/embark-ui/src/components/EnsResolve.js b/embark-ui/src/components/EnsResolve.js index 879bacbde..7428e938a 100644 --- a/embark-ui/src/components/EnsResolve.js +++ b/embark-ui/src/components/EnsResolve.js @@ -11,26 +11,26 @@ class EnsResolve extends Component { super(props); this.state = { - name: '', + subdomain: '', showResult: false }; } handleChange(e) { - this.setState({name: e.target.value, showResult: false}); + this.setState({subdomain: e.target.value, showResult: false}); } handleResolve() { this.setState({showResult: true}); - this.props.resolve(this.state.name); + this.props.resolve(this.state.subdomain); } showResult() { - let ensRecord = this.props.ensRecords.find((record) => record.name === this.state.name); + let ensRecord = this.props.ensRecords.find((record) => record.subdomain === this.state.subdomain); if (ensRecord) { return The address is: {ensRecord.address}; } else { - return We could not find an address for this name; + return We could not find an address for this subdomain; } } diff --git a/embark-ui/src/reducers/index.js b/embark-ui/src/reducers/index.js index 9a0701148..194ae32df 100644 --- a/embark-ui/src/reducers/index.js +++ b/embark-ui/src/reducers/index.js @@ -59,8 +59,8 @@ const filtrer = { )); }, ensRecords: function(record, index, self) { - return record.name && record.address && record.address !== voidAddress && index === self.findIndex((r) => ( - r.address=== record.address && r.name === record.name + return record.subdomain && record.address && record.address !== voidAddress && index === self.findIndex((r) => ( + r.address=== record.address && r.subdomain === record.subdomain )); } };