Skip to content

Commit eafa5a1

Browse files
committed
updated readme, automation-contracts mappings
1 parent 9281a76 commit eafa5a1

File tree

4 files changed

+43
-37
lines changed

4 files changed

+43
-37
lines changed

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/contracts/=node_modules/@openzeppelin/contracts-v4/',
13+
'@openzeppelin/contracts-v4/=node_modules/@openzeppelin/contracts-v4/',
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/scheduler/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/contracts/=node_modules/@openzeppelin/contracts-v4/',
13+
'@openzeppelin/contracts-v4/=node_modules/@openzeppelin/contracts-v4/',
1314
'ds-test/=lib/forge-std/lib/ds-test/src/',
1415
'forge-std/=lib/forge-std/src/']
1516
out = 'packages/automation-contracts/scheduler/out/default'

packages/ethereum-contracts/CHANGELOG.md

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,18 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
77

88
### Breaking
99

10-
The npm dependency @openzeppelin/contracts is now mapped to the local path `@openzeppelin/contracts-v4`.
10+
The npm dependency @openzeppelin/contracts is now mapped to the path `@openzeppelin/contracts-v4`.
1111
This frees up the default path `@openzeppelin/contracts` for v5 which most new Solidity projects use.
1212

13-
In order to use this package in a **foundry project (new or existing) with dependencies installed as git submodules**, this steps are recommended:
14-
15-
1. Add openzeppelin-contracts v4 as a submodule:
16-
```
17-
git submodule add -b release-v4.9 https://github.com/OpenZeppelin/openzeppelin-contracts lib/openzeppelin-contracts-v4
13+
In an existing foundry project, you will need to add this remapping:
1814
```
19-
Note the explicit local path with v4 postfix.
20-
21-
2. Add this mapping to `foundry.toml` or `remappings.txt` (depending on where they are located in your project):
15+
@openzeppelin/contracts-v4/=lib/openzeppelin-contracts-v4/contracts/
2216
```
23-
"@openzeppelin/contracts-v4/=lib/openzeppelin-contracts-v4/contracts/"
24-
```
25-
26-
That way, projects can use the import path `@openzeppelin/contracts` for openzeppelin v5. This is the default when using npm for installing the openzeppelin dependency.
2717

