@reality.eth/contracts 3.0.46 → 3.0.48

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.
Files changed (72) hide show
  1. package/.prettierrc +16 -0
  2. package/abi/solc-0.8.20/RealityETH-4.0.abi.json +1 -0
  3. package/abi/solc-0.8.20/RealityETH_ERC20-4.0.abi.json +1 -0
  4. package/bytecode/Arbitrator.bin +1 -1
  5. package/bytecode/RealityETH-3.0.bin +1 -1
  6. package/bytecode/RealityETH-4.0.bin +1 -0
  7. package/bytecode/RealityETH_ERC20-3.0.bin +1 -1
  8. package/bytecode/RealityETH_ERC20-4.0.bin +1 -0
  9. package/chains/chainid.network.json +5033 -431
  10. package/chains/deployments/300/ETH/RealityETH-3.0.json +7 -0
  11. package/chains/supported.json +3 -0
  12. package/development/contracts/.solhint.json +9 -0
  13. package/development/contracts/Arbitrator.sol +32 -56
  14. package/development/contracts/BalanceHolder.sol +4 -10
  15. package/development/contracts/BalanceHolder_ERC20.sol +5 -11
  16. package/development/contracts/CallbackClient.sol +3 -10
  17. package/development/contracts/ERC20Token.sol +29 -30
  18. package/development/contracts/ExplodingCallbackClient.sol +1 -4
  19. package/development/contracts/IArbitrator.sol +10 -7
  20. package/development/contracts/IArbitratorCore.sol +7 -14
  21. package/development/contracts/IArbitratorCrowdFundable.sol +3 -2
  22. package/development/contracts/IArbitratorErrors.sol +10 -0
  23. package/development/contracts/IArbitratorForeignProxy.sol +1 -1
  24. package/development/contracts/IArbitratorLegacy.sol +3 -3
  25. package/development/contracts/IArbitratorManagement.sol +15 -27
  26. package/development/contracts/IBalanceHolder.sol +3 -3
  27. package/development/contracts/IBalanceHolder_ERC20.sol +5 -5
  28. package/development/contracts/IERC20.sol +4 -5
  29. package/development/contracts/IOwned.sol +3 -3
  30. package/development/contracts/IRealityETH.sol +5 -58
  31. package/development/contracts/IRealityETHCommitReveal.sol +17 -0
  32. package/development/contracts/IRealityETHCommitReveal_ERC20.sol +16 -0
  33. package/development/contracts/IRealityETHCore.sol +135 -0
  34. package/development/contracts/IRealityETHCore_ERC20.sol +149 -0
  35. package/development/contracts/IRealityETHErrors.sol +86 -0
  36. package/development/contracts/IRealityETHErrors_ERC20.sol +13 -0
  37. package/development/contracts/IRealityETH_ERC20.sol +5 -62
  38. package/development/contracts/Owned.sol +4 -6
  39. package/development/contracts/{RealityETH-3.0.sol → RealityETH-4.0.sol} +221 -383
  40. package/development/contracts/{RealityETH_ERC20-3.0.sol → RealityETH_ERC20-4.0.sol} +238 -474
  41. package/development/contracts/RealityETH_ERC20_Factory.sol +47 -42
  42. package/development/contracts/RegisteredWalletArbitrator.sol +8 -15
  43. package/development/contracts/compile.py +3 -0
  44. package/development/scripts/string_to_error.py +111 -0
  45. package/development/version_checksums/check_matches_flat.sh +20 -0
  46. package/development/version_checksums/check_matches_last.sh +37 -0
  47. package/development/version_checksums/log_bytecode_history.sh +41 -0
  48. package/generated/chains.json +33 -5
  49. package/generated/contracts.json +10 -0
  50. package/generated/tokens.json +1 -0
  51. package/non_standard_deployments/zksync/LICENSE +21 -0
  52. package/non_standard_deployments/zksync/README.md +51 -0
  53. package/non_standard_deployments/zksync/deploy/deploy.ts +11 -0
  54. package/non_standard_deployments/zksync/deploy/utils.ts +168 -0
  55. package/non_standard_deployments/zksync/hardhat.config.ts +55 -0
  56. package/non_standard_deployments/zksync/package-lock.json +6295 -0
  57. package/non_standard_deployments/zksync/package.json +34 -0
  58. package/package.json +7 -3
  59. package/scripts/transfer_arbitrator.js +60 -0
  60. package/tests/python/requirements.txt +55 -54
  61. package/tests/python/test.py +150 -50
  62. package/tests/python/test_erc20.py +15 -14
  63. package/tokens/ETH.json +3 -2
  64. package/non_standard_deployments/zksync2/README +0 -21
  65. package/non_standard_deployments/zksync2/contracts/RealityETH_ERC20-3.0.sol +0 -1096
  66. package/non_standard_deployments/zksync2/deploy/deploy.ts +0 -62
  67. package/non_standard_deployments/zksync2/deploy/deploy_erc20.ts +0 -56
  68. package/non_standard_deployments/zksync2/deploy/deploy_mainnet.ts +0 -46
  69. package/non_standard_deployments/zksync2/hardhat.config.ts +0 -27
  70. package/non_standard_deployments/zksync2/package.json +0 -15
  71. package/non_standard_deployments/zksync2/yarn.lock +0 -2898
  72. /package/non_standard_deployments/{zksync2 → zksync}/contracts/RealityETH-3.0.sol +0 -0
