Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

17 changes: 0 additions & 17 deletions .eslintrc.js

This file was deleted.

102 changes: 43 additions & 59 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,90 +1,74 @@
name: Publish to NPM
run-name: Publish release ${{ github.event.release.tag_name }} to NPM
name: Publish

on:
release:
types: [released] # A release was published, or a pre-release was changed to a release. https://docs.github.com/en/webhooks-and-events/webhooks/webhook-events-and-payloads?actionType=released#release
types: [released]

permissions:
contents: read
id-token: write
attestations: write

jobs:
publish:
name: Publish to NPM
name: Publish
runs-on: ubuntu-latest
permissions:
id-token: write # ! Required for GitHub Attestations, removing will create a Sev 0 incident !
attestations: write # ! Required for GitHub Attestations, removing will create a Sev 0 incident !
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0

- name: Check Input
run: echo "Release Tag - ${{ github.event.release.tag_name }}"

- name: Validate Tag
run: |
if [[ "${{ github.event.release.tag_name }}" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Tag ${{ github.event.release.tag_name }} is valid"
else
echo "Tag is invalid"
exit 1
fi

- name: Clean Tag
id: clean-tag
run: |
echo "::set-output name=TAG::$(grep -Eo '[^v]?[0-9]+\.[0-9]+\.[0-9]+$' <<< '${{ github.event.release.tag_name }}')"

- name: Validated Tag
run: echo "package.json version - ${{ steps.clean-tag.outputs.TAG }}"
- name: Initialize submodules
run: git submodule update --init --recursive

- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v6
with:
node-version-file: ".nvmrc"
registry-url: https://registry.npmjs.org/

- name: Update package.json version
run: |
tmp=$(mktemp)
jq '.version = "${{ steps.clean-tag.outputs.TAG }}"' ./package.json > "$tmp" && mv "$tmp" ./package.json
cache: yarn

- name: Install dependencies
run: |
yarn install --frozen-lockfile --network-concurrency 1
run: yarn install --frozen-lockfile --network-concurrency 1

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Show Forge Version
run: forge --version

- name: Install Forge dependancies
run: forge install
- name: Cache Foundry build output
uses: actions/cache@v4
with:
path: |
foundry-out
cache
key: ${{ runner.os }}-foundry-${{ hashFiles('foundry.lock', 'foundry.toml') }}

- name: Compile contracts
run: |
yarn compile
- name: Compile contracts (Foundry)
run: forge build

- name: Build dist files
run: |
rm -rf dist && yarn build
run: yarn build

# ! Do NOT remove - this will cause a Sev 0 incident !
- name: Pack NPM package
run: |
npm pack
run: npm pack

- name: Generate attestation
uses: actions/attest-build-provenance@v1
with:
subject-path: ./*.tgz
# ! ------------------------------------------------- !
- name: Get release tag
id: release
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"

- name: Publish package
uses: JS-DevTools/npm-publish@19c28f1ef146469e409470805ea4279d47c3d35c # v3.1.1
- name: Publish to NPM
uses: JS-DevTools/npm-publish@v4
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
with:
token: ${{ secrets.CONTRACTS_NPM_TOKEN }}
access: public
tag: "latest"
provenance: true
registry: https://registry.npmjs.org/
package: package.json
tag: ${{ steps.release.outputs.tag }}
provenance: true
Comment thread
cursor[bot] marked this conversation as resolved.
strategy: all

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Release tag ignores package version

High Severity

The publish workflow no longer validates the GitHub release tag or updates the package.json version before npm publish. This can cause the published package's version on NPM to diverge from the GitHub release tag, potentially confusing consumers.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2ee3fba. Configure here.


- name: Attest build provenance
uses: actions/attest-build-provenance@v3
with:
subject-name: ${{ github.repository }}
subject-path: ${{ github.workspace }}
push-to-registry: true
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
162 changes: 49 additions & 113 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,142 +1,78 @@
name: test
name: Test

on:
push:
branches: [main]
branches:
- main
pull_request:
branches: [main]
branches:
- main

permissions:
contents: read

jobs:
forge-test:
name: Run Forge Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Show Forge Version
run: forge --version
- name: Run tests and install dependancies
run: forge test -vvv
- name: Debug Info1
if: '!cancelled()'
run: pwd
hardhat-test:
name: Run Hardhat Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: lts/*
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile --network-concurrency 1
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Show Forge Version
run: forge --version
- name: Install Forge dependancies
run: forge install
- name: Run Tests
run: yarn test
eslint:
name: Run eslint
continue-on-error: true
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: lts/*
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile --network-concurrency 1
- name: Run eslint
run: yarn run eslint
solhint:
name: Run solhint
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: 'yarn'
node-version-file: ".nvmrc"
cache: yarn
- name: Install dependencies
run: yarn install --frozen-lockfile --network-concurrency 1
- name: Run solhint
run: yarn run solhint contracts/**/*.sol
slither:
name: Run slither
run: yarn run solhint
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated

forge-test:
name: Foundry test
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Uninstall Debian package that slither needs to uninstall
run: sudo apt remove python3-typing-extensions
- name: Install Slither
run: sudo pip3 install slither-analyzer
- name: Show Slither Version
run: slither --version
- name: Checkout
uses: actions/checkout@v6
with:
submodules: recursive
fetch-depth: 0

- name: Initialize submodules
run: git submodule update --init --recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Show Forge Version
run: forge --version
- name: Run slither
run: slither --compile-force-framework forge --foundry-out-directory foundry-out .
readme:
name: Check README.md is contained in each contracts directory
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Run check script
run: sh readmecheck.sh
dependency-review:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
- name: Dependency Review
uses: actions/dependency-review-action@v4
with:
# Possible values: "critical", "high", "moderate", "low"
fail-on-severity: critical

# Address https://github.com/actions/dependency-review-action/issues/456
base-ref: ${{ github.event.pull_request.base.sha || github.event.repository.default_branch }}
head-ref: ${{ github.event.pull_request.head.sha || github.ref }}
publish:
name: Publish to NPM (dry run)
- name: Cache Foundry build output
uses: actions/cache@v4
with:
path: |
foundry-out
cache
key: ${{ runner.os }}-foundry-${{ hashFiles('foundry.lock', 'foundry.toml') }}

- name: Run Forge tests
run: forge test -vvv

package-check:
name: Package build (v3)
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
- name: Checkout
uses: actions/checkout@v6

- name: Setup node
uses: actions/setup-node@v6
with:
node-version-file: ".nvmrc"
registry-url: https://registry.npmjs.org/
cache: 'yarn'
cache: yarn

- name: Install dependencies
run: yarn install --frozen-lockfile --network-concurrency 1
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Show Forge Version
run: forge --version
- name: Install Forge dependancies
run: forge install
- name: Compile contracts
run: yarn compile

- name: Build dist files
run: rm -rf dist && yarn build
- name: Test publish
run: yarn build

- name: Pack NPM package
run: npm pack --dry-run
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ node.json
.vscode/
package-lock.json

# Hardhat files
# Build artifacts
cache
artifacts
cache_hardhat

# Build files
dist/
Expand Down
24 changes: 21 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
hardhat.config.ts
# Build and config files
tsconfig.json
foundry.toml
foundry.lock
remappings.txt
slither.config.json

# Development directories
node_modules
scripts
test
perfTest
lib
audits
deploy
abi

# Documentation (available on GitHub)
*.md
!README.md
!LICENSE.md

# Exclude test/mock contracts
contracts/mocks
# Exclude test/mock contracts (also negated in package.json "files")
contracts/mocks/**

# Exclude binary assets
**/*.png
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18.17.1
22.12.0
Loading
Loading