@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.
Files changed (71) 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 -81
  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 +23 -23
  20. package/development/contracts/IArbitratorCore.sol +14 -0
  21. package/development/contracts/IArbitratorCrowdFundable.sol +8 -0
  22. package/development/contracts/IArbitratorErrors.sol +10 -0
  23. package/development/contracts/IArbitratorForeignProxy.sol +15 -7
  24. package/development/contracts/IArbitratorLegacy.sol +9 -0
  25. package/development/contracts/IArbitratorManagement.sol +25 -0
  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/tokens.json +1 -0
  50. package/non_standard_deployments/zksync/LICENSE +21 -0
  51. package/non_standard_deployments/zksync/README.md +51 -0
  52. package/non_standard_deployments/zksync/deploy/deploy.ts +11 -0
  53. package/non_standard_deployments/zksync/deploy/utils.ts +168 -0
  54. package/non_standard_deployments/zksync/hardhat.config.ts +55 -0
  55. package/non_standard_deployments/zksync/package-lock.json +6295 -0
  56. package/non_standard_deployments/zksync/package.json +34 -0
  57. package/package.json +7 -3
  58. package/scripts/transfer_arbitrator.js +60 -0
  59. package/tests/python/requirements.txt +55 -54
  60. package/tests/python/test.py +150 -50
  61. package/tests/python/test_erc20.py +15 -14
  62. package/tokens/ETH.json +3 -2
  63. package/non_standard_deployments/zksync2/README +0 -21
  64. package/non_standard_deployments/zksync2/contracts/RealityETH_ERC20-3.0.sol +0 -1096
  65. package/non_standard_deployments/zksync2/deploy/deploy.ts +0 -62
  66. package/non_standard_deployments/zksync2/deploy/deploy_erc20.ts +0 -56
  67. package/non_standard_deployments/zksync2/deploy/deploy_mainnet.ts +0 -46
  68. package/non_standard_deployments/zksync2/hardhat.config.ts +0 -27
  69. package/non_standard_deployments/zksync2/package.json +0 -15
  70. package/non_standard_deployments/zksync2/yarn.lock +0 -2898
  71. /package/non_standard_deployments/{zksync2 → zksync}/contracts/RealityETH-3.0.sol +0 -0
@@ -43,6 +43,13 @@ if VERNUM >= 2.1:
43
43
  else:
44
44
  CLAIM_FEE = 0
45
45
 
46
+ if VERNUM >= 4.0:
47
+ IS_COMMIT_REVEAL_SUPPORTED = False
48
+ else:
49
+ IS_COMMIT_REVEAL_SUPPORTED = True
50
+
51
+ print("IS_COMMIT_REVEAL_SUPPORTED is "+str(IS_COMMIT_REVEAL_SUPPORTED))
52
+
46
53
  DEPLOY_GAS = 8000000
47
54
 
48
55
  QINDEX_CONTENT_HASH = 0
@@ -67,7 +74,7 @@ def calculate_answer_hash(answer, nonce):
67
74
  raise Exception("hash functions expect bytes for bytes32 parameters")
68
75
  if not isinstance(nonce, int):
69
76
  raise Exception("hash functions expect int for uint256 parameters")
70
- return "0x"+encode_hex(bytes(Web3.solidityKeccak(['bytes32', 'uint256'], [answer, nonce])))
77
+ return "0x"+encode_hex(bytes(Web3.solidity_keccak(['bytes32', 'uint256'], [answer, nonce])))
71
78
 
72
79
  def calculate_commitment_id(question_id, answer_hash, bond):
73
80
  if question_id[:2] == "0x":
@@ -77,20 +84,20 @@ def calculate_commitment_id(question_id, answer_hash, bond):
77
84
  if not isinstance(bond, int):
78
85
  raise Exception("hash functions expect int for uint256 parameters")
79
86
  #return decode_hex(keccak_256(question_id + answer_hash + decode_hex(hex(bond)[2:].zfill(64))).hexdigest())
80
- return "0x"+encode_hex(bytes(Web3.solidityKeccak(['bytes32', 'bytes32', 'uint256'], [question_id, answer_hash, bond])))
87
+ return "0x"+encode_hex(bytes(Web3.solidity_keccak(['bytes32', 'bytes32', 'uint256'], [question_id, answer_hash, bond])))
81
88
 
82
89
  def calculate_content_hash(template_id, question_str, opening_ts):
83
- return "0x"+encode_hex(bytes(Web3.solidityKeccak(['uint256', 'uint32', 'string'], [template_id, opening_ts, question_str])))
90
+ return "0x"+encode_hex(bytes(Web3.solidity_keccak(['uint256', 'uint32', 'string'], [template_id, opening_ts, question_str])))
84
91
 
85
92
  def calculate_question_id(cntrct, template_id, question_str, arbitrator, timeout, opening_ts, nonce, sender, min_bond):
86
93
  content_hash = calculate_content_hash(template_id, question_str, opening_ts)
87
94
  if VERNUM >= 3:
88
- return "0x"+encode_hex(bytes(Web3.solidityKeccak(['bytes32', 'address', 'uint32', 'uint256', 'address', 'address', 'uint256'], [content_hash, arbitrator, timeout, min_bond, cntrct, sender, nonce])))
95
+ return "0x"+encode_hex(bytes(Web3.solidity_keccak(['bytes32', 'address', 'uint32', 'uint256', 'address', 'address', 'uint256'], [content_hash, arbitrator, timeout, min_bond, cntrct, sender, nonce])))
89
96
  else:
90
- return "0x"+encode_hex(bytes(Web3.solidityKeccak(['bytes32', 'address', 'uint32', 'address', 'uint256'], [content_hash, arbitrator, timeout, sender, nonce])))
97
+ return "0x"+encode_hex(bytes(Web3.solidity_keccak(['bytes32', 'address', 'uint32', 'address', 'uint256'], [content_hash, arbitrator, timeout, sender, nonce])))
91
98
 
