Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: switch to bun for dep management #249

Merged
merged 7 commits into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

32 changes: 8 additions & 24 deletions .github/workflows/ci-deep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,14 @@ jobs:
- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install Pnpm"
uses: "pnpm/action-setup@v2"
with:
version: "8"

- name: "Install Node.js"
uses: "actions/setup-node@v3"
with:
cache: "pnpm"
node-version: "lts/*"
- name: "Install Bun"
uses: "oven-sh/setup-bun@v1"

- name: "Install the Node.js dependencies"
run: "pnpm install"
run: "bun install"

- name: "Lint the contracts"
run: "pnpm lint"
- name: "Lint the code"
run: "bun run lint"

- name: "Add lint summary"
run: |
Expand All @@ -57,19 +49,11 @@ jobs:
- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install Pnpm"
uses: "pnpm/action-setup@v2"
with:
version: "8"

- name: "Install Node.js"
uses: "actions/setup-node@v3"
with:
cache: "pnpm"
node-version: "lts/*"
- name: "Install Bun"
uses: "oven-sh/setup-bun@v1"

- name: "Install the Node.js dependencies"
run: "pnpm install"
run: "bun install"

- name: "Produce an optimized build with --via-ir"
run: "FOUNDRY_PROFILE=optimized forge build"
Expand Down
36 changes: 10 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,14 @@ jobs:
- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install Pnpm"
uses: "pnpm/action-setup@v2"
with:
version: "8"

- name: "Install Node.js"
uses: "actions/setup-node@v3"
with:
cache: "pnpm"
node-version: "lts/*"
- name: "Install Bun"
uses: "oven-sh/setup-bun@v1"

- name: "Install the Node.js dependencies"
run: "pnpm install"
run: "bun install"

- name: "Lint the contracts"
run: "pnpm lint"
- name: "Lint the code"
run: "bun run lint"

- name: "Add lint summary"
run: |
Expand All @@ -55,19 +47,11 @@ jobs:
- name: "Install Foundry"
uses: "foundry-rs/foundry-toolchain@v1"

- name: "Install Pnpm"
uses: "pnpm/action-setup@v2"
with:
version: "8"

- name: "Install Node.js"
uses: "actions/setup-node@v3"
with:
cache: "pnpm"
node-version: "lts/*"
- name: "Install Bun"
uses: "oven-sh/setup-bun@v1"

- name: "Install the Node.js dependencies"
run: "pnpm install"
run: "bun install"

- name: "Show the Foundry config"
run: "forge config"
Expand All @@ -76,7 +60,7 @@ jobs:
run: "./shell/prepare-artifacts.sh"

- name: "Build the test contracts"
run: "FOUNDRY_PROFILE=test-optimized forge build"
run: "FOUNDRY_PROFILE=test-optimized forge build"

- name: "Cache the build and the node modules so that they can be re-used by the other jobs"
uses: "actions/cache/save@v3"
Expand Down Expand Up @@ -195,7 +179,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Check out the repo"
uses: "actions/checkout@v3"
uses: "actions/checkout@v3"

