Skip to content

Commit 781c0cf

Browse files
authored
Merge pull request #14 from kleros/refactor/docs-and-error-messages
docs: add return docs + error messages
2 parents 34368ad + 752fc7a commit 781c0cf

File tree

5 files changed

+60
-24
lines changed

5 files changed

+60
-24
lines changed

.node-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
10.23.0
1+
10.24.1

contracts/kleros/xKlerosLiquid.sol

+3-3
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ contract xKlerosLiquid is Initializable, TokenController, Arbitrator {
176176

177177
// Dispute
178178
// Use a mapping instead of an array so that upgrading (appending variables to) the Dispute struct is possible without big layout changes.
179-
mapping(uint => Dispute) public disputes; // The disputes.
179+
mapping(uint => Dispute) public disputes; // The disputes.
180180
uint public totalDisputes;
181181

182182
// Juror
@@ -395,9 +395,9 @@ contract xKlerosLiquid is Initializable, TokenController, Arbitrator {
395395
if (phase == Phase.staking) {
396396
require(now - lastPhaseChange >= minStakingTime, "The minimum staking time has not passed yet.");
397397
require(disputesWithoutJurors > 0, "There are no disputes that need jurors.");
398-
/** collectRoundLength is added so that the last validator to reveal cannot know
398+
/** collectRoundLength is added so that the last validator to reveal cannot know
399399
* during the staking phase which random seed is going to be used in the drawing phase.
400-
*/
400+
*/
401401
RNBlock = RNGenerator.nextCommitPhaseStartBlock() + RNGenerator.collectRoundLength();
402402
phase = Phase.generating;
403403
} else if (phase == Phase.generating) {

contracts/tokens/WrappedPinakion.sol

+19-5
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: [@unknownunknown1, @MerlinEgalite, @hbarcelos*, @shalzz]
4+
* @reviewers: [@unknownunknown1, @MerlinEgalite, @hbarcelos, @shalzz]
55
* @auditors: []
66
* @bounties: []
77
* @deployments: []
@@ -119,7 +119,7 @@ contract WrappedPinakion is Initializable {
119119
* someone invoking `relayTokensAndCall()` on the Foreign bridge contract.
120120
* @param _token The token address the _amount belongs to.
121121
* @param _amount The amount of wrapped PNK to mint.
122-
* @param _data Calldata containing the address of the recipient.
122+
* @param _data Calldata containing the address of the recipient.
123123
* Notice that the address has to be padded to the right 32 bytes.
124124
*/
125125
function onTokenBridged(
@@ -165,10 +165,14 @@ contract WrappedPinakion is Initializable {
165165
* @notice Moves `_amount` tokens from the caller's account to `_recipient`.
166166
* @param _recipient The entity receiving the funds.
167167
* @param _amount The amount to tranfer in base units.
168+
* @return True on success.
168169
*/
169170
function transfer(address _recipient, uint256 _amount) public returns (bool) {
170171
if (isContract(controller)) {
171-
require(TokenController(controller).onTransfer(msg.sender, _recipient, _amount));
172+
require(
173+
TokenController(controller).onTransfer(msg.sender, _recipient, _amount),
174+
"Token controller rejects transfer."
175+
);
172176
}
173177
balances[msg.sender] = balances[msg.sender].sub(_amount); // ERC20: transfer amount exceeds balance
174178
balances[_recipient] = balances[_recipient].add(_amount);
@@ -182,14 +186,18 @@ contract WrappedPinakion is Initializable {
182186
* @param _sender The entity to take the funds from.
183187
* @param _recipient The entity receiving the funds.
184188
* @param _amount The amount to tranfer in base units.
189+
* @return True on success.
185190
*/
186191
function transferFrom(
187192
address _sender,
188193
address _recipient,
189194
uint256 _amount
190195
) public returns (bool) {
191196
if (isContract(controller)) {
192-
require(TokenController(controller).onTransfer(_sender, _recipient, _amount));
197+
require(
198+
TokenController(controller).onTransfer(_sender, _recipient, _amount),
199+
"Token controller rejects transfer."
200+
);
193201
}
194202

195203
/** The controller of this contract can move tokens around at will,
@@ -211,6 +219,7 @@ contract WrappedPinakion is Initializable {
211219
* @notice Approves `_spender` to spend `_amount`.
212220
* @param _spender The entity allowed to spend funds.
213221
* @param _amount The amount of base units the entity will be allowed to spend.
222+
* @return True on success.
214223
*/
215224
function approve(address _spender, uint256 _amount) public returns (bool) {
216225
// Alerts the token controller of the approve function call
@@ -230,6 +239,7 @@ contract WrappedPinakion is Initializable {
230239
* @notice Increases the `_spender` allowance by `_addedValue`.
231240
* @param _spender The entity allowed to spend funds.
232241
* @param _addedValue The amount of extra base units the entity will be allowed to spend.
242+
* @return True on success.
233243
*/
234244
function increaseAllowance(address _spender, uint256 _addedValue) public returns (bool) {
235245
uint256 newAllowance = allowance[msg.sender][_spender].add(_addedValue);
@@ -250,6 +260,7 @@ contract WrappedPinakion is Initializable {
250260
* @notice Decreases the `_spender` allowance by `_subtractedValue`.
251261
* @param _spender The entity whose spending allocation will be reduced.
252262
* @param _subtractedValue The reduction of spending allocation in base units.
263+
* @return True on success.
253264
*/
254265
function decreaseAllowance(address _spender, uint256 _subtractedValue) public returns (bool) {
255266
uint256 newAllowance = allowance[msg.sender][_spender].sub(_subtractedValue); // ERC20: decreased allowance below zero
@@ -287,7 +298,10 @@ contract WrappedPinakion is Initializable {
287298
*/
288299
function _burn(uint256 _amount) internal {
289300
if (isContract(controller)) {
290-
require(TokenController(controller).onTransfer(msg.sender, address(0x0), _amount));
301+
require(
302+
TokenController(controller).onTransfer(msg.sender, address(0x0), _amount),
303+
"Token controller rejects transfer."
304+
);
291305
}
292306
balances[msg.sender] = balances[msg.sender].sub(_amount); // ERC20: burn amount exceeds balance
293307
totalSupply = totalSupply.sub(_amount);

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"mocha": "^8.1.1",
4141
"npm-run-all": "^4.1.5",
4242
"prettier": "2.3.0",
43-
"prettier-plugin-solidity": "^1.0.0-beta.10",
43+
"prettier-plugin-solidity": "1.0.0-beta.6",
4444
"solhint": "^3.3.4",
4545
"solhint-plugin-prettier": "^0.0.5",
4646
"solidity-coverage": "^0.5.11",

yarn.lock

+36-14
Original file line numberDiff line numberDiff line change
@@ -1916,9 +1916,16 @@
19161916
integrity sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ==
19171917

19181918
"@solidity-parser/parser@^0.12.0":
1919-
version "0.12.0"
1920-
resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.12.0.tgz#18a0fb2a9d2484b23176f63b16093c64794fc323"
1921-
integrity sha512-DT3f/Aa4tQysZwUsuqBwvr8YRJzKkvPUKV/9o2/o5EVw3xqlbzmtx4O60lTUcZdCawL+N8bBLNUyOGpHjGlJVQ==
1919+
version "0.12.2"
1920+
resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.12.2.tgz#1afad367cb29a2ed8cdd4a3a62701c2821fb578f"
1921+
integrity sha512-d7VS7PxgMosm5NyaiyDJRNID5pK4AWj1l64Dbz0147hJgy5k2C0/ZiKK/9u5c5K+HRUVHmp+RMvGEjGh84oA5Q==
1922+
1923+
"@solidity-parser/parser@^0.13.2":
1924+
version "0.13.2"
1925+
resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.13.2.tgz#b6c71d8ca0b382d90a7bbed241f9bc110af65cbe"
1926+
integrity sha512-RwHnpRnfrnD2MSPveYoPh8nhofEvX7fgjHk1Oq+NNvCcLx4r1js91CO9o+F/F3fBzOCyvm8kKRTriFICX/odWw==
1927+
dependencies:
1928+
antlr4ts "^0.5.0-alpha.4"
19221929

19231930
"@solidity-parser/parser@^0.8.0":
19241931
version "0.8.2"
@@ -2684,6 +2691,11 @@ [email protected]:
26842691
resolved "https://registry.yarnpkg.com/antlr4/-/antlr4-4.7.1.tgz#69984014f096e9e775f53dd9744bf994d8959773"
26852692
integrity sha512-haHyTW7Y9joE5MVs37P2lNYfU2RWBLfcRDD8OWldcdZm5TiCE91B5Xl1oWSwiDUSd4rlExpt2pu1fksYQjRBYQ==
26862693

2694+
antlr4ts@^0.5.0-alpha.4:
2695+
version "0.5.0-alpha.4"
2696+
resolved "https://registry.yarnpkg.com/antlr4ts/-/antlr4ts-0.5.0-alpha.4.tgz#71702865a87478ed0b40c0709f422cf14d51652a"
2697+
integrity sha512-WPQDt1B74OfPv/IMS2ekXAKkTZIHl88uMetg6q3OTqgFxZ/dxDXI0EWLyZid/1Pe6hTftyg5N7gel5wNAGxXyQ==
2698+
26872699
[email protected], any-promise@^1.0.0, any-promise@^1.3.0:
26882700
version "1.3.0"
26892701
resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f"
@@ -12004,7 +12016,7 @@ prettier-linter-helpers@^1.0.0:
1200412016
dependencies:
1200512017
fast-diff "^1.1.2"
1200612018

12007-
prettier-plugin-solidity@^1.0.0-alpha.56:
12019+
1200812020
version "1.0.0-beta.6"
1200912021
resolved "https://registry.yarnpkg.com/prettier-plugin-solidity/-/prettier-plugin-solidity-1.0.0-beta.6.tgz#aa7b14a60cd6e22e46db75c84d836b569fb63f65"
1201012022
integrity sha512-WymLqd22Hl93t5+HDNLk08TAWp4i4vZMhpihuVqkwOApjCT7mH1qwhLtvf3m+NdU//qj8vrPDmMoT+xc74skcg==
@@ -12018,16 +12030,26 @@ prettier-plugin-solidity@^1.0.0-alpha.56:
1201812030
solidity-comments-extractor "^0.0.4"
1201912031
string-width "^4.2.0"
1202012032

12033+
12034+
version "2.3.0"
12035+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.0.tgz#b6a5bf1284026ae640f17f7ff5658a7567fc0d18"
12036+
integrity sha512-kXtO4s0Lz/DW/IJ9QdWhAf7/NmPWQXkFr/r/WkR3vyI+0v8amTDxiaQSLzs8NBlytfLWX/7uQUMIW677yLKl4w==
12037+
1202112038
prettier@^1.14.3:
1202212039
version "1.19.1"
1202312040
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
1202412041
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
1202512042

12026-
prettier@^2.0.5, prettier@^2.1.2, prettier@^2.2.1:
12043+
prettier@^2.1.2:
1202712044
version "2.2.1"
1202812045
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5"
1202912046
integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==
1203012047

12048+
prettier@^2.2.1:
12049+
version "2.3.1"
12050+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.1.tgz#76903c3f8c4449bc9ac597acefa24dc5ad4cbea6"
12051+
integrity sha512-p+vNbgpLjif/+D+DwAZAbndtRrR0md0MwfmOVN9N+2RgyACMT+7tfaRnT+WDPkqnuVwleyuBIG2XBxKDme3hPA==
12052+
1203112053
private@^0.1.6, private@^0.1.8:
1203212054
version "0.1.8"
1203312055
resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff"
@@ -13394,19 +13416,19 @@ solc@^0.6.3:
1339413416
semver "^5.5.0"
1339513417
tmp "0.0.33"
1339613418

13397-
solhint-plugin-prettier@^0.0.4:
13398-
version "0.0.4"
13399-
resolved "https://registry.yarnpkg.com/solhint-plugin-prettier/-/solhint-plugin-prettier-0.0.4.tgz#ab55ff776d64ff665c52bed41a3b4795c391c9d8"
13400-
integrity sha512-JVxh8ZkD4ydb0EndbNcstpFU+vWzUvX3jr9z6u72+Srg/zjD8JQ1tIMjMn0H1PnsNLItZqPZ6RYIPJB6HOsVMg==
13419+
solhint-plugin-prettier@^0.0.5:
13420+
version "0.0.5"
13421+
resolved "https://registry.yarnpkg.com/solhint-plugin-prettier/-/solhint-plugin-prettier-0.0.5.tgz#e3b22800ba435cd640a9eca805a7f8bc3e3e6a6b"
13422+
integrity sha512-7jmWcnVshIrO2FFinIvDQmhQpfpS2rRRn3RejiYgnjIE68xO2bvrYvjqVNfrio4xH9ghOqn83tKuTzLjEbmGIA==
1340113423
dependencies:
1340213424
prettier-linter-helpers "^1.0.0"
1340313425

13404-
solhint@^3.2.0:
13405-
version "3.3.4"
13406-
resolved "https://registry.yarnpkg.com/solhint/-/solhint-3.3.4.tgz#81770c60eeb027e6e447cb91ed599baf5e888e09"
13407-
integrity sha512-AEyjshF/PC6kox1c1l79Pji+DK9WVuk5u2WEh6bBKt188gWa63NBOAgYg0fBRr5CTUmsuGc1sGH7dgUVs83mKw==
13426+
solhint@^3.3.4:
13427+
version "3.3.6"
13428+
resolved "https://registry.yarnpkg.com/solhint/-/solhint-3.3.6.tgz#abe9af185a9a7defefba480047b3e42cbe9a1210"
13429+
integrity sha512-HWUxTAv2h7hx3s3hAab3ifnlwb02ZWhwFU/wSudUHqteMS3ll9c+m1FlGn9V8ztE2rf3Z82fQZA005Wv7KpcFA==
1340813430
dependencies:
13409-
"@solidity-parser/parser" "^0.12.0"
13431+
"@solidity-parser/parser" "^0.13.2"
1341013432
ajv "^6.6.1"
1341113433
antlr4 "4.7.1"
1341213434
ast-parents "0.0.1"

0 commit comments

Comments
 (0)