@@ -25,6 +25,7 @@ contract ArbitrableExample is IArbitrableV2 {
25
25
address public immutable governor;
26
26
IArbitratorV2 public arbitrator; // Arbitrator is set in constructor.
27
27
uint256 public disputeTemplates; // The number of dispute templates created.
28
+ bytes public arbitratorExtraData; // Extra data to set up the arbitration.
28
29
IERC20 public immutable weth; // The WETH token.
29
30
mapping (uint256 => uint256 ) public externalIDtoLocalID; // Maps external (arbitrator side) dispute IDs to local dispute IDs.
30
31
DisputeStruct[] public disputes; // Stores the disputes' info. disputes[disputeID].
@@ -37,9 +38,15 @@ contract ArbitrableExample is IArbitrableV2 {
37
38
/// @param _arbitrator The arbitrator to rule on created disputes.
38
39
/// @param _templateData The dispute template data.
39
40
/// @param _weth The WETH token.
40
- constructor (IArbitratorV2 _arbitrator , string memory _templateData , IERC20 _weth ) {
41
+ constructor (
42
+ IArbitratorV2 _arbitrator ,
43
+ string memory _templateData ,
44
+ bytes memory _arbitratorExtraData ,
45
+ IERC20 _weth
46
+ ) {
41
47
governor = msg .sender ;
42
48
arbitrator = _arbitrator;
49
+ arbitratorExtraData = _arbitratorExtraData;
43
50
weth = _weth;
44
51
emit DisputeTemplate (disputeTemplates++ , "" , _templateData);
45
52
}
@@ -58,47 +65,39 @@ contract ArbitrableExample is IArbitrableV2 {
58
65
arbitrator = _arbitrator;
59
66
}
60
67
68
+ function changeArbitratorExtraData (bytes calldata _arbitratorExtraData ) external {
69
+ require (msg .sender == governor, "Not authorized: governor only. " );
70
+ arbitratorExtraData = _arbitratorExtraData;
71
+ }
72
+
61
73
// ************************************* //
62
74
// * State Modifiers * //
63
75
// ************************************* //
64
76
65
77
/// @dev Calls createDispute function of the specified arbitrator to create a dispute.
66
78
/// Note that we don’t need to check that msg.value is enough to pay arbitration fees as it’s the responsibility of the arbitrator contract.
67
- /// @param _templateId The identifier of the dispute template. Should not be used with _templateUri.
68
79
/// @param _action The action that requires arbitration.
69
- /// @param _arbitratorExtraData Extra data for the arbitrator.
70
80
/// @return disputeID Dispute id (on arbitrator side) of the dispute created.
71
- function createDispute (
72
- uint256 _templateId ,
73
- string calldata _action ,
74
- bytes calldata _arbitratorExtraData
75
- ) external payable returns (uint256 disputeID ) {
81
+ function createDispute (string calldata _action ) external payable returns (uint256 disputeID ) {
76
82
emit Action (_action);
77
83
78
84
uint256 numberOfRulingOptions = 2 ;
79
85
uint256 localDisputeID = disputes.length ;
80
86
disputes.push (DisputeStruct ({isRuled: false , ruling: 0 , numberOfRulingOptions: numberOfRulingOptions}));
81
87
82
- disputeID = arbitrator.createDispute {value: msg .value }(numberOfRulingOptions, _arbitratorExtraData );
88
+ disputeID = arbitrator.createDispute {value: msg .value }(numberOfRulingOptions, arbitratorExtraData );
83
89
externalIDtoLocalID[disputeID] = localDisputeID;
84
90
85
91
uint256 externalDisputeID = uint256 (keccak256 (abi.encodePacked (_action)));
86
- emit DisputeRequest (arbitrator, disputeID, externalDisputeID, _templateId , "" );
92
+ emit DisputeRequest (arbitrator, disputeID, externalDisputeID, disputeTemplates - 1 , "" );
87
93
}
88
94
89
95
/// @dev Calls createDispute function of the specified arbitrator to create a dispute.
90
96
/// Note that we don’t need to check that msg.value is enough to pay arbitration fees as it’s the responsibility of the arbitrator contract.
91
- /// @param _templateId The identifier of the dispute template. Should not be used with _templateUri.
92
97
/// @param _action The action that requires arbitration.
93
- /// @param _arbitratorExtraData Extra data for the arbitrator.
94
98
/// @param _feeInWeth Amount of fees in WETH for the arbitrator.
95
99
/// @return disputeID Dispute id (on arbitrator side) of the dispute created.
96
- function createDispute (
97
- uint256 _templateId ,
98
- string calldata _action ,
99
- bytes calldata _arbitratorExtraData ,
100
- uint256 _feeInWeth
101
- ) external payable returns (uint256 disputeID ) {
100
+ function createDispute (string calldata _action , uint256 _feeInWeth ) external payable returns (uint256 disputeID ) {
102
101
emit Action (_action);
103
102
104
103
uint256 numberOfRulingOptions = 2 ;
@@ -108,11 +107,11 @@ contract ArbitrableExample is IArbitrableV2 {
108
107
require (weth.safeTransferFrom (msg .sender , address (this ), _feeInWeth), "Transfer failed " );
109
108
require (weth.increaseAllowance (address (arbitrator), _feeInWeth), "Allowance increase failed " );
110
109
111
- disputeID = arbitrator.createDispute (numberOfRulingOptions, _arbitratorExtraData , weth, _feeInWeth);
110
+ disputeID = arbitrator.createDispute (numberOfRulingOptions, arbitratorExtraData , weth, _feeInWeth);
112
111
externalIDtoLocalID[disputeID] = localDisputeID;
113
112
114
113
uint256 externalDisputeID = uint256 (keccak256 (abi.encodePacked (_action)));
115
- emit DisputeRequest (arbitrator, disputeID, externalDisputeID, _templateId , "" );
114
+ emit DisputeRequest (arbitrator, disputeID, externalDisputeID, disputeTemplates - 1 , "" );
116
115
}
117
116
118
117
/// @dev To be called by the arbitrator of the dispute, to declare the winning ruling.
0 commit comments