@@ -1,7 +1,6 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-only
2
2
 
3
- pragma solidity 0.8.10;
4
-
3
+ pragma solidity 0.8.20;
5
4
 
6
5
  /**
7
6
  * @title ERC20 interface
@@ -20,11 +19,11 @@ interface IERC20 {
20
19
 
21
20
  function transferFrom(address from, address to, uint256 value) external returns (bool);
22
21
 
23
- function decimals() external returns (uint8);
22
+ function decimals() external returns (uint8);
24
23
 
25
- function name() external returns (string memory);
24
+ function name() external returns (string memory);
26
25
 
27
- function symbol() external returns (string memory);
26
+ function symbol() external returns (string memory);
28
27
 
29
28
  event Transfer(address indexed from, address indexed to, uint256 value);
30
29
 
@@ -1,8 +1,8 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-only
2
2
 
3
- pragma solidity 0.8.10;
3
+ pragma solidity 0.8.20;
4
4
 
5
5
  interface IOwned {
6
- function owner ( ) external view returns ( address );
7
- function transferOwnership ( address newOwner ) external;
6
+ function owner() external view returns (address);
7
+ function transferOwnership(address newOwner) external;
8
8
  }
@@ -1,63 +1,10 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-only
2
2
 
3
- pragma solidity 0.8.10;
3
+ pragma solidity 0.8.20;
4
4
 
5
- import './IBalanceHolder.sol';
5
+ import {IRealityETHCore} from "./IRealityETHCore.sol";
6
+ import {IRealityETHCommitReveal} from "./IRealityETHCommitReveal.sol";
6
7
 
7
- interface IRealityETH is IBalanceHolder {
8
- event LogAnswerReveal (bytes32 indexed question_id, address indexed user, bytes32 indexed answer_hash, bytes32 answer, uint256 nonce, uint256 bond);
9
- event LogCancelArbitration (bytes32 indexed question_id);
10
- event LogClaim (bytes32 indexed question_id, address indexed user, uint256 amount);
11
- event LogFinalize (bytes32 indexed question_id, bytes32 indexed answer);
12
- event LogFundAnswerBounty (bytes32 indexed question_id, uint256 bounty_added, uint256 bounty, address indexed user);
13
- event LogMinimumBond (bytes32 indexed question_id, uint256 min_bond);
14
- event LogNewAnswer (bytes32 answer, bytes32 indexed question_id, bytes32 history_hash, address indexed user, uint256 bond, uint256 ts, bool is_commitment);
15
- event LogNewQuestion (bytes32 indexed question_id, address indexed user, uint256 template_id, string question, bytes32 indexed content_hash, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 created);
16
- event LogNewTemplate (uint256 indexed template_id, address indexed user, string question_text);
17
- event LogNotifyOfArbitrationRequest (bytes32 indexed question_id, address indexed user);
18
- event LogReopenQuestion (bytes32 indexed question_id, bytes32 indexed reopened_question_id);
19
- event LogSetQuestionFee (address arbitrator, uint256 amount);
8
+ /* solhint-disable func-name-mixedcase */
20
9
 
