Skip to content
Permalink
Browse files

feat(disputes): build voteCounters and PNKRepartitions from getters

  • Loading branch information...
epiqueras authored and satello committed Feb 15, 2018
1 parent 1246968 commit ba48e678e9c22ec64bd507503e489184af5d7140
Showing with 22 additions and 5 deletions.
  1. +1 −1 src/abstractWrappers/Disputes.js
  2. +21 −4 src/contractWrappers/KlerosWrapper.js
@@ -559,7 +559,7 @@ class Disputes extends AbstractWrapper {
disputeState: dispute.state,
disputeStatus: dispute.status,
voteCounters: dispute.voteCounters,
appealsRepartitioned: dispute.appealsRepartitioned,
PNKRepartitions: dispute.PNKRepartitions,

// Store Data
description: constractStoreData ? constractStoreData.description : undefined,
@@ -374,16 +374,33 @@ class KlerosWrapper extends ContractWrapper {
const contractInstance = await this.load(contractAddress)
try {
const dispute = await contractInstance.disputes(disputeId)

const numberOfAppeals = dispute[2].toNumber()
const rulingChoices = dispute[3].toNumber()

const voteCounters = []
const PNKRepartitions = []
for (let appeal = 0; appeal <= numberOfAppeals; appeal++) {
const counter = []
const repartition = []
for (let choice = 0; choice <= rulingChoices; choice++) {
counter.push(contractInstance.getVoteCount(disputeId, appeal, choice))
repartition.push(contractInstance.repartitionedPNK(disputeId, appeal, choice))
}
voteCounters.push(counter)
PNKRepartitions.push(repartition)
}

return {
arbitratedContract: dispute[0],
firstSession: dispute[1].toNumber(),
numberOfAppeals: dispute[2].toNumber(),
rulingChoices: dispute[3].toNumber(),
numberOfAppeals,
rulingChoices,
initialNumberJurors: dispute[4].toNumber(),
arbitrationFeePerJuror: this._Web3Wrapper.fromWei(dispute[5], 'ether'),
state: dispute[6].toNumber(),
voteCounters: dispute[8],
appealsRepartitioned: dispute[11],
voteCounters,
PNKRepartitions,
status: (await contractInstance.disputeStatus(disputeId)).toNumber()
}
} catch (e) {

0 comments on commit ba48e67

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