Skip to content

Commit 485c8d5

Browse files
intial commit
1 parent 8883ef8 commit 485c8d5

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

src/WeEthModule.sol

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
// SPDX-License-Identifier: AGPL-3.0-or-later
22
pragma solidity ^0.8.21;
33

4-
import { AccessControlEnumerable } from "openzeppelin-contracts/contracts/access/extensions/AccessControlEnumerable.sol";
54
import { IERC20Metadata as IERC20 } from "openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol";
65

6+
import { AccessControlEnumerableUpgradeable }
7+
from "openzeppelin-contracts-upgradeable/contracts/access/extensions/AccessControlEnumerableUpgradeable.sol";
8+
9+
import { UUPSUpgradeable } from "openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol";
10+
711
import { Ethereum } from "spark-address-registry/Ethereum.sol";
812

913
import { IEETHLike, ILiquidityPoolLike, IWETHLike, IWEETHLike } from "./libraries/WeETHLib.sol";
@@ -14,22 +18,29 @@ interface IWithdrawRequestNFTLike {
1418
function isValid(uint256 requestId) external view returns (bool);
1519
}
1620

17-
contract WeEthModule is AccessControlEnumerable {
21+
contract WeEthModule is AccessControlEnumerableUpgradeable, UUPSUpgradeable {
1822

19-
address public immutable almProxy;
23+
address public almProxy;
2024

2125
/**********************************************************************************************/
2226
/*** Initialization ***/
2327
/**********************************************************************************************/
2428

25-
constructor(address admin, address _almProxy) {
29+
constructor() {
30+
_disableInitializers();
31+
}
32+
33+
function initialize(address admin, address _almProxy) external initializer {
2634
require(_almProxy != address(0), "WeEthModule/invalid-alm-proxy");
2735

2836
_grantRole(DEFAULT_ADMIN_ROLE, admin);
2937

3038
almProxy = _almProxy;
3139
}
3240

41+
// Only DEFAULT_ADMIN_ROLE can upgrade the implementation
42+
function _authorizeUpgrade(address) internal view override onlyRole(DEFAULT_ADMIN_ROLE) {}
43+
3344
/**********************************************************************************************/
3445
/*** External functions ***/
3546
/**********************************************************************************************/

test/mainnet-fork/weETH.t.sol

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ pragma solidity >=0.8.0;
33

44
import { ReentrancyGuard } from "../../lib/openzeppelin-contracts/contracts/utils/ReentrancyGuard.sol";
55

6+
import { ERC1967Proxy } from "../../lib/openzeppelin-contracts/contracts/proxy/ERC1967/ERC1967Proxy.sol";
7+
68
import { IWEETHLike, ILiquidityPoolLike, IEETHLike } from "../../src/libraries/WeETHLib.sol";
79

810
import { WeEthModule } from "../../src/WeEthModule.sol";
@@ -20,6 +22,10 @@ interface IWithdrawRequestNFTLike {
2022
function roleRegistry() external view returns (address);
2123
}
2224

25+
interface IWeEthModuleLike {
26+
function initialize(address admin, address _almProxy) external;
27+
}
28+
2329
contract MainnetControllerWeETHTestBase is ForkTestBase {
2430

2531
IWEETHLike weETH = IWEETHLike(Ethereum.WEETH);
@@ -39,7 +45,15 @@ contract MainnetControllerWeETHTestBase is ForkTestBase {
3945
eETH = IEETHLike(address(IWEETHLike(Ethereum.WEETH).eETH()));
4046
liquidityPool = ILiquidityPoolLike(IEETHLike(eETH).liquidityPool());
4147

42-
weETHModule = address(new WeEthModule(Ethereum.SPARK_PROXY, address(almProxy)));
48+
weETHModule = address(
49+
new ERC1967Proxy(
50+
address(new WeEthModule()),
51+
abi.encodeCall(
52+
WeEthModule.initialize,
53+
(Ethereum.SPARK_PROXY, address(almProxy))
54+
)
55+
)
56+
);
4357
}
4458

4559
function _getBlock() internal override pure returns (uint256) {

0 commit comments

Comments
 (0)