WIP Fetch Reimbursement events
This commit is contained in:
@@ -30,5 +30,8 @@ export default class BudgetRoute extends Route {
|
||||
}
|
||||
schedule('afterRender', this.kredits.fetchMissingReimbursements,
|
||||
this.kredits.fetchMissingReimbursements.perform);
|
||||
|
||||
schedule('afterRender', this.kredits.syncReimbursementEvents,
|
||||
this.kredits.syncReimbursementEvents.perform);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -780,5 +780,32 @@ export default Service.extend({
|
||||
this.contributors
|
||||
.findBy('address', to)
|
||||
.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);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user