92
99
  def calculate_history_hash(last_history_hash, answer_or_commitment_id, bond, answerer, is_commitment):
93
- return "0x"+encode_hex(bytes(Web3.solidityKeccak(['bytes32', 'bytes32', 'uint256', 'address', 'bool'], [last_history_hash, answer_or_commitment_id, bond, answerer, is_commitment])))
100
+ return "0x"+encode_hex(bytes(Web3.solidity_keccak(['bytes32', 'bytes32', 'uint256', 'address', 'bool'], [last_history_hash, answer_or_commitment_id, bond, answerer, is_commitment])))
94
101
 
95
102
  def from_question_for_contract(txt):
96
103
  return txt
@@ -156,13 +163,13 @@ class TestRealitio(TestCase):
156
163
 
157
164
 
158
165
  def assertZeroStatus(self, txid, msg=None):
159
- self.assertEqual(self.web3.eth.getTransactionReceipt(txid)['status'], 0, msg)
166
+ self.assertEqual(self.web3.eth.get_transaction_receipt(txid)['status'], 0, msg)
160
167
 
161
168
  # Sometimes we seem to get a zero status receipt with no exception raised
162
169
  # Not sure if this is what's supposed to happen, but call this in the with block to make sure we get an exception
163
170
  def raiseOnZeroStatus(self, txid):
164
- if self.web3.eth.getTransactionReceipt(txid)['status'] == 0:
165
- #print(self.web3.eth.getTransactionReceipt(txid))
171
+ if self.web3.eth.get_transaction_receipt(txid)['status'] == 0:
172
+ #print(self.web3.eth.get_transaction_receipt(txid))
166
173
  raise TransactionFailed
167
174
 
168
175
  def _block_timestamp(self):
@@ -208,7 +215,7 @@ class TestRealitio(TestCase):
208
215
  bcode = f.read().strip("\n")
209
216
  f.close()
210
217
 
211
- for solcv in ['solc-0.4.25', 'solc-0.8.6']:
218
+ for solcv in ['solc-0.4.25', 'solc-0.8.6', 'solc-0.8.20']:
212
219
  abi_file = '../../abi/'+solcv+'/' + con_name + '.abi.json'
213
220
  if os.path.exists(abi_file):
214
221
  with open(abi_file) as f:
@@ -217,7 +224,7 @@ class TestRealitio(TestCase):
217
224
  break
218
225
 
219
226
  tx_hash = self.web3.eth.contract(abi=contract_if, bytecode=bcode).constructor().transact(self.deploy_tx)
220
- addr = self.web3.eth.getTransactionReceipt(tx_hash).get('contractAddress')
227
+ addr = self.web3.eth.get_transaction_receipt(tx_hash).get('contractAddress')
221
228
  return self.web3.eth.contract(addr, abi=contract_if)
222
229
 
223
230
  def testS(self):
@@ -230,6 +237,7 @@ class TestRealitio(TestCase):
230
237
 
231
238
  prov = EthereumTesterProvider(EthereumTester(PyEVMBackend(genesis_params)))
232
239
  self.web3 = Web3(prov)
240
+ self.web3.strict_bytes_type_checking = False
233
241
  self.web3.testing.mine()
234
242
 
235
243
  self.deploy_tx = {
@@ -285,7 +293,7 @@ class TestRealitio(TestCase):
285
293
  0,
286
294
  0
287
295
  ).transact(self._txargs(val=1100))
288
- txr = self.web3.eth.getTransactionReceipt(txid)
296
+ txr = self.web3.eth.get_transaction_receipt(txid)
289
297
 
290
298
  expected_content_hash = calculate_content_hash(0, "my question", 0)
291
299
 
@@ -558,6 +566,10 @@ class TestRealitio(TestCase):
558
566
  print("Skipping test_arbitrator_answering_assigning_answerer_right_commit, not a feature of this contract")
559
567
  return
560
568
 
569
+ if not IS_COMMIT_REVEAL_SUPPORTED:
570
+ print("Skipping test_arbitrator_answering_assigning_answerer_right_commit, contract does not support commit-reveal")
571
+ return
572
+
561
573
  k2 = self.web3.eth.accounts[2]
562
574
  k3 = self.web3.eth.accounts[3]
563
575
  k4 = self.web3.eth.accounts[4]
@@ -599,6 +611,10 @@ class TestRealitio(TestCase):
599
611
  @unittest.skipIf(WORKING_ONLY, "Not under construction")
600
612
  def test_arbitrator_answering_assigning_answerer_wrong_commit(self):
601
613
 
614
+ if not IS_COMMIT_REVEAL_SUPPORTED:
615
+ print("Skipping test_arbitrator_answering_assigning_answerer_wrong_commit, contract does not support commit-reveal")
616
+ return
617
+
602
618
  if VERNUM < 2.1:
603
619
  print("Skipping test_arbitrator_answering_assigning_answerer_wrong_commit, not a feature of this contract")
604
620
  return
@@ -689,6 +705,10 @@ class TestRealitio(TestCase):
689
705
  @unittest.skipIf(WORKING_ONLY, "Not under construction")
690
706
  def test_arbitrator_answering_assigning_answerer_unrevealed_commit(self):
691
707
 
708
+ if not IS_COMMIT_REVEAL_SUPPORTED:
709
+ print("Skipping test_arbitrator_answering_assigning_answerer_unrevealed_commit, contract does not support commit-reveal")
710
+ return
711
+
692
712
  if VERNUM < 2.1:
693
713
  print("Skipping test_arbitrator_answering_assigning_answerer_unrevealed_commit, not a feature of this contract")
694
714
  return
@@ -766,6 +786,10 @@ class TestRealitio(TestCase):
766
786
  @unittest.skipIf(WORKING_ONLY, "Not under construction")
