diff --git a/embark-ui/src/actions/index.js b/embark-ui/src/actions/index.js
index 5414ef60..0442554e 100644
--- a/embark-ui/src/actions/index.js
+++ b/embark-ui/src/actions/index.js
@@ -143,7 +143,7 @@ export const ensRecord = {
export const ENS_RECORDS = createRequestTypes('ENS_RECORDS');
export const ensRecords = {
post: (subdomain, address) => action(ENS_RECORDS[REQUEST], {subdomain, address}),
- success: (_record, payload) => action(ENS_RECORDS[SUCCESS], {ensRecords: [{subdomain: payload.subdomain, address: payload.address}]}),
+ success: (record) => action(ENS_RECORDS[SUCCESS], {ensRecords: [record]}),
failure: (error) => action(ENS_RECORDS[FAILURE], {error})
};
diff --git a/embark-ui/src/components/EnsRegister.js b/embark-ui/src/components/EnsRegister.js
index 63a40ee7..5024dc0a 100644
--- a/embark-ui/src/components/EnsRegister.js
+++ b/embark-ui/src/components/EnsRegister.js
@@ -30,11 +30,10 @@ class EnsRegister extends Component {
}
showResult() {
- let ensRecord = this.props.ensRecords.find((record) => record.address === this.state.address && record.subdomain === this.state.subdomain);
- if (ensRecord) {
- return Successfully registered;
+ if (this.props.ensErrors) {
+ return An error happened: {this.props.ensErrors};
} else {
- return An error happened;
+ return Successfully registered;
}
}
@@ -65,7 +64,8 @@ class EnsRegister extends Component {
EnsRegister.propTypes = {
register: PropTypes.func,
- ensRecords: PropTypes.arrayOf(PropTypes.object)
+ ensRecords: PropTypes.arrayOf(PropTypes.object),
+ ensErrors: PropTypes.string
};
export default EnsRegister;
diff --git a/embark-ui/src/containers/EnsContainer.js b/embark-ui/src/containers/EnsContainer.js
index 68a15af8..630991f8 100644
--- a/embark-ui/src/containers/EnsContainer.js
+++ b/embark-ui/src/containers/EnsContainer.js
@@ -6,7 +6,7 @@ import {ensRecord, ensRecords} from "../actions";
import EnsRegister from "../components/EnsRegister";
import EnsLookup from "../components/EnsLookup";
import EnsResolve from "../components/EnsResolve";
-import {getEnsRecords, isEnsEnabled} from "../reducers/selectors";
+import {getEnsRecords, isEnsEnabled, getEnsErrors} from "../reducers/selectors";
class EnsContainer extends Component {
@@ -15,7 +15,7 @@ class EnsContainer extends Component {
-
+
);
}
@@ -38,12 +38,14 @@ EnsContainer.propTypes = {
resolve: PropTypes.func,
lookup: PropTypes.func,
register: PropTypes.func,
- isEnsEnabled: PropTypes.bool
+ isEnsEnabled: PropTypes.bool,
+ ensErrors: PropTypes.string
};
function mapStateToProps(state) {
return {
ensRecords: getEnsRecords(state),
+ ensErrors: getEnsErrors(state),
isEnsEnabled: isEnsEnabled(state)
};
}
diff --git a/embark-ui/src/reducers/index.js b/embark-ui/src/reducers/index.js
index 9a070114..64c9b6ef 100644
--- a/embark-ui/src/reducers/index.js
+++ b/embark-ui/src/reducers/index.js
@@ -1,5 +1,5 @@
import {combineReducers} from 'redux';
-import {REQUEST} from "../actions";
+import {REQUEST, SUCCESS} from "../actions";
const BN_FACTOR = 10000;
const voidAddress = '0x0000000000000000000000000000000000000000';
@@ -95,6 +95,20 @@ function errorMessage(state = null, action) {
return action.error || state;
}
+/* eslint multiline-ternary: "off" */
+function errorEntities(state = {}, action) {
+ if (!action.type.endsWith(SUCCESS)) {
+ return state;
+ }
+ let newState = {};
+ for (let name of Object.keys(entitiesDefaultState)) {
+ if (action[name] && action[name].length > 0) {
+ newState[name] = action[name][0].error;
+ }
+ }
+ return {...state, ...newState};
+}
+
function loading(_state = false, action) {
return action.type.endsWith(REQUEST);
}
@@ -102,7 +116,8 @@ function loading(_state = false, action) {
const rootReducer = combineReducers({
entities,
loading,
- errorMessage
+ errorMessage,
+ errorEntities
});
export default rootReducer;
diff --git a/embark-ui/src/reducers/selectors.js b/embark-ui/src/reducers/selectors.js
index aa0e8e43..5b51102c 100644
--- a/embark-ui/src/reducers/selectors.js
+++ b/embark-ui/src/reducers/selectors.js
@@ -98,6 +98,10 @@ export function getEnsRecords(state) {
return state.entities.ensRecords;
}
+export function getEnsErrors(state) {
+ return state.errorEntities.ensRecords;
+}
+
export function isEnsEnabled(state) {
return Boolean(state.entities.plugins.find((plugin) => plugin.name === 'ens'));
}
diff --git a/lib/modules/ens/ENSFunctions.js b/lib/modules/ens/ENSFunctions.js
index a73de580..bde805d7 100644
--- a/lib/modules/ens/ENSFunctions.js
+++ b/lib/modules/ens/ENSFunctions.js
@@ -104,4 +104,3 @@ if (typeof module !== 'undefined' && module.exports) {
lookupAddress
};
}
-;
diff --git a/lib/modules/ens/embarkjs.js b/lib/modules/ens/embarkjs.js
index 2aed0ca1..93cd2b9d 100644
--- a/lib/modules/ens/embarkjs.js
+++ b/lib/modules/ens/embarkjs.js
@@ -1,4 +1,4 @@
-/*global EmbarkJS, web3, lookupAddress, resolveName, registerSubDomain, namehash, reverseAddrSuffix*/
+/*global EmbarkJS, web3, lookupAddress, resolveName, registerSubDomain, reverseAddrSuffix*/
let __embarkENS = {};