Skip to content

Commit e95f3ac

Browse files
authored
Merge pull request #4 from kleros/review/unknownunknown1
Review/unknownunknown1
2 parents e5b670a + 3009217 commit e95f3ac

File tree

7 files changed

+262
-217
lines changed

7 files changed

+262
-217
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
PRIVATE_KEYS='{"sokol-fork": <private key>, "xdai": <private key>}'
1+
PRIVATE_KEYS='{"sokol-fork": "<private key>", "xdai": "<private key>"}'

contracts/kleros/xKlerosLiquid.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* https://contributing.kleros.io/smart-contract-workflow
33
* @authors: [@fnanni-0]
4-
* @reviewers: [@shalzz]
4+
* @reviewers: [@shalzz, @unknownunknown1]
55
* @auditors: []
66
* @bounties: []
77
* @deployments: []
@@ -426,6 +426,7 @@ contract xKlerosLiquid is Initializable, TokenController, Arbitrator {
426426
* @param _disputeID The ID of the dispute.
427427
*/
428428
function passPeriod(uint _disputeID) external {
429+
require(_disputeID < totalDisputes, "Dispute ID does not exist.");
429430
Dispute storage dispute = disputes[_disputeID];
430431
if (dispute.period == Period.evidence) {
431432
require(
@@ -494,6 +495,7 @@ contract xKlerosLiquid is Initializable, TokenController, Arbitrator {
494495
uint _disputeID,
495496
uint _iterations
496497
) external onlyDuringPhase(Phase.drawing) onlyDuringPeriod(_disputeID, Period.evidence) {
498+
require(_disputeID < totalDisputes, "Dispute ID does not exist.");
497499
Dispute storage dispute = disputes[_disputeID];
498500
uint endIndex = dispute.drawsInRound + _iterations;
499501
require(endIndex >= dispute.drawsInRound);
@@ -897,7 +899,7 @@ contract xKlerosLiquid is Initializable, TokenController, Arbitrator {
897899
* In such case allow unstaking. Always allow unstaking.
898900
*/
899901
if ((totalStake - juror.stakedTokens + newTotalStake > maxTotalStakeAllowed) && (newTotalStake > juror.stakedTokens))
900-
return false; // Maximum xPNK stake reached. And
902+
return false; // Maximum PNK stake reached.
901903
// Update total stake.
902904
totalStake = totalStake - juror.stakedTokens + newTotalStake;
903905

contracts/tokens/WrappedPinakion.sol

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* https://contributing.kleros.io/smart-contract-workflow
33
* @authors: [@fnanni-0]
4-
* @reviewers: []
4+
* @reviewers: [@unknownunknown1]
55
* @auditors: []
66
* @bounties: []
77
* @deployments: []
@@ -24,8 +24,6 @@ contract WrappedPinakion is Initializable {
2424
* @dev Emitted when `value` tokens are moved from one account (`from`) to another (`to`).
2525
*
2626
* Note that `value` may be zero.
27-
* Also note that due to continuous minting we cannot emit transfer events from the address 0 when tokens are created.
28-
* In order to keep consistency, we decided not to emit those events from the address 0 even when minting is done within a transaction.
2927
*/
3028
event Transfer(address indexed from, address indexed to, uint256 value);
3129

@@ -52,9 +50,6 @@ contract WrappedPinakion is Initializable {
5250
/// @dev Number of decimals of the token.
5351
uint8 public decimals;
5452

55-
/// @dev The contract's governor.
56-
address public governor;
57-
5853
/// @dev The token's controller.
5954
address public controller;
6055

@@ -66,12 +61,6 @@ contract WrappedPinakion is Initializable {
6661

6762
/* Modifiers */
6863

69-
/// @dev Verifies that the sender has ability to modify governed parameters.
70-
modifier onlyByGovernor() {
71-
require(governor == msg.sender, "The caller is not the governor.");
72-
_;
73-
}
74-
7564
/// @dev Verifies that the sender has ability to modify controlled parameters.
7665
modifier onlyController() {
7766
require(controller == msg.sender, "The caller is not the controller.");
@@ -98,19 +87,11 @@ contract WrappedPinakion is Initializable {
9887
xPinakion = _xPinakion;
9988
tokenBridge = _tokenBridge;
10089

101-
governor = msg.sender;
10290
controller = msg.sender;
10391
}
10492

10593
/* External */
10694

107-
/** @dev Changes `governor` to `_governor`.
108-
* @param _governor The address of the new governor.
109-
*/
110-
function changeGovernor(address _governor) external onlyByGovernor {
111-
governor = _governor;
112-
}
113-
11495
/** @dev Changes `controller` to `_controller`.
11596
* @param _controller The new controller of the contract
11697
*/
@@ -149,7 +130,7 @@ contract WrappedPinakion is Initializable {
149130
tokenBridge.relayTokens(xPinakion, _receiver, _amount);
150131
}
151132

152-
/** @dev Transfers `_amount` to `_recipient` and withdraws accrued tokens.
133+
/** @dev Moves `_amount` tokens from the caller's account to `_recipient`.
153134
* @param _recipient The entity receiving the funds.
154135
* @param _amount The amount to tranfer in base units.
155136
*/
@@ -163,7 +144,8 @@ contract WrappedPinakion is Initializable {
163144
return true;
164145
}
165146

166-
/** @dev Transfers `_amount` from `_sender` to `_recipient` and withdraws accrued tokens.
147+
/** @dev Moves `_amount` tokens from `_sender` to `_recipient` using the
148+
* allowance mechanism. `_amount` is then deducted from the caller's allowance.
167149
* @param _sender The entity to take the funds from.
168150
* @param _recipient The entity receiving the funds.
169151
* @param _amount The amount to tranfer in base units.
@@ -249,7 +231,7 @@ contract WrappedPinakion is Initializable {
249231
emit Transfer(address(0x0), msg.sender, _amount);
250232
}
251233

252-
/** @dev Burns `_amount` of tokens and withdraws accrued tokens.
234+
/** @dev Destroys `_amount` tokens from the caller. Cannot burn locked tokens.
253235
* @param _amount The quantity of tokens to burn in base units.
254236
*/
255237
function _burn(uint256 _amount) internal {
@@ -277,11 +259,11 @@ contract WrappedPinakion is Initializable {
277259
/* Getters */
278260

279261
/**
280-
* @dev Calculates the current user accrued balance.
281-
* @param _human The submission ID.
282-
* @return The current balance.
283-
*/
284-
function balanceOf(address _human) public view returns (uint256) {
285-
return balances[_human];
262+
* @dev Gets the balance of the specified address.
263+
* @param _owner The address to query the balance of.
264+
* @return uint256 value representing the amount owned by the passed address.
265+
*/
266+
function balanceOf(address _owner) public view returns (uint256) {
267+
return balances[_owner];
286268
}
287269
}

test/helpers/events.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function getEmittedEvent(eventName, receipt) {
2-
return receipt.events.find(({event}) => event === eventName);
2+
return receipt.events.find(({ event }) => event === eventName)
33
}
44

55
module.exports = {
66
getEmittedEvent,
7-
};
7+
}

test/helpers/time.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
const {time} = require("@openzeppelin/test-helpers");
1+
const { time } = require('@openzeppelin/test-helpers')
22

33
async function latestBlockNumber() {
4-
return Number(await time.latestBlock());
4+
return Number(await time.latestBlock())
55
}
66

77
async function latestTime() {
8-
return Number(await time.latest());
8+
return Number(await time.latest())
99
}
1010

1111
async function increaseTime(secondsPassed) {
12-
return time.increase(secondsPassed);
12+
return time.increase(secondsPassed)
1313
}
1414

1515
async function advanceBlock() {
16-
return time.advanceBlock();
16+
return time.advanceBlock()
1717
}
1818

1919
async function advanceBlockTo(block) {
20-
return time.advanceBlockTo(block);
20+
return time.advanceBlockTo(block)
2121
}
2222

2323
module.exports = {
@@ -26,4 +26,4 @@ module.exports = {
2626
advanceBlock,
2727
advanceBlockTo,
2828
latestBlockNumber,
29-
};
29+
}

0 commit comments

Comments
 (0)