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

🔁 Upgrade to pnpm and Configuration Variables #50

Merged
merged 3 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
🔁 Upgrade to pnpm and Configuration Variables
Signed-off-by: Pascal Marco Caversaccio <pascal.caversaccio@hotmail.ch>
  • Loading branch information
pcaversaccio committed Nov 6, 2023
commit af98be62e4de47ca82e9d143393c1146a9e41c4c
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ trim_trailing_whitespace = false

[*.sol]
indent_size = 4
max_line_length = 120
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
root: true,
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 11,
ecmaVersion: 12,
},
plugins: ["@typescript-eslint"],
extends: [
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
38 changes: 29 additions & 9 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,44 @@ 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: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ node_modules
.env.production.local
.env.local

# Hardhat configuration file
vars.json

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

# Yarn integrity file
.yarn-integrity
Expand Down
8 changes: 2 additions & 6 deletions contracts/Create.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,42 +46,38 @@
* `bytecode` must have a `payable` constructor.
* @param bytecode The creation bytecode.
*/
function deploy(
uint256 amount,
bytes memory bytecode
) public returns (address newContract) {
if (address(this).balance < amount)
revert InsufficientBalance(address(this));
function deploy(uint256 amount, bytes memory bytecode) public returns (address newContract) {
if (address(this).balance < amount) revert InsufficientBalance(address(this));
if (bytecode.length == 0) revert ZeroBytecodeLength(address(this));
// solhint-disable-next-line no-inline-assembly
assembly ("memory-safe") {
/** @dev `CREATE` opcode
*
* Stack input
* ------------
* value: value in wei to send to the new account.
* offset: byte offset in the memory in bytes, the instructions of the new account.
* size: byte size to copy (size of the instructions).
*
* Stack output
* ------------
* address: the address of the deployed contract.
*
* How are bytes stored in Solidity:
* In memory the `bytes` is stored by having first the length of the `bytes` and then the data,
* this results in the following schema: `<32-bytes length><data>` at the location where bytecode points to.
*
* Now if we want to use the data with `CREATE`, we first point to the start of the raw data, which is after the length.
* Therefore, we add 32 (the space required for the length) to the location stored in the bytecode variable.
* This is the first parameter. For the second parameter, we read the length from memory using `mload`.
* As the length is the first 32 bytes at the location of `bytecode`, we can read the length by calling `mload(bytecode)`.
*/
newContract := create(amount, add(bytecode, 0x20), mload(bytecode))
}
if (newContract == address(0)) revert Failed(address(this));
emit ContractCreation(newContract);
return newContract;
}

Check warning

Code scanning / Slither

Assembly usage Warning


/**
* @dev Returns the address where a contract will be stored if deployed via `deploy`.
Expand Down
Loading
Loading