- name: "Restore the cached build and the node modules"
uses: "actions/cache/restore@v3"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ out
.pnp.*
lcov.info
package-lock.json
pnpm-lock.yaml
yarn.lock
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ broadcast
cache
coverage
docs
lib
node_modules
out-optimized
out
Expand All @@ -17,6 +16,7 @@ test
*.log
.DS_Store
.pnp.*
bun.lockb
lcov.info
package-lock.json
pnpm-lock.yaml
Expand Down
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
".gas-snapshot": "julia"
},
"editor.formatOnSave": true,
"npm.exclude": "**/lib/**",
"solidity.formatter": "forge"
}
14 changes: 10 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You will need the following software on your machine:
- [Git](https://git-scm.com/downloads)
- [Foundry](https://github.com/foundry-rs/foundry)
- [Node.Js](https://nodejs.org/en/download/)
- [Pnpm](https://pnpm.io/)
- [Bun](https://bun.sh)

In addition, familiarity with [Solidity](https://soliditylang.org/) is requisite.

Expand All @@ -26,14 +26,21 @@ Clone this repository including submodules:
$ git clone --recurse-submodules -j8 [email protected]:sablier-labs/v2-periphery.git
```

Then, inside the project's directory, run this to install the Node.js dependencies:
Then, inside the project's directory, run this to install the Node.js dependencies and build the contracts:

```shell
$ pnpm install
$ bun install
$ bun run build
```

Now you can start making changes.

To see a list of all available scripts:

```shell
$ bun run
```

## Pull Requests

When making a pull request, ensure that:
Expand All @@ -48,7 +55,6 @@ When making a pull request, ensure that:
- Gas snapshots are provided and demonstrate an improvement (or an acceptable deficit given other improvements).
- Reference contracts are modified correspondingly if relevant.
- New tests are included for all new features or code paths.
- If making a modification to third-party Node.js dependencies, `pnpm audit` passes.
- A descriptive summary of the PR has been provided.

## Environment Variables
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ In-depth documentation is available at [docs.sablier.com](https://docs.sablier.c

This is the recommended approach.

Install Sablier V2 Periphery as a Node.js package:
Install Sablier V2 Periphery using your favorite package manager, e.g., with Bun:

```shell
yarn add @sablier/v2-periphery
bun add @sablier/v2-periphery
```

Then, if you are using Foundry, add these to your `remappings.txt` file:
Expand All @@ -36,6 +36,8 @@ Then, if you are using Foundry, add these to your `remappings.txt` file:

### Git Submodules

This installation method is not recommended, but it is available for those who prefer it.

First, install the submodule using Forge:

```sh
Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ The scope of the Program is limited to bugs that result in the draining of funds
The Program does NOT cover the following:

- Code located in the [test](./test) or [script](./script) directories.
- External code in the [lib](./lib) directory, except for code that is explicitly used by a deployed contract located in
the [src](./src) directory.
- External code in `node_modules`, except for code that is explicitly used by a deployed contract located in the
[src](./src) directory.
- Contract deployments on test networks, such as Sepolia.
- Bugs in third-party contracts or platforms interacting with Sablier V2 Periphery.
- Previously reported or discovered vulnerabilities in contracts built by third parties on Sablier V2 Periphery.
Expand Down
Binary file added bun.lockb
Binary file not shown.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@
"clean": "rm -rf artifacts broadcast cache docs out-optimized out",
"gas:report": "forge test --gas-report --no-match-test \"test(Fuzz)?_RevertWhen_\\w{1,}?\"",
"gas:snapshot": "forge snapshot --no-match-test \"test(Fuzz)?_RevertWhen_\\w{1,}?\"",
"gas:snapshot:optimized": "pnpm build:optimized && FOUNDRY_PROFILE=test-optimized forge snapshot --no-match-test \"test(Fork)?(Fuzz)?_RevertWhen_\\w{1,}?\"",
"lint": "pnpm lint:sol && pnpm prettier:check",
"lint:sol": "forge fmt --check && pnpm solhint \"{script,src,test}/**/*.sol\"",
"prepack": "pnpm install && bash ./shell/prepare-artifacts.sh",
"gas:snapshot:optimized": "bun run build:optimized && FOUNDRY_PROFILE=test-optimized forge snapshot --no-match-test \"test(Fork)?(Fuzz)?_RevertWhen_\\w{1,}?\"",
"lint": "bun run lint:sol && bun run prettier:check",
"lint:sol": "forge fmt --check && bun solhint \"{script,src,test}/**/*.sol\"",
"prepack": "bun install && bash ./shell/prepare-artifacts.sh",
"prettier:check": "prettier --check \"**/*.{json,md,yml}\"",
"prettier:write": "prettier --write \"**/*.{json,md,yml}\"",
"test": "forge test",
"test:lite": "FOUNDRY_PROFILE=lite forge test",
"test:optimized": "pnpm build:optimized && FOUNDRY_PROFILE=test-optimized forge test"
"test:optimized": "bun run build:optimized && FOUNDRY_PROFILE=test-optimized forge test"
}
}
4 changes: 2 additions & 2 deletions shell/prepare-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Pre-requisites:
# - foundry (https://getfoundry.sh)
# - pnpm (https://pnpm.io)
# - bun (https://bun.sh)

# Strict mode: https://gist.github.com/vncsna/64825d5609c146e80de8b1fd623011ca
set -euo pipefail
Expand Down Expand Up @@ -40,4 +40,4 @@ libraries=./artifacts/libraries
cp out-optimized/Errors.sol/Errors.json $libraries

# Format the artifacts with Prettier
pnpm prettier --write ./artifacts
bun prettier --write ./artifacts
12 changes: 6 additions & 6 deletions src/types/DataTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ library Batch {
/// @notice A struct encapsulating all parameters of {SablierV2LockupDynamic.createWithDelta} except for the asset.
struct CreateWithDeltas {
address sender;
bool cancelable;
bool transferable;
address recipient;
uint128 totalAmount;
Broker broker;
bool cancelable;
bool transferable;
LockupDynamic.SegmentWithDelta[] segments;
Broker broker;
}

/// @notice A struct encapsulating all parameters of {SablierV2LockupLinear.createWithDurations} except for the
Expand All @@ -38,13 +38,13 @@ library Batch {
/// asset.
struct CreateWithMilestones {
address sender;
address recipient;
uint128 totalAmount;
uint40 startTime;
bool cancelable;
bool transferable;
address recipient;
uint128 totalAmount;
Broker broker;
LockupDynamic.Segment[] segments;
Broker broker;
}

/// @notice A struct encapsulating all parameters of {SablierV2LockupLinear.createWithRange} except for the asset.
Expand Down
Loading