767
787
  def test_arbitrator_answering_single_unrevealed_commit(self):
768
788
 
789
+ if not IS_COMMIT_REVEAL_SUPPORTED:
790
+ print("Skipping test_arbitrator_answering_single_unrevealed_commit, contract does not support commit-reveal")
791
+ return
792
+
769
793
  if VERNUM < 3.0:
770
794
  print("Skipping test_arbitrator_answering_assigning_answerer_single_unrevealed_commit, not a feature of this contract")
771
795
  return
@@ -871,6 +895,9 @@ class TestRealitio(TestCase):
871
895
 
872
896
  def submitAnswerReturnUpdatedState(self, st, qid, ans, max_last, bond, sdr, is_commitment = False, is_arbitrator = False, skip_sender = False, tx_acct = None):
873
897
 
898
+ if is_commitment and not IS_COMMIT_REVEAL_SUPPORTED:
899
+ raise Exception("Test tried to set is_commitment to true but the contract version does not support commitments")
900
+
874
901
  if tx_acct is None:
875
902
  tx_acct = sdr
876
903
 
@@ -1118,6 +1145,10 @@ class TestRealitio(TestCase):
1118
1145
  @unittest.skipIf(WORKING_ONLY, "Not under construction")
1119
1146
  def test_bond_claim_after_reveal_fail(self):
1120
1147
 
1148
+ if not IS_COMMIT_REVEAL_SUPPORTED:
1149
+ print("Skipping test_bond_claim_after_reveal_fail, contract does not support commit-reveal")
1150
+ return
1151
+
1121
1152
  k3 = self.web3.eth.accounts[3]
1122
1153
  k4 = self.web3.eth.accounts[4]
1123
1154
  k5 = self.web3.eth.accounts[5]
@@ -1132,7 +1163,7 @@ class TestRealitio(TestCase):
1132
1163
  st = None
1133
1164
  st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1002, 0, 1, k3, False)
1134
1165
  st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1001, 1, 2, k5, False)
1135
- st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1003, 2, 4, k4, False)
1166
+ st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1003, 2, 4, k4, False)
1136
1167
  st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1002, 4, 8, k6, False)
1137
1168
  st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1004, 8, 16, k5, True)
1138
1169
  st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1002, 16, 32, k4, True)
@@ -1145,12 +1176,14 @@ class TestRealitio(TestCase):
1145
1176
  @unittest.skipIf(WORKING_ONLY, "Not under construction")
1146
1177
  def test_bond_claim_split_over_transactions_payee_later(self):
1147
1178
 
1179
+ k2 = self.web3.eth.accounts[2]
1148
1180
  k3 = self.web3.eth.accounts[3]
1149
1181
  k4 = self.web3.eth.accounts[4]
1150
1182
  k5 = self.web3.eth.accounts[5]
1151
1183
  k6 = self.web3.eth.accounts[6]
1152
1184
 
1153
1185
  if ERC20:
1186
+ self._issueTokens(k2, 1000000, 1000000)
1154
1187
  self._issueTokens(k3, 1000000, 1000000)
1155
1188
  self._issueTokens(k4, 1000000, 1000000)
1156
1189
  self._issueTokens(k5, 1000000, 1000000)
@@ -1159,7 +1192,41 @@ class TestRealitio(TestCase):
1159
1192
  st = None
1160
1193
  st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1002, 0, 1, k3, False)
1161
1194
  st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1001, 1, 2, k5, False)
1162
- st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1003, 2, 4, k4, False)
1195
+ st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1003, 2, 4, k4, False)
1196
+ st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1002, 4, 8, k6, False)
1197
+ st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1004, 8, 16, k5, False)
1198
+ st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1002, 16, 32, k2, False)
1199
+
1200
+ self._advance_clock(33)
1201
+ self.rc0.functions.claimWinnings(self.question_id, st['hash'][:2], st['addr'][:2], st['bond'][:2], st['answer'][:2]).transact()
1202
+ self.rc0.functions.claimWinnings(self.question_id, st['hash'][2:], st['addr'][2:], st['bond'][2:], st['answer'][2:]).transact()
1203
+
1204
+ self.assertEqual(self.rc0.functions.balanceOf(k2).call(),32+16-8+1000)
1205
+ self.assertEqual(self.rc0.functions.balanceOf(k6).call(),8+8+4+2-1)
1206
+ self.assertEqual(self.rc0.functions.balanceOf(k3).call(),1+1)
1207
+
1208
+ @unittest.skipIf(WORKING_ONLY, "Not under construction")
1209
+ def test_bond_claim_split_over_transactions_payee_later_unrevealed_commit(self):
1210
+
1211
+ if not IS_COMMIT_REVEAL_SUPPORTED:
1212
+ print("Skipping test_bond_claim_split_over_transactions_payee_later_unrevealed_commit, contract does not support commit-reveal")
1213
+ return
1214
+
1215
+ k3 = self.web3.eth.accounts[3]
1216
+ k4 = self.web3.eth.accounts[4]
1217
+ k5 = self.web3.eth.accounts[5]
1218
+ k6 = self.web3.eth.accounts[6]
1219
+
1220
+ if ERC20:
1221
+ self._issueTokens(k3, 1000000, 1000000)
1222
+ self._issueTokens(k4, 1000000, 1000000)
1223
+ self._issueTokens(k5, 1000000, 1000000)
1224
+ self._issueTokens(k6, 1000000, 1000000)
1225
+
1226
+ st = None
1227
+ st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1002, 0, 1, k3, False)
1228
+ st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1001, 1, 2, k5, False)
1229
+ st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1003, 2, 4, k4, False)
1163
1230
  st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1002, 4, 8, k6, False)
1164
1231
  st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1004, 8, 16, k5, True)
