pull out fetchMeta
This commit is contained in:
parent
2d6656fc43
commit
2b34d76b8c
@ -38,16 +38,9 @@ export default class BadgeReg {
|
||||
.then((badgeReg) => {
|
||||
return badgeReg.instance.fromName.call({}, [name])
|
||||
.then(([ id, address ]) => {
|
||||
return Promise.all([
|
||||
badgeReg.instance.meta.call({}, [id, 'TITLE']),
|
||||
badgeReg.instance.meta.call({}, [id, 'IMG'])
|
||||
])
|
||||
.then(([ title, img ]) => {
|
||||
title = bytesToHex(title);
|
||||
title = title === ZERO ? null : hex2Ascii(title);
|
||||
if (bytesToHex(img) === ZERO) img = null;
|
||||
|
||||
const data = { address, name, title, icon: img };
|
||||
return this.fetchMeta(id)
|
||||
.then(({ title, icon }) => {
|
||||
const data = { address, name, title, icon };
|
||||
this.certifiers[name] = data;
|
||||
return data;
|
||||
});
|
||||
@ -55,6 +48,22 @@ export default class BadgeReg {
|
||||
});
|
||||
}
|
||||
|
||||
fetchMeta (id) {
|
||||
return this._registry.getContract('badgereg')
|
||||
.then((badgeReg) => {
|
||||
return Promise.all([
|
||||
badgeReg.instance.meta.call({}, [id, 'TITLE']),
|
||||
badgeReg.instance.meta.call({}, [id, 'IMG'])
|
||||
]);
|
||||
})
|
||||
.then(([ title, icon ]) => {
|
||||
title = bytesToHex(title);
|
||||
title = title === ZERO ? null : hex2Ascii(title);
|
||||
if (bytesToHex(icon) === ZERO) icon = null;
|
||||
return { title, icon };
|
||||
});
|
||||
}
|
||||
|
||||
checkIfCertified (certifier, address) {
|
||||
if (!this.contracts[certifier]) {
|
||||
this.contracts[certifier] = this._api.newContract(ABI, certifier);
|
||||
|
Loading…
Reference in New Issue
Block a user