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