Skip to content

Commit a5bf3a6

Browse files
authored
[ETHEREUM-CONTRACTS] Migrate to OpenZeppelin v5 (#2097)
1 parent 972c214 commit a5bf3a6

File tree

90 files changed

+530
-201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+530
-201
lines changed

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
[submodule "lib/forge-std"]
22
path = lib/forge-std
33
url = https://github.com/foundry-rs/forge-std
4+
[submodule "lib/openzeppelin-contracts"]
5+
path = lib/openzeppelin-contracts
6+
url = https://github.com/OpenZeppelin/openzeppelin-contracts.git
7+
branch = release-v5.4

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<h1>Welcome to superfluid protocol-monorepo 👋</h1>
33

44
<p>
5-
<a href="#superfluid-finance/ethereum-contracts" target="_blank">
5+
<a href="https://www.npmjs.com/package/@superfluid-finance/ethereum-contracts" target="_blank">
66
<img alt="npm" src="https://img.shields.io/npm/v/@superfluid-finance/ethereum-contracts?label=ethereum-contracts">
77
</a>
88
<a href="#superfluid-finance/subgraph" target="_blank">

lib/openzeppelin-contracts

Submodule openzeppelin-contracts added at c64a1ed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
},
5353
"scripts": {
5454
"prepare": "husky && npm run git-submodule:init",
55+
"postinstall": "ln -fs ../lib/openzeppelin-contracts node_modules/@openzeppelin-v5",
5556
"lint": "run-s -l lint:*",
5657
"lint:syncpack": "syncpack lint",
5758
"lint:shellcheck": "tasks/shellcheck-all-tasks.sh",

packages/automation-contracts/autowrap/contracts/Manager.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ contract Manager is IManager, Ownable {
3131
address _cfa,
3232
uint64 _minLower,
3333
uint64 _minUpper
34-
) {
34+
) Ownable(_msgSender()) {
3535
if (_cfa == address(0)) revert ZeroAddress();
3636
if (_minLower >= _minUpper) revert WrongLimits(_minLower, _minUpper);
3737

packages/automation-contracts/autowrap/contracts/strategies/StrategyBase.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ abstract contract StrategyBase is IStrategy, Ownable {
1414
/// @dev IStrategy.manager implementation.
1515
address public override manager;
1616

17+
constructor() Ownable(_msgSender()) { }
18+
1719
/// @dev IStrategy.changeManager implementation.
1820
function changeManager(address newManager)
1921
external

packages/automation-contracts/autowrap/foundry.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ optimizer_runs = 200
99
remappings = [
1010
'@superfluid-finance/solidity-semantic-money/src/=packages/solidity-semantic-money/src/',
1111
'@superfluid-finance/ethereum-contracts/=packages/ethereum-contracts/',
12-
'@openzeppelin/=node_modules/@openzeppelin/',
12+
'@openzeppelin-v5/=lib/openzeppelin-contracts/',
13+
'@openzeppelin/=lib/openzeppelin-contracts/',
1314
'ds-test/=lib/forge-std/lib/ds-test/src/',
1415
'forge-std/=lib/forge-std/src/']
1516
out = 'packages/automation-contracts/autowrap/out/default'

packages/automation-contracts/autowrap/hardhat.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,22 @@ require("@nomiclabs/hardhat-ethers");
33
require("@nomicfoundation/hardhat-verify");
44
require("hardhat-deploy");
55
require("hardhat/config");
6+
const {TASK_COMPILE_GET_REMAPPINGS} = require("hardhat/builtin-tasks/task-names");
67

78
// You need to export an object to set up your config
89
// Go to https://hardhat.org/config/ to learn more
910

11+
// Remapping for OpenZeppelin contracts
12+
subtask(TASK_COMPILE_GET_REMAPPINGS).setAction(
13+
async (_, __, runSuper) => {
14+
const remappings = await runSuper();
15+
return {
16+
...remappings,
17+
"@openzeppelin/contracts/": "@openzeppelin-v5/contracts/",
18+
};
19+
}
20+
);
21+
1022
/**
1123
* @type import('hardhat/config').HardhatUserConfig
1224
*/

packages/automation-contracts/autowrap/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"description": "Open contracts that allow upgrading underlying token to supertokens based on running stream",
44
"version": "0.3.0",
55
"devDependencies": {
6-
"@openzeppelin/contracts": "^4.9.6",
76
"@superfluid-finance/ethereum-contracts": "^1.13.0",
87
"@superfluid-finance/metadata": "^1.6.2"
98
},

packages/automation-contracts/autowrap/test/Manager.t.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-License-Identifier: UNLICENSED
22
pragma solidity ^0.8.0;
3+
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
34
import { ISuperToken } from "@superfluid-finance/ethereum-contracts/contracts/superfluid/SuperToken.sol";
45
import { SuperTokenV1Library } from "@superfluid-finance/ethereum-contracts/contracts/apps/SuperTokenV1Library.sol";
56
import { FoundrySuperfluidTester } from "@superfluid-finance/ethereum-contracts/test/foundry/FoundrySuperfluidTester.t.sol";
@@ -108,7 +109,7 @@ contract ManagerTests is FoundrySuperfluidTester {
108109
vm.prank(admin);
109110
manager.setLimits(newMinLower, newMinUpper);
110111
// non owner can't set new limits
111-
vm.expectRevert(bytes("Ownable: caller is not the owner"));
112+
vm.expectRevert(abi.encodeWithSelector(Ownable.OwnableUnauthorizedAccount.selector, address(this)));
112113
manager.setLimits(newMinLower, newMinUpper);
113114
}
114115

@@ -124,7 +125,7 @@ contract ManagerTests is FoundrySuperfluidTester {
124125
manager.addApprovedStrategy(address(wrapStrategy));
125126
vm.stopPrank();
126127
// non owner can't add new strategy
127-
vm.expectRevert(bytes("Ownable: caller is not the owner"));
128+
vm.expectRevert(abi.encodeWithSelector(Ownable.OwnableUnauthorizedAccount.selector, address(this)));
128129
manager.addApprovedStrategy(address(wrapStrategy));
129130
bool isStrategyApproved = manager.approvedStrategies(address(wrapStrategy));
130131
assertTrue(isStrategyApproved, "strategy should be register");
@@ -135,7 +136,7 @@ contract ManagerTests is FoundrySuperfluidTester {
135136
//add strategy to be removed
136137
manager.addApprovedStrategy(address(wrapStrategy));
137138
// non owner can't add new strategy
138-
vm.expectRevert(bytes("Ownable: caller is not the owner"));
139+
vm.expectRevert(abi.encodeWithSelector(Ownable.OwnableUnauthorizedAccount.selector, address(this)));
139140
manager.removeApprovedStrategy(address(wrapStrategy));
140141
vm.startPrank(admin);
141142
vm.expectEmit(true, true, true, true);

0 commit comments

Comments
 (0)