Skip to content
Permalink
Browse files

feat(disputes): fetch ruling from blockchain (#164)

  • Loading branch information...
satello committed Aug 8, 2018
1 parent 6ff816c commit ef7d9ab8211964ed8e952d3e909e8d06c1e6c332
Showing with 29 additions and 9 deletions.
  1. +24 −0 src/contracts/implementations/arbitrator/Kleros.js
  2. +5 −9 src/resources/Disputes.js
@@ -610,6 +610,30 @@ class Kleros extends ContractImplementation {
return openDisputes
}

getVoteForJuror = async (disputeId, appeal, address) => {
await this.loadContract()

const numberOfJurors = await this.getAmountOfJurorsForDispute(disputeId)
let jurorDraw = null
for (let i=0; i < numberOfJurors; i++) {
const jurorAddress = await this.contractInstance.getVoteAccount(
disputeId,
appeal,
i
)

// NOTE jurors can only vote once per session so this is safe for now.
if (jurorAddress === address) {
jurorDraw = i
break
}
}

if (_.isNull(jurorDraw)) return null

return this.getVoteForDraw(disputeId, appeal, jurorDraw)
}

/**
* Get the ruling that a juror gave in dispute
* @param {number} disputeId - the index of the dispute.
@@ -381,14 +381,10 @@ class Disputes {
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
)
)
ruling = await this._ArbitratorInstance.getVoteForJuror(
dispute.disputeId,
appeal,
account
)
}

@@ -410,7 +406,7 @@ class Disputes {
createdAt: appealCreatedAt,
fee: dispute.arbitrationFeePerJuror * draws.length,
draws,
rulings,
ruling,
canRule
}
appealRulings[appeal] = {

0 comments on commit ef7d9ab

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