From 16eaafc68896abe471ab1352b88f5f68e8a3a858 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 10 Apr 2019 12:46:44 -0400 Subject: [PATCH] get contributor list from hash gotten from contract --- app/js/services/Meritocracy.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/app/js/services/Meritocracy.js b/app/js/services/Meritocracy.js index ab659ce..fd5a408 100644 --- a/app/js/services/Meritocracy.js +++ b/app/js/services/Meritocracy.js @@ -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) { } }); } +