1165
1232
  st = self.submitAnswerReturnUpdatedState( st, self.question_id, 1002, 16, 32, k4, True)
@@ -1172,12 +1239,21 @@ class TestRealitio(TestCase):
1172
1239
 
1173
1240
  @unittest.skipIf(WORKING_ONLY, "Not under construction")
1174
1241
  def test_answer_reveal_calculation(self):
1242
+
1243
+ if not IS_COMMIT_REVEAL_SUPPORTED:
1244
+ print("Skipping test_answer_reveal_calculation, contract does not support commit-reveal")
1245
+ return
1246
+
1175
1247
  h = calculate_answer_hash(to_answer_for_contract(1003), 94989)
1176
1248
  self.assertEqual(h, '0x23e796d2bf4f5f890b1242934a636f4802aadd480b6f83c754d2bd5920f78845')
1177
1249
 
1178
1250
  @unittest.skipIf(WORKING_ONLY, "Not under construction")
1179
1251
  def test_answer_commit_normal(self):
1180
1252
 
1253
+ if not IS_COMMIT_REVEAL_SUPPORTED:
1254
+ print("Skipping test_answer_commit_normal, contract does not support commit-reveal")
1255
+ return
1256
+
1181
1257
  k3 = self.web3.eth.accounts[3]
1182
1258
  k4 = self.web3.eth.accounts[4]
1183
1259
  k5 = self.web3.eth.accounts[5]
@@ -1222,7 +1298,7 @@ class TestRealitio(TestCase):
1222
1298
 
1223
1299
  self.raiseOnZeroStatus(txid)
1224
1300
 
1225
- #rcp = self.web3.eth.getTransactionReceipt(txid)
1301
+ #rcp = self.web3.eth.get_transaction_receipt(txid)
1226
1302
  self._advance_clock(33)
1227
1303
  #time.sleep(10)
1228
1304
 
@@ -1234,6 +1310,11 @@ class TestRealitio(TestCase):
1234
1310
 
1235
1311
  @unittest.skipIf(WORKING_ONLY, "Not under construction")
1236
1312
  def test_answer_commit_skip_sender(self):
1313
+
1314
+ if not IS_COMMIT_REVEAL_SUPPORTED:
1315
+ print("Skipping test_answer_commit_skip_sender, contract does not support commit-reveal")
1316
+ return
1317
+
1237
1318
  st = None
1238
1319
 
1239
1320
  k3 = self.web3.eth.accounts[3]
@@ -1267,6 +1348,10 @@ class TestRealitio(TestCase):
1267
1348
  @unittest.skipIf(WORKING_ONLY, "Not under construction")
1268
1349
  def test_answer_no_answer_no_commit(self):
1269
1350
 
1351
+ if not IS_COMMIT_REVEAL_SUPPORTED:
1352
+ print("Skipping test_answer_no_answer_no_commit, contract does not support commit-reveal")
1353
+ return
1354
+
1270
1355
  k3 = self.web3.eth.accounts[3]
1271
1356
  if ERC20:
1272
1357
  self._issueTokens(k3, 1000000, 1000000)
@@ -1291,6 +1376,10 @@ class TestRealitio(TestCase):
1291
1376
  @unittest.skipIf(WORKING_ONLY, "Not under construction")
1292
1377
  def test_answer_commit_expired(self):
1293
1378
 
1379
+ if not IS_COMMIT_REVEAL_SUPPORTED:
1380
+ print("Skipping test_answer_commit_expired, contract does not support commit-reveal")
1381
+ return
1382
+
1294
1383
  k3 = self.web3.eth.accounts[3]
1295
1384
  if ERC20:
1296
1385
  self._issueTokens(k3, 1000000, 1000000)
@@ -1308,6 +1397,10 @@ class TestRealitio(TestCase):
1308
1397
  @unittest.skipIf(WORKING_ONLY, "Not under construction")
1309
1398
  def test_answer_commit_with_arbitration_pending(self):
1310
1399
 
1400
+ if not IS_COMMIT_REVEAL_SUPPORTED:
1401
+ print("Skipping test_answer_commit_with_arbitration_pending, contract does not support commit-reveal")
1402
+ return
1403
+
1311
1404
  k3 = self.web3.eth.accounts[3]
1312
1405
  if ERC20:
1313
1406
  self._issueTokens(k3, 1000, 1000)
@@ -1664,17 +1757,17 @@ class TestRealitio(TestCase):
1664
1757
  if ERC20:
1665
1758
  starting_bal = self.token0.functions.balanceOf(k5).call()
1666
1759
  else:
1667
- starting_bal = self.web3.eth.getBalance(k5)
1760
+ starting_bal = self.web3.eth.get_balance(k5)
1668
1761
 
1669
1762
  txid = self.rc0.functions.withdraw().transact(self._txargs(sender=k5))
1670
- rcpt = self.web3.eth.getTransactionReceipt(txid)
1671
- gas_spent = rcpt['cumulativeGasUsed']
1763
+ rcpt = self.web3.eth.get_transaction_receipt(txid)
1764
+ gas_spent = rcpt['cumulativeGasUsed'] * rcpt['effectiveGasPrice']
1672
1765
 
1673
1766
  if ERC20:
1674
1767
  ending_bal = self.token0.functions.balanceOf(k5).call()
1675
1768
  self.assertEqual(ending_bal, starting_bal + k5bal)
1676
1769
  else:
1677
- ending_bal = self.web3.eth.getBalance(k5)
1770
+ ending_bal = self.web3.eth.get_balance(k5)
1678
1771
  self.assertEqual(ending_bal, starting_bal + k5bal - gas_spent)
1679
1772
 
1680
1773
  self.assertEqual(self.rc0.functions.balanceOf(k5).call(), 0)
@@ -1731,23 +1824,24 @@ class TestRealitio(TestCase):
1731
1824
  if ERC20:
