@reality.eth/contracts 3.0.45 → 3.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +16 -0
- package/abi/solc-0.8.20/RealityETH-4.0.abi.json +1 -0
- package/abi/solc-0.8.20/RealityETH_ERC20-4.0.abi.json +1 -0
- package/bytecode/Arbitrator.bin +1 -1
- package/bytecode/RealityETH-3.0.bin +1 -1
- package/bytecode/RealityETH-4.0.bin +1 -0
- package/bytecode/RealityETH_ERC20-3.0.bin +1 -1
- package/bytecode/RealityETH_ERC20-4.0.bin +1 -0
- package/chains/chainid.network.json +5033 -431
- package/chains/deployments/300/ETH/RealityETH-3.0.json +7 -0
- package/chains/supported.json +3 -0
- package/development/contracts/.solhint.json +9 -0
- package/development/contracts/Arbitrator.sol +32 -81
- package/development/contracts/BalanceHolder.sol +4 -10
- package/development/contracts/BalanceHolder_ERC20.sol +5 -11
- package/development/contracts/CallbackClient.sol +3 -10
- package/development/contracts/ERC20Token.sol +29 -30
- package/development/contracts/ExplodingCallbackClient.sol +1 -4
- package/development/contracts/IArbitrator.sol +23 -23
- package/development/contracts/IArbitratorCore.sol +14 -0
- package/development/contracts/IArbitratorCrowdFundable.sol +8 -0
- package/development/contracts/IArbitratorErrors.sol +10 -0
- package/development/contracts/IArbitratorForeignProxy.sol +15 -7
- package/development/contracts/IArbitratorLegacy.sol +9 -0
- package/development/contracts/IArbitratorManagement.sol +25 -0
- package/development/contracts/IBalanceHolder.sol +3 -3
- package/development/contracts/IBalanceHolder_ERC20.sol +5 -5
- package/development/contracts/IERC20.sol +4 -5
- package/development/contracts/IOwned.sol +3 -3
- package/development/contracts/IRealityETH.sol +5 -58
- package/development/contracts/IRealityETHCommitReveal.sol +17 -0
- package/development/contracts/IRealityETHCommitReveal_ERC20.sol +16 -0
- package/development/contracts/IRealityETHCore.sol +135 -0
- package/development/contracts/IRealityETHCore_ERC20.sol +149 -0
- package/development/contracts/IRealityETHErrors.sol +86 -0
- package/development/contracts/IRealityETHErrors_ERC20.sol +13 -0
- package/development/contracts/IRealityETH_ERC20.sol +5 -62
- package/development/contracts/Owned.sol +4 -6
- package/development/contracts/{RealityETH-3.0.sol → RealityETH-4.0.sol} +221 -383
- package/development/contracts/{RealityETH_ERC20-3.0.sol → RealityETH_ERC20-4.0.sol} +238 -474
- package/development/contracts/RealityETH_ERC20_Factory.sol +47 -42
- package/development/contracts/RegisteredWalletArbitrator.sol +8 -15
- package/development/contracts/compile.py +3 -0
- package/development/scripts/string_to_error.py +111 -0
- package/development/version_checksums/check_matches_flat.sh +20 -0
- package/development/version_checksums/check_matches_last.sh +37 -0
- package/development/version_checksums/log_bytecode_history.sh +41 -0
- package/generated/chains.json +33 -5
- package/generated/tokens.json +1 -0
- package/non_standard_deployments/zksync/LICENSE +21 -0
- package/non_standard_deployments/zksync/README.md +51 -0
- package/non_standard_deployments/zksync/deploy/deploy.ts +11 -0
- package/non_standard_deployments/zksync/deploy/utils.ts +168 -0
- package/non_standard_deployments/zksync/hardhat.config.ts +55 -0
- package/non_standard_deployments/zksync/package-lock.json +6295 -0
- package/non_standard_deployments/zksync/package.json +34 -0
- package/package.json +7 -3
- package/scripts/transfer_arbitrator.js +60 -0
- package/tests/python/requirements.txt +55 -54
- package/tests/python/test.py +150 -50
- package/tests/python/test_erc20.py +15 -14
- package/tokens/ETH.json +3 -2
- package/non_standard_deployments/zksync2/README +0 -21
- package/non_standard_deployments/zksync2/contracts/RealityETH_ERC20-3.0.sol +0 -1096
- package/non_standard_deployments/zksync2/deploy/deploy.ts +0 -62
- package/non_standard_deployments/zksync2/deploy/deploy_erc20.ts +0 -56
- package/non_standard_deployments/zksync2/deploy/deploy_mainnet.ts +0 -46
- package/non_standard_deployments/zksync2/hardhat.config.ts +0 -27
- package/non_standard_deployments/zksync2/package.json +0 -15
- package/non_standard_deployments/zksync2/yarn.lock +0 -2898
- /package/non_standard_deployments/{zksync2 → zksync}/contracts/RealityETH-3.0.sol +0 -0
package/chains/supported.json
CHANGED
|
@@ -72,6 +72,9 @@
|
|
|
72
72
|
"explorerURL": "https://zksync2-testnet.zkscan.io",
|
|
73
73
|
"network_name": "zkSync2-testnet"
|
|
74
74
|
},
|
|
75
|
+
"300": {
|
|
76
|
+
"network_name": "zksync-era-sepolia"
|
|
77
|
+
},
|
|
75
78
|
"324": {
|
|
76
79
|
"explorerURL": "https://explorer.zksync.io/",
|
|
77
80
|
"graphURL": "https://api.thegraph.com/subgraphs/name/realityeth/realityeth-zksync-era",
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
2
|
|
|
3
|
-
pragma solidity ^0.8.
|
|
3
|
+
pragma solidity ^0.8.20;
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
5
|
+
import {IArbitrator} from "./IArbitrator.sol";
|
|
6
|
+
import {IRealityETH} from "./IRealityETH.sol";
|
|
7
|
+
import {IERC20} from "./IERC20.sol";
|
|
8
|
+
import {Owned} from "./Owned.sol";
|
|
9
9
|
|
|
10
10
|
contract Arbitrator is Owned, IArbitrator {
|
|
11
|
-
|
|
12
11
|
IRealityETH public realitio;
|
|
13
12
|
|
|
14
13
|
mapping(bytes32 => uint256) public arbitration_bounties;
|
|
@@ -18,56 +17,26 @@ contract Arbitrator is Owned, IArbitrator {
|
|
|
18
17
|
|
|
19
18
|
string public metadata;
|
|
20
19
|
|
|
21
|
-
event LogRequestArbitration(
|
|
22
|
-
bytes32 indexed question_id,
|
|
23
|
-
uint256 fee_paid,
|
|
24
|
-
address requester,
|
|
25
|
-
uint256 remaining
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
event LogSetRealitio(
|
|
29
|
-
address realitio
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
event LogSetQuestionFee(
|
|
33
|
-
uint256 fee
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
event LogSetDisputeFee(
|
|
38
|
-
uint256 fee
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
event LogSetCustomDisputeFee(
|
|
42
|
-
bytes32 indexed question_id,
|
|
43
|
-
uint256 fee
|
|
44
|
-
);
|
|
45
|
-
|
|
46
20
|
/// @notice Constructor. Sets the deploying address as owner.
|
|
47
21
|
constructor() {
|
|
48
22
|
owner = msg.sender;
|
|
49
23
|
}
|
|
50
24
|
|
|
51
25
|
/// @notice Returns the Realitio contract address - deprecated in favour of realitio()
|
|
52
|
-
function realitycheck()
|
|
53
|
-
external view returns(IRealityETH) {
|
|
26
|
+
function realitycheck() external view returns (IRealityETH) {
|
|
54
27
|
return realitio;
|
|
55
28
|
}
|
|
56
29
|
|
|
57
30
|
/// @notice Set the Reality Check contract address
|
|
58
31
|
/// @param addr The address of the Reality Check contract
|
|
59
|
-
function setRealitio(address addr)
|
|
60
|
-
onlyOwner
|
|
61
|
-
public {
|
|
32
|
+
function setRealitio(address addr) public onlyOwner {
|
|
62
33
|
realitio = IRealityETH(addr);
|
|
63
34
|
emit LogSetRealitio(addr);
|
|
64
35
|
}
|
|
65
36
|
|
|
66
37
|
/// @notice Set the default fee
|
|
67
38
|
/// @param fee The default fee amount
|
|
68
|
-
function setDisputeFee(uint256 fee)
|
|
69
|
-
onlyOwner
|
|
70
|
-
public {
|
|
39
|
+
function setDisputeFee(uint256 fee) public onlyOwner {
|
|
71
40
|
dispute_fee = fee;
|
|
72
41
|
emit LogSetDisputeFee(fee);
|
|
73
42
|
}
|
|
@@ -75,9 +44,7 @@ contract Arbitrator is Owned, IArbitrator {
|
|
|
75
44
|
/// @notice Set a custom fee for this particular question
|
|
76
45
|
/// @param question_id The question in question
|
|
77
46
|
/// @param fee The fee amount
|
|
78
|
-
function setCustomDisputeFee(bytes32 question_id, uint256 fee)
|
|
79
|
-
onlyOwner
|
|
80
|
-
public {
|
|
47
|
+
function setCustomDisputeFee(bytes32 question_id, uint256 fee) public onlyOwner {
|
|
81
48
|
custom_dispute_fees[question_id] = fee;
|
|
82
49
|
emit LogSetCustomDisputeFee(question_id, fee);
|
|
83
50
|
}
|
|
@@ -85,8 +52,7 @@ contract Arbitrator is Owned, IArbitrator {
|
|
|
85
52
|
/// @notice Return the dispute fee for the specified question. 0 indicates that we won't arbitrate it.
|
|
86
53
|
/// @param question_id The question in question
|
|
87
54
|
/// @dev Uses a general default, but can be over-ridden on a question-by-question basis.
|
|
88
|
-
function getDisputeFee(bytes32 question_id)
|
|
89
|
-
public view returns (uint256) {
|
|
55
|
+
function getDisputeFee(bytes32 question_id) public view returns (uint256) {
|
|
90
56
|
return (custom_dispute_fees[question_id] > 0) ? custom_dispute_fees[question_id] : dispute_fee;
|
|
91
57
|
}
|
|
92
58
|
|
|
@@ -96,9 +62,7 @@ contract Arbitrator is Owned, IArbitrator {
|
|
|
96
62
|
/// You could set an impossibly high fee if you want to prevent us being used as arbitrator unless we submit the question.
|
|
97
63
|
/// (Submitting the question ourselves is not implemented here.)
|
|
98
64
|
/// This fee can be used as a revenue source, an anti-spam measure, or both.
|
|
99
|
-
function setQuestionFee(uint256 fee)
|
|
100
|
-
onlyOwner
|
|
101
|
-
public {
|
|
65
|
+
function setQuestionFee(uint256 fee) public onlyOwner {
|
|
102
66
|
realitio.setQuestionFee(fee);
|
|
103
67
|
emit LogSetQuestionFee(fee);
|
|
104
68
|
}
|
|
@@ -107,9 +71,7 @@ contract Arbitrator is Owned, IArbitrator {
|
|
|
107
71
|
/// @param question_id The question in question
|
|
108
72
|
/// @param answer The answer
|
|
109
73
|
/// @param answerer The answerer. If arbitration changed the answer, it should be the payer. If not, the old answerer.
|
|
110
|
-
function submitAnswerByArbitrator(bytes32 question_id, bytes32 answer, address answerer)
|
|
111
|
-
onlyOwner
|
|
112
|
-
public {
|
|
74
|
+
function submitAnswerByArbitrator(bytes32 question_id, bytes32 answer, address answerer) public onlyOwner {
|
|
113
75
|
delete arbitration_bounties[question_id];
|
|
114
76
|
realitio.submitAnswerByArbitrator(question_id, answer, answerer);
|
|
115
77
|
}
|
|
@@ -121,9 +83,14 @@ contract Arbitrator is Owned, IArbitrator {
|
|
|
121
83
|
/// @param last_history_hash The history hash before the final one
|
|
122
84
|
/// @param last_answer_or_commitment_id The last answer given, or the commitment ID if it was a commitment.
|
|
123
85
|
/// @param last_answerer The address that supplied the last answer
|
|
124
|
-
function assignWinnerAndSubmitAnswerByArbitrator(
|
|
125
|
-
|
|
126
|
-
|
|
86
|
+
function assignWinnerAndSubmitAnswerByArbitrator(
|
|
87
|
+
bytes32 question_id,
|
|
88
|
+
bytes32 answer,
|
|
89
|
+
address payee_if_wrong,
|
|
90
|
+
bytes32 last_history_hash,
|
|
91
|
+
bytes32 last_answer_or_commitment_id,
|
|
92
|
+
address last_answerer
|
|
93
|
+
) public onlyOwner {
|
|
127
94
|
delete arbitration_bounties[question_id];
|
|
128
95
|
realitio.assignWinnerAndSubmitAnswerByArbitrator(question_id, answer, payee_if_wrong, last_history_hash, last_answer_or_commitment_id, last_answerer);
|
|
129
96
|
}
|
|
@@ -131,9 +98,7 @@ contract Arbitrator is Owned, IArbitrator {
|
|
|
131
98
|
/// @notice Cancel a previous arbitration request
|
|
132
99
|
/// @dev This is intended for situations where the arbitration is happening non-atomically and the fee or something change.
|
|
133
100
|
/// @param question_id The question in question
|
|
134
|
-
function cancelArbitration(bytes32 question_id)
|
|
135
|
-
onlyOwner
|
|
136
|
-
public {
|
|
101
|
+
function cancelArbitration(bytes32 question_id) public onlyOwner {
|
|
137
102
|
realitio.cancelArbitration(question_id);
|
|
138
103
|
}
|
|
139
104
|
|
|
@@ -142,11 +107,9 @@ contract Arbitrator is Owned, IArbitrator {
|
|
|
142
107
|
/// Will trigger an error if the notification fails, eg because the question has already been finalized
|
|
143
108
|
/// @param question_id The question in question
|
|
144
109
|
/// @param max_previous If specified, reverts if a bond higher than this was submitted after you sent your transaction.
|
|
145
|
-
function requestArbitration(bytes32 question_id, uint256 max_previous)
|
|
146
|
-
external payable returns (bool) {
|
|
147
|
-
|
|
110
|
+
function requestArbitration(bytes32 question_id, uint256 max_previous) external payable returns (bool) {
|
|
148
111
|
uint256 arbitration_fee = getDisputeFee(question_id);
|
|
149
|
-
|
|
112
|
+
if (arbitration_fee == 0) revert TheArbitratorMustHaveSetANonZeroFeeForTheQuestion();
|
|
150
113
|
|
|
151
114
|
arbitration_bounties[question_id] += msg.value;
|
|
152
115
|
uint256 paid = arbitration_bounties[question_id];
|
|
@@ -156,50 +119,38 @@ contract Arbitrator is Owned, IArbitrator {
|
|
|
156
119
|
emit LogRequestArbitration(question_id, msg.value, msg.sender, 0);
|
|
157
120
|
return true;
|
|
158
121
|
} else {
|
|
159
|
-
|
|
122
|
+
if (realitio.isFinalized(question_id)) revert TheQuestionMustNotHaveBeenFinalized();
|
|
160
123
|
emit LogRequestArbitration(question_id, msg.value, msg.sender, arbitration_fee - paid);
|
|
161
124
|
return false;
|
|
162
125
|
}
|
|
163
|
-
|
|
164
126
|
}
|
|
165
127
|
|
|
166
128
|
/// @notice Withdraw any accumulated ETH fees to the specified address
|
|
167
129
|
/// @param addr The address to which the balance should be sent
|
|
168
|
-
function withdraw(address addr)
|
|
169
|
-
|
|
170
|
-
public {
|
|
171
|
-
payable(addr).transfer(address(this).balance);
|
|
130
|
+
function withdraw(address addr) public onlyOwner {
|
|
131
|
+
payable(addr).transfer(address(this).balance);
|
|
172
132
|
}
|
|
173
133
|
|
|
174
134
|
/// @notice Withdraw any accumulated token fees to the specified address
|
|
175
135
|
/// @param addr The address to which the balance should be sent
|
|
176
136
|
/// @dev Only needed if the Realitio contract used is using an ERC20 token
|
|
177
137
|
/// @dev Also only normally useful if a per-question fee is set, otherwise we only have ETH.
|
|
178
|
-
function withdrawERC20(IERC20 _token, address addr)
|
|
179
|
-
onlyOwner
|
|
180
|
-
public {
|
|
138
|
+
function withdrawERC20(IERC20 _token, address addr) public onlyOwner {
|
|
181
139
|
uint256 bal = _token.balanceOf(address(this));
|
|
182
|
-
IERC20(_token).transfer(addr, bal);
|
|
140
|
+
IERC20(_token).transfer(addr, bal);
|
|
183
141
|
}
|
|
184
142
|
|
|
185
|
-
receive()
|
|
186
|
-
external payable {
|
|
187
|
-
}
|
|
143
|
+
receive() external payable {}
|
|
188
144
|
|
|
189
145
|
/// @notice Withdraw any accumulated question fees from the specified address into this contract
|
|
190
146
|
/// @dev Funds can then be liberated from this contract with our withdraw() function
|
|
191
147
|
/// @dev This works in the same way whether the realitio contract is using ETH or an ERC20 token
|
|
192
|
-
function callWithdraw()
|
|
193
|
-
|
|
194
|
-
public {
|
|
195
|
-
realitio.withdraw();
|
|
148
|
+
function callWithdraw() public onlyOwner {
|
|
149
|
+
realitio.withdraw();
|
|
196
150
|
}
|
|
197
151
|
|
|
198
152
|
/// @notice Set a metadata string, expected to be JSON, containing things like arbitrator TOS address
|
|
199
|
-
function setMetaData(string memory _metadata)
|
|
200
|
-
onlyOwner
|
|
201
|
-
external {
|
|
153
|
+
function setMetaData(string memory _metadata) external onlyOwner {
|
|
202
154
|
metadata = _metadata;
|
|
203
155
|
}
|
|
204
|
-
|
|
205
156
|
}
|
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
2
|
|
|
3
|
-
pragma solidity ^0.8.
|
|
3
|
+
pragma solidity ^0.8.20;
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import {IBalanceHolder} from "./IBalanceHolder.sol";
|
|
6
6
|
|
|
7
7
|
contract BalanceHolder is IBalanceHolder {
|
|
8
|
-
|
|
9
8
|
mapping(address => uint256) public balanceOf;
|
|
10
9
|
|
|
11
|
-
event LogWithdraw(
|
|
12
|
-
address indexed user,
|
|
13
|
-
uint256 amount
|
|
14
|
-
);
|
|
10
|
+
event LogWithdraw(address indexed user, uint256 amount);
|
|
15
11
|
|
|
16
|
-
function withdraw()
|
|
17
|
-
public {
|
|
12
|
+
function withdraw() public {
|
|
18
13
|
uint256 bal = balanceOf[msg.sender];
|
|
19
14
|
balanceOf[msg.sender] = 0;
|
|
20
15
|
payable(msg.sender).transfer(bal);
|
|
21
16
|
emit LogWithdraw(msg.sender, bal);
|
|
22
17
|
}
|
|
23
|
-
|
|
24
18
|
}
|
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
2
|
|
|
3
|
-
pragma solidity ^0.8.
|
|
3
|
+
pragma solidity ^0.8.20;
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import {IERC20} from "./IERC20.sol";
|
|
6
|
+
import {IBalanceHolder_ERC20} from "./IBalanceHolder_ERC20.sol";
|
|
7
7
|
|
|
8
8
|
contract BalanceHolder_ERC20 is IBalanceHolder_ERC20 {
|
|
9
|
-
|
|
10
9
|
IERC20 public token;
|
|
11
10
|
|
|
12
11
|
mapping(address => uint256) public balanceOf;
|
|
13
12
|
|
|
14
|
-
event LogWithdraw(
|
|
15
|
-
address indexed user,
|
|
16
|
-
uint256 amount
|
|
17
|
-
);
|
|
13
|
+
event LogWithdraw(address indexed user, uint256 amount);
|
|
18
14
|
|
|
19
|
-
function withdraw()
|
|
20
|
-
public {
|
|
15
|
+
function withdraw() public {
|
|
21
16
|
uint256 bal = balanceOf[msg.sender];
|
|
22
17
|
balanceOf[msg.sender] = 0;
|
|
23
18
|
require(token.transfer(msg.sender, bal));
|
|
24
19
|
emit LogWithdraw(msg.sender, bal);
|
|
25
20
|
}
|
|
26
|
-
|
|
27
21
|
}
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
pragma solidity ^0.4.25;
|
|
2
2
|
|
|
3
3
|
contract CallbackClient {
|
|
4
|
+
mapping(bytes32 => bytes32) public answers;
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
event LogCallback(bytes32 question_id, bytes32 question_answer, address sender);
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
bytes32 question_id,
|
|
9
|
-
bytes32 question_answer,
|
|
10
|
-
address sender
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
function __realitycheck_callback(bytes32 question_id, bytes32 question_answer)
|
|
14
|
-
public {
|
|
8
|
+
function __realitycheck_callback(bytes32 question_id, bytes32 question_answer) public {
|
|
15
9
|
answers[question_id] = question_answer;
|
|
16
10
|
emit LogCallback(question_id, question_answer, msg.sender);
|
|
17
11
|
}
|
|
18
|
-
|
|
19
12
|
}
|
|
@@ -6,8 +6,8 @@ pragma solidity ^0.4.25;
|
|
|
6
6
|
*/
|
|
7
7
|
library SafeMath {
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
* @dev Multiplies two numbers, reverts on overflow.
|
|
10
|
+
*/
|
|
11
11
|
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
12
12
|
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
|
|
13
13
|
// benefit is lost if 'b' is also tested.
|
|
@@ -23,8 +23,8 @@ library SafeMath {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
|
|
27
|
+
*/
|
|
28
28
|
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
29
29
|
// Solidity only automatically asserts when dividing by 0
|
|
30
30
|
require(b > 0);
|
|
@@ -35,8 +35,8 @@ library SafeMath {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
* @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
|
|
39
|
+
*/
|
|
40
40
|
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
41
41
|
require(b <= a);
|
|
42
42
|
uint256 c = a - b;
|
|
@@ -45,8 +45,8 @@ library SafeMath {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
* @dev Adds two numbers, reverts on overflow.
|
|
49
|
+
*/
|
|
50
50
|
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
51
51
|
uint256 c = a + b;
|
|
52
52
|
require(c >= a);
|
|
@@ -55,9 +55,9 @@ library SafeMath {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
* @dev Divides two numbers and returns the remainder (unsigned integer modulo),
|
|
59
|
+
* reverts when dividing by zero.
|
|
60
|
+
*/
|
|
61
61
|
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
|
|
62
62
|
require(b != 0);
|
|
63
63
|
return a % b;
|
|
@@ -96,29 +96,28 @@ interface IERC20 {
|
|
|
96
96
|
contract ERC20 is IERC20 {
|
|
97
97
|
using SafeMath for uint256;
|
|
98
98
|
|
|
99
|
-
mapping
|
|
99
|
+
mapping(address => uint256) private _balances;
|
|
100
100
|
|
|
101
|
-
mapping
|
|
101
|
+
mapping(address => mapping(address => uint256)) private _allowed;
|
|
102
102
|
|
|
103
103
|
uint256 private _totalSupply;
|
|
104
104
|
|
|
105
|
-
function mint(address to, uint256 val)
|
|
106
|
-
public {
|
|
105
|
+
function mint(address to, uint256 val) public {
|
|
107
106
|
_mint(to, val);
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
* @dev Total number of tokens in existence
|
|
111
|
+
*/
|
|
113
112
|
function totalSupply() public view returns (uint256) {
|
|
114
113
|
return _totalSupply;
|
|
115
114
|
}
|
|
116
115
|
|
|
117
116
|
/**
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
117
|
+
* @dev Gets the balance of the specified address.
|
|
118
|
+
* @param owner The address to query the balance of.
|
|
119
|
+
* @return An uint256 representing the amount owned by the passed address.
|
|
120
|
+
*/
|
|
122
121
|
function balanceOf(address owner) public view returns (uint256) {
|
|
123
122
|
return _balances[owner];
|
|
124
123
|
}
|
|
@@ -134,10 +133,10 @@ contract ERC20 is IERC20 {
|
|
|
134
133
|
}
|
|
135
134
|
|
|
136
135
|
/**
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
136
|
+
* @dev Transfer token for a specified address
|
|
137
|
+
* @param to The address to transfer to.
|
|
138
|
+
* @param value The amount to be transferred.
|
|
139
|
+
*/
|
|
141
140
|
function transfer(address to, uint256 value) public returns (bool) {
|
|
142
141
|
_transfer(msg.sender, to, value);
|
|
143
142
|
return true;
|
|
@@ -207,11 +206,11 @@ contract ERC20 is IERC20 {
|
|
|
207
206
|
}
|
|
208
207
|
|
|
209
208
|
/**
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
209
|
+
* @dev Transfer token for a specified addresses
|
|
210
|
+
* @param from The address to transfer from.
|
|
211
|
+
* @param to The address to transfer to.
|
|
212
|
+
* @param value The amount to be transferred.
|
|
213
|
+
*/
|
|
215
214
|
function _transfer(address from, address to, uint256 value) internal {
|
|
216
215
|
require(to != address(0));
|
|
217
216
|
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
pragma solidity ^0.4.25;
|
|
2
2
|
|
|
3
3
|
contract ExplodingCallbackClient {
|
|
4
|
-
|
|
5
4
|
// Just write some state to avoid warnings that this could be pure
|
|
6
5
|
bool impurity;
|
|
7
6
|
|
|
8
|
-
function __realitycheck_callback(bytes32 question_id, bytes32 question_answer)
|
|
9
|
-
public {
|
|
7
|
+
function __realitycheck_callback(bytes32 question_id, bytes32 question_answer) public {
|
|
10
8
|
question_id == 0x0;
|
|
11
9
|
question_answer = 0x0;
|
|
12
10
|
impurity = true;
|
|
13
11
|
revert();
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
2
|
|
|
3
|
-
pragma solidity
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
3
|
+
pragma solidity 0.8.20;
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
This interface describes the Arbitrator contract originally deployed and managed by the reality.eth team. See below for the various parts it comprises.
|
|
7
|
+
For the minimal interface that will be able to interact with the reality.eth UI as an arbitrator, use IArbitratorCore.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {IArbitratorCore} from "./IArbitratorCore.sol";
|
|
11
|
+
|
|
12
|
+
// This provides management functionality to handle ownership, set fees etc.
|
|
13
|
+
import {IArbitratorManagement} from "./IArbitratorManagement.sol";
|
|
14
|
+
|
|
15
|
+
// This provides the old function realitycheck(), replaced by realitio().
|
|
16
|
+
import {IArbitratorLegacy} from "./IArbitratorLegacy.sol";
|
|
17
|
+
|
|
18
|
+
// This provides a function for querying the status of crowd-funded arbitration.
|
|
19
|
+
import {IArbitratorCrowdFundable} from "./IArbitratorCrowdFundable.sol";
|
|
20
|
+
|
|
21
|
+
// Errors (from v4)
|
|
22
|
+
import {IArbitratorErrors} from "./IArbitratorErrors.sol";
|
|
23
|
+
|
|
24
|
+
/* solhint-disable no-empty-blocks */
|
|
25
|
+
interface IArbitrator is IArbitratorCore, IArbitratorLegacy, IArbitratorManagement, IArbitratorCrowdFundable, IArbitratorErrors {}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
|
|
3
|
+
pragma solidity 0.8.20;
|
|
4
|
+
|
|
5
|
+
import {IRealityETH} from "./IRealityETH.sol";
|
|
6
|
+
|
|
7
|
+
interface IArbitratorCore {
|
|
8
|
+
event LogRequestArbitration(bytes32 indexed question_id, uint256 fee_paid, address requester, uint256 remaining);
|
|
9
|
+
|
|
10
|
+
function getDisputeFee(bytes32 question_id) external view returns (uint256);
|
|
11
|
+
function metadata() external view returns (string memory);
|
|
12
|
+
function realitio() external view returns (IRealityETH);
|
|
13
|
+
function requestArbitration(bytes32 question_id, uint256 max_previous) external payable returns (bool);
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
|
|
3
|
+
pragma solidity 0.8.20;
|
|
4
|
+
|
|
5
|
+
interface IArbitratorErrors {
|
|
6
|
+
/// @notice The arbitrator must have set a non-zero fee for the question
|
|
7
|
+
error TheArbitratorMustHaveSetANonZeroFeeForTheQuestion();
|
|
8
|
+
/// @notice The question must not have been finalized
|
|
9
|
+
error TheQuestionMustNotHaveBeenFinalized();
|
|
10
|
+
}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
2
|
|
|
3
|
-
pragma solidity
|
|
3
|
+
pragma solidity 0.8.20;
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/*
|
|
6
|
+
This defines the features needed by a "foreign proxy" for a cross-chain arbitrator as created by Kleros, for example see
|
|
7
|
+
https://github.com/kleros/cross-chain-realitio-proxy
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
In this arrangement, the "foreign" side is deployed on the chain where reality.eth is, and the "home" side is deployed on the chain where Kleros is.
|
|
10
|
+
|
|
11
|
+
If you implement this you should also inherit and implement the functions in IArbitratorCore, with the exception of requestArbitration() which is done on the other chain.
|
|
12
|
+
|
|
13
|
+
The metadata() string defined in IArbitratorCore should return some JSON to tell the UI that it is dealing with a foreign proxy, like:
|
|
14
|
+
{ foreignProxy: true }
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
interface IArbitratorForeignProxy {
|
|
18
|
+
function foreignProxy() external returns (address);
|
|
19
|
+
function foreignChainId() external returns (uint256);
|
|
12
20
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
|
+
|
|
3
|
+
pragma solidity 0.8.20;
|
|
4
|
+
|
|
5
|
+
import {IERC20} from "./IERC20.sol";
|
|
6
|
+
|
|
7
|
+
interface IArbitratorManagement {
|
|
8
|
+
event LogSetRealitio(address realitio);
|
|
9
|
+
|
|
10
|
+
event LogSetQuestionFee(uint256 fee);
|
|
11
|
+
|
|
12
|
+
event LogSetDisputeFee(uint256 fee);
|
|
13
|
+
|
|
14
|
+
event LogSetCustomDisputeFee(bytes32 indexed question_id, uint256 fee);
|
|
15
|
+
|
|
16
|
+
function setRealitio(address addr) external;
|
|
17
|
+
function setDisputeFee(uint256 fee) external;
|
|
18
|
+
function setCustomDisputeFee(bytes32 question_id, uint256 fee) external;
|
|
19
|
+
function setQuestionFee(uint256 fee) external;
|
|
20
|
+
function submitAnswerByArbitrator(bytes32 question_id, bytes32 answer, address answerer) external;
|
|
21
|
+
function withdraw(address addr) external;
|
|
22
|
+
function withdrawERC20(IERC20 _token, address addr) external;
|
|
23
|
+
function callWithdraw() external;
|
|
24
|
+
function setMetaData(string memory _metadata) external;
|
|
25
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
2
2
|
|
|
3
|
-
pragma solidity
|
|
3
|
+
pragma solidity 0.8.20;
|
|
4
4
|
|
|
5
5
|
interface IBalanceHolder {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
function withdraw() external;
|
|
7
|
+
function balanceOf(address) external view returns (uint256);
|
|
8
8
|
}
|