Updates after merge (last remaining middleware nigglies)
This commit is contained in:
parent
566b6a1967
commit
7c78dff386
@ -17,6 +17,7 @@ import thunk from 'redux-thunk';
|
|||||||
import { routerMiddleware } from 'react-router-redux';
|
import { routerMiddleware } from 'react-router-redux';
|
||||||
|
|
||||||
import ErrorsMiddleware from '~/ui/Errors/middleware';
|
import ErrorsMiddleware from '~/ui/Errors/middleware';
|
||||||
|
|
||||||
import SettingsMiddleware from './providers/settings/middleware';
|
import SettingsMiddleware from './providers/settings/middleware';
|
||||||
import SignerMiddleware from './providers/signerMiddleware';
|
import SignerMiddleware from './providers/signerMiddleware';
|
||||||
|
|
||||||
@ -25,25 +26,24 @@ import ChainMiddleware from './providers/chainMiddleware';
|
|||||||
import RegistryMiddleware from './providers/registry/middleware';
|
import RegistryMiddleware from './providers/registry/middleware';
|
||||||
|
|
||||||
export default function (api, browserHistory, forEmbed = false) {
|
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 = [
|
const middleware = [
|
||||||
settings.toMiddleware(),
|
new SettingsMiddleware().toMiddleware(),
|
||||||
signer.toMiddleware(),
|
new SignerMiddleware(api).toMiddleware(),
|
||||||
errors.toMiddleware(),
|
new ErrorsMiddleware().toMiddleware(),
|
||||||
chain.toMiddleware()
|
new ChainMiddleware().toMiddleware()
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!forEmbed) {
|
if (!forEmbed) {
|
||||||
const certifications = new CertificationsMiddleware(api).toMiddleware();
|
middleware.push(
|
||||||
const registry = new RegistryMiddleware(api).toMiddleware();
|
new CertificationsMiddleware(api).toMiddleware(),
|
||||||
|
new RegistryMiddleware(api).toMiddleware()
|
||||||
middleware.push(certifications, registry);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const routeMiddleware = browserHistory ? routerMiddleware(browserHistory) : [];
|
return middleware.concat(
|
||||||
|
browserHistory
|
||||||
return middleware.concat(routeMiddleware, thunk);
|
? routerMiddleware(browserHistory)
|
||||||
|
: [],
|
||||||
|
thunk
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -63,9 +63,10 @@ export default class CertificationsMiddleware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toMiddleware () {
|
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 Confirmed = contract.events.find((e) => e.name === 'Confirmed');
|
||||||
const Revoked = contract.events.find((e) => e.name === 'Revoked');
|
const Revoked = contract.events.find((e) => e.name === 'Revoked');
|
||||||
|
|
||||||
@ -77,12 +78,12 @@ export default class CertificationsMiddleware {
|
|||||||
let badgeRegFilter = null;
|
let badgeRegFilter = null;
|
||||||
let fetchCertifiersPromise = null;
|
let fetchCertifiersPromise = null;
|
||||||
|
|
||||||
const updateFilter = updatableFilter(this._api, (filterId) => {
|
const updateFilter = updatableFilter(api, (filterId) => {
|
||||||
filterChanged = true;
|
filterChanged = true;
|
||||||
filter = filterId;
|
filter = filterId;
|
||||||
});
|
});
|
||||||
|
|
||||||
const badgeRegUpdateFilter = updatableFilter(this._api, (filterId) => {
|
const badgeRegUpdateFilter = updatableFilter(api, (filterId) => {
|
||||||
filterChanged = true;
|
filterChanged = true;
|
||||||
badgeRegFilter = filterId;
|
badgeRegFilter = filterId;
|
||||||
});
|
});
|
||||||
@ -100,7 +101,7 @@ export default class CertificationsMiddleware {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
shortFetchChanges();
|
shortFetchChanges();
|
||||||
|
|
||||||
this._api.subscribe('eth_blockNumber', (err) => {
|
api.subscribe('eth_blockNumber', (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -128,7 +129,8 @@ export default class CertificationsMiddleware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onBadgeRegLogs (logs) {
|
function onBadgeRegLogs (logs) {
|
||||||
return badgeReg.getContract()
|
return badgeReg
|
||||||
|
.getContract()
|
||||||
.then((badgeRegContract) => {
|
.then((badgeRegContract) => {
|
||||||
logs = badgeRegContract.parseEventLogs(logs);
|
logs = badgeRegContract.parseEventLogs(logs);
|
||||||
|
|
||||||
@ -145,12 +147,12 @@ export default class CertificationsMiddleware {
|
|||||||
|
|
||||||
filterChanged = false;
|
filterChanged = false;
|
||||||
|
|
||||||
this._api.eth[method](badgeRegFilter)
|
api.eth[method](badgeRegFilter)
|
||||||
.then(onBadgeRegLogs)
|
.then(onBadgeRegLogs)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error('Failed to fetch badge reg events:', err);
|
console.error('Failed to fetch badge reg events:', err);
|
||||||
})
|
})
|
||||||
.then(() => this._api.eth[method](filter))
|
.then(() => api.eth[method](filter))
|
||||||
.then(onLogs)
|
.then(onLogs)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error('Failed to fetch new certifier events:', err);
|
console.error('Failed to fetch new certifier events:', err);
|
||||||
|
@ -84,7 +84,7 @@ export default class RegistryMiddleware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cacheReverses () {
|
cacheReverses () {
|
||||||
const { registry } = Contracts.get();
|
const { registry } = Contracts.get(this._api);
|
||||||
const cached = this.read(this.store.getState().nodeStatus.netChain);
|
const cached = this.read(this.store.getState().nodeStatus.netChain);
|
||||||
|
|
||||||
if (cached) {
|
if (cached) {
|
||||||
|
Loading…
Reference in New Issue
Block a user