1732
1825
  starting_bal = self.token0.functions.balanceOf(k5).call()
1733
1826
  else:
1734
- starting_bal = self.web3.eth.getBalance(k5)
1827
+ starting_bal = self.web3.eth.get_balance(k5)
1735
1828
 
1736
1829
  txid = self.rc0.functions.withdraw().transact(self._txargs(sender=k5))
1737
- rcpt = self.web3.eth.getTransactionReceipt(txid)
1830
+ rcpt = self.web3.eth.get_transaction_receipt(txid)
1738
1831
  gas_used = rcpt['cumulativeGasUsed']
1832
+ gas_spent = gas_used * rcpt['effectiveGasPrice']
1739
1833
 
1740
1834
  if ERC20:
1741
1835
  ending_bal = self.token0.functions.balanceOf(k5).call()
1742
1836
  else:
1743
- ending_bal = self.web3.eth.getBalance(k5)
1837
+ ending_bal = self.web3.eth.get_balance(k5)
1744
1838
 
1745
1839
  self.assertEqual(self.rc0.functions.balanceOf(k5).call(), 0)
1746
1840
 
1747
1841
  if ERC20:
1748
1842
  self.assertEqual(ending_bal, starting_bal + starting_deposited)
1749
1843
  else:
1750
- self.assertEqual(ending_bal, starting_bal + starting_deposited - gas_used)
1844
+ self.assertEqual(ending_bal, starting_bal + starting_deposited - gas_spent)
1751
1845
 
1752
1846
  return
1753
1847
 
@@ -1792,16 +1886,16 @@ class TestRealitio(TestCase):
1792
1886
  if ERC20:
1793
1887
  starting_bal = self.token0.functions.balanceOf(k5).call()
1794
1888
  else:
1795
- starting_bal = self.web3.eth.getBalance(k5)
1889
+ starting_bal = self.web3.eth.get_balance(k5)
1796
1890
 
1797
1891
  txid = self.rc0.functions.withdraw().transact(self._txargs(sender=k5))
1798
- rcpt = self.web3.eth.getTransactionReceipt(txid)
1892
+ rcpt = self.web3.eth.get_transaction_receipt(txid)
1799
1893
  gas_used = rcpt['cumulativeGasUsed']
1800
1894
 
1801
1895
  if ERC20:
1802
1896
  ending_bal = self.token0.functions.balanceOf(k5).call()
1803
1897
  else:
1804
- ending_bal = self.web3.eth.getBalance(k5)
1898
+ ending_bal = self.web3.eth.get_balance(k5)
1805
1899
 
1806
1900
  self.assertEqual(self.rc0.functions.balanceOf(k5).call(), 0)
1807
1901
 
@@ -1870,7 +1964,7 @@ class TestRealitio(TestCase):
1870
1964
  0
1871
1965
  ,1100
1872
1966
  ).transact()
1873
- rcpt = self.web3.eth.getTransactionReceipt(txid)
1967
+ rcpt = self.web3.eth.get_transaction_receipt(txid)
1874
1968
  gas_used = rcpt['cumulativeGasUsed']
1875
1969
  self.assertTrue(gas_used < 140000)
1876
1970
  else:
@@ -1882,7 +1976,7 @@ class TestRealitio(TestCase):
1882
1976
  0,
1883
1977
  0
1884
1978
  ).transact(self._txargs(val=1100))
1885
- rcpt = self.web3.eth.getTransactionReceipt(txid)
1979
+ rcpt = self.web3.eth.get_transaction_receipt(txid)
1886
1980
  gas_used = rcpt['cumulativeGasUsed']
1887
1981
  #self.assertEqual(gas_used, 120000)
1888
1982
  self.assertTrue(gas_used < 110000)
@@ -1895,7 +1989,7 @@ class TestRealitio(TestCase):
1895
1989
  txid = self.rc0.functions.submitAnswerERC20(self.question_id, to_answer_for_contract(12345), 0
1896
1990
  ,1
1897
1991
  ).transact()
1898
- rcpt = self.web3.eth.getTransactionReceipt(txid)
1992
+ rcpt = self.web3.eth.get_transaction_receipt(txid)
1899
1993
 
1900
1994
  self.assertTrue(rcpt['cumulativeGasUsed'] < 140000)
1901
1995
 
@@ -1905,13 +1999,13 @@ class TestRealitio(TestCase):
1905
1999
  txid2 = self.rc0.functions.submitAnswerERC20(self.question_id, to_answer_for_contract(12346), 0
1906
2000
  ,2
1907
2001
  ).transact()
1908
- rcpt = self.web3.eth.getTransactionReceipt(txid2)
2002
+ rcpt = self.web3.eth.get_transaction_receipt(txid2)
1909
2003
  self.assertTrue(rcpt['cumulativeGasUsed'] < 80000)
1910
2004
 
1911
2005
  else:
1912
2006
 
1913
2007
  txid = self.rc0.functions.submitAnswer(self.question_id, to_answer_for_contract(12345), 0).transact(self._txargs(val=1))
1914
- rcpt = self.web3.eth.getTransactionReceipt(txid)
2008
+ rcpt = self.web3.eth.get_transaction_receipt(txid)
1915
2009
 
1916
2010
  self.assertTrue(rcpt['cumulativeGasUsed'] < 103000)
1917
2011
 
@@ -1919,7 +2013,7 @@ class TestRealitio(TestCase):
1919
2013
  # This is what we want, because you may need to be able to get a challenge through at busy times
1920
2014
 
1921
2015
  txid2 = self.rc0.functions.submitAnswer(self.question_id, to_answer_for_contract(12346), 0).transact(self._txargs(val=2))
1922
- rcpt = self.web3.eth.getTransactionReceipt(txid2)
2016
+ rcpt = self.web3.eth.get_transaction_receipt(txid2)
1923
2017
  self.assertTrue(rcpt['cumulativeGasUsed'] < 56000)