21
- function assignWinnerAndSubmitAnswerByArbitrator (bytes32 question_id, bytes32 answer, address payee_if_wrong, bytes32 last_history_hash, bytes32 last_answer_or_commitment_id, address last_answerer) external;
22
- function cancelArbitration (bytes32 question_id) external;
23
- function claimMultipleAndWithdrawBalance (bytes32[] calldata question_ids, uint256[] calldata lengths, bytes32[] calldata hist_hashes, address[] calldata addrs, uint256[] calldata bonds, bytes32[] calldata answers) external;
24
- function claimWinnings (bytes32 question_id, bytes32[] calldata history_hashes, address[] calldata addrs, uint256[] calldata bonds, bytes32[] calldata answers) external;
25
- function createTemplate (string calldata content) external returns (uint256);
26
- function notifyOfArbitrationRequest (bytes32 question_id, address requester, uint256 max_previous) external;
27
- function setQuestionFee (uint256 fee) external;
28
- function submitAnswerByArbitrator (bytes32 question_id, bytes32 answer, address answerer) external;
29
- function submitAnswerReveal (bytes32 question_id, bytes32 answer, uint256 nonce, uint256 bond) external;
30
- function askQuestion (uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce) external payable returns (bytes32);
31
- function askQuestionWithMinBond (uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 min_bond) external payable returns (bytes32);
32
- function createTemplateAndAskQuestion (string calldata content, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce) external payable returns (bytes32);
33
- function fundAnswerBounty (bytes32 question_id) external payable;
34
- function reopenQuestion (uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 min_bond, bytes32 reopens_question_id) external payable returns (bytes32);
35
- function submitAnswer (bytes32 question_id, bytes32 answer, uint256 max_previous) external payable;
36
- function submitAnswerCommitment (bytes32 question_id, bytes32 answer_hash, uint256 max_previous, address _answerer) external payable;
37
- function submitAnswerFor (bytes32 question_id, bytes32 answer, uint256 max_previous, address answerer) external payable;
38
- function arbitrator_question_fees (address) external view returns (uint256);
39
- function commitments (bytes32) external view returns (uint32 reveal_ts, bool is_revealed, bytes32 revealed_answer);
40
- function getArbitrator (bytes32 question_id) external view returns (address);
41
- function getBestAnswer (bytes32 question_id) external view returns (bytes32);
42
- function getBond (bytes32 question_id) external view returns (uint256);
43
- function getBounty (bytes32 question_id) external view returns (uint256);
44
- function getContentHash (bytes32 question_id) external view returns (bytes32);
45
- function getFinalAnswer (bytes32 question_id) external view returns (bytes32);
46
- function getFinalAnswerIfMatches (bytes32 question_id, bytes32 content_hash, address arbitrator, uint32 min_timeout, uint256 min_bond) external view returns (bytes32);
47
- function getFinalizeTS (bytes32 question_id) external view returns (uint32);
48
- function getHistoryHash (bytes32 question_id) external view returns (bytes32);
49
- function getMinBond (bytes32 question_id) external view returns (uint256);
50
- function getOpeningTS (bytes32 question_id) external view returns (uint32);
51
- function getTimeout (bytes32 question_id) external view returns (uint32);
52
- function isFinalized (bytes32 question_id) external view returns (bool);
53
- function isPendingArbitration (bytes32 question_id) external view returns (bool);
54
- function isSettledTooSoon (bytes32 question_id) external view returns (bool);
55
- function question_claims (bytes32) external view returns (address payee, uint256 last_bond, uint256 queued_funds);
56
- function questions (bytes32) external view returns (bytes32 content_hash, address arbitrator, uint32 opening_ts, uint32 timeout, uint32 finalize_ts, bool is_pending_arbitration, uint256 bounty, bytes32 best_answer, bytes32 history_hash, uint256 bond, uint256 min_bond);
57
- function reopened_questions (bytes32) external view returns (bytes32);
58
- function reopener_questions (bytes32) external view returns (bool);
59
- function resultFor (bytes32 question_id) external view returns (bytes32);
60
- function resultForOnceSettled (bytes32 question_id) external view returns (bytes32);
61
- function template_hashes (uint256) external view returns (bytes32);
62
- function templates (uint256) external view returns (uint256);
63
- }
10
+ interface IRealityETH is IRealityETHCore, IRealityETHCommitReveal {}
@@ -0,0 +1,17 @@
1
+ // SPDX-License-Identifier: GPL-3.0-only
2
+
3
+ pragma solidity 0.8.20;
4
+
5
+ // These functions were removed from IRealityETH in version 4.
6
+ interface IRealityETHCommitReveal {
7
+ // Stored in a mapping indexed by commitment_id, a hash of commitment hash, question, bond.
8
+ struct Commitment {
9
+ uint32 reveal_ts;
10
+ bool is_revealed;
11
+ bytes32 revealed_answer;
12
+ }
13
+ event LogAnswerReveal(bytes32 indexed question_id, address indexed user, bytes32 indexed answer_hash, bytes32 answer, uint256 nonce, uint256 bond);
14
+ function commitments(bytes32) external view returns (uint32 reveal_ts, bool is_revealed, bytes32 revealed_answer);
15
+ function submitAnswerCommitment(bytes32 question_id, bytes32 answer_hash, uint256 max_previous, address _answerer) external payable;
16
+ function submitAnswerReveal(bytes32 question_id, bytes32 answer, uint256 nonce, uint256 bond) external;
17
+ }
@@ -0,0 +1,16 @@
1
+ // SPDX-License-Identifier: GPL-3.0-only
2
+
3
+ pragma solidity 0.8.20;
4
+
5
+ interface IRealityETHCommitReveal_ERC20 {
6
+ // Stored in a mapping indexed by commitment_id, a hash of commitment hash, question, bond.
7
+ struct Commitment {
8
+ uint32 reveal_ts;
9
+ bool is_revealed;
10
+ bytes32 revealed_answer;
11
+ }
12
+ event LogAnswerReveal(bytes32 indexed question_id, address indexed user, bytes32 indexed answer_hash, bytes32 answer, uint256 nonce, uint256 bond);
13
+ function commitments(bytes32) external view returns (uint32 reveal_ts, bool is_revealed, bytes32 revealed_answer);
14
+ function submitAnswerCommitmentERC20(bytes32 question_id, bytes32 answer_hash, uint256 max_previous, address _answerer, uint256 tokens) external;
15
+ function submitAnswerReveal(bytes32 question_id, bytes32 answer, uint256 nonce, uint256 bond) external;
16
+ }
@@ -0,0 +1,135 @@
1
+ // SPDX-License-Identifier: GPL-3.0-only
2
+
3
+ pragma solidity 0.8.20;
4
+
5
+ import {IBalanceHolder} from "./IBalanceHolder.sol";
6
+ import {IRealityETHErrors} from "./IRealityETHErrors.sol";
7
+
8
+ /* solhint-disable func-name-mixedcase */
9
+
10
+ interface IRealityETHCore is IBalanceHolder, IRealityETHErrors {
11
+ event LogCancelArbitration(bytes32 indexed question_id);
12
+ event LogClaim(bytes32 indexed question_id, address indexed user, uint256 amount);
13
+ event LogFinalize(bytes32 indexed question_id, bytes32 indexed answer);
14
+ event LogFundAnswerBounty(bytes32 indexed question_id, uint256 bounty_added, uint256 bounty, address indexed user);
15
+ event LogMinimumBond(bytes32 indexed question_id, uint256 min_bond);
16
+ event LogNewAnswer(bytes32 answer, bytes32 indexed question_id, bytes32 history_hash, address indexed user, uint256 bond, uint256 ts, bool is_commitment);
17
+ event LogNewQuestion(
18
+ bytes32 indexed question_id,
19
+ address indexed user,
20
+ uint256 template_id,
21
+ string question,
22
+ bytes32 indexed content_hash,
23
+ address arbitrator,
24
+ uint32 timeout,
25
+ uint32 opening_ts,
26
+ uint256 nonce,
27
+ uint256 created
28
+ );
29
+ event LogNewTemplate(uint256 indexed template_id, address indexed user, string question_text);
30
+ event LogNotifyOfArbitrationRequest(bytes32 indexed question_id, address indexed user);
31
+ event LogReopenQuestion(bytes32 indexed question_id, bytes32 indexed reopened_question_id);
32
+ event LogSetQuestionFee(address arbitrator, uint256 amount);
33
+
34
+ struct Question {
35
+ bytes32 content_hash;
36
+ address arbitrator;
37
+ uint32 opening_ts;
38
+ uint32 timeout;
39
+ uint32 finalize_ts;
40
+ bool is_pending_arbitration;
41
+ uint256 bounty;
42
+ bytes32 best_answer;
43
+ bytes32 history_hash;
44
+ uint256 bond;
45
+ uint256 min_bond;
46
+ }
47
+
48
+ // Only used when claiming more bonds than fits into a transaction
49
+ // Stored in a mapping indexed by question_id.
50
+ struct Claim {
51
+ address payee;
52
+ uint256 last_bond;
53
+ uint256 queued_funds; // Only used on v3 or lower (related to commit-reveal)
54
+ }
55
+
56
+ function assignWinnerAndSubmitAnswerByArbitrator(
57
+ bytes32 question_id,
58
+ bytes32 answer,
59
+ address payee_if_wrong,
60
+ bytes32 last_history_hash,
61
+ bytes32 last_answer_or_commitment_id,
62
+ address last_answerer
63
+ ) external;
64
+ function cancelArbitration(bytes32 question_id) external;
65
+ function claimMultipleAndWithdrawBalance(
66
+ bytes32[] calldata question_ids,
67
+ uint256[] calldata lengths,
68
+ bytes32[] calldata hist_hashes,
69
+ address[] calldata addrs,
70
+ uint256[] calldata bonds,
71
+ bytes32[] calldata answers
72
+ ) external;
73
+ function claimWinnings(bytes32 question_id, bytes32[] calldata history_hashes, address[] calldata addrs, uint256[] calldata bonds, bytes32[] calldata answers) external;
74
+ function createTemplate(string calldata content) external returns (uint256);
75
+ function notifyOfArbitrationRequest(bytes32 question_id, address requester, uint256 max_previous) external;
76
+ function setQuestionFee(uint256 fee) external;
77
+ function submitAnswerByArbitrator(bytes32 question_id, bytes32 answer, address answerer) external;
78
+ function askQuestion(uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce) external payable returns (bytes32);
79
+ function askQuestionWithMinBond(uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 min_bond) external payable returns (bytes32);
80
+ function createTemplateAndAskQuestion(string calldata content, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce) external payable returns (bytes32);
81
+ function fundAnswerBounty(bytes32 question_id) external payable;
82
+ function reopenQuestion(
83
+ uint256 template_id,
84
+ string calldata question,
85
+ address arbitrator,
86
+ uint32 timeout,
87
+ uint32 opening_ts,
88
+ uint256 nonce,
89
+ uint256 min_bond,
90
+ bytes32 reopens_question_id
91
+ ) external payable returns (bytes32);
92
+ function submitAnswer(bytes32 question_id, bytes32 answer, uint256 max_previous) external payable;
93
+ function submitAnswerFor(bytes32 question_id, bytes32 answer, uint256 max_previous, address answerer) external payable;
94
+ function arbitrator_question_fees(address) external view returns (uint256);
95
+ function getArbitrator(bytes32 question_id) external view returns (address);
96
+ function getBestAnswer(bytes32 question_id) external view returns (bytes32);
97
+ function getBond(bytes32 question_id) external view returns (uint256);
98
+ function getBounty(bytes32 question_id) external view returns (uint256);
99
+ function getContentHash(bytes32 question_id) external view returns (bytes32);
100
+ function getFinalAnswer(bytes32 question_id) external view returns (bytes32);
101
+ function getFinalAnswerIfMatches(bytes32 question_id, bytes32 content_hash, address arbitrator, uint32 min_timeout, uint256 min_bond) external view returns (bytes32);
102
+ function getFinalizeTS(bytes32 question_id) external view returns (uint32);
103
+ function getHistoryHash(bytes32 question_id) external view returns (bytes32);
104
+ function getMinBond(bytes32 question_id) external view returns (uint256);
105
+ function getOpeningTS(bytes32 question_id) external view returns (uint32);
106
+ function getTimeout(bytes32 question_id) external view returns (uint32);
107
+ function isFinalized(bytes32 question_id) external view returns (bool);
108
+ function isPendingArbitration(bytes32 question_id) external view returns (bool);
109
+ function isSettledTooSoon(bytes32 question_id) external view returns (bool);
110
+ function question_claims(bytes32) external view returns (address payee, uint256 last_bond, uint256 queued_funds);
111
+ function questions(
112
+ bytes32
113
+ )
114
+ external
115
+ view
116
+ returns (
117
+ bytes32 content_hash,
118
+ address arbitrator,
119
+ uint32 opening_ts,
120
+ uint32 timeout,
121
+ uint32 finalize_ts,
122
+ bool is_pending_arbitration,
123
+ uint256 bounty,
124
+ bytes32 best_answer,
125
+ bytes32 history_hash,
126
+ uint256 bond,
127
+ uint256 min_bond
128
+ );
129
+ function reopened_questions(bytes32) external view returns (bytes32);
130
+ function reopener_questions(bytes32) external view returns (bool);
131
+ function resultFor(bytes32 question_id) external view returns (bytes32);
132
+ function resultForOnceSettled(bytes32 question_id) external view returns (bytes32);
133
+ function template_hashes(uint256) external view returns (bytes32);
134
+ function templates(uint256) external view returns (uint256);
135
+ }
@@ -0,0 +1,149 @@
1
+ // SPDX-License-Identifier: GPL-3.0-only
2
+
3
+ pragma solidity 0.8.20;
4
+
5
+ import {IBalanceHolder_ERC20} from "./IBalanceHolder_ERC20.sol";
6
+ import {IERC20} from "./IERC20.sol";
7
+ import {IRealityETHErrors_ERC20} from "./IRealityETHErrors_ERC20.sol";
8
+
9
+ /* solhint-disable func-name-mixedcase */
10
+
11
+ // solhint-disable-next-line contract-name-camelcase
12
+ interface IRealityETHCore_ERC20 is IBalanceHolder_ERC20, IRealityETHErrors_ERC20 {
13
+ event LogCancelArbitration(bytes32 indexed question_id);
14
+ event LogClaim(bytes32 indexed question_id, address indexed user, uint256 amount);
15
+ event LogFinalize(bytes32 indexed question_id, bytes32 indexed answer);
16
+ event LogFundAnswerBounty(bytes32 indexed question_id, uint256 bounty_added, uint256 bounty, address indexed user);
17
+ event LogMinimumBond(bytes32 indexed question_id, uint256 min_bond);
18
+ event LogNewAnswer(bytes32 answer, bytes32 indexed question_id, bytes32 history_hash, address indexed user, uint256 bond, uint256 ts, bool is_commitment);
19
+ event LogNewQuestion(
20
+ bytes32 indexed question_id,
21
+ address indexed user,
22
+ uint256 template_id,
23
+ string question,
24
+ bytes32 indexed content_hash,
25
+ address arbitrator,
26
+ uint32 timeout,
27
+ uint32 opening_ts,
28
+ uint256 nonce,
29
+ uint256 created
30
+ );
31
+ event LogNewTemplate(uint256 indexed template_id, address indexed user, string question_text);
32
+ event LogNotifyOfArbitrationRequest(bytes32 indexed question_id, address indexed user);
33
+ event LogReopenQuestion(bytes32 indexed question_id, bytes32 indexed reopened_question_id);
34
+ event LogSetQuestionFee(address arbitrator, uint256 amount);
35
+
36
+ struct Question {
37
+ bytes32 content_hash;
38
+ address arbitrator;
39
+ uint32 opening_ts;
40
+ uint32 timeout;
41
+ uint32 finalize_ts;
42
+ bool is_pending_arbitration;
43
+ uint256 bounty;
44
+ bytes32 best_answer;
45
+ bytes32 history_hash;
46
+ uint256 bond;
47
+ uint256 min_bond;
48
+ }
49
+
50
+ // Only used when claiming more bonds than fits into a transaction
51
+ // Stored in a mapping indexed by question_id.
52
+ struct Claim {
53
+ address payee;
54
+ uint256 last_bond;
55
+ uint256 queued_funds; // Only used on v3 or lower (related to commit-reveal)
56
+ }
57
+
58
+ function askQuestion(uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce) external returns (bytes32);
59
+ function askQuestionERC20(uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 tokens) external returns (bytes32);
60
+ function askQuestionWithMinBondERC20(
61
+ uint256 template_id,
62
+ string calldata question,
63
+ address arbitrator,
64
+ uint32 timeout,
65
+ uint32 opening_ts,
66
+ uint256 nonce,
67
+ uint256 min_bond,
68
+ uint256 tokens
69
+ ) external returns (bytes32);
70
+ function assignWinnerAndSubmitAnswerByArbitrator(
71
+ bytes32 question_id,
72
+ bytes32 answer,
73
+ address payee_if_wrong,
74
+ bytes32 last_history_hash,
75
+ bytes32 last_answer_or_commitment_id,
76
+ address last_answerer
77
+ ) external;
78
+ function cancelArbitration(bytes32 question_id) external;
79
+ function claimMultipleAndWithdrawBalance(
80
+ bytes32[] calldata question_ids,
81
+ uint256[] calldata lengths,
82
+ bytes32[] calldata hist_hashes,
83
+ address[] calldata addrs,
84
+ uint256[] calldata bonds,
85
+ bytes32[] calldata answers
86
+ ) external;
87
+ function claimWinnings(bytes32 question_id, bytes32[] calldata history_hashes, address[] calldata addrs, uint256[] calldata bonds, bytes32[] calldata answers) external;
88
+ function createTemplate(string calldata content) external returns (uint256);
89
+ function createTemplateAndAskQuestion(string calldata content, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce) external returns (bytes32);
90
+ function fundAnswerBountyERC20(bytes32 question_id, uint256 tokens) external;
91
+ function notifyOfArbitrationRequest(bytes32 question_id, address requester, uint256 max_previous) external;
92
+ function reopenQuestionERC20(
93
+ uint256 template_id,
94
+ string calldata question,
95
+ address arbitrator,
96
+ uint32 timeout,
97
+ uint32 opening_ts,
98
+ uint256 nonce,
99
+ uint256 min_bond,
100
+ bytes32 reopens_question_id,
101
+ uint256 tokens
102
+ ) external returns (bytes32);
103
+ function setQuestionFee(uint256 fee) external;
104
+ function setToken(IERC20 _token) external;
105
+ function submitAnswerByArbitrator(bytes32 question_id, bytes32 answer, address answerer) external;
106
+ function submitAnswerERC20(bytes32 question_id, bytes32 answer, uint256 max_previous, uint256 tokens) external;
107
+ function submitAnswerForERC20(bytes32 question_id, bytes32 answer, uint256 max_previous, address answerer, uint256 tokens) external;
108
+ function arbitrator_question_fees(address) external view returns (uint256);
109
+ function getArbitrator(bytes32 question_id) external view returns (address);
110
+ function getBestAnswer(bytes32 question_id) external view returns (bytes32);
111
+ function getBond(bytes32 question_id) external view returns (uint256);
112
+ function getBounty(bytes32 question_id) external view returns (uint256);
113
+ function getContentHash(bytes32 question_id) external view returns (bytes32);
114
+ function getFinalAnswer(bytes32 question_id) external view returns (bytes32);
115
+ function getFinalAnswerIfMatches(bytes32 question_id, bytes32 content_hash, address arbitrator, uint32 min_timeout, uint256 min_bond) external view returns (bytes32);
116
+ function getFinalizeTS(bytes32 question_id) external view returns (uint32);
117
+ function getHistoryHash(bytes32 question_id) external view returns (bytes32);
118
+ function getMinBond(bytes32 question_id) external view returns (uint256);
119
+ function getOpeningTS(bytes32 question_id) external view returns (uint32);
120
+ function getTimeout(bytes32 question_id) external view returns (uint32);
121
+ function isFinalized(bytes32 question_id) external view returns (bool);
122
+ function isPendingArbitration(bytes32 question_id) external view returns (bool);
123
+ function isSettledTooSoon(bytes32 question_id) external view returns (bool);
124
+ function question_claims(bytes32) external view returns (address payee, uint256 last_bond, uint256 queued_funds);
125
+ function questions(
126
+ bytes32
127
+ )
128
+ external
129
+ view
130
+ returns (
131
+ bytes32 content_hash,
132
+ address arbitrator,
133
+ uint32 opening_ts,
134
+ uint32 timeout,
135
+ uint32 finalize_ts,
136
+ bool is_pending_arbitration,
137
+ uint256 bounty,
138
+ bytes32 best_answer,
139
+ bytes32 history_hash,
140
+ uint256 bond,
141
+ uint256 min_bond
142
+ );
143
+ function reopened_questions(bytes32) external view returns (bytes32);
144
+ function reopener_questions(bytes32) external view returns (bool);
145
+ function resultFor(bytes32 question_id) external view returns (bytes32);
146
+ function resultForOnceSettled(bytes32 question_id) external view returns (bytes32);
147
+ function template_hashes(uint256) external view returns (bytes32);
148
+ function templates(uint256) external view returns (uint256);
149
+ }
@@ -0,0 +1,86 @@
1
+ // SPDX-License-Identifier: GPL-3.0-only
2
+
3
+ pragma solidity 0.8.20;
4
+
5
+ interface IRealityETHErrors {
6
+ /// @notice msg.sender must be arbitrator
7
+ error MsgSenderMustBeArbitrator();
8
+ /// @notice question must not exist
9
+ error QuestionMustNotExist();
10
+ /// @notice question must exist
11
+ error QuestionMustExist();
12
+ /// @notice question must not be pending arbitration
13
+ error QuestionMustNotBePendingArbitration();
14
+ /// @notice finalization deadline must not have passed
15
+ error FinalizationDeadlineMustNotHavePassed();
16
+ /// @notice opening date must have passed
17
+ error OpeningDateMustHavePassed();
18
+ /// @notice question must be pending arbitration
19
+ error QuestionMustBePendingArbitration();
20
+ /// @notice finalization dealine must not have passed
21
+ error FinalizationDealineMustNotHavePassed();
22
+ /// @notice question must be finalized
23
+ error QuestionMustBeFinalized();
24
+ /// @notice bond must be positive
25
+ error BondMustBePositive();
26
+ /// @notice bond must exceed the minimum
27
+ error BondMustExceedTheMinimum();
28
+ /// @notice bond must be double at least previous bond
29
+ error BondMustBeDoubleAtLeastPreviousBond();
30
+ /// @notice bond must exceed max_previous
31
+ error BondMustExceedMax_Previous();
32
+ /// @notice template must exist
33
+ error TemplateMustExist();
34
+ /// @notice timeout must be positive
35
+ error TimeoutMustBePositive();
36
+ /// @notice timeout must be less than 365 days
37
+ error TimeoutMustBeLessThan365Days();
38
+ /// @notice Tokens provided must cover question fee
39
+ error TokensProvidedMustCoverQuestionFee();
40
+ /// @notice answerer must be non-zero
41
+ error AnswererMustBeNonZero();
42
+ /// @notice commitment must not already exist
43
+ error CommitmentMustNotAlreadyExist();
44
+ /// @notice commitment must not have been revealed yet
45
+ error CommitmentMustNotHaveBeenRevealedYet();
46
+ /// @notice reveal deadline must not have passed
47
+ error RevealDeadlineMustNotHavePassed();
48
+ /// @notice Question must already have an answer when arbitration is requested
49
+ error QuestionMustAlreadyHaveAnAnswerWhenArbitrationIsRequested();
50
+ /// @notice answerer must be provided
51
+ error AnswererMustBeProvided();
52
+ /// @notice You must wait for the reveal deadline before finalizing
53
+ error YouMustWaitForTheRevealDeadlineBeforeFinalizing();
54
+ /// @notice Question was settled too soon and has not been reopened
55
+ error QuestionWasSettledTooSoonAndHasNotBeenReopened();
56
+ /// @notice Question replacement was settled too soon and has not been reopened
57
+ error QuestionReplacementWasSettledTooSoonAndHasNotBeenReopened();
58
+ /// @notice You can only reopen questions that resolved as settled too soon
59
+ error YouCanOnlyReopenQuestionsThatResolvedAsSettledTooSoon();
60
+ /// @notice content hash mismatch
61
+ error ContentHashMismatch();
62
+ /// @notice arbitrator mismatch
63
+ error ArbitratorMismatch();
64
+ /// @notice timeout mismatch
65
+ error TimeoutMismatch();
66
+ /// @notice opening_ts mismatch
67
+ error Opening_TsMismatch();
68
+ /// @notice min_bond mismatch
69
+ error Min_BondMismatch();
70
+ /// @notice Question is already reopening a previous question
71
+ error QuestionIsAlreadyReopeningAPreviousQuestion();
72
+ /// @notice Question has already been reopened
73
+ error QuestionHasAlreadyBeenReopened();
74
+ /// @notice content hash must match
75
+ error ContentHashMustMatch();
76
+ /// @notice arbitrator must match
77
+ error ArbitratorMustMatch();
78
+ /// @notice timeout must be long enough
79
+ error TimeoutMustBeLongEnough();
80
+ /// @notice bond must be high enough
81
+ error BondMustBeHighEnough();
82
+ /// @notice at least one history hash entry must be provided
83
+ error AtLeastOneHistoryHashEntryMustBeProvided();
84
+ /// @notice History input provided did not match the expected hash
85
+ error HistoryInputProvidedDidNotMatchTheExpectedHash();
86
+ }
@@ -0,0 +1,13 @@
1
+ // SPDX-License-Identifier: GPL-3.0-only
2
+
3
+ pragma solidity 0.8.20;
4
+
5
+ import {IRealityETHErrors} from "./IRealityETHErrors.sol";
6
+
7
+ // solhint-disable-next-line contract-name-camelcase
8
+ interface IRealityETHErrors_ERC20 is IRealityETHErrors {
9
+ /// @notice Token can only be initialized once
10
+ error TokenCanOnlyBeInitializedOnce();
11
+ /// @notice Transfer of tokens failed, insufficient approved balance?
12
+ error TransferOfTokensFailedInsufficientApprovedBalance();
13
+ }
@@ -1,67 +1,10 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-only
2
2
 
