WIP Fetch Reimbursement events

This commit is contained in:
2024-03-14 16:42:20 +01:00
parent 77f95a096a
commit 8c5c6b7c6b
3 changed files with 33 additions and 1 deletions
+3
View File
@@ -30,5 +30,8 @@ export default class BudgetRoute extends Route {
} }
schedule('afterRender', this.kredits.fetchMissingReimbursements, schedule('afterRender', this.kredits.fetchMissingReimbursements,
this.kredits.fetchMissingReimbursements.perform); this.kredits.fetchMissingReimbursements.perform);
schedule('afterRender', this.kredits.syncReimbursementEvents,
this.kredits.syncReimbursementEvents.perform);
} }
} }
+27
View File
@@ -780,5 +780,32 @@ export default Service.extend({
this.contributors this.contributors
.findBy('address', to) .findBy('address', to)
.incrementProperty('balance', value); .incrementProperty('balance', value);
},
syncReimbursementEvents: task(function * () {
yield this.fetchEvents(
'Reimbursement', // contract
'ReimbursementAdded', // event
0,
// this.kredits.currentBlock - (2*60*24*14), // from block
this.currentBlock // to block
);
}).group('syncTaskGroup'),
async fetchEvents(contractName, eventName, fromBlock, toBlock) {
const contract = this.kredits[contractName].contract;
const eventFilter = contract.filters[eventName]();
const filterOptions = { fromBlock, toBlock };
console.debug(contract, eventFilter, filterOptions);
contract.queryFilter(eventFilter)
.then(events => {
events.forEach(event => {
console.debug("Event:", event.args.creator, event.args.key, event.args.value);
});
}).catch(e => {
console.error(e);
});
} }
}); });
+3 -1
View File
@@ -62,7 +62,9 @@ module.exports = function(environment) {
} }
}, },
corsProxy: 'https://cors.5apps.com/?uri=' corsProxy: 'https://cors.5apps.com/?uri=',
hideVetoedEntriesAfterBlocks: 5760 // 48 hours
}; };
if (environment === 'development') { if (environment === 'development') {