@reality.eth/contracts 4.0.0-rc.0 → 4.0.0-rc.2

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 (30) hide show
  1. package/abi/solc-0.8.20/Arbitrator.abi.json +1 -0
  2. package/abi/solc-0.8.20/RealityETH-4.0.abi.json +1 -1
  3. package/abi/solc-0.8.20/RealityETHFreezableExample_ERC20-4.0.abi.json +1 -0
  4. package/abi/solc-0.8.20/RealityETHReopenable-4.0.abi.json +1 -1
  5. package/abi/solc-0.8.20/RealityETHReopenable_ERC20-4.0.abi.json +1 -1
  6. package/abi/solc-0.8.20/RealityETH_ERC20-4.0.abi.json +1 -1
  7. package/bytecode/Arbitrator.bin +1 -1
  8. package/bytecode/RealityETH-4.0.bin +1 -1
  9. package/bytecode/RealityETHFreezableExample_ERC20-4.0.bin +1 -0
  10. package/bytecode/RealityETHReopenable-4.0.bin +1 -1
  11. package/bytecode/RealityETHReopenable_ERC20-4.0.bin +1 -1
  12. package/bytecode/RealityETH_ERC20-4.0.bin +1 -1
  13. package/development/contracts/IBalanceHolder.sol +1 -0
  14. package/development/contracts/IRealityETH.sol +6 -2
  15. package/development/contracts/{IRealityETHCore.sol → IRealityETHCore_Common.sol} +4 -8
  16. package/development/contracts/IRealityETHCore_ERC20.sol +3 -108
  17. package/development/contracts/IRealityETHCore_Native.sol +12 -0
  18. package/development/contracts/IRealityETHCreateTemplateAndAskQuestion.sol +8 -0
  19. package/development/contracts/IRealityETH_ERC20.sol +5 -1
  20. package/development/contracts/RealityETH-4.0.sol +12 -559
  21. package/development/contracts/RealityETHCore_Common.sol +543 -0
  22. package/development/contracts/RealityETHFreezableExample_ERC20-4.0.sol +17 -0
  23. package/development/contracts/RealityETHFreezable_ERC20.sol +39 -0
  24. package/development/contracts/RealityETHReopenable-4.0.sol +6 -6
  25. package/development/contracts/RealityETHReopenable_ERC20-4.0.sol +6 -6
  26. package/development/contracts/RealityETH_ERC20-4.0.sol +13 -556
  27. package/package.json +1 -1
  28. package/tests/python/test.py +106 -1
  29. package/development/contracts/BalanceHolder_ERC20.sol +0 -21
  30. package/development/contracts/IBalanceHolder_ERC20.sol +0 -11
@@ -36,6 +36,11 @@ if "ERC20" in REALITYETH_CONTRACT:
36
36
  else:
37
37
  ERC20 = False
38
38
 
39
+ if "Freezable" in REALITYETH_CONTRACT:
40
+ IS_FREEZE_SUPPORTED = True
41
+ else:
42
+ IS_FREEZE_SUPPORTED = False
43
+
39
44
  print("Version is "+str(VERNUM))
40
45
 
41
46
  if VERNUM >= 2.1:
@@ -2639,7 +2644,7 @@ class TestRealitio(TestCase):
2639
2644
 
2640
2645
  self.assertEqual(self.rc0.functions.balanceOf(k3).call(), claimable)
2641
2646
 
2642
- #@unittest.skipIf(WORKING_ONLY, "Not under construction")
2647
+ @unittest.skipIf(WORKING_ONLY, "Not under construction")
2643
2648
  def test_is_history_of_unfinalized_question_valid(self):
2644
2649
 
2645
2650
  if not IS_PROVE_HISTORY_SUPPORTED:
@@ -2708,6 +2713,106 @@ class TestRealitio(TestCase):
2708
2713
  with self.assertRaises(TransactionFailed):
2709
2714
  self.rc0.functions.isHistoryOfUnfinalizedQuestionValid(self.question_id, st['hash'], st['addr'], st['bond'], st['answer']).transact()
2710
2715
 