1924
2018
 
1925
2019
  @unittest.skipIf(WORKING_ONLY, "Not under construction")
@@ -1967,7 +2061,7 @@ class TestRealitio(TestCase):
1967
2061
 
1968
2062
  start_arb_bal = self.token0.functions.balanceOf(self.arb0.address).call()
1969
2063
  txid = self.arb0.functions.callWithdraw().transact(self._txargs(sender=k7))
1970
- rcpt = self.web3.eth.getTransactionReceipt(txid)
2064
+ rcpt = self.web3.eth.get_transaction_receipt(txid)
1971
2065
  end_arb_bal = self.token0.functions.balanceOf(self.arb0.address).call()
1972
2066
 
1973
2067
  self.assertEqual(end_arb_bal - start_arb_bal, 100 + (321*2))
@@ -1996,10 +2090,10 @@ class TestRealitio(TestCase):
1996
2090
  end_bal = self.rc0.functions.balanceOf(self.arb0.address).call()
1997
2091
  self.assertEqual(end_bal - start_bal, (321*2))
1998
2092
 
1999
- start_arb_bal = self.web3.eth.getBalance(self.arb0.address)
2093
+ start_arb_bal = self.web3.eth.get_balance(self.arb0.address)
2000
2094
  txid = self.arb0.functions.callWithdraw().transact(self._txargs(sender=k7))
2001
- rcpt = self.web3.eth.getTransactionReceipt(txid)
2002
- end_arb_bal = self.web3.eth.getBalance(self.arb0.address)
2095
+ rcpt = self.web3.eth.get_transaction_receipt(txid)
2096
+ end_arb_bal = self.web3.eth.get_balance(self.arb0.address)
2003
2097
 
2004
2098
  self.assertEqual(end_arb_bal - start_arb_bal, 100 + (321*2))
2005
2099
  self.assertEqual(self.rc0.functions.balanceOf(self.arb0.address).call(), 0)
@@ -2120,11 +2214,11 @@ class TestRealitio(TestCase):
2120
2214
  1100
2121
2215
  ).transact(self._txargs())
2122
2216
  bal_after = self.token0.functions.balanceOf(k0).call()
2123
- rcpt = self.web3.eth.getTransactionReceipt(txid)
2217
+ rcpt = self.web3.eth.get_transaction_receipt(txid)
2124
2218
  self.assertEqual(bal_after, bal_before - 1100, "New question bounty is deducted")
2125
2219
  gas_used = rcpt['cumulativeGasUsed']
2126
2220
  else:
2127
- bal_before = self.web3.eth.getBalance(k0)
2221
+ bal_before = self.web3.eth.get_balance(k0)
2128
2222
  txid = self.rc0.functions.askQuestionWithMinBond(
2129
2223
  0,
2130
2224
  "my question 2",
@@ -2134,10 +2228,11 @@ class TestRealitio(TestCase):
2134
2228
  0,
2135
2229
  1000
2136
2230
  ).transact(self._txargs(val=1100))
2137
- rcpt = self.web3.eth.getTransactionReceipt(txid)
2231
+ rcpt = self.web3.eth.get_transaction_receipt(txid)
2138
2232
  gas_used = rcpt['cumulativeGasUsed']
2139
- bal_after = self.web3.eth.getBalance(k0)
2140
- self.assertEqual(bal_after, bal_before - 1100 - gas_used, "New question bouny is deducted")
2233
+ gas_spent = gas_used * rcpt['effectiveGasPrice']
2234
+ bal_after = self.web3.eth.get_balance(k0)
2235
+ self.assertEqual(bal_after, bal_before - 1100 - gas_spent, "New question bouny is deducted")
2141
2236
 
2142
2237
  #self.assertEqual(gas_used, 120000)
2143
2238
  self.assertTrue(gas_used < 160000)
@@ -2263,7 +2358,7 @@ class TestRealitio(TestCase):
2263
2358
  if ERC20:
2264
2359
  start_arb_bal = self.token0.functions.balanceOf(t.a8).call()
2265
2360
  else:
2266
- start_arb_bal = self.web3.eth.getBalance(t.a8)
2361
+ start_arb_bal = self.web3.eth.get_balance(t.a8)
2267
2362
 
2268
2363
  self.arb0.functions.callWithdraw().transact(self._txargs(sender=k7))
2269
2364
  self.arb0.functions.withdrawToRegisteredWallet().transact(self._txargs(sender=k4))
@@ -2271,7 +2366,7 @@ class TestRealitio(TestCase):
2271
2366
  if ERC20:
2272
2367
  end_arb_bal = self.token0.functions.balanceOf(t.a8).call()
2273
2368
  else:
2274
- end_arb_bal = self.web3.eth.getBalance(t.a8)
2369
+ end_arb_bal = self.web3.eth.get_balance(t.a8)
2275
2370
 
2276
2371
  self.assertEqual(end_arb_bal - start_arb_bal, (100+321+321))
2277
2372
  self.assertEqual(self.rc0.functions.balanceOf(self.arb0.address).call(), 0)
@@ -2359,19 +2454,20 @@ class TestRealitio(TestCase):
2359
2454
  self.rc0.functions.withdraw().transact(self._txargs())
2360
2455
  bal_before = self.token0.functions.balanceOf(k0).call()
2361
2456
  txid = self.rc0.functions.reopenQuestionERC20( 0, "my question", self.arb0.address, 30, 0, 1, 0, self.question_id, 123).transact(self._txargs(gas=300000))
2362
- rcpt = self.web3.eth.getTransactionReceipt(txid)
2457
+ rcpt = self.web3.eth.get_transaction_receipt(txid)
2363
2458
  self.raiseOnZeroStatus(txid)