3
- pragma solidity 0.8.10;
3
+ pragma solidity 0.8.20;
4
4
 
5
- import './IBalanceHolder_ERC20.sol';
6
-
7
- interface IRealityETH_ERC20 is IBalanceHolder_ERC20 {
8
- event LogAnswerReveal (bytes32 indexed question_id, address indexed user, bytes32 indexed answer_hash, bytes32 answer, uint256 nonce, uint256 bond);
9
- event LogCancelArbitration (bytes32 indexed question_id);
10
- event LogClaim (bytes32 indexed question_id, address indexed user, uint256 amount);
11
- event LogFinalize (bytes32 indexed question_id, bytes32 indexed answer);
12
- event LogFundAnswerBounty (bytes32 indexed question_id, uint256 bounty_added, uint256 bounty, address indexed user);
13
- event LogMinimumBond (bytes32 indexed question_id, uint256 min_bond);
14
- event LogNewAnswer (bytes32 answer, bytes32 indexed question_id, bytes32 history_hash, address indexed user, uint256 bond, uint256 ts, bool is_commitment);
15
- event LogNewQuestion (bytes32 indexed question_id, address indexed user, uint256 template_id, string question, bytes32 indexed content_hash, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 created);
16
- event LogNewTemplate (uint256 indexed template_id, address indexed user, string question_text);
17
- event LogNotifyOfArbitrationRequest (bytes32 indexed question_id, address indexed user);
18
- event LogReopenQuestion (bytes32 indexed question_id, bytes32 indexed reopened_question_id);
19
- event LogSetQuestionFee (address arbitrator, uint256 amount);
20
-
21
- function askQuestion (uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce) external returns (bytes32);
22
- function askQuestionERC20 (uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 tokens) external returns (bytes32);
23
- function askQuestionWithMinBondERC20 (uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 min_bond, uint256 tokens) external returns (bytes32);
24
- function assignWinnerAndSubmitAnswerByArbitrator (bytes32 question_id, bytes32 answer, address payee_if_wrong, bytes32 last_history_hash, bytes32 last_answer_or_commitment_id, address last_answerer) external;
25
- function cancelArbitration (bytes32 question_id) external;
26
- function claimMultipleAndWithdrawBalance (bytes32[] calldata question_ids, uint256[] calldata lengths, bytes32[] calldata hist_hashes, address[] calldata addrs, uint256[] calldata bonds, bytes32[] calldata answers) external;
27
- function claimWinnings (bytes32 question_id, bytes32[] calldata history_hashes, address[] calldata addrs, uint256[] calldata bonds, bytes32[] calldata answers) external;
28
- function createTemplate (string calldata content) external returns (uint256);
29
- function createTemplateAndAskQuestion (string calldata content, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce) external returns (bytes32);
30
- function fundAnswerBountyERC20 (bytes32 question_id, uint256 tokens) external;
31
- function notifyOfArbitrationRequest (bytes32 question_id, address requester, uint256 max_previous) external;
32
- function reopenQuestionERC20 (uint256 template_id, string calldata question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce, uint256 min_bond, bytes32 reopens_question_id, uint256 tokens) external returns (bytes32);
33
- function setQuestionFee (uint256 fee) external;
34
- function setToken (address _token) external;
35
- function submitAnswerByArbitrator (bytes32 question_id, bytes32 answer, address answerer) external;
36
- function submitAnswerCommitmentERC20 (bytes32 question_id, bytes32 answer_hash, uint256 max_previous, address _answerer, uint256 tokens) external;
37
- function submitAnswerERC20 (bytes32 question_id, bytes32 answer, uint256 max_previous, uint256 tokens) external;
38
- function submitAnswerForERC20 (bytes32 question_id, bytes32 answer, uint256 max_previous, address answerer, uint256 tokens) external;
39
- function submitAnswerReveal (bytes32 question_id, bytes32 answer, uint256 nonce, uint256 bond) external;
40
- function arbitrator_question_fees (address) external view returns (uint256);
41
- function commitments (bytes32) external view returns (uint32 reveal_ts, bool is_revealed, bytes32 revealed_answer);
42
- function getArbitrator (bytes32 question_id) external view returns (address);
43
- function getBestAnswer (bytes32 question_id) external view returns (bytes32);
44
- function getBond (bytes32 question_id) external view returns (uint256);
45
- function getBounty (bytes32 question_id) external view returns (uint256);
46
- function getContentHash (bytes32 question_id) external view returns (bytes32);
47
- function getFinalAnswer (bytes32 question_id) external view returns (bytes32);
48
- function getFinalAnswerIfMatches (bytes32 question_id, bytes32 content_hash, address arbitrator, uint32 min_timeout, uint256 min_bond) external view returns (bytes32);
49
- function getFinalizeTS (bytes32 question_id) external view returns (uint32);
50
- function getHistoryHash (bytes32 question_id) external view returns (bytes32);
51
- function getMinBond (bytes32 question_id) external view returns (uint256);
52
- function getOpeningTS (bytes32 question_id) external view returns (uint32);
53
- function getTimeout (bytes32 question_id) external view returns (uint32);
54
- function isFinalized (bytes32 question_id) external view returns (bool);
55
- function isPendingArbitration (bytes32 question_id) external view returns (bool);
56
- function isSettledTooSoon (bytes32 question_id) external view returns (bool);
57
- function question_claims (bytes32) external view returns (address payee, uint256 last_bond, uint256 queued_funds);
58
- function questions (bytes32) external view returns (bytes32 content_hash, address arbitrator, uint32 opening_ts, uint32 timeout, uint32 finalize_ts, bool is_pending_arbitration, uint256 bounty, bytes32 best_answer, bytes32 history_hash, uint256 bond, uint256 min_bond);
59
- function reopened_questions (bytes32) external view returns (bytes32);
60
- function reopener_questions (bytes32) external view returns (bool);
61
- function resultFor (bytes32 question_id) external view returns (bytes32);
62
- function resultForOnceSettled (bytes32 question_id) external view returns (bytes32);
63
- function template_hashes (uint256) external view returns (bytes32);
64
- function templates (uint256) external view returns (uint256);
65
- }
5
+ import {IRealityETHCore_ERC20} from "./IRealityETHCore_ERC20.sol";
6
+ import {IRealityETHCommitReveal_ERC20} from "./IRealityETHCommitReveal_ERC20.sol";
66
7
 
8
+ /* solhint-disable func-name-mixedcase */
67
9
 
10
+ interface IRealityETH_ERC20 is IRealityETHCore_ERC20, IRealityETHCommitReveal_ERC20 {}
@@ -1,8 +1,8 @@
1
1
  // SPDX-License-Identifier: GPL-3.0-only
2
2
 
3
- pragma solidity ^0.8.10;
3
+ pragma solidity ^0.8.20;
4
4
 
5
- import './IOwned.sol';
5
+ import "./IOwned.sol";
6
6
 
7
7
  contract Owned is IOwned {
8
8
  address public owner;
@@ -11,14 +11,12 @@ contract Owned is IOwned {
11
11
  owner = msg.sender;
12
12
  }
13
13
 
14
- modifier onlyOwner {
14
+ modifier onlyOwner() {
15
15
  require(msg.sender == owner);
16
16
  _;
17
17
  }
18
18
 
19
- function transferOwnership(address newOwner)
20
- onlyOwner
21
- external {
19
+ function transferOwnership(address newOwner) external onlyOwner {
22
20
  owner = newOwner;
23
21
  }
24
22
  }