Pin reimbursements
All checks were successful
Release Drafter / Update release notes draft (pull_request) Successful in 3s

This commit is contained in:
Râu Cao 2023-04-26 15:58:19 +02:00
parent 3c7bcf038e
commit 83b3045afd
Signed by: raucao
GPG Key ID: 15E65F399D084BA9

View File

@ -29,8 +29,7 @@ class IpfsPinner {
const contracts = [ const contracts = [
this.kredits.Contributor, this.kredits.Contributor,
this.kredits.Contribution, this.kredits.Contribution,
// TODO uncomment once we have data here this.kredits.Reimbursement
// this.kredits.Reimbursement
] ]
for (const contract of contracts) { for (const contract of contracts) {
@ -72,6 +71,11 @@ class IpfsPinner {
.then(data => { return this.ipfsApi.pin(data); }) .then(data => { return this.ipfsApi.pin(data); })
.then(callback); .then(callback);
}); });
this.kredits.Reimbursement.on('ReimbursementAdded', (id) => {
this.kredits.Reimbursement.getData(id)
.then(data => { return this.ipfsApi.pin(data); })
.then(callback);
});
} }
async _pinAllFromContract (contract, itemCount, progressBar) { async _pinAllFromContract (contract, itemCount, progressBar) {
@ -91,7 +95,7 @@ class IpfsPinner {
cid = await ipfsApi.pin(data); cid = await ipfsApi.pin(data);
debug(`Pinned ${contract.constructor.name} #${id} at ${cid}`); debug(`Pinned ${contract.constructor.name} #${id} at ${cid}`);
} catch(e) { } catch(e) {
debug(`Error while trying to load an pin ${contract.constructor.name} #${id}:`) debug(`Error while trying to load and pin ${contract.constructor.name} #${id}:`)
debug(e); debug(e);
debug(`\nTrying again...`); debug(`\nTrying again...`);
loadAndPin(id); loadAndPin(id);