2716
+ #@unittest.skipIf(WORKING_ONLY, "Not under construction")
2717
+ def test_frozen(self):
2718
+
2719
+ if not IS_FREEZE_SUPPORTED:
2720
+ print("Skipping test_frozen, not supported by this version")
2721
+ return
2722
+
2723
+ k0 = self.web3.eth.accounts[0]
2724
+ k3 = self.web3.eth.accounts[3]
2725
+ k4 = self.web3.eth.accounts[4]
2726
+ k5 = self.web3.eth.accounts[5]
2727
+
2728
+ if ERC20:
2729
+ self._issueTokens(k0, 1000000, 1000000)
2730
+ self._issueTokens(k3, 1000000, 1000000)
2731
+ self._issueTokens(k4, 1000000, 1000000)
2732
+
2733
+ # We'll set up a question that finalizes before the freeze date to check we can still get its result after the freeze
2734
+ txid = self.rc0.functions.askQuestionERC20(
2735
+ 0,
2736
+ "my early question",
2737
+ self.arb0.address,
2738
+ 30,
2739
+ 0,
2740
+ 0
2741
+ ,1100
2742
+ ).transact(self._txargs())
2743
+ early_question_id = calculate_question_id(self.rc0.address, 0, "my early question", self.arb0.address, 30, 0, 0, self.web3.eth.accounts[0], 0)
2744
+ st = None
2745
+ st = self.submitAnswerReturnUpdatedState( st, early_question_id, 1001, 0, 200, k3)
2746
+ st = self.submitAnswerReturnUpdatedState( st, early_question_id, 1001, 200, 400, k3)
2747
+
2748
+ self.assertFalse(self.rc0.functions.isFinalized(early_question_id).call())
2749
+ # Can't get result as not finalized
2750
+ with self.assertRaises(TransactionFailed):
2751
+ self.assertEqual(self.rc0.functions.resultFor(early_question_id).call(), to_answer_for_contract(1001))
2752
+
2753
+ self._advance_clock(40)
2754
+ self.assertTrue(self.rc0.functions.isFinalized(early_question_id).call())
2755
+ self.assertEqual(self.rc0.functions.resultFor(early_question_id).call(), to_answer_for_contract(1001))
2756
+
2757
+ txid = self.rc0.functions.askQuestionERC20(
2758
+ 0,
2759
+ "my question",
2760
+ self.arb0.address,
2761
+ 30,
2762
+ 0,
2763
+ 0
2764
+ ,1100
2765
+ ).transact(self._txargs())
2766
+ question_id = calculate_question_id(self.rc0.address, 0, "my question", self.arb0.address, 30, 0, 0, self.web3.eth.accounts[0], 0)
2767
+
2768
+ # Start with the series we used before and make sure it goes through
2769
+ st = None
2770
+ st = self.submitAnswerReturnUpdatedState( st, question_id, 1001, 0, 200, k3)
2771
+ st = self.submitAnswerReturnUpdatedState( st, question_id, 1001, 200, 400, k3)
2772
+
2773
+ freeze_ts = self.rc0.functions.freeze_ts().call()
2774
+ self.assertTrue(freeze_ts == 0, "Freeze timestamp should be zero before freeze")
2775
+ self.rc0.functions.setFreezeTimestamp(self._block_timestamp()).transact(self._txargs())
2776
+ freeze_ts = self.rc0.functions.freeze_ts().call()
2777
+ self.assertTrue(freeze_ts > 0, "Freeze timestamp should be not zero after freeze")
2778
+
2779
+ # You can no longer answer a question
2780
+ with self.assertRaises(TransactionFailed):
2781
+ self.submitAnswerReturnUpdatedState( st, question_id, 1001, 400, 800, k3)
2782
+
2783
+ # You can no longer request arbitration
2784
+ fee = self.arb0.functions.getDisputeFee(encode_hex("0x00")).call()
2785
+ txid = self.arb0.functions.requestArbitration(question_id, 0).transact(self._txargs(val=fee))
2786
+ with self.assertRaises(TransactionFailed):
2787
+ self.raiseOnZeroStatus(txid)
2788
+
2789
+ # The question will no longer finalize, even after the time has elapsed
2790
+ self.assertFalse(self.rc0.functions.isFinalized(question_id).call())
2791
+ self._advance_clock(40)
2792
+ self.assertFalse(self.rc0.functions.isFinalized(question_id).call())
2793
+ # Can't get result as not finalized
2794
+ with self.assertRaises(TransactionFailed):
2795
+ self.assertEqual(self.rc0.functions.resultFor(question_id).call(), to_answer_for_contract(1001))
2796
+
2797
+ # The question that was finalized before is still finalized
2798
+ self.assertTrue(self.rc0.functions.isFinalized(early_question_id).call())
2799
+ # You can still get the result
2800
+ self.assertEqual(self.rc0.functions.resultFor(early_question_id).call(), to_answer_for_contract(1001))
2801
+
2802
+ # You can no longer ask a new question
2803
+ with self.assertRaises(TransactionFailed):
2804
+ txid = self.rc0.functions.askQuestionERC20(
2805
+ 0,
2806
+ "my question xyz",
2807
+ self.arb0.address,
2808
+ 30,
2809
+ 0,
2810
+ 0
2811
+ ,1100
2812
+ ).transact(self._txargs())
2813
+ self.raiseOnZeroStatus(txid)
2814
+
2815
+
2711
2816
  if __name__ == '__main__':
2712
2817
  main()
2713
2818
 
@@ -1,21 +0,0 @@
1
- // SPDX-License-Identifier: GPL-3.0-only
2
-
3
- pragma solidity ^0.8.20;
4
-
5
- import {IERC20} from "./IERC20.sol";
6
- import {IBalanceHolder_ERC20} from "./IBalanceHolder_ERC20.sol";
7
-
8
- contract BalanceHolder_ERC20 is IBalanceHolder_ERC20 {
9
- IERC20 public token;
10
-
11
- mapping(address => uint256) public balanceOf;
12
-
13
- event LogWithdraw(address indexed user, uint256 amount);
14
-
15
- function withdraw() public {
16
- uint256 bal = balanceOf[msg.sender];
17
- balanceOf[msg.sender] = 0;
18
- require(token.transfer(msg.sender, bal));
19
- emit LogWithdraw(msg.sender, bal);
20
- }
21
- }
@@ -1,11 +0,0 @@
1
- // SPDX-License-Identifier: GPL-3.0-only
2
-
3
- pragma solidity 0.8.20;
4
-
5
- import "./IERC20.sol";
6
-
7
- interface IBalanceHolder_ERC20 {
8
- function withdraw() external;
9
- function balanceOf(address) external view returns (uint256);
10
- function token() external view returns (IERC20);
11
- }