Skip to content

Commit

Permalink
♻️ Upgrade to ethers v6 (#167)
Browse files Browse the repository at this point in the history
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
  • Loading branch information
pcaversaccio authored Dec 11, 2023
1 parent 072fa08 commit 1d6b05d
Show file tree
Hide file tree
Showing 19 changed files with 8,196 additions and 15,984 deletions.
6 changes: 3 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
node_modules
cache
cache_hardhat-zk
artifacts
artifacts-zk
cache
cache-zk
coverage
typechain-types
coverage
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 12,
},
plugins: ["@typescript-eslint"],
extends: [
"eslint:recommended",
Expand Down
27 changes: 19 additions & 8 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,35 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Cache node modules
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: latest
run_install: false

- name: Get pnpm cache directory path
id: pnpm-cache-dir-path
run: echo "dir=$(pnpm store path --silent)" >> $GITHUB_OUTPUT

- name: Restore pnpm cache
uses: actions/cache@v3
id: pnpm-cache
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
path: ${{ steps.pnpm-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-
${{ runner.os }}-pnpm-store-
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}

- name: Install npm project with a clean slate
run: npm ci --prefer-offline
- name: Install pnpm project with a clean slate
run: pnpm install --prefer-offline --frozen-lockfile

- name: Prettier and lint
run: npm run lint:check
run: pnpm lint:check

codespell:
runs-on: ${{ matrix.os }}
Expand All @@ -54,7 +65,7 @@ jobs:
uses: codespell-project/actions-codespell@v2.0
with:
check_filenames: true
skip: ./.git,package-lock.json
skip: ./.git,pnpm-lock.yaml

validate-links:
runs-on: ${{ matrix.os }}
Expand Down
37 changes: 29 additions & 8 deletions .github/workflows/test-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ concurrency:
jobs:
tests:
runs-on: ${{ matrix.os }}
permissions:
contents: read
security-events: write
strategy:
matrix:
os:
Expand All @@ -20,27 +23,45 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Cache node modules
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: latest
run_install: false

- name: Get pnpm cache directory path
id: pnpm-cache-dir-path
run: echo "dir=$(pnpm store path --silent)" >> $GITHUB_OUTPUT

- name: Restore pnpm cache
uses: actions/cache@v3
id: pnpm-cache
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
path: ${{ steps.pnpm-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-
${{ runner.os }}-pnpm-store-
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}

- name: Install npm project with a clean slate
run: npm ci --prefer-offline
- name: Install pnpm project with a clean slate
run: pnpm install --prefer-offline --frozen-lockfile

- name: Hardhat tests
run: npm run test
run: pnpm test

- name: Slither static analyser
uses: crytic/slither-action@v0.3.0
continue-on-error: true
id: slither
with:
node-version: ${{ matrix.node_version }}
fail-on: config
sarif: results.sarif

- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ steps.slither.outputs.sarif }}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ node_modules
.env.local

# Log files
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# Yarn integrity file
.yarn-integrity
Expand All @@ -45,6 +48,7 @@ yarn-error.log*

# Hardhat files
cache
cache_hardhat
artifacts
.deps

Expand All @@ -56,7 +60,7 @@ coverage
coverage.json

# zkSync files
cache-zk
cache_hardhat-zk
artifacts-zk

# Miscellaneous files
Expand Down
6 changes: 3 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
node_modules
cache
cache_hardhat-zk
artifacts
artifacts-zk
cache
cache-zk
coverage
typechain-types
coverage
7 changes: 3 additions & 4 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
node_modules
cache
cache_hardhat-zk
artifacts
artifacts-zk
cache
cache-zk
coverage
typechain-types
flattened
coverage
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ Helper smart contract to make easier and safer usage of the [`CREATE2`](https://
Since [Hardhat](https://hardhat.org) implements great features for Solidity debugging like Solidity stack traces, `console.log`, and explicit error messages when transactions fail, we leverage [Hardhat](https://hardhat.org) for testing:

```console
npm run test
pnpm run test
```

### Test Coverage

This project repository implements a test coverage [plugin](https://github.com/sc-forks/solidity-coverage). Simply run:

```console
npm run coverage
pnpm run coverage
```

The written tests available in the file [`Create2Deployer.test.ts`](./test/Create2Deployer.test.ts) achieve a test coverage of 100%:
Expand Down
52 changes: 52 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 🛡️ Security Policy

## 📬 Reporting a Vulnerability

Please report any security issues you find to [pascal.caversaccio@hotmail.ch](mailto:pascal.caversaccio@hotmail.ch). My public PGP key is:

```sh
-----BEGIN PGP PUBLIC KEY BLOCK-----
Comment: Type: 3,072-bit RSA
Comment: Fingerprint: 063E966C93AB4356492FE0327C3B4B4B7725111F


mQGNBGBUv08BDADTYA0GjLhbKbCezlVAubakXh0jcIbkqZPF1wueSbSgDjlS6+d8
67V6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6+v8Vj2viT
sq0oF8aqSLh4eRADXkERzL99UAVIolME2rkugC6B+5hyxkY6bQTAiqAdAY5w8M+b
fbgPyGx7AySNu0+RgAtfDfqG6Mz3SotgdgOU21M+mUHnfbDSlDlIGU8sZczrXxS2
aMfM1uqzowVfLswMuFVdq37A/fTmnkacc8o2ZSIEPHtfflDxHw4emaxr
=Hf4k
-----END PGP PUBLIC KEY BLOCK-----
```
14 changes: 7 additions & 7 deletions contracts/mocks/ERC20Mock.sol
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// SPDX-License-Identifier: MIT
// Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/mocks/ERC20Mock.sol
// Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/mocks/token/ERC20Mock.sol
pragma solidity ^0.8.9;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";

// Mock class using ERC20
contract ERC20Mock is ERC20 {
constructor(
string memory name,
string memory symbol,
address initialAccount,
uint256 initialBalance
) payable ERC20(name, symbol) {
_mint(initialAccount, initialBalance);
string memory name_,
string memory symbol_,
address initialAccount_,
uint256 initialBalance_
) payable ERC20(name_, symbol_) {
_mint(initialAccount_, initialBalance_);
}

function mint(address account, uint256 amount) public {
Expand Down
6 changes: 3 additions & 3 deletions deploy/deploy-zksync.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Note that the deployment scripts must be placed in the `deploy` folder for `hardhat deploy-zksync`
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { Wallet } from "zksync-web3";
import { Wallet } from "zksync-ethers";
import { Deployer } from "@matterlabs/hardhat-zksync-deploy";

const PRIVATE_KEY: string = process.env.PRIVATE_KEY_ZKS || "";
Expand All @@ -16,8 +16,8 @@ export default async function main(hre: HardhatRuntimeEnvironment) {
const artifact = await deployer.loadArtifact("Create2Deployer");
const create2Deployer = await deployer.deploy(artifact);

await create2Deployer.deployed();
const create2DeployerAddress = create2Deployer.address;
await create2Deployer.waitForDeployment();
const create2DeployerAddress = await create2Deployer.getAddress();

console.log("Create2Deployer deployed to:", create2DeployerAddress);

Expand Down
30 changes: 26 additions & 4 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import * as dotenv from "dotenv";

import { HardhatUserConfig, task } from "hardhat/config";
import "@nomiclabs/hardhat-truffle5";
import "@nomicfoundation/hardhat-ethers";
import "@nomicfoundation/hardhat-verify";
import "@nomicfoundation/hardhat-chai-matchers";
import "@typechain/hardhat";

import "@matterlabs/hardhat-zksync-solc";
import "@matterlabs/hardhat-zksync-deploy";
import "@matterlabs/hardhat-zksync-verify";
import "@matterlabs/hardhat-zksync-ethers";
import "hardhat-gas-reporter";
import "solidity-coverage";
import "hardhat-abi-exporter";
Expand All @@ -22,6 +24,22 @@ task("accounts", "Prints the list of accounts", async (_, hre) => {
}
});

task(
"balances",
"Prints the list of accounts and their balances",
async (_, hre) => {
const accounts = await hre.ethers.getSigners();

for (const account of accounts) {
console.log(
account.address +
" " +
(await hre.ethers.provider.getBalance(account.address)),
);
}
},
);

const config: HardhatUserConfig = {
solidity: {
// Only use Solidity default versions `>=0.8.20` for EVM networks that support the opcode `PUSH0`
Expand All @@ -30,7 +48,7 @@ const config: HardhatUserConfig = {
settings: {
optimizer: {
enabled: true,
runs: 999999,
runs: 999_999,
},
},
},
Expand Down Expand Up @@ -345,15 +363,15 @@ const config: HardhatUserConfig = {
zkSyncTestnet: {
chainId: 300,
url: process.env.ZKSYNC_TESTNET_URL || "",
ethNetwork: process.env.ETH_SEPOLIA_TESTNET_URL || "",
ethNetwork: "sepolia",
zksync: true,
verifyURL:
"https://explorer.sepolia.era.zksync.dev/contract_verification",
},
zkSyncMain: {
chainId: 324,
url: process.env.ZKSYNC_MAINNET_URL || "",
ethNetwork: process.env.ETH_MAINNET_URL || "",
ethNetwork: "mainnet",
zksync: true,
verifyURL:
"https://zksync2-mainnet-explorer.zksync.io/contract_verification",
Expand Down Expand Up @@ -468,6 +486,10 @@ const config: HardhatUserConfig = {
spacing: 2,
pretty: true,
},
sourcify: {
// Enable Sourcify verification by default
enabled: true,
},
etherscan: {
apiKey: {
// For Ethereum testnets & mainnet
Expand Down
Loading

0 comments on commit 1d6b05d

Please sign in to comment.