@reality.eth/contracts 3.0.0 → 3.0.3

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 (60) hide show
  1. package/README.md +28 -6
  2. package/chains/chainid.network.json +2708 -174
  3. package/chains/deployments/1/ETH/RealityETH-3.0.json +4 -1
  4. package/chains/deployments/1/SWISE/RealityETH_ERC20-3.0.json +7 -0
  5. package/chains/deployments/10/OETH/RealityETH-3.0.json +6 -0
  6. package/chains/deployments/100/GNO/RealityETH_ERC20-3.0.json +7 -0
  7. package/chains/deployments/100/SWISE/RealityETH_ERC20-3.0.json +7 -0
  8. package/chains/deployments/100/XDAI/RealityETH-3.0.json +3 -1
  9. package/chains/deployments/1337702/ETH/RealityETH-3.0.json +6 -0
  10. package/chains/deployments/4/ETH/RealityETH-3.0.json +3 -1
  11. package/chains/deployments/42/ETH/RealityETH-3.0.json +4 -1
  12. package/chains/deployments/56/DEXE/RealityETH_ERC20-3.0.json +7 -0
  13. package/chains/deployments/69/OETH/RealityETH-3.0.json +6 -0
  14. package/chains/deployments/77/XDAI/RealityETH-2.1-rc1.json +1 -3
  15. package/chains/deployments/777/CTH/RealityETH-3.0.json +6 -0
  16. package/chains/supported.json +25 -4
  17. package/development/contracts/Arbitrator.sol +7 -6
  18. package/development/contracts/BalanceHolder.sol +4 -2
  19. package/development/contracts/{BalanceHolderERC20.sol → BalanceHolder_ERC20.sol} +3 -2
  20. package/development/contracts/IArbitrator.sol +4 -7
  21. package/development/contracts/IArbitratorForeignProxy.sol +12 -0
  22. package/development/contracts/IBalanceHolder.sol +3 -1
  23. package/development/contracts/IBalanceHolder_ERC20.sol +11 -0
  24. package/development/contracts/IERC20.sol +1 -1
  25. package/development/contracts/IOwned.sol +1 -1
  26. package/development/contracts/IRealityETH.sol +63 -0
  27. package/development/contracts/IRealityETH_ERC20.sol +67 -0
  28. package/development/contracts/Owned.sol +4 -2
  29. package/development/contracts/RealityETH-3.0.sol +4 -82
  30. package/development/contracts/RealityETH_ERC20-3.0.sol +3 -3
  31. package/example.js +66 -0
  32. package/generated/chains.json +103 -12
  33. package/generated/contracts.json +91 -7
  34. package/generated/tokens.json +34 -2
  35. package/index.js +9 -3
  36. package/meta/RealityETH-2.0.json +1 -0
  37. package/meta/RealityETH-2.1.json +1 -0
  38. package/meta/RealityETH-3.0.json +7 -0
  39. package/meta/RealityETH_ERC20-2.0.json +1 -0
  40. package/meta/RealityETH_ERC20-3.0.json +7 -0
  41. package/package.json +3 -3
  42. package/scripts/deploy.js +14 -3
  43. package/scripts/fetch_and_reformat_chains_json.js +31 -0
  44. package/scripts/{format_abi.js → format_json.js} +0 -0
  45. package/scripts/generate_chains_json.js +3 -0
  46. package/tokens/CTH.json +7 -0
  47. package/tokens/DEXE.json +7 -0
  48. package/tokens/ETH.json +2 -1
  49. package/tokens/GNO.json +1 -0
  50. package/tokens/OETH.json +8 -0
  51. package/tokens/SWISE.json +8 -0
  52. package/development/contracts/IRealitio.sol +0 -44
  53. package/development/contracts/MultiSigWallet.sol +0 -391
  54. package/development/contracts/Realitio.sol +0 -756
  55. package/development/contracts/RealitioERC20.sol +0 -825
  56. package/development/contracts/RealitioSafeMath256.sol +0 -36
  57. package/development/contracts/RealitioSafeMath32.sol +0 -17
  58. package/development/contracts/Realitio_v2_1.sol +0 -819
  59. package/development/contracts/SplitterWallet.sol +0 -142
  60. package/tests/python/test_wallet.py +0 -185