2364
2459
  bal_after = self.token0.functions.balanceOf(k0).call()
2365
2460
  self.assertEqual(bal_after, bal_before - 123, "New question bounty is deducted")
2366
2461
  else:
2367
- bal_before = self.web3.eth.getBalance(k0)
2462
+ bal_before = self.web3.eth.get_balance(k0)
2368
2463
  txid = self.rc0.functions.reopenQuestion( 0, "my question", self.arb0.address, 30, 0, 1, 0, self.question_id).transact(self._txargs(val=123))
2369
2464
  self.raiseOnZeroStatus(txid)
2370
- rcpt = self.web3.eth.getTransactionReceipt(txid)
2371
- gas_spent = rcpt['cumulativeGasUsed']
2372
- bal_after = self.web3.eth.getBalance(k0)
2465
+ rcpt = self.web3.eth.get_transaction_receipt(txid)
2466
+ gas_used = rcpt['cumulativeGasUsed']
2467
+ gas_spent = gas_used * rcpt['effectiveGasPrice']
2468
+ bal_after = self.web3.eth.get_balance(k0)
2373
2469
  self.assertEqual(bal_after, bal_before - 123 - gas_spent, "New question bounty is deducted")
2374
- txr = self.web3.eth.getTransactionReceipt(txid)
2470
+ txr = self.web3.eth.get_transaction_receipt(txid)
2375
2471
 
2376
2472
  self.assertEqual("0x"+encode_hex(self.rc0.functions.reopened_questions(self.question_id).call()), expected_reopen_id, "reopened_questions returns reopened question id")
2377
2473
 
@@ -2394,7 +2490,7 @@ class TestRealitio(TestCase):
2394
2490
  # Different nonce should still fail
2395
2491
  with self.assertRaises(TransactionFailed):
2396
2492
  if ERC20:
2397
- txid = self.rc0.functions.reopenQuestionERC20( 0, "my question", self.arb0.address, 30, 0, 2, 0, self.question_id, 123).transact(self._txargs(val=123))
2493
+ txid = self.rc0.functions.reopenQuestionERC20( 0, "my question", self.arb0.address, 30, 0, 2, 0, self.question_id, 123).transact(self._txargs())
2398
2494
  else:
2399
2495
  txid = self.rc0.functions.reopenQuestion( 0, "my question", self.arb0.address, 30, 0, 2, 0, self.question_id).transact(self._txargs(val=123))
2400
2496
  self.raiseOnZeroStatus(txid)
@@ -2490,6 +2586,10 @@ class TestRealitio(TestCase):
2490
2586
  @unittest.skipIf(WORKING_ONLY, "Not under construction")
2491
2587
  def test_too_soon_bonds_under_unrevealed_commit(self):
2492
2588
 
2589
+ if not IS_COMMIT_REVEAL_SUPPORTED:
2590
+ print("Skipping test_too_soon_bonds_under_unrevealed_commit, contract does not support commit-reveal")
2591
+ return
2592
+
2493
2593
  if VERNUM < 3.0:
2494
2594
  print("Skipping test_reopen_question, not a feature of this contract")
2495
2595
  return
@@ -55,7 +55,7 @@ def calculate_answer_hash(answer, nonce):
55
55
  raise Exception("hash functions expect bytes for bytes32 parameters")
56
56
  if not isinstance(nonce, int):
57
57
  raise Exception("hash functions expect int for uint256 parameters")
58
- return "0x"+encode_hex(bytes(Web3.solidityKeccak(['bytes32', 'uint256'], [answer, nonce])))
58
+ return "0x"+encode_hex(bytes(Web3.solidity_keccak(['bytes32', 'uint256'], [answer, nonce])))
59
59
 
60
60
  def calculate_commitment_id(question_id, answer_hash, bond):
61
61
  if question_id[:2] == "0x":
@@ -65,17 +65,17 @@ def calculate_commitment_id(question_id, answer_hash, bond):
65
65
  if not isinstance(bond, int):
66
66
  raise Exception("hash functions expect int for uint256 parameters")
67
67
  #return decode_hex(keccak_256(question_id + answer_hash + decode_hex(hex(bond)[2:].zfill(64))).hexdigest())
68
- return "0x"+encode_hex(bytes(Web3.solidityKeccak(['bytes32', 'bytes32', 'uint256'], [question_id, answer_hash, bond])))
68
+ return "0x"+encode_hex(bytes(Web3.solidity_keccak(['bytes32', 'bytes32', 'uint256'], [question_id, answer_hash, bond])))
69
69
 
70
70
  def calculate_content_hash(template_id, question_str, opening_ts):
71
- return "0x"+encode_hex(bytes(Web3.solidityKeccak(['uint256', 'uint32', 'string'], [template_id, opening_ts, question_str])))
71
+ return "0x"+encode_hex(bytes(Web3.solidity_keccak(['uint256', 'uint32', 'string'], [template_id, opening_ts, question_str])))
72
72
 
73
73
  def calculate_question_id(template_id, question_str, arbitrator, timeout, opening_ts, nonce, sender):
74
74
  content_hash = calculate_content_hash(template_id, question_str, opening_ts)
75
- return "0x"+encode_hex(bytes(Web3.solidityKeccak(['bytes32', 'address', 'uint32', 'address', 'uint256'], [content_hash, arbitrator, timeout, sender, nonce])))
75
+ return "0x"+encode_hex(bytes(Web3.solidity_keccak(['bytes32', 'address', 'uint32', 'address', 'uint256'], [content_hash, arbitrator, timeout, sender, nonce])))
76
76
 
77
77
  def calculate_history_hash(last_history_hash, answer_or_commitment_id, bond, answerer, is_commitment):