28-
**Note:**
29-
foundry by default auto-detects mappings based on the contents of the lib directory and nested foundry configuration files.
30-
Because of this, it may automatically add a mapping `openzeppelin/=lib/openzeppelin-contracts-v4/contracts/` .
31-
In case you're using the import path `openzeppelin/...` in your project, that may not be what you want.
32-
In this case you can either change the import path to something else, or you can disable mapping auto-detection with `auto_detect_remappings = false` (see [docs](https://book.getfoundry.sh/reference/config/solidity-compiler#auto_detect_remappings)). If you disable it, you may need to explicitly add some mappings, e.g. for forge-std.
18+
In an existing hardhat project, just update the package.
19+
In this case, if you are using openzeppelin v4 in your own contracts too, you may want to also change the import paths to `@openzeppelin/contracts-v4/`.
3320

34-
In order to use this package in a **project with dependencies managed by npm packages**, you don't need to do anything.
35-
Except: if you relied on the openzeppelin-contracts v4 dependency installed by this package, you now need to either also adjust the import path, or explicity add the dependency with the default path to your project.
21+
For more details, consult the updated `README.md` (section _Installation_).^
3622

3723
## [v1.12.1]
3824

packages/ethereum-contracts/README.md

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,58 @@
2828

2929
## Usage
3030

31-
If you're building a dapp using existing protocol or Super Token contracts, then you should use [`@superfluid-finance/sdk-core`](/packages/sdk-core). [Here](https://docs.superfluid.finance/superfluid/networks/networks) you can find a list of networks where the Superfluid protocol is already deployed.
32-
33-
If you're building a smart contract that uses Superfluid protocol, or even your own [SuperApp](https://docs.superfluid.finance/), then great! This is definitely the place to be.
31+
[Here](https://explorer.superfluid.org/protocol) you can find a list of networks where the Superfluid protocol is already deployed.
3432

3533
### Installation
3634

37-
Prerequisites:
38-
- [node.js v18+](https://nodejs.org/en/download). The project recommends 22, and is tested with node 18,20,22.
39-
- [yarn](https://classic.yarnpkg.com/en/docs/install)
35+
Once you have set up your project, cd into its base directory and add the npm package:
36+
37+
##### foundry
38+
39+
**Prerequisites:**
4040
- [forge](https://book.getfoundry.sh/getting-started/installation)
4141

42-
Once you have set up your project, cd into its base directory and add the npm package:
42+
**Install dependencies:**
43+
```sh
44+
forge install superfluid-protocol-monorepo=superfluid-finance/protocol-monorepo@dev --no-commit
45+
forge install openzeppelin-contracts-v4=https://github.com/OpenZeppelin/openzeppelin-contracts@release-v4.9 --no-commit
46+
```
4347

44-
##### hardhat
48+
**Set up remappings:**
4549
```sh
46-
$ yarn add @superfluid-finance/ethereum-contracts
50+
echo -e "@superfluid-finance/=lib/superfluid-protocol-monorepo/packages/\n@openzeppelin/contracts-v4/=lib/openzeppelin-contracts-v4/contracts/" >> remappings.txt
4751
```
4852

49-
##### foundry
53+
If you want to use **openzeppelin v4** in your project's contracts, you should either:
54+
- use the custom import path `@openzeppelin/contracts-v4` in your contracts
55+
or
56+
- add a remapping for the default import path: `@openzeppelin/contracts/=lib/openzeppelin-contracts-v4/contracts/`
57+
58+
If you want to use **openzeppelin v5** in your project's contracts, you can use it alongside the v4 needed by Superfluid.
59+
60+
##### hardhat
5061

62+
**Prerequisites:**
63+
- [node.js v18+](https://nodejs.org/en/download). The project recommends v22, and is tested with versions 18,20,22.
64+
- [yarn](https://classic.yarnpkg.com/en/docs/install) or any other node package manager of your choice.
65+
66+
**Install dependencies:**
5167
```sh
52-
$ forge install superfluid-protocol-monorepo=superfluid-finance/protocol-monorepo@dev
53-
$ # or using ethereum-contracts@v1.6.0
54-
$ forge install superfluid-protocol-monorepo=superfluid-finance/protocol-monorepo@$(git ls-remote https://github.com/superfluid-finance/protocol-monorepo.git ethereum-contracts@v1.6.0 | awk '{print $1}')
68+
$ yarn add @superfluid-finance/ethereum-contracts
5569
```
5670

71+
If you want to use **openzeppelin v4** in your project's contracts, we recommend using the package installed as a nested dependency of this package, using the import path `@openzeppelin/contracts-v4/`.
72+
73+
If you want to use **openzeppelin v5** in your project's contracts, you need to add the dependency yourself and can use it at the default import path `@openzeppelin/contracts/`.
74+
5775
### Smart Contract
5876

5977
You can then import Superfluid interfaces or contracts into your contracts like this:
6078

6179
```js
62-
import { IConstantFlowAgreementV1 } from "@superfluid-finance/ethereum-contracts/contracts/interfaces/agreements/IConstantFlowAgreementV1.sol";
80+
import { IConstantFlowAgreementV1 } from "@superfluid-finance/ethereum-contracts/contracts/interfaces/superfluid/ISuperfluid.sol";
6381
```
64-
The paths in the npm package are the same as in this repository.
82+
(Most interfaces belonging to the Superfluid protocol can be imported from `ISuperfluid.sol`)
6583

6684
### Writing Tests
6785

0 commit comments

Comments
 (0)