diff --git a/js/src/contracts/badgereg.js b/js/src/contracts/badgereg.js index 45f7df315..629add3a4 100644 --- a/js/src/contracts/badgereg.js +++ b/js/src/contracts/badgereg.js @@ -53,7 +53,7 @@ export default class BadgeReg { name = name === ZERO32 ? null : hex2Ascii(name); return this.fetchMeta(id) .then(({ title, icon }) => { - const data = { address, name, title, icon }; + const data = { address, id, name, title, icon }; this.certifiers[id] = data; return data; }); diff --git a/js/src/redux/providers/certifications/actions.js b/js/src/redux/providers/certifications/actions.js index a8cc43f03..d0c2d56f4 100644 --- a/js/src/redux/providers/certifications/actions.js +++ b/js/src/redux/providers/certifications/actions.js @@ -22,6 +22,10 @@ export const fetchCertifications = (address) => ({ type: 'fetchCertifications', address }); -export const addCertification = (address, name, title, icon) => ({ - type: 'addCertification', address, name, title, icon +export const addCertification = (address, id, name, title, icon) => ({ + type: 'addCertification', address, id, name, title, icon +}); + +export const removeCertification = (address, id, name, title, icon) => ({ + type: 'removeCertification', address, id, name, title, icon }); diff --git a/js/src/redux/providers/certifications/middleware.js b/js/src/redux/providers/certifications/middleware.js index 715a5cb59..d90045270 100644 --- a/js/src/redux/providers/certifications/middleware.js +++ b/js/src/redux/providers/certifications/middleware.js @@ -44,8 +44,8 @@ export default class CertificationsMiddleware { logs.forEach((log) => { const certifier = certifiers.find((c) => c.address === log.address); if (!certifier) throw new Error(`Could not find certifier at ${log.address}.`); - const { name, title, icon } = certifier; - dispatch(addCertification(log.params.who.value, name, title, icon)); + const { id, name, title, icon } = certifier; + dispatch(addCertification(log.params.who.value, id, name, title, icon)); }); }) .catch((err) => { @@ -59,7 +59,7 @@ export default class CertificationsMiddleware { new Array(+count).fill(null).forEach((_, id) => { badgeReg.fetchCertifier(id) .then((cert) => { - if (!certifiers.some((c) => c.address === cert.address)) { + if (!certifiers.some((c) => c.id === cert.id)) { certifiers = certifiers.concat(cert); fetchConfirmedEvents(store.dispatch); } diff --git a/js/src/redux/providers/certifications/reducer.js b/js/src/redux/providers/certifications/reducer.js index 87b0dfd33..df726be82 100644 --- a/js/src/redux/providers/certifications/reducer.js +++ b/js/src/redux/providers/certifications/reducer.js @@ -21,13 +21,13 @@ export default (state = initialState, action) => { return state; } - const { address, name, icon, title } = action; + const { address, id, name, icon, title } = action; const certifications = state[address] || []; - if (certifications.some((c) => c.name === name)) { + if (certifications.some((c) => c.id === id)) { return state; } - const newCertifications = certifications.concat({ name, icon, title }); + const newCertifications = certifications.concat({ id, name, icon, title }); return { ...state, [address]: newCertifications }; };