Make it work

This commit is contained in:
2019-07-02 16:35:53 +02:00
parent 746149e89a
commit 03438bb890
4 changed files with 18 additions and 9 deletions

View File

@@ -7,7 +7,8 @@ class IpfsPinner {
pinAll () {
return Promise.all([
this._pinAllFromContract(this.kredits.Contributor),
this._pinAllFromContract(this.kredits.Contribution)
this._pinAllFromContract(this.kredits.Contribution),
this._pinAllFromContract(this.kredits.Proposal)
]);
}
@@ -30,10 +31,13 @@ class IpfsPinner {
}
_pinAllFromContract (contract) {
console.log(`Pinning data from ${contract.constructor.name}...`);
return contract.count.then(count => {
let promises = [...Array(count).keys()].map(i => {
let id = i + 1; // 0 => 1 - ids start with 1 and not with 0
console.log(`Loading ${contract.constructor.name} #${id}`);
return contract.getData(id).then(data => {
console.log(`Pinning ${contract.constructor.name} #${id}`);
return this.ipfsApi.pin(data);
});
});