Skip to content
Permalink
Browse files

feat(disputes): get jurors rulings

  • Loading branch information...
satello committed Jul 31, 2018
1 parent 169757d commit d0964c0608a23c1834bb81b21cf1082daffb32c0
Showing with 34 additions and 0 deletions.
  1. +19 −0 src/contracts/implementations/arbitrator/Kleros.js
  2. +15 −0 src/resources/Disputes.js
@@ -610,6 +610,25 @@ class Kleros extends ContractImplementation {
return openDisputes
}

/**
* Get the ruling that a juror gave in dispute
* @param {number} disputeId - the index of the dispute.
* @param {number} appeal - the index of the appeal.
* @param {number} draw - the index of the vote draw.
* @returns {number} ruling.
*/
getVoteForDraw = async (disputeId, appeal, draw) => {
await this.loadContract()

const vote = await this.contractInstance.getVoteRuling(
disputeId,
appeal,
draw
)

return vote.toNumber()
}

/**
* Find when a ruling was made in a session
* @param {number} session - The session number.
@@ -378,6 +378,20 @@ class Disputes {
// Wait for parallel requests to complete
;[ruling, canRule] = await Promise.all(rulingPromises)

let rulings = []
// if can't rule that means they already did or they missed it
if (!canRule) {
rulings = await Promise.all(
draws.map(
draw => this._ArbitratorInstance.getVoteForDraw(
dispute.disputeId,
appeal,
draw
)
)
)
}

const appealCreatedAt = await this.getAppealCreatedAt(
dispute.disputeId,
account,
@@ -396,6 +410,7 @@ class Disputes {
createdAt: appealCreatedAt,
fee: dispute.arbitrationFeePerJuror * draws.length,
draws,
rulings,
canRule
}
appealRulings[appeal] = {

0 comments on commit d0964c0

Please sign in to comment.
You can’t perform that action at this time.