Skip to content

Commit 1cbb55a

Browse files
author
hurstelm
committed
fix(arbitration): come back to wNative as public
1 parent 61fc72c commit 1cbb55a

File tree

10 files changed

+56
-53
lines changed

10 files changed

+56
-53
lines changed

contracts/src/arbitration/KlerosCore.sol

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ contract KlerosCore is KlerosCoreBase {
1515
// ************************************* //
1616

1717
/// @custom:oz-upgrades-unsafe-allow constructor
18-
constructor() KlerosCoreBase(address(0)) {
18+
constructor() {
1919
_disableInitializers();
2020
}
2121

@@ -30,6 +30,7 @@ contract KlerosCore is KlerosCoreBase {
3030
/// @param _timesPerPeriod The `timesPerPeriod` property value of the general court.
3131
/// @param _sortitionExtraData The extra data for sortition module.
3232
/// @param _sortitionModuleAddress The sortition module responsible for sortition of the jurors.
33+
/// @param _wNative The address for WETH tranfers.
3334
function initialize(
3435
address _governor,
3536
address _guardian,
@@ -40,7 +41,8 @@ contract KlerosCore is KlerosCoreBase {
4041
uint256[4] memory _courtParameters,
4142
uint256[4] memory _timesPerPeriod,
4243
bytes memory _sortitionExtraData,
43-
ISortitionModule _sortitionModuleAddress
44+
ISortitionModule _sortitionModuleAddress,
45+
address _wNative
4446
) external reinitializer(1) {
4547
__KlerosCoreBase_initialize(
4648
_governor,
@@ -52,7 +54,8 @@ contract KlerosCore is KlerosCoreBase {
5254
_courtParameters,
5355
_timesPerPeriod,
5456
_sortitionExtraData,
55-
_sortitionModuleAddress
57+
_sortitionModuleAddress,
58+
_wNative
5659
);
5760
}
5861

contracts/src/arbitration/KlerosCoreBase.sol

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
101101
Dispute[] public disputes; // The disputes.
102102
mapping(IERC20 => CurrencyRate) public currencyRates; // The price of each token in ETH.
103103
bool public paused; // Whether asset withdrawals are paused.
104-
address immutable W_NATIVE; // The address for WETH tranfers.
104+
address public wNative; // The address for WETH tranfers.
105105

106106
// ************************************* //
107107
// * Events * //
@@ -192,17 +192,6 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
192192
// * Constructor * //
193193
// ************************************* //
194194

195-
/**
196-
* @dev This contract is deployed only once per chain, as the logic master contract.
197-
* New instances are created with minimal proxy from the factory.
198-
* This is only needed to set the wrapped native token, which is used in SafeSend.
199-
* Since it is constant per chain, it can be safely set as immutable to optimize gas usage.
200-
* @param _wNative The Wrapped Native Token on this chain.
201-
*/
202-
constructor(address _wNative) {
203-
W_NATIVE = _wNative;
204-
}
205-
206195
function __KlerosCoreBase_initialize(
207196
address _governor,
208197
address _guardian,
@@ -213,13 +202,15 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
213202
uint256[4] memory _courtParameters,
214203
uint256[4] memory _timesPerPeriod,
215204
bytes memory _sortitionExtraData,
216-
ISortitionModule _sortitionModuleAddress
205+
ISortitionModule _sortitionModuleAddress,
206+
address _wNative
217207
) internal onlyInitializing {
218208
governor = _governor;
219209
guardian = _guardian;
220210
pinakion = _pinakion;
221211
jurorProsecutionModule = _jurorProsecutionModule;
222212
sortitionModule = _sortitionModuleAddress;
213+
wNative = _wNative;
223214

224215
// NULL_DISPUTE_KIT: an empty element at index 0 to indicate when a dispute kit is not supported.
225216
disputeKits.push();
@@ -816,7 +807,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
816807
// No one was coherent, send the rewards to the governor.
817808
if (round.feeToken == NATIVE_CURRENCY) {
818809
// The dispute fees were paid in ETH
819-
SafeSend.safeSend(payable(governor), round.totalFeesForJurors, W_NATIVE);
810+
SafeSend.safeSend(payable(governor), round.totalFeesForJurors, wNative);
820811
} else {
821812
// The dispute fees were paid in ERC20
822813
round.feeToken.safeTransfer(governor, round.totalFeesForJurors);
@@ -868,7 +859,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
868859
pinakion.safeTransfer(account, pnkReward);
869860
if (round.feeToken == NATIVE_CURRENCY) {
870861
// The dispute fees were paid in ETH
871-
SafeSend.safeSend(payable(account), feeReward, W_NATIVE);
862+
SafeSend.safeSend(payable(account), feeReward, wNative);
872863
} else {
873864
// The dispute fees were paid in ERC20
874865
round.feeToken.safeTransfer(account, feeReward);
@@ -894,7 +885,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable
894885
if (leftoverFeeReward != 0) {
895886
if (round.feeToken == NATIVE_CURRENCY) {
896887
// The dispute fees were paid in ETH
897-
SafeSend.safeSend(payable(governor), leftoverFeeReward, W_NATIVE);
888+
SafeSend.safeSend(payable(governor), leftoverFeeReward, wNative);
898889
} else {
899890
// The dispute fees were paid in ERC20
900891
round.feeToken.safeTransfer(governor, leftoverFeeReward);

contracts/src/arbitration/KlerosCoreNeo.sol

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ contract KlerosCoreNeo is KlerosCoreBase {
2323
// ************************************* //
2424

2525
/// @custom:oz-upgrades-unsafe-allow constructor
26-
constructor() KlerosCoreBase(address(0)) {
26+
constructor() {
2727
_disableInitializers();
2828
}
2929

@@ -39,6 +39,7 @@ contract KlerosCoreNeo is KlerosCoreBase {
3939
/// @param _sortitionExtraData The extra data for sortition module.
4040
/// @param _sortitionModuleAddress The sortition module responsible for sortition of the jurors.
4141
/// @param _jurorNft NFT contract to vet the jurors.
42+
/// @param _wNative The address for WETH tranfers.
4243
function initialize(
4344
address _governor,
4445
address _guardian,
@@ -50,7 +51,8 @@ contract KlerosCoreNeo is KlerosCoreBase {
5051
uint256[4] memory _timesPerPeriod,
5152
bytes memory _sortitionExtraData,
5253
ISortitionModule _sortitionModuleAddress,
53-
IERC721 _jurorNft
54+
IERC721 _jurorNft,
55+
address _wNative
5456
) external reinitializer(2) {
5557
__KlerosCoreBase_initialize(
5658
_governor,
@@ -62,7 +64,8 @@ contract KlerosCoreNeo is KlerosCoreBase {
6264
_courtParameters,
6365
_timesPerPeriod,
6466
_sortitionExtraData,
65-
_sortitionModuleAddress
67+
_sortitionModuleAddress,
68+
_wNative
6669
);
6770
jurorNft = _jurorNft;
6871
}

contracts/src/arbitration/KlerosGovernor.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ contract KlerosGovernor is IArbitrableV2 {
5050
bytes public arbitratorExtraData; // Extra data for arbitrator.
5151
IDisputeTemplateRegistry public templateRegistry; // The dispute template registry.
5252
uint256 public templateId; // The current dispute template identifier.
53-
address public wNative; // The address for WETH tranfers.
5453

5554
uint256 public submissionBaseDeposit; // The base deposit in wei that needs to be paid in order to submit the list.
5655
uint256 public submissionTimeout; // Time in seconds allowed for submitting the lists. Once it's passed the contract enters the approval period.
@@ -63,6 +62,8 @@ contract KlerosGovernor is IArbitrableV2 {
6362
Submission[] public submissions; // Stores all created transaction lists. submissions[_listID].
6463
Session[] public sessions; // Stores all submitting sessions. sessions[_session].
6564

65+
address public wNative; // The address for WETH tranfers.
66+
6667
// ************************************* //
6768
// * Function Modifiers * //
6869
// ************************************* //

contracts/src/arbitration/dispute-kits/DisputeKitClassic.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ contract DisputeKitClassic is DisputeKitClassicBase {
1818
// ************************************* //
1919

2020
/// @custom:oz-upgrades-unsafe-allow constructor
21-
constructor() DisputeKitClassicBase(address(0)) {
21+
constructor() {
2222
_disableInitializers();
2323
}
2424

2525
/// @dev Initializer.
2626
/// @param _governor The governor's address.
2727
/// @param _core The KlerosCore arbitrator.
28-
function initialize(address _governor, KlerosCore _core) external reinitializer(1) {
29-
__DisputeKitClassicBase_initialize(_governor, _core);
28+
/// @param _wNative The address for WETH tranfers.
29+
function initialize(address _governor, KlerosCore _core, address _wNative) external reinitializer(1) {
30+
__DisputeKitClassicBase_initialize(_governor, _core, _wNative);
3031
}
3132

3233
function initialize7() external reinitializer(7) {

contracts/src/arbitration/dispute-kits/DisputeKitClassicBase.sol

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
5959
uint256 public constant ONE_BASIS_POINT = 10000; // One basis point, for scaling.
6060

6161
address public governor; // The governor of the contract.
62-
address immutable W_NATIVE; // The address for WETH tranfers.
6362
KlerosCore public core; // The Kleros Core arbitrator
6463
Dispute[] public disputes; // Array of the locally created disputes.
6564
mapping(uint256 => uint256) public coreDisputeIDToLocal; // Maps the dispute ID in Kleros Core to the local dispute ID.
6665
bool public singleDrawPerJuror; // Whether each juror can only draw once per dispute, false by default.
6766
mapping(uint256 localDisputeID => mapping(uint256 localRoundID => mapping(address drawnAddress => bool)))
6867
public alreadyDrawn; // True if the address has already been drawn, false by default. To be added to the Round struct when fully redeploying rather than upgrading.
6968
mapping(uint256 coreDisputeID => bool) public coreDisputeIDToActive; // True if this dispute kit is active for this core dispute ID.
69+
address public wNative; // The address for WETH tranfers.
7070

7171
// ************************************* //
7272
// * Events * //
@@ -142,23 +142,18 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
142142
// * Constructor * //
143143
// ************************************* //
144144

145-
/**
146-
* @dev This contract is deployed only once per chain, as the logic master contract.
147-
* New instances are created with minimal proxy from the factory.
148-
* This is only needed to set the wrapped native token, which is used in SafeSend.
149-
* Since it is constant per chain, it can be safely set as immutable to optimize gas usage.
150-
* @param _wNative The Wrapped Native Token on this chain.
151-
*/
152-
constructor(address _wNative) {
153-
W_NATIVE = _wNative;
154-
}
155-
156145
/// @dev Initializer.
157146
/// @param _governor The governor's address.
158147
/// @param _core The KlerosCore arbitrator.
159-
function __DisputeKitClassicBase_initialize(address _governor, KlerosCore _core) internal onlyInitializing {
148+
/// @param _wNative The address for WETH tranfers.
149+
function __DisputeKitClassicBase_initialize(
150+
address _governor,
151+
KlerosCore _core,
152+
address _wNative
153+
) internal onlyInitializing {
160154
governor = _governor;
161155
core = _core;
156+
wNative = _wNative;
162157
}
163158

164159
// ************************ //
@@ -423,7 +418,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
423418
core.appeal{value: appealCost}(_coreDisputeID, dispute.numberOfChoices, dispute.extraData);
424419
}
425420

426-
if (msg.value > contribution) SafeSend.safeSend(payable(msg.sender), msg.value - contribution, W_NATIVE);
421+
if (msg.value > contribution) SafeSend.safeSend(payable(msg.sender), msg.value - contribution, wNative);
427422
}
428423

429424
/// @dev Allows those contributors who attempted to fund an appeal round to withdraw any reimbursable fees or rewards after the dispute gets resolved.
@@ -468,7 +463,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
468463
round.contributions[_beneficiary][_choice] = 0;
469464

470465
if (amount != 0) {
471-
SafeSend.safeSend(_beneficiary, amount, W_NATIVE); // Deliberate use of send to prevent reverting fallback. It's the user's responsibility to accept ETH.
466+
SafeSend.safeSend(_beneficiary, amount, wNative); // Deliberate use of send to prevent reverting fallback. It's the user's responsibility to accept ETH.
472467
emit Withdrawal(_coreDisputeID, _coreRoundID, _choice, _beneficiary, amount);
473468
}
474469
}

contracts/src/arbitration/dispute-kits/DisputeKitGated.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ contract DisputeKitGated is DisputeKitClassicBase {
3434
// ************************************* //
3535

3636
/// @custom:oz-upgrades-unsafe-allow constructor
37-
constructor() DisputeKitClassicBase(address(0)) {
37+
constructor() {
3838
_disableInitializers();
3939
}
4040

4141
/// @dev Initializer.
4242
/// @param _governor The governor's address.
4343
/// @param _core The KlerosCore arbitrator.
44-
function initialize(address _governor, KlerosCore _core) external reinitializer(1) {
45-
__DisputeKitClassicBase_initialize(_governor, _core);
44+
/// @param _wNative The address for WETH tranfers.
45+
function initialize(address _governor, KlerosCore _core, address _wNative) external reinitializer(1) {
46+
__DisputeKitClassicBase_initialize(_governor, _core, _wNative);
4647
}
4748

4849
function initialize7() external reinitializer(7) {

contracts/src/arbitration/dispute-kits/DisputeKitGatedShutter.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,16 @@ contract DisputeKitGatedShutter is DisputeKitClassicBase {
5353
// ************************************* //
5454

5555
/// @custom:oz-upgrades-unsafe-allow constructor
56-
constructor() DisputeKitClassicBase(address(0)) {
56+
constructor() {
5757
_disableInitializers();
5858
}
5959

6060
/// @dev Initializer.
6161
/// @param _governor The governor's address.
6262
/// @param _core The KlerosCore arbitrator.
63-
function initialize(address _governor, KlerosCore _core) external reinitializer(1) {
64-
__DisputeKitClassicBase_initialize(_governor, _core);
63+
/// @param _wNative The address for WETH tranfers.
64+
function initialize(address _governor, KlerosCore _core, address _wNative) external reinitializer(1) {
65+
__DisputeKitClassicBase_initialize(_governor, _core, _wNative);
6566
}
6667

6768
function initialize7() external reinitializer(7) {

contracts/src/arbitration/dispute-kits/DisputeKitShutter.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,16 @@ contract DisputeKitShutter is DisputeKitClassicBase {
3737
// ************************************* //
3838

3939
/// @custom:oz-upgrades-unsafe-allow constructor
40-
constructor() DisputeKitClassicBase(address(0)) {
40+
constructor() {
4141
_disableInitializers();
4242
}
4343

4444
/// @dev Initializer.
4545
/// @param _governor The governor's address.
4646
/// @param _core The KlerosCore arbitrator.
47-
function initialize(address _governor, KlerosCore _core) external reinitializer(1) {
48-
__DisputeKitClassicBase_initialize(_governor, _core);
47+
/// @param _wNative The address for WETH tranfers.
48+
function initialize(address _governor, KlerosCore _core, address _wNative) external reinitializer(1) {
49+
__DisputeKitClassicBase_initialize(_governor, _core, _wNative);
4950
}
5051

5152
function initialize8() external reinitializer(8) {

contracts/src/arbitration/dispute-kits/DisputeKitSybilResistant.sol

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,22 @@ contract DisputeKitSybilResistant is DisputeKitClassicBase {
3131
// ************************************* //
3232

3333
/// @custom:oz-upgrades-unsafe-allow constructor
34-
constructor() DisputeKitClassicBase(address(0)) {
34+
constructor() {
3535
_disableInitializers();
3636
}
3737

3838
/// @dev Initializer.
3939
/// @param _governor The governor's address.
4040
/// @param _core The KlerosCore arbitrator.
4141
/// @param _poh The Proof of Humanity registry.
42-
function initialize(address _governor, KlerosCore _core, IProofOfHumanity _poh) external reinitializer(1) {
43-
__DisputeKitClassicBase_initialize(_governor, _core);
42+
/// @param _wNative The address for WETH tranfers.
43+
function initialize(
44+
address _governor,
45+
KlerosCore _core,
46+
IProofOfHumanity _poh,
47+
address _wNative
48+
) external reinitializer(1) {
49+
__DisputeKitClassicBase_initialize(_governor, _core, _wNative);
4450
poh = _poh;
4551
singleDrawPerJuror = true;
4652
}

0 commit comments

Comments
 (0)