Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
feat(disputes): build voteCounters and PNKRepartitions from getters
Browse files Browse the repository at this point in the history
  • Loading branch information
epiqueras authored and satello committed Feb 16, 2018
1 parent 1246968 commit ba48e67
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/abstractWrappers/Disputes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 21 additions & 4 deletions src/contractWrappers/KlerosWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ba48e67

Please sign in to comment.