Skip to content

Commit c3c6c83

Browse files
committed
refactor: match KlerosLiquid ABI (xdai-->eth)
1 parent 07583a1 commit c3c6c83

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

contracts/kleros/xKlerosLiquid.sol

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ contract xKlerosLiquid is Initializable, TokenController, Arbitrator {
138138
* @param _address The juror affected.
139139
* @param _disputeID The ID of the dispute.
140140
* @param _tokenAmount The amount of tokens won or lost.
141-
* @param _xDaiAmount The amount of xDai won or lost.
141+
* @param _ETHAmount The amount of xDai won or lost.
142142
*/
143-
event TokenAndETHShift(address indexed _address, uint indexed _disputeID, int _tokenAmount, int _xDaiAmount);
143+
event TokenAndETHShift(address indexed _address, uint indexed _disputeID, int _tokenAmount, int _ETHAmount);
144144

145145
/* Storage */
146146

@@ -164,7 +164,6 @@ contract xKlerosLiquid is Initializable, TokenController, Arbitrator {
164164
uint public maxDrawingTime; // The maximum drawing time.
165165
// True if insolvent (`balance < stakedTokens || balance < lockedTokens`) token transfers should be blocked. Used to avoid blocking penalties.
166166
bool public lockInsolventTransfers;
167-
uint public totalStake;
168167
// General Storage
169168
Court[] public courts; // The subcourts.
170169
using SortitionSumTreeFactory for SortitionSumTreeFactory.SortitionSumTrees; // Use library functions for sortition sum trees.
@@ -577,9 +576,9 @@ contract xKlerosLiquid is Initializable, TokenController, Arbitrator {
577576
* @param _disputeID The ID of the dispute.
578577
* @param _appeal The appeal.
579578
* @return tokenReward The token reward.
580-
* @return xDaiReward The xDai reward.
579+
* @return ETHReward The xDai reward.
581580
*/
582-
function computeTokenAndETHRewards(uint _disputeID, uint _appeal) private view returns(uint tokenReward, uint xDaiReward) {
581+
function computeTokenAndETHRewards(uint _disputeID, uint _appeal) private view returns(uint tokenReward, uint ETHReward) {
583582
Dispute storage dispute = disputes[_disputeID];
584583

585584
// Distribute penalties and arbitration fees.
@@ -588,17 +587,17 @@ contract xKlerosLiquid is Initializable, TokenController, Arbitrator {
588587
uint activeCount = dispute.votesInEachRound[_appeal];
589588
if (activeCount > 0) {
590589
tokenReward = dispute.penaltiesInEachRound[_appeal] / activeCount;
591-
xDaiReward = dispute.totalFeesForJurors[_appeal] / activeCount;
590+
ETHReward = dispute.totalFeesForJurors[_appeal] / activeCount;
592591
} else {
593592
tokenReward = 0;
594-
xDaiReward = 0;
593+
ETHReward = 0;
595594
}
596595
} else {
597596
// Distribute penalties and fees evenly between coherent jurors.
598597
uint winningChoice = dispute.voteCounters[dispute.voteCounters.length - 1].winningChoice;
599598
uint coherentCount = dispute.voteCounters[_appeal].counts[winningChoice];
600599
tokenReward = dispute.penaltiesInEachRound[_appeal] / coherentCount;
601-
xDaiReward = dispute.totalFeesForJurors[_appeal] / coherentCount;
600+
ETHReward = dispute.totalFeesForJurors[_appeal] / coherentCount;
602601
}
603602
}
604603

contracts/kleros/KlerosLiquidExtraViews.sol renamed to contracts/kleros/xKlerosLiquidExtraViews.sol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* https://contributing.kleros.io/smart-contract-workflow
3-
* @reviewers: []
3+
* @reviewers: [@hbarcelos]
44
* @auditors: []
55
* @bounties: []
66
* @deployments: []
@@ -10,19 +10,19 @@ pragma solidity ^0.4.24;
1010
import { xKlerosLiquid } from "./xKlerosLiquid.sol";
1111

1212
/**
13-
* @title KlerosLiquidExtraViews
14-
* @author Enrique Piqueras - <epiquerass@gmail.com>
15-
* @dev Extra view functions for KlerosLiquid. Not part of bug bounty.
13+
* @title xKlerosLiquidExtraViews
14+
* @dev This contract is an adaption of Mainnet's xKlerosLiquidExtraViews (https://github.com/kleros/kleros/blob/69cfbfb2128c29f1625b3a99a3183540772fda08/contracts/kleros/KlerosLiquidExtraViews.sol)
15+
* for xDai chain.
1616
*/
17-
contract KlerosLiquidExtraViews {
17+
contract xKlerosLiquidExtraViews {
1818
/* Storage */
1919

2020
xKlerosLiquid public klerosLiquid;
2121

2222
/* Constructor */
2323

24-
/** @dev Constructs the KlerosLiquidExtraViews contract.
25-
* @param _klerosLiquid The address of KlerosLiquid.
24+
/** @dev Constructs the xKlerosLiquidExtraViews contract.
25+
* @param _klerosLiquid The address of KlerosLiquid on xDai.
2626
*/
2727
constructor(xKlerosLiquid _klerosLiquid) public {
2828
klerosLiquid = _klerosLiquid;

test/kleros/kleros-liquid.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ contract('xKlerosLiquid', (accounts) => {
544544
expect(
545545
tokensShiftEvents
546546
.reduce(
547-
(acc, e) => acc.add(e.args._xDaiAmount),
547+
(acc, e) => acc.add(e.args._ETHAmount),
548548
web3.utils.toBN(0)
549549
)
550550
.toNumber()
@@ -1044,6 +1044,7 @@ contract('xKlerosLiquid', (accounts) => {
10441044
const ETHAfter = web3.utils.toBN(await web3.eth.getBalance(partyB))
10451045
expect(ETHAfter.gt(ETHBefore)).to.equal(true)
10461046
})
1047+
10471048
it('Should handle invalid extra data.', async () => {
10481049
const disputeID = 0
10491050
const extraData = `0x${(1000).toString(16).padStart(64, '0')}${(0)
@@ -1072,4 +1073,5 @@ contract('xKlerosLiquid', (accounts) => {
10721073
web3.utils.toBN(3)
10731074
)
10741075
})
1076+
10751077
})

0 commit comments

Comments
 (0)