Merge branch 'master' into feature/111-unconfirmed_balances
This commit is contained in:
+33
-10
@@ -84,9 +84,10 @@ export default Service.extend({
|
||||
});
|
||||
}
|
||||
|
||||
function instantiateWithAccount (web3Provider, context) {
|
||||
async function instantiateWithAccount (web3Provider, context) {
|
||||
console.debug('[kredits] Using user-provided instance, e.g. from Mist browser or Metamask');
|
||||
ethProvider = new ethers.providers.Web3Provider(web3Provider);
|
||||
// const network = await ethProvider.getNetwork();
|
||||
ethProvider.listAccounts().then(accounts => {
|
||||
context.set('currentUserAccounts', accounts);
|
||||
const ethSigner = accounts.length === 0 ? null : ethProvider.getSigner();
|
||||
@@ -162,10 +163,15 @@ export default Service.extend({
|
||||
},
|
||||
|
||||
addContributor(attributes) {
|
||||
if (attributes.github_uid) {
|
||||
const uidInt = parseInt(attributes.github_uid);
|
||||
attributes.github_uid = uidInt;
|
||||
}
|
||||
|
||||
console.debug('[kredits] add contributor', attributes);
|
||||
|
||||
return this.kredits.Contributor.add(attributes)
|
||||
.then((data) => {
|
||||
return this.kredits.Contributor.add(attributes, { gasLimit: 350000 })
|
||||
.then(data => {
|
||||
console.debug('[kredits] add contributor response', data);
|
||||
return Contributor.create(attributes);
|
||||
});
|
||||
@@ -215,12 +221,22 @@ export default Service.extend({
|
||||
console.debug('[kredits] vote for', proposalId);
|
||||
|
||||
return this.kredits.Proposal.functions.vote(proposalId)
|
||||
.then((data) => {
|
||||
.then(data => {
|
||||
console.debug('[kredits] vote response', data);
|
||||
return data;
|
||||
});
|
||||
},
|
||||
|
||||
veto(contributionId) {
|
||||
console.debug('[kredits] veto against', contributionId);
|
||||
|
||||
return this.kredits.Contribution.functions.veto(contributionId, { gasLimit: 300000 })
|
||||
.then(data => {
|
||||
console.debug('[kredits] veto response', data);
|
||||
return data;
|
||||
});
|
||||
},
|
||||
|
||||
getCurrentUser: computed('kredits.provider', function() {
|
||||
if (isEmpty(this.currentUserAccounts)) {
|
||||
return RSVP.resolve();
|
||||
@@ -241,23 +257,30 @@ export default Service.extend({
|
||||
return this.proposals.findBy('id', proposalId.toString());
|
||||
},
|
||||
|
||||
findContributionById(contributionId) {
|
||||
return this.contributions.findBy('id', contributionId.toString());
|
||||
},
|
||||
|
||||
// Contract events
|
||||
addContractEventHandlers() {
|
||||
// Proposal events
|
||||
this.kredits.Contribution
|
||||
.on('ContributionVetoed', this.handleContributionVetoed.bind(this))
|
||||
|
||||
this.kredits.Proposal
|
||||
.on('ProposalCreated', this.handleProposalCreated.bind(this))
|
||||
.on('ProposalVoted', this.handleProposalVoted.bind(this))
|
||||
.on('ProposalExecuted', this.handleProposalExecuted.bind(this));
|
||||
|
||||
// Token events
|
||||
this.kredits.Token
|
||||
.on('Transfer', this.handleTransfer.bind(this));
|
||||
},
|
||||
|
||||
handleContributionVetoed(contributionId) {
|
||||
console.debug('[kredits] ContributionVetoed event received for ', contributionId);
|
||||
const contribution = this.contributions.findBy('id', contributionId);
|
||||
console.debug('[kredits] contribution', contribution);
|
||||
|
||||
if (contribution) {
|
||||
contribution.set('vetoed', true);
|
||||
}
|
||||
},
|
||||
|
||||
handleProposalCreated(proposalId) {
|
||||
let proposal = this.findProposalById(proposalId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user