@@ -0,0 +1,31 @@
1
+ /*
2
+ Add new lines to the abi file for more meaningful version control
3
+ */
4
+
5
+ const request = require('request');
6
+ const fs = require('fs');
7
+
8
+ const url = 'https://chainid.network/chains.json';
9
+ const out = './../chains/chainid.network.json';
10
+
11
+ let options = {json: true};
12
+
13
+ request(url, options, (error, res, body) => {
14
+ if (error) {
15
+ console.log(error)
16
+ };
17
+
18
+ if (!error && res.statusCode == 200) {
19
+ // console.log(body);
20
+ fs.writeFileSync(out, JSON.stringify(body, null, 4));
21
+ // do something with JSON, using the 'body' variable
22
+ };
23
+ });
24
+ //
25
+
26
+
27
+ /*
28
+
29
+ const file = process.argv[2]
30
+ const abi = JSON.parse(fs.readFileSync(file));
31
+ */
File without changes
@@ -42,6 +42,9 @@ for (var ci = 0; ci< chain_id_list.length; ci++) {
42
42
  if (thisr.indexOf('INFURA_API_KEY') !== -1) {
43
43
  continue;
44
44
  }
45
+ if (thisr.indexOf('ALCHEMY_API_KEY') !== -1) {
46
+ continue;
47
+ }
45
48
  rpc.push(thisr);
46
49
  }
47
50
  }
@@ -0,0 +1,7 @@
1
+ {
2
+ "decimals": 18,
3
+ "small_number": 10000000000000000000,
4
+ "native_chains": {
5
+ "777": true
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "decimals": 18,
3
+ "small_number": 1000000000000000000,
4
+ "erc20_chains": {
5
+ "56": "0x039cb485212f996a9dbb85a9a75d898f94d38da6"
6
+ }
7
+ }
package/tokens/ETH.json CHANGED
@@ -4,6 +4,7 @@
4
4
  "native_chains": {
5
5
  "1": true,
6
6
  "4": true,
7
- "42": true
7
+ "42": true,
8
+ "1337702": true
8
9
  }
9
10
  }
package/tokens/GNO.json CHANGED
@@ -3,5 +3,6 @@
3
3
  "small_number": 10000000,
4
4
  "erc20_chains": {
5
5
  "1": "0x6810e776880c02933d47db1b9fc05908e5386b96"
6
+ ,"100": "0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb"
6
7
  }
7
8
  }
