get contributor list from hash gotten from contract

This commit is contained in:
Jonathan Rainville 2019-04-10 12:46:44 -04:00
parent 38be32c60c
commit 16eaafc688
No known key found for this signature in database
GPG Key ID: 5F4630B759727D9C
1 changed files with 6 additions and 10 deletions

View File

@ -3,9 +3,6 @@ import Meritocracy from 'Embark/contracts/Meritocracy';
import EmbarkJS from 'Embark/EmbarkJS';
import axios from 'axios';
const IPFS_HASH = 'QmfWJJYFBJReu2rzTDzkBKXHazE52GVWrTcVNKdcupnxNH';
const IPNS_HASH = 'QmPW4ZGXXvVYxC7Uez62m9yYZZYVHmo98c8rP6Hu1nb1Na';
const mainAccount = web3.eth.defaultAccount;
export function addContributor(name, address) {
@ -34,16 +31,14 @@ export function addContributor(name, address) {
});
}
export function getContributorList() {
export function getContributorList(hash) {
return new Promise(async (resolve, reject) => {
try {
// TODO figure out how to make IPFS/IPNS work
const hash = await EmbarkJS.Storage.resolve(IPNS_HASH, (err, hash) => {
console.log('Resolved??', {err, hash});
});
console.log({hash});
if (!hash) {
hash = await Meritocracy.methods.contributorListIPFSHash().call();
}
const url = await EmbarkJS.Storage.getUrl(hash);
console.log({url});
const response = await axios.get(url);
resolve(response.data.contributors);
} catch (e) {
@ -72,3 +67,4 @@ export function saveContributorList(list) {
}
});
}