Updates after merge (last remaining middleware nigglies)

This commit is contained in:
Jaco Greeff 2017-05-10 17:50:23 +02:00
parent 566b6a1967
commit 7c78dff386
3 changed files with 26 additions and 24 deletions

View File

@ -17,6 +17,7 @@ import thunk from 'redux-thunk';
import { routerMiddleware } from 'react-router-redux';
import ErrorsMiddleware from '~/ui/Errors/middleware';
import SettingsMiddleware from './providers/settings/middleware';
import SignerMiddleware from './providers/signerMiddleware';
@ -25,25 +26,24 @@ import ChainMiddleware from './providers/chainMiddleware';
import RegistryMiddleware from './providers/registry/middleware';
export default function (api, browserHistory, forEmbed = false) {
const errors = new ErrorsMiddleware();
const signer = new SignerMiddleware(api);
const settings = new SettingsMiddleware();
const chain = new ChainMiddleware();
const middleware = [
settings.toMiddleware(),
signer.toMiddleware(),
errors.toMiddleware(),
chain.toMiddleware()
new SettingsMiddleware().toMiddleware(),
new SignerMiddleware(api).toMiddleware(),
new ErrorsMiddleware().toMiddleware(),
new ChainMiddleware().toMiddleware()
];
if (!forEmbed) {
const certifications = new CertificationsMiddleware(api).toMiddleware();
const registry = new RegistryMiddleware(api).toMiddleware();
middleware.push(certifications, registry);
middleware.push(
new CertificationsMiddleware(api).toMiddleware(),
new RegistryMiddleware(api).toMiddleware()
);
}
const routeMiddleware = browserHistory ? routerMiddleware(browserHistory) : [];
return middleware.concat(routeMiddleware, thunk);
return middleware.concat(
browserHistory
? routerMiddleware(browserHistory)
: [],
thunk
);
}

View File

@ -63,9 +63,10 @@ export default class CertificationsMiddleware {
}
toMiddleware () {
const badgeReg = Contracts.get(this._api).badgeReg;
const api = this._api;
const badgeReg = Contracts.get(api).badgeReg;
const contract = new Contract(this._api, CertifierABI);
const contract = new Contract(api, CertifierABI);
const Confirmed = contract.events.find((e) => e.name === 'Confirmed');
const Revoked = contract.events.find((e) => e.name === 'Revoked');
@ -77,12 +78,12 @@ export default class CertificationsMiddleware {
let badgeRegFilter = null;
let fetchCertifiersPromise = null;
const updateFilter = updatableFilter(this._api, (filterId) => {
const updateFilter = updatableFilter(api, (filterId) => {
filterChanged = true;
filter = filterId;
});
const badgeRegUpdateFilter = updatableFilter(this._api, (filterId) => {
const badgeRegUpdateFilter = updatableFilter(api, (filterId) => {
filterChanged = true;
badgeRegFilter = filterId;
});
@ -100,7 +101,7 @@ export default class CertificationsMiddleware {
.then(() => {
shortFetchChanges();
this._api.subscribe('eth_blockNumber', (err) => {
api.subscribe('eth_blockNumber', (err) => {
if (err) {
return;
}
@ -128,7 +129,8 @@ export default class CertificationsMiddleware {
}
function onBadgeRegLogs (logs) {
return badgeReg.getContract()
return badgeReg
.getContract()
.then((badgeRegContract) => {
logs = badgeRegContract.parseEventLogs(logs);
@ -145,12 +147,12 @@ export default class CertificationsMiddleware {
filterChanged = false;
this._api.eth[method](badgeRegFilter)
api.eth[method](badgeRegFilter)
.then(onBadgeRegLogs)
.catch((err) => {
console.error('Failed to fetch badge reg events:', err);
})
.then(() => this._api.eth[method](filter))
.then(() => api.eth[method](filter))
.then(onLogs)
.catch((err) => {
console.error('Failed to fetch new certifier events:', err);

View File

@ -84,7 +84,7 @@ export default class RegistryMiddleware {
}
cacheReverses () {
const { registry } = Contracts.get();
const { registry } = Contracts.get(this._api);
const cached = this.read(this.store.getState().nodeStatus.netChain);
if (cached) {