@@ -0,0 +1,8 @@
1
+ {
2
+ "decimals": 18,
3
+ "small_number": 10000000000000000000,
4
+ "native_chains": {
5
+ "10": true,
6
+ "69": true
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "decimals": 18,
3
+ "small_number": 1000000000000000000,
4
+ "erc20_chains": {
5
+ "1": "0x48C3399719B582dD63eB5AADf12A40B4C3f52FA2",
6
+ "100": "0xfdA94F056346d2320d4B5E468D6Ad099b2277746"
7
+ }
8
+ }
@@ -1,44 +0,0 @@
1
- // SPDX-License-Identifier: GPL-3.0-only
2
-
3
- pragma solidity ^0.8.6;
4
-
5
- interface IRealitio {
6
- function claimWinnings ( bytes32 question_id, bytes32[] memory history_hashes, address[] memory addrs, uint256[] memory bonds, bytes32[] memory answers ) external;
7
- function getFinalAnswerIfMatches ( bytes32 question_id, bytes32 content_hash, address arbitrator, uint32 min_timeout, uint256 min_bond ) external view returns ( bytes32 );
8
- function getBounty ( bytes32 question_id ) external view returns ( uint256 );
9
- function getArbitrator ( bytes32 question_id ) external view returns ( address );
10
- function getBond ( bytes32 question_id ) external view returns ( uint256 );
11
- function claimMultipleAndWithdrawBalance ( bytes32[] memory question_ids, uint256[] memory lengths, bytes32[] memory hist_hashes, address[] memory addrs, uint256[] memory bonds, bytes32[] memory answers ) external;
12
- function withdraw ( ) external;
13
- function submitAnswerReveal ( bytes32 question_id, bytes32 answer, uint256 nonce, uint256 bond ) external;
14
- function setQuestionFee ( uint256 fee ) external;
15
- function template_hashes ( uint256 ) external view returns ( bytes32 );
16
- function getContentHash ( bytes32 question_id ) external view returns ( bytes32 );
17
- function question_claims ( bytes32 ) external view returns ( address payee, uint256 last_bond, uint256 queued_funds );
18
- function fundAnswerBounty ( bytes32 question_id ) external payable;
19
- function arbitrator_question_fees ( address ) external view returns ( uint256 );
20
- function balanceOf ( address ) external view returns ( uint256 );
21
- function askQuestion ( uint256 template_id, string memory question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce ) external payable returns ( bytes32 );
22
- function submitAnswer ( bytes32 question_id, bytes32 answer, uint256 max_previous ) external payable;
23
- function submitAnswerFor ( bytes32 question_id, bytes32 answer, uint256 max_previous, address answerer ) external payable; // Only available from v2.1
24
- function isFinalized ( bytes32 question_id ) external view returns ( bool );
25
- function getHistoryHash ( bytes32 question_id ) external view returns ( bytes32 );
26
- function commitments ( bytes32 ) external view returns ( uint32 reveal_ts, bool is_revealed, bytes32 revealed_answer );
27
- function createTemplate ( string memory content ) external returns ( uint256 );
28
- function getBestAnswer ( bytes32 question_id ) external view returns ( bytes32 );
29
- function isPendingArbitration ( bytes32 question_id ) external view returns ( bool );
30
- 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 );
31
- function getOpeningTS ( bytes32 question_id ) external view returns ( uint32 );
32
- function getTimeout ( bytes32 question_id ) external view returns ( uint32 );
33
- function createTemplateAndAskQuestion ( string memory content, string memory question, address arbitrator, uint32 timeout, uint32 opening_ts, uint256 nonce ) external payable returns ( bytes32 );
34
- function getFinalAnswer ( bytes32 question_id ) external view returns ( bytes32 );
35
- function getFinalizeTS ( bytes32 question_id ) external view returns ( uint32 );
36
- function templates ( uint256 ) external view returns ( uint256 );
37
- function resultFor ( bytes32 question_id ) external view returns ( bytes32 );
38
- function submitAnswerCommitment ( bytes32 question_id, bytes32 answer_hash, uint256 max_previous, address _answerer ) external payable;
39
- function notifyOfArbitrationRequest ( bytes32 question_id, address requester, uint256 max_previous ) external;
40
- function submitAnswerByArbitrator ( bytes32 question_id, bytes32 answer, address answerer ) external;
41
- 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;
42
- function cancelArbitration(bytes32 question_id) external; // Only available from v2.1
43
- }
44
-
@@ -1,391 +0,0 @@
1
- pragma solidity ^0.4.25;
2
-
3
-
4
- /// @title Multisignature wallet - Allows multiple parties to agree on transactions before execution.
5
- /// @author Stefan George - <stefan.george@consensys.net>
6
- contract MultiSigWallet {
7
-
8
- /*
9
- * Events
10
- */
11
- event Confirmation(address indexed sender, uint indexed transactionId);
12
- event Revocation(address indexed sender, uint indexed transactionId);
13
- event Submission(uint indexed transactionId);
14
- event Execution(uint indexed transactionId);
15
- event ExecutionFailure(uint indexed transactionId);
16
- event Deposit(address indexed sender, uint value);
17
- event OwnerAddition(address indexed owner);
18
- event OwnerRemoval(address indexed owner);
19
- event RequirementChange(uint required);
20
-
21
- /*
22
- * Constants
23
- */
24
- uint constant public MAX_OWNER_COUNT = 50;
25
-
26
- /*
27
- * Storage
28
- */
29
- mapping (uint => Transaction) public transactions;
30
- mapping (uint => mapping (address => bool)) public confirmations;
31
- mapping (address => bool) public isOwner;
32
- address[] public owners;
33
- uint public required;
34
- uint public transactionCount;
35
-
36
- struct Transaction {
37
- address destination;
38
- uint value;
39
- bytes data;
40
- bool executed;
41
- }
42
-
43
- /*
44
- * Modifiers
45
- */
46
- modifier onlyWallet() {
47
- require(msg.sender == address(this));
48
- _;
49
- }
50
-
51
- modifier ownerDoesNotExist(address owner) {
52
- require(!isOwner[owner]);
53
- _;
54
- }
55
-
56
- modifier ownerExists(address owner) {
57
- require(isOwner[owner]);
58
- _;
59
- }
60
-
61
- modifier transactionExists(uint transactionId) {
62
- require(transactions[transactionId].destination != 0);
63
- _;
64
- }
65
-
66
- modifier confirmed(uint transactionId, address owner) {
67
- require(confirmations[transactionId][owner]);
68
- _;
69
- }
70
-
71
- modifier notConfirmed(uint transactionId, address owner) {
72
- require(!confirmations[transactionId][owner]);
73
- _;
74
- }
75
-
76
- modifier notExecuted(uint transactionId) {
77
- require(!transactions[transactionId].executed);
78
- _;
79
- }
80
-
81
- modifier notNull(address _address) {
82
- require(_address != 0);
83
- _;
84
- }
85
-
86
- modifier validRequirement(uint ownerCount, uint _required) {
87
- require(ownerCount <= MAX_OWNER_COUNT
88
- && _required <= ownerCount
89
- && _required != 0
90
- && ownerCount != 0);
91
- _;
92
- }
93
-
94
- /// @dev Fallback function allows to deposit ether.
95
- function()
96
- public payable
97
- {
98
- if (msg.value > 0)
99
- emit Deposit(msg.sender, msg.value);
100
- }
101
-
102
- /*
103
- * Public functions
104
- */
105
- /// @dev Contract constructor sets initial owners and required number of confirmations.
106
- /// @param _owners List of initial owners.
107
- /// @param _required Number of required confirmations.
108
- constructor(address[] _owners, uint _required)
109
- public
110
- validRequirement(_owners.length, _required)
111
- {
112
- for (uint i=0; i<_owners.length; i++) {
113
- require(!isOwner[_owners[i]] && _owners[i] != 0);
114
- isOwner[_owners[i]] = true;
115
- }
116
- owners = _owners;
117
- required = _required;
118
- }
119
-
120
- /// @dev Allows to add a new owner. Transaction has to be sent by wallet.
121
- /// @param owner Address of new owner.
122
- function addOwner(address owner)
123
- public
124
- onlyWallet
125
- ownerDoesNotExist(owner)
126
- notNull(owner)
127
- validRequirement(owners.length + 1, required)
128
- {
129
- isOwner[owner] = true;
130
- owners.push(owner);
131
- emit OwnerAddition(owner);
132
- }
133
-
134
- /// @dev Allows to remove an owner. Transaction has to be sent by wallet.
135
- /// @param owner Address of owner.
136
- function removeOwner(address owner)
137
- public
138
- onlyWallet
139
- ownerExists(owner)
140
- {
141
- isOwner[owner] = false;
142
- for (uint i=0; i<owners.length - 1; i++)
143
- if (owners[i] == owner) {
144
- owners[i] = owners[owners.length - 1];
145
- break;
146
- }
147
- owners.length -= 1;
148
- if (required > owners.length)
149
- changeRequirement(owners.length);
150
- emit OwnerRemoval(owner);
151
- }
152
-
153
- /// @dev Allows to replace an owner with a new owner. Transaction has to be sent by wallet.
154
- /// @param owner Address of owner to be replaced.
155
- /// @param newOwner Address of new owner.
156
- function replaceOwner(address owner, address newOwner)
157
- public
158
- onlyWallet
159
- ownerExists(owner)
160
- ownerDoesNotExist(newOwner)
161
- {
162
- for (uint i=0; i<owners.length; i++)
163
- if (owners[i] == owner) {
164
- owners[i] = newOwner;
165
- break;
166
- }
167
- isOwner[owner] = false;
168
- isOwner[newOwner] = true;
169
- emit OwnerRemoval(owner);
170
- emit OwnerAddition(newOwner);
171
- }
172
-
173
- /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet.
174
- /// @param _required Number of required confirmations.
175
- function changeRequirement(uint _required)
176
- public
177
- onlyWallet
178
- validRequirement(owners.length, _required)
179
- {
180
- required = _required;
181
- emit RequirementChange(_required);
182
- }
183
-
184
- /// @dev Allows an owner to submit and confirm a transaction.
185
- /// @param destination Transaction target address.
186
- /// @param value Transaction ether value.
187
- /// @param data Transaction data payload.
188
- /// @return Returns transaction ID.
189
- function submitTransaction(address destination, uint value, bytes data)
190
- public
191
- returns (uint transactionId)
192
- {
193
- transactionId = addTransaction(destination, value, data);
194
- //confirmTransaction(transactionId);
195
- }
196
-
197
- /// @dev Allows an owner to confirm a transaction.
198
- /// @param transactionId Transaction ID.
199
- function confirmTransaction(uint transactionId)
200
- public
201
- ownerExists(msg.sender)
202
- transactionExists(transactionId)
203
- notConfirmed(transactionId, msg.sender)
204
- {
205
- confirmations[transactionId][msg.sender] = true;
206
- emit Confirmation(msg.sender, transactionId);
207
- executeTransaction(transactionId);
208
- }
209
-
210
- /// @dev Allows an owner to revoke a confirmation for a transaction.
211
- /// @param transactionId Transaction ID.
212
- function revokeConfirmation(uint transactionId)
213
- public
214
- ownerExists(msg.sender)
215
- confirmed(transactionId, msg.sender)
216
- notExecuted(transactionId)
217
- {
218
- confirmations[transactionId][msg.sender] = false;
219
- emit Revocation(msg.sender, transactionId);
220
- }
221
-
222
- /// @dev Allows anyone to execute a confirmed transaction.
223
- /// @param transactionId Transaction ID.
224
- function executeTransaction(uint transactionId)
225
- public
226
- ownerExists(msg.sender)
227
- confirmed(transactionId, msg.sender)
228
- notExecuted(transactionId)
229
- {
230
- if (isConfirmed(transactionId)) {
231
- Transaction storage txn = transactions[transactionId];
232
- txn.executed = true;
233
- if (external_call(txn.destination, txn.value, txn.data.length, txn.data))
234
- emit Execution(transactionId);
235
- else {
236
- emit ExecutionFailure(transactionId);
237
- txn.executed = false;
238
- }
239
- }
240
- }
241
-
242
- // call has been separated into its own function in order to take advantage
243
- // of the Solidity's code generator to produce a loop that copies tx.data into memory.
244
- function external_call(address destination, uint value, uint dataLength, bytes data) private returns (bool) {
245
- bool result;
246
- assembly {
247
- let x := mload(0x40) // "Allocate" memory for output (0x40 is where "free memory" pointer is stored by convention)
248
- let d := add(data, 32) // First 32 bytes are the padded length of data, so exclude that
249
- result := call(
250
- sub(gas, 34710), // 34710 is the value that solidity is currently emitting
251
- // It includes callGas (700) + callVeryLow (3, to pay for SUB) + callValueTransferGas (9000) +
252
- // callNewAccountGas (25000, in case the destination address does not exist and needs creating)
253
- destination,
254
- value,
255
- d,
256
- dataLength, // Size of the input (in bytes) - this is what fixes the padding problem
257
- x,
258
- 0 // Output is ignored, therefore the output size is zero
259
- )
260
- }
261
- return result;
262
- }
263
-
264
- /// @dev Returns the confirmation status of a transaction.
265
- /// @param transactionId Transaction ID.
266
- /// @return Confirmation status.
267
- function isConfirmed(uint transactionId)
268
- public
269
- constant
270
- returns (bool)
271
- {
272
- uint count = 0;
273
- for (uint i=0; i<owners.length; i++) {
274
- if (confirmations[transactionId][owners[i]])
275
- count += 1;
276
- if (count == required)
277
- return true;
278
- }
279
- }
280
-
281
- /*
282
- * Internal functions
283
- */
284
- /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet.
285
- /// @param destination Transaction target address.
286
- /// @param value Transaction ether value.
287
- /// @param data Transaction data payload.
288
- /// @return Returns transaction ID.
289
- function addTransaction(address destination, uint value, bytes data)
290
- internal
291
- returns (uint transactionId)
292
- {
293
- transactionId = transactionCount;
294
- transactions[transactionId] = Transaction({
295
- destination: destination,
296
- value: value,
297
- data: data,
298
- executed: false
299
- });
300
- transactionCount += 1;
301
- emit Submission(transactionId);
302
- }
303
-
304
- /*
305
- * Web3 call functions
306
- */
307
- /// @dev Returns number of confirmations of a transaction.
308
- /// @param transactionId Transaction ID.
309
- /// @return Number of confirmations.
310
- function getConfirmationCount(uint transactionId)
311
- public
312
- constant
313
- returns (uint count)
314
- {
315
- for (uint i=0; i<owners.length; i++)
316
- if (confirmations[transactionId][owners[i]])
317
- count += 1;
318
- }
319
-
320
- /// @dev Returns total number of transactions after filers are applied.
321
- /// @param pending Include pending transactions.
322
- /// @param executed Include executed transactions.
323
- /// @return Total number of transactions after filters are applied.
324
- function getTransactionCount(bool pending, bool executed)
325
- public
326
- constant
327
- returns (uint count)
328
- {
329
- for (uint i=0; i<transactionCount; i++)
330
- if ( pending && !transactions[i].executed
331
- || executed && transactions[i].executed)
332
- count += 1;
333
- }
334
-
335
- /// @dev Returns list of owners.
336
- /// @return List of owner addresses.
337
- function getOwners()
338
- public
339
- constant
340
- returns (address[])
341
- {
342
- return owners;
343
- }
344
-
345
- /// @dev Returns array with owner addresses, which confirmed transaction.
346
- /// @param transactionId Transaction ID.
347
- /// @return Returns array of owner addresses.
348
- function getConfirmations(uint transactionId)
349
- public
350
- constant
351
- returns (address[] _confirmations)
352
- {
353
- address[] memory confirmationsTemp = new address[](owners.length);
354
- uint count = 0;
355
- uint i;
356
- for (i=0; i<owners.length; i++)
357
- if (confirmations[transactionId][owners[i]]) {
358
- confirmationsTemp[count] = owners[i];
359
- count += 1;
360
- }
361
- _confirmations = new address[](count);
362
- for (i=0; i<count; i++)
363
- _confirmations[i] = confirmationsTemp[i];
364
- }
365
-
366
- /// @dev Returns list of transaction IDs in defined range.
367
- /// @param from Index start position of transaction array.
368
- /// @param to Index end position of transaction array.
369
- /// @param pending Include pending transactions.
370
- /// @param executed Include executed transactions.
371
- /// @return Returns array of transaction IDs.
372
- function getTransactionIds(uint from, uint to, bool pending, bool executed)
373
- public
374
- constant
375
- returns (uint[] _transactionIds)
376
- {
377
- uint[] memory transactionIdsTemp = new uint[](transactionCount);
378
- uint count = 0;
379
- uint i;
380
- for (i=0; i<transactionCount; i++)
381
- if ( pending && !transactions[i].executed
382
- || executed && transactions[i].executed)
383
- {
384
- transactionIdsTemp[count] = i;
385
- count += 1;
386
- }
387
- _transactionIds = new uint[](to - from);
388
- for (i=from; i<to; i++)
389
- _transactionIds[i - from] = transactionIdsTemp[i];
390
- }
391
- }