Fetch certifiers only when needed (#3978)

* Fetch certifiers once + on new Logs

* Linting

* BadgeReg First Query

* Rightly fetching badges on page change

* PR Grumbles

* Only fetch certifiers onces
This commit is contained in:
Nicolas Gotchac
2016-12-27 16:23:58 +01:00
committed by Gav Wood
parent b27c809c64
commit 7581ac635f
3 changed files with 133 additions and 61 deletions

View File

@@ -31,9 +31,13 @@ export default class BadgeReg {
this.contracts = {}; // by name
}
getContract () {
return this._registry.getContract('badgereg');
}
certifierCount () {
return this._registry
.getContract('badgereg')
return this
.getContract()
.then((badgeReg) => {
return badgeReg.instance.badgeCount.call({}, [])
.then((count) => count.valueOf());
@@ -45,8 +49,8 @@ export default class BadgeReg {
return Promise.resolve(this.certifiers[id]);
}
return this._registry
.getContract('badgereg')
return this
.getContract()
.then((badgeReg) => {
return badgeReg.instance.badge.call({}, [ id ]);
})
@@ -70,8 +74,8 @@ export default class BadgeReg {
}
fetchMeta (id) {
return this._registry
.getContract('badgereg')
return this
.getContract()
.then((badgeReg) => {
return Promise.all([
badgeReg.instance.meta.call({}, [id, 'TITLE']),