Skip to content

Commit

Permalink
Setup LSP Smart Contracts as Monorepo on develop (#902)
Browse files Browse the repository at this point in the history
* build!: setup monorepo with turborepo for `@lukso/lsp-smart-contracts`

* build!: move LSP2 as its own package (#829)

* build: start setting Turborepo configs for the monorepo (#828)

* build!: setup lsp-smart-contracts as monorepo

* build: fix setup eslint for root + packages

* build: setup LSP package template with instructions

* build: add `COVERAGE` as env variable

* build: fix package-lock

* build: keep root config for eslint

* ci: update CI commands to run temporarily steps for root + package

* build: replace `dts` by `unbuild`

* docs: apply new prettier to auto-generated docs

* build: add missing npm command for `turbo test`

* build!: setup lsp-smart-contracts as monorepo

* build: fix setup eslint for root + packages

* build: setup LSP package template with instructions

* chore: start moving LSP2 in its own package

* chore: setup Foundry tests for LSP2

* chore: remove other folders not relevant

* build: upgrade packages dependencies

* ci: update CI for solc_version to allow `packages/` path

* build: use `eslint-config-custom` as internal dependency at root

* docs: update autogenerated docs config

* ci: remove `lsp2` in testing matrix

* chore: update README of LSP2 + template packages

* feat: remove duplicated content (#856)

* ci: remove import require tests for testing constant imports (#859)

* build!: move LSP25 in its own package (#851)

* chore: disable generation of interfaceIds (#862)

* build!: move LSP20 in its own package (#853)

* build!: move `LSP4` in its own package (#855)

* build!: move LSP5 + LSP10 in their own packages (#852)

* build!: move LSP5 in its own package

* build: add `lsp2` package dependency in root

* ci: update remappings for compiling `solc_version`

* build: setup LSP10 as its own package

* docs: update dodoc config for LSP5 + LSP10

* build!: move LSP1 in its own package (#854)

* build!: move LSP1 in its own package

* refactor: update import paths for lsp1

* build!: move LSP17ContractExtension in its own package (#858)

* ci: create deployment script to deploy + verify base contracts on mainnet (#849)

* refactor: convert verify balance script into Hardhat task

* ci: add script to deploy and verify base contracts on mainnet

* ci: create bash file + setup mainnet deployer

* ci: refactor workflow to deploy and verify contracts using Hardhat task

* build!: move LSP17ContractExtension in its own package

* docs: add latest LSP7 + LSP8 Tokens audit report (#861)

* wip

---------

Co-authored-by: Jean Cvllr <31145285+CJ42@users.noreply.github.com>
Co-authored-by: CJ42 <cavallerajean@gmail.com>

* build!: move LSP14 in its own package (#860)

* build: move LSP14 in its own package

* refactor: update import paths + add LSP14 in remappings

* build: upgrade Typescript version in `packages` and `template/` (#867)

* build!:  move LSP0 in its own package (#864)

* build!: move lsp0 to its own package

* refactor: modify imports

* chore: prettify

* test: resolve foundry imports

* test: resolve artifacts import

* chore: add suggested changes

* build!: move LSP6 in its own package (#866)

* build!: move LSP6 in its own package

* test: move most of LSP6 foundry tests in package

* docs: update paths for LSP6 auto-generated docs

* chore: disable prettier for permissions values

* test: fix import paths in Foundry tests at root

* style: ignore artifacts and types from prettier (#868)

* style: ignore artifacts and types from prettier

* build: upgrade Typescript version in `packages` and `template/` (#867)

* build!:  move LSP0 in its own package (#864)

* build!: move lsp0 to its own package

* refactor: modify imports

* chore: prettify

* test: resolve foundry imports

* test: resolve artifacts import

* chore: add suggested changes

* build!: move LSP6 in its own package (#866)

* build!: move LSP6 in its own package

* test: move most of LSP6 foundry tests in package

* docs: update paths for LSP6 auto-generated docs

* chore: disable prettier for permissions values

* test: fix import paths in Foundry tests at root

---------

Co-authored-by: Jean Cvllr <31145285+CJ42@users.noreply.github.com>

* ci: cache Typescript `types/` of packages in CI (#863)

* build!: move LSP7 in its own package (#865)

* build!: move lsp17 to its own package (#871)

* build!: re-open LSP16 PR to move it again as its own package (#877)

* build!: move LSP17ContractExtension in its own package (#858)

* ci: create deployment script to deploy + verify base contracts on mainnet (#849)

* refactor: convert verify balance script into Hardhat task

* ci: add script to deploy and verify base contracts on mainnet

* ci: create bash file + setup mainnet deployer

* ci: refactor workflow to deploy and verify contracts using Hardhat task

* build!: move LSP17ContractExtension in its own package

* docs: add latest LSP7 + LSP8 Tokens audit report (#861)

* wip

---------

Co-authored-by: Jean Cvllr <31145285+CJ42@users.noreply.github.com>
Co-authored-by: CJ42 <cavallerajean@gmail.com>

* build!: move lsp16 to its own package

* build: update package-lock.json

* docs: update docs

* test: remove test command of lsp16

* ci: update ci reference for lsp16

* test: add mock contracts

---------

Co-authored-by: Skima Harvey <64636974+skimaharvey@users.noreply.github.com>
Co-authored-by: YamenMerhi <yamennmerhi@gmail.com>

* build!: move LSP8 in its own package (#878)

* build!: move LSP8 in its own package

* docs: update auto-generated docs for LSP8 package

* test: update path for LSP8Mintable TS types

* build!: move LSP3 and Universal Profile in their own package (#879)

* build!: move LSP9 in its own package (#869)

* feat: create LSP12 package (#882)

* build!: move LSP1 URD in its own package (#880)

* build!: create lsp23 package (#883)

* build!: create lsp23 package

* refactor: update types path in lsp23 tests

* ci: fix benchmark

* test: replace use of factories with types factories

* tests: fix lsp6 types issue

* tests: clean up lsp20 types issues

* tests: clean up lsp7 types issue

* tests: fix up types issues

* tests: fix reentrancy tests

* build: update package names (#885)

* build: update package names

* chore: update remmapingss

* chore: fix import remappings

* chore: update dodoc config

---------

Co-authored-by: CJ42 <cavallerajean@gmail.com>

* feat: move constants in their respective packages (#884)

* build: setup template package as `module`

* build: setup constant export file in template

* refactor!: move each TS constants & Types into their respective packages

* refactor: add constants and typings for LSP2

* refactor: import interface IDs, typeIds and data keys per sub-package into root

* chore: rename prettier config files to `.cjs`

* revert: remove type `module`

* chore: update import paths

* build: register `build:js` command

* build: fix `build:js` command and missing dependencies and configs

* ci: cache `dist` folder

* test: update import paths for constants and types

* docs: add missing generated docs paths

* chore: update incorrect Typechain paths

* chore: remove `smock` library

* refactror: remove legacy contracts & tests (#890)

* docs: add packages table, npm version to each package (#886)

* chore: create packages table

* chore: add npm versaion badges to packages

* build!: upgrade all packages + root to latest Hardhat version and ethers v6 (#889)

* build!: create final package for `@lukso/lsp-smart-contracts` (#896)

* chore!: move `@lukso/lsp-smart-contracts` in its own package

* build: move all the build and config files into `packages/lsp-smart-contracts`

* test: move all the tests/ under `packages/lsp-smart-contracts`

* build: organise `package.json` for root and `@lukso/lsp-smart-contracts`

* build: cleanup test and scripts commands from root to package

* ci: adjust CI for build lint test for all packages

* chore: remap import paths for `LSP0ERC725Account` to `@lukso/lsp0-contracts/`

* ci: update CI job path runner for `solc_version`

* build: tmp turn off global import disallowed in `.sol` file for `lsp-smart-contracts`

* chore: remap import paths

* test: fix Benchmark tests for ethers v6 syntax

* chore: fix some Solidity import path compiler errors

* build: update `package-lock.json`

* test: update foundry tests setting for `@lukso/lsp-smart-contracts`

* chore: add missing environnement variable in `turbo.json`

* test: repair tests that import helpers from root

* chore: fix types imports in tests

* build: adjust foundry build settings to prevent race condition when installing solc in CI

* chore: ignore temporarily lsp16 package for foundry tests

* ci: disable temporarily foundry gas report in CI

* ci: specify working directory for gas benchmark CI

---------

Co-authored-by: b00ste <daniel@lukso.io>

* chore: export artifacts from each package (#895)

* chore: include types in the release package (#898)

* build: prepare manifest file (#897)

* chore: update manifest file for release

* chore: add lsp-smart-contracts package

* chiore: add pre-release true to lsp-smart-contracts package

* build: remove `release-as` options in favour of git commit message `release-as`

---------

Co-authored-by: CJ42 <cavallerajean@gmail.com>

* ci: setup CI to release per packages individually (#900)

* docs: add documentation in `RELEASE.md` for creating pre-releases per packages

* ci: update CI for monorepo configs

* docs: add extra mention for pre-releases

* ci: create JS script to publish each packages on npm

* feat!: allow operator to revoke himself (#901)

* feat!: allow operator to revoke himself

* test: add test for operator revoking himself

* refactor!: change LSP7 interfaceId

* chore: fix parameter and generate natspec

* Make `attributes` optional (#872)

* chore: do suggested changes

* feat: Add contract asset type (#891)

* Add contract asset

* Make fileType optional

* PR remarks

* Change names

* chore: re-add updated tests in LSP7 + LSP8

---------

Co-authored-by: Dominik Zborowski <dominik.zborowski@gmail.com>
Co-authored-by: Jean Cvllr <31145285+CJ42@users.noreply.github.com>
Co-authored-by: CJ42 <cavallerajean@gmail.com>

---------

Co-authored-by: b00ste.lyx <62855857+b00ste@users.noreply.github.com>
Co-authored-by: Skima Harvey <64636974+skimaharvey@users.noreply.github.com>
Co-authored-by: Yamen Merhi <yamennmerhi@gmail.com>
Co-authored-by: b00ste <daniel@lukso.io>
Co-authored-by: Dominik Zborowski <dominik.zborowski@gmail.com>
  • Loading branch information
6 people authored Mar 4, 2024
1 parent f4b21eb commit 0b9244e
Show file tree
Hide file tree
Showing 793 changed files with 30,924 additions and 38,412 deletions.
12 changes: 0 additions & 12 deletions .eslintrc.json

This file was deleted.

9 changes: 7 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

# compare gas diff only when editing Solidity smart contract code
paths:
- "contracts/**/*.sol"
- "packages/**/contracts/**/*.sol"

# do not run on releases (merging to main)
branches-ignore:
Expand All @@ -22,6 +22,9 @@ on:
jobs:
benchmark:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./packages/lsp-smart-contracts

steps:
- name: Checkout base branch
Expand All @@ -40,7 +43,9 @@ jobs:
run: npm ci

- name: 🏗️ Build contract artifacts
run: npx hardhat compile
run: |
npm run build
npm run build:turbo
- name: 🧪 Run Benchmark tests
# Rename the file to be able to generate benchmark JSON report
Expand Down
109 changes: 21 additions & 88 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ name: Node.js CI - Build + Lint + Test
on: pull_request

jobs:
build:
build-lint-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
- name: Use Node.js '16.15.0'
uses: actions/setup-node@v2
- name: Use Node.js v20
uses: actions/setup-node@v3
with:
node-version: "16.15.0"
node-version: "20.x"
cache: "npm"

- name: 📦 Install dependencies
Expand All @@ -29,87 +29,20 @@ jobs:

# This will also generate the Typechain types used by the Chai tests
- name: 🏗️ Build contract artifacts
run: npx hardhat compile

- name: 📤 cache dependencies + build
uses: actions/cache@v2
with:
path: |
artifacts
node_modules
types
contracts.ts
key: ${{ github.run_id }}

- name: 🧪 run import/requires tests
run: npm run test:importRequire

- name: 📚 generate ABI docs
run: npm run build:docs

- name: 🔍 check if ABI auto-generated docs need to be updated
run: |-
if [[ $(git diff --name-only) != "" ]];
then
echo "Error: Please generate ABI docs after making changes to Solidity code and Natspec comments!"
exit 1
fi
test-suites:
strategy:
matrix:
lsp:
[
"up",
"upinit",
"lsp1",
"lsp2",
"lsp6",
"lsp6init",
"lsp7",
"lsp7init",
"lsp8",
"lsp8init",
"lsp9",
"lsp9init",
"lsp11",
"lsp11init",
"lsp17",
"lsp17extensions",
"lsp20",
"lsp20init",
"lsp23",
"universalfactory",
"reentrancy",
"reentrancyinit",
"mocks",
]

runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v3

- name: 📥 restore cache
uses: actions/cache@v2
id: "build-cache"
with:
path: |
artifacts
node_modules
types
contracts.ts
key: ${{ github.run_id }}

- name: Use Node.js v16
uses: actions/setup-node@v2
with:
node-version: "16.x"
cache: "npm"

- name: Install dependencies
if: steps.build-cache.outputs.cache-hit != 'true'
run: npm ci

- name: 🧪 run tests
run: npm run test:${{ matrix.lsp }}
run: |
npm run build
npm run build:js
# - name: 📚 generate ABI docs
# run: npm run build:docs

# - name: 🔍 check if ABI auto-generated docs need to be updated
# run: |-
# if [[ $(git diff --name-only) != "" ]];
# then
# echo "Error: Please generate ABI docs after making changes to Solidity code and Natspec comments!"
# exit 1
# fi

- name: 🧪 Run tests for each package
run: npm run test
38 changes: 20 additions & 18 deletions .github/workflows/foundry-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
pull_request:
# compare gas diff only when editing Solidity smart contract code
paths:
- "contracts/**/*.sol"
- "tests/foundry/**/*.sol"
- "packages/**/*.sol"
- "packages/lsp-smart-contracts/tests/foundry/**/*.sol"

jobs:
foundry-tests:
Expand All @@ -24,7 +24,9 @@ jobs:
run: npm ci

- name: NPM build
run: npx hardhat compile
run: |
npm run build
npm run build:foundry
- name: Run Foundry tests
run: npm run test:foundry
Expand All @@ -34,18 +36,18 @@ jobs:
# due to non-deterministic fuzzing (but still use pseudo-random fuzzing seeds)
FOUNDRY_FUZZ_SEED: 0x${{ github.event.pull_request.base.sha || github.sha }}

- name: Compare gas reports
uses: Rubilmax/foundry-gas-diff@v3.13.1
with:
summaryQuantile: 0.9 # only display the 10% most significant gas diffs in the summary (defaults to 20%)
sortCriteria: avg,max # sort diff rows by criteria
sortOrders: desc,asc # and directions
id: gas_diff

- name: Add gas diff to sticky comment
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
uses: marocchino/sticky-pull-request-comment@v2
with:
# delete the comment in case changes no longer impact gas costs
delete: ${{ !steps.gas_diff.outputs.markdown }}
message: ${{ steps.gas_diff.outputs.markdown }}
# - name: Compare gas reports
# uses: Rubilmax/foundry-gas-diff@v3.13.1
# with:
# summaryQuantile: 0.9 # only display the 10% most significant gas diffs in the summary (defaults to 20%)
# sortCriteria: avg,max # sort diff rows by criteria
# sortOrders: desc,asc # and directions
# id: gas_diff

# - name: Add gas diff to sticky comment
# if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
# uses: marocchino/sticky-pull-request-comment@v2
# with:
# # delete the comment in case changes no longer impact gas costs
# delete: ${{ !steps.gas_diff.outputs.markdown }}
# message: ${{ steps.gas_diff.outputs.markdown }}
18 changes: 12 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,38 @@ jobs:
# a new release is created:

- uses: actions/checkout@v3
if: ${{ steps.release.outputs.release_created }}
if: ${{ steps.release.outputs.releases_created }}

- name: Use Node.js '16.15.0'
uses: actions/setup-node@v2
if: ${{ steps.release.outputs.release_created }}
if: ${{ steps.release.outputs.releases_created }}
with:
node-version: "16.15.0"
registry-url: "https://registry.npmjs.org"
scope: "@lukso"
cache: "npm"

- name: Install Dependencies
if: ${{ steps.release.outputs.release_created }}
if: ${{ steps.release.outputs.releases_created }}
run: npm ci

# `npm run build:js` will also generate the auto-generated constants for methods, errors and events,
# including extracting their devdocs and userdocs
- name: Prepare artifacts to publish
if: ${{ steps.release.outputs.release_created }}
if: ${{ steps.release.outputs.releases_created }}
run: |
npm run build
npm run build:js
npm run package
npm run build:types
- name: Publish on NPM
if: ${{ steps.release.outputs.release_created }}
run: npm publish --access public
if: ${{ steps.release.outputs.releases_created }}
run: |
(cat <<END > outputs.json
${{toJSON(steps.release.outputs)}}
END
)
node ./publish.mjs outputs.json
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_KEY }}
15 changes: 9 additions & 6 deletions .github/workflows/solc_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ on:
- "develop"
# Only run when `.sol` files have been changed
paths:
- "contracts/**/*.sol"
- "*.sol"

pull_request:
paths:
- "contracts/**/*.sol"
- "*.sol"

jobs:
solc_version:
runs-on: ubuntu-latest
defaults:
run:
working-directory: packages/lsp-smart-contracts
strategy:
matrix:
solc: [
Expand Down Expand Up @@ -75,12 +78,12 @@ jobs:
- name: Compile Smart Contracts
run: |
if [[ "<" == "${{ steps.comparison.outputs.comparison-result }}" ]]
then
then
solc $(ls contracts/**/*.sol | grep -v "Extension4337\|contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset") \
--allow-paths $(pwd)/node_modules/ \
--allow-paths $(pwd)/node_modules/,$(pwd)/packages/ \
../=$(pwd)/contracts/ \
@=node_modules/@ \
solidity-bytes-utils/=node_modules/solidity-bytes-utils/ \
../=$(pwd)/contracts/
solidity-bytes-utils/=node_modules/solidity-bytes-utils/
else
solc contracts/**/*.sol \
@=node_modules/@ \
Expand Down
15 changes: 10 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,16 @@ forge-cache/
gas_benchmark.md

# Exclude build output folders
/common
/module
/contracts.ts
/devdocs
/userdocs
/**/dist
/**/contracts.ts
/**/devdocs
/**/userdocs

# test temporary folder
/.test

# Turborepo
.turbo

# Custom setup
foundry_artifacts/
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = git@github.com:foundry-rs/forge-std.git
url = https://github.com/foundry-rs/forge-std.git
Loading

0 comments on commit 0b9244e

Please sign in to comment.