78
- return "0x"+encode_hex(bytes(Web3.solidityKeccak(['bytes32', 'bytes32', 'uint256', 'address', 'bool'], [last_history_hash, answer_or_commitment_id, bond, answerer, is_commitment])))
78
+ return "0x"+encode_hex(bytes(Web3.solidity_keccak(['bytes32', 'bytes32', 'uint256', 'address', 'bool'], [last_history_hash, answer_or_commitment_id, bond, answerer, is_commitment])))
79
79
 
80
80
  def from_question_for_contract(txt):
81
81
  return txt
@@ -90,13 +90,13 @@ def from_answer_for_contract(txt):
90
90
  class TestRealitio(TestCase):
91
91
 
92
92
  def assertZeroStatus(self, txid, msg=None):
93
- self.assertEqual(self.web3.eth.getTransactionReceipt(txid)['status'], 0, msg)
93
+ self.assertEqual(self.web3.eth.get_transaction_receipt(txid)['status'], 0, msg)
94
94
 
95
95
  # Sometimes we seem to get a zero status receipt with no exception raised
96
96
  # Not sure if this is what's supposed to happen, but call this in the with block to make sure we get an exception
97
97
  def raiseOnZeroStatus(self, txid):
98
- if self.web3.eth.getTransactionReceipt(txid)['status'] == 0:
99
- #print(self.web3.eth.getTransactionReceipt(txid))
98
+ if self.web3.eth.get_transaction_receipt(txid)['status'] == 0:
99
+ #print(self.web3.eth.get_transaction_receipt(txid))
100
100
  raise TransactionFailed
101
101
 
102
102
  def _block_timestamp(self):
@@ -190,7 +190,7 @@ class TestRealitio(TestCase):
190
190
  f.close()
191
191
 
192
192
  tx_hash = self.web3.eth.contract(abi=contract_if, bytecode=bcode).constructor().transact(self.deploy_tx)
193
- addr = self.web3.eth.getTransactionReceipt(tx_hash).get('contractAddress')
193
+ addr = self.web3.eth.get_transaction_receipt(tx_hash).get('contractAddress')
194
194
  return self.web3.eth.contract(addr, abi=contract_if)
195
195
 
196
196
  def testS(self):
@@ -203,6 +203,7 @@ class TestRealitio(TestCase):
203
203
  prov = EthereumTesterProvider(EthereumTester(PyEVMBackend(genesis_params)))
204
204
 
205
205
  self.web3 = Web3(prov)
206
+ self.web3.strict_bytes_type_checking = False
206
207
  self.web3.testing.mine()
207
208
 
208
209
  k0 = self.web3.eth.accounts[0]
@@ -774,7 +775,7 @@ class TestRealitio(TestCase):
774
775
 
775
776
  self.raiseOnZeroStatus(txid)
776
777
 
777
- #rcp = self.web3.eth.getTransactionReceipt(txid)
778
+ #rcp = self.web3.eth.get_transaction_receipt(txid)
778
779
  self._advance_clock(33)
779
780
  #time.sleep(10)
780
781
 
@@ -1257,7 +1258,7 @@ class TestRealitio(TestCase):
1257
1258
  0
1258
1259
  ,1100
1259
1260
  ).transact()
1260
- rcpt = self.web3.eth.getTransactionReceipt(txid)
1261
+ rcpt = self.web3.eth.get_transaction_receipt(txid)
1261
1262
  gas_used = rcpt['cumulativeGasUsed']
1262
1263
  self.assertTrue(gas_used < 140000)
1263
1264
 
@@ -1267,7 +1268,7 @@ class TestRealitio(TestCase):
1267
1268
  txid = self.rc0.functions.submitAnswerERC20(self.question_id, to_answer_for_contract(12345), 0
1268
1269
  ,1
1269
1270
  ).transact()
1270
- rcpt = self.web3.eth.getTransactionReceipt(txid)
1271
+ rcpt = self.web3.eth.get_transaction_receipt(txid)
1271
1272
 
1272
1273
  self.assertTrue(rcpt['cumulativeGasUsed'] < 140000)
1273
1274
 
@@ -1277,7 +1278,7 @@ class TestRealitio(TestCase):
1277
1278
  txid2 = self.rc0.functions.submitAnswerERC20(self.question_id, to_answer_for_contract(12346), 0
1278
1279
  ,2
1279
1280
  ).transact()
1280
- rcpt = self.web3.eth.getTransactionReceipt(txid2)
1281
+ rcpt = self.web3.eth.get_transaction_receipt(txid2)
1281
1282
  self.assertTrue(rcpt['cumulativeGasUsed'] < 80000)
1282
1283
 
1283
1284
  @unittest.skipIf(WORKING_ONLY, "Not under construction")
@@ -1321,7 +1322,7 @@ class TestRealitio(TestCase):
1321
1322
 
1322
1323
  start_arb_bal = self.token0.functions.balanceOf(self.arb0.address).call()
1323
1324
  txid = self.arb0.functions.callWithdraw().transact(self._txargs(sender=k7))
1324
- rcpt = self.web3.eth.getTransactionReceipt(txid)
1325
+ rcpt = self.web3.eth.get_transaction_receipt(txid)
1325
1326
  end_arb_bal = self.token0.functions.balanceOf(self.arb0.address).call()
1326
1327
 
1327
1328
  self.assertEqual(end_arb_bal - start_arb_bal, 100 + (321*2))
package/tokens/ETH.json CHANGED
@@ -2,15 +2,16 @@
2
2
  "decimals": 18,
3
3
  "small_number": 10000000000000000,
4
4
  "native_chains": {
5
- "1": true,
5
+ "1": true,
6
6
  "4": true,
7
7
  "5": true,
8
8
  "42": true,
9
9
  "280": true,
10
+ "300": true,
10
11
  "324": true,
11
12
  "1101": true,
12
13
  "534353": true,
13
14
  "1337702": true,
14
15
  "11155111": true
15
16
  }
16
- }
17
+ }