Skip to content

Commit 0b9244e

Browse files
CJ42b00steskimaharveyYamenMerhidzbo
authored
Setup LSP Smart Contracts as Monorepo on develop (#902)
* 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 <[email protected]> Co-authored-by: CJ42 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> Co-authored-by: CJ42 <[email protected]> * 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 <[email protected]> Co-authored-by: YamenMerhi <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> Co-authored-by: Jean Cvllr <[email protected]> Co-authored-by: CJ42 <[email protected]> --------- Co-authored-by: b00ste.lyx <[email protected]> Co-authored-by: Skima Harvey <[email protected]> Co-authored-by: Yamen Merhi <[email protected]> Co-authored-by: b00ste <[email protected]> Co-authored-by: Dominik Zborowski <[email protected]>
1 parent f4b21eb commit 0b9244e

File tree

793 files changed

+30924
-38412
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

793 files changed

+30924
-38412
lines changed

.eslintrc.json

-12
This file was deleted.

.github/workflows/benchmark.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313

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

1818
# do not run on releases (merging to main)
1919
branches-ignore:
@@ -22,6 +22,9 @@ on:
2222
jobs:
2323
benchmark:
2424
runs-on: ubuntu-latest
25+
defaults:
26+
run:
27+
working-directory: ./packages/lsp-smart-contracts
2528

2629
steps:
2730
- name: Checkout base branch
@@ -40,7 +43,9 @@ jobs:
4043
run: npm ci
4144

4245
- name: 🏗️ Build contract artifacts
43-
run: npx hardhat compile
46+
run: |
47+
npm run build
48+
npm run build:turbo
4449
4550
- name: 🧪 Run Benchmark tests
4651
# Rename the file to be able to generate benchmark JSON report

.github/workflows/build-lint-test.yml

+21-88
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ name: Node.js CI - Build + Lint + Test
55
on: pull_request
66

77
jobs:
8-
build:
8+
build-lint-test:
99
runs-on: ubuntu-latest
1010

1111
steps:
1212
- uses: actions/checkout@v3
1313

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

2121
- name: 📦 Install dependencies
@@ -29,87 +29,20 @@ jobs:
2929

3030
# This will also generate the Typechain types used by the Chai tests
3131
- name: 🏗️ Build contract artifacts
32-
run: npx hardhat compile
33-
34-
- name: 📤 cache dependencies + build
35-
uses: actions/cache@v2
36-
with:
37-
path: |
38-
artifacts
39-
node_modules
40-
types
41-
contracts.ts
42-
key: ${{ github.run_id }}
43-
44-
- name: 🧪 run import/requires tests
45-
run: npm run test:importRequire
46-
47-
- name: 📚 generate ABI docs
48-
run: npm run build:docs
49-
50-
- name: 🔍 check if ABI auto-generated docs need to be updated
51-
run: |-
52-
if [[ $(git diff --name-only) != "" ]];
53-
then
54-
echo "Error: Please generate ABI docs after making changes to Solidity code and Natspec comments!"
55-
exit 1
56-
fi
57-
58-
test-suites:
59-
strategy:
60-
matrix:
61-
lsp:
62-
[
63-
"up",
64-
"upinit",
65-
"lsp1",
66-
"lsp2",
67-
"lsp6",
68-
"lsp6init",
69-
"lsp7",
70-
"lsp7init",
71-
"lsp8",
72-
"lsp8init",
73-
"lsp9",
74-
"lsp9init",
75-
"lsp11",
76-
"lsp11init",
77-
"lsp17",
78-
"lsp17extensions",
79-
"lsp20",
80-
"lsp20init",
81-
"lsp23",
82-
"universalfactory",
83-
"reentrancy",
84-
"reentrancyinit",
85-
"mocks",
86-
]
87-
88-
runs-on: ubuntu-latest
89-
needs: [build]
90-
steps:
91-
- uses: actions/checkout@v3
92-
93-
- name: 📥 restore cache
94-
uses: actions/cache@v2
95-
id: "build-cache"
96-
with:
97-
path: |
98-
artifacts
99-
node_modules
100-
types
101-
contracts.ts
102-
key: ${{ github.run_id }}
103-
104-
- name: Use Node.js v16
105-
uses: actions/setup-node@v2
106-
with:
107-
node-version: "16.x"
108-
cache: "npm"
109-
110-
- name: Install dependencies
111-
if: steps.build-cache.outputs.cache-hit != 'true'
112-
run: npm ci
113-
114-
- name: 🧪 run tests
115-
run: npm run test:${{ matrix.lsp }}
32+
run: |
33+
npm run build
34+
npm run build:js
35+
36+
# - name: 📚 generate ABI docs
37+
# run: npm run build:docs
38+
39+
# - name: 🔍 check if ABI auto-generated docs need to be updated
40+
# run: |-
41+
# if [[ $(git diff --name-only) != "" ]];
42+
# then
43+
# echo "Error: Please generate ABI docs after making changes to Solidity code and Natspec comments!"
44+
# exit 1
45+
# fi
46+
47+
- name: 🧪 Run tests for each package
48+
run: npm run test

.github/workflows/foundry-tests.yml

+20-18
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on:
44
pull_request:
55
# compare gas diff only when editing Solidity smart contract code
66
paths:
7-
- "contracts/**/*.sol"
8-
- "tests/foundry/**/*.sol"
7+
- "packages/**/*.sol"
8+
- "packages/lsp-smart-contracts/tests/foundry/**/*.sol"
99

1010
jobs:
1111
foundry-tests:
@@ -24,7 +24,9 @@ jobs:
2424
run: npm ci
2525

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

37-
- name: Compare gas reports
38-
uses: Rubilmax/[email protected]
39-
with:
40-
summaryQuantile: 0.9 # only display the 10% most significant gas diffs in the summary (defaults to 20%)
41-
sortCriteria: avg,max # sort diff rows by criteria
42-
sortOrders: desc,asc # and directions
43-
id: gas_diff
44-
45-
- name: Add gas diff to sticky comment
46-
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
47-
uses: marocchino/sticky-pull-request-comment@v2
48-
with:
49-
# delete the comment in case changes no longer impact gas costs
50-
delete: ${{ !steps.gas_diff.outputs.markdown }}
51-
message: ${{ steps.gas_diff.outputs.markdown }}
39+
# - name: Compare gas reports
40+
# uses: Rubilmax/[email protected]
41+
# with:
42+
# summaryQuantile: 0.9 # only display the 10% most significant gas diffs in the summary (defaults to 20%)
43+
# sortCriteria: avg,max # sort diff rows by criteria
44+
# sortOrders: desc,asc # and directions
45+
# id: gas_diff
46+
47+
# - name: Add gas diff to sticky comment
48+
# if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
49+
# uses: marocchino/sticky-pull-request-comment@v2
50+
# with:
51+
# # delete the comment in case changes no longer impact gas costs
52+
# delete: ${{ !steps.gas_diff.outputs.markdown }}
53+
# message: ${{ steps.gas_diff.outputs.markdown }}

.github/workflows/release.yml

+12-6
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,38 @@ jobs:
2828
# a new release is created:
2929

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

3333
- name: Use Node.js '16.15.0'
3434
uses: actions/setup-node@v2
35-
if: ${{ steps.release.outputs.release_created }}
35+
if: ${{ steps.release.outputs.releases_created }}
3636
with:
3737
node-version: "16.15.0"
3838
registry-url: "https://registry.npmjs.org"
3939
scope: "@lukso"
4040
cache: "npm"
4141

4242
- name: Install Dependencies
43-
if: ${{ steps.release.outputs.release_created }}
43+
if: ${{ steps.release.outputs.releases_created }}
4444
run: npm ci
4545

4646
# `npm run build:js` will also generate the auto-generated constants for methods, errors and events,
4747
# including extracting their devdocs and userdocs
4848
- name: Prepare artifacts to publish
49-
if: ${{ steps.release.outputs.release_created }}
49+
if: ${{ steps.release.outputs.releases_created }}
5050
run: |
5151
npm run build
5252
npm run build:js
5353
npm run package
54+
npm run build:types
5455
5556
- name: Publish on NPM
56-
if: ${{ steps.release.outputs.release_created }}
57-
run: npm publish --access public
57+
if: ${{ steps.release.outputs.releases_created }}
58+
run: |
59+
(cat <<END > outputs.json
60+
${{toJSON(steps.release.outputs)}}
61+
END
62+
)
63+
node ./publish.mjs outputs.json
5864
env:
5965
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_KEY }}

.github/workflows/solc_version.yml

+9-6
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ on:
1111
- "develop"
1212
# Only run when `.sol` files have been changed
1313
paths:
14-
- "contracts/**/*.sol"
14+
- "*.sol"
1515

1616
pull_request:
1717
paths:
18-
- "contracts/**/*.sol"
18+
- "*.sol"
1919

2020
jobs:
2121
solc_version:
2222
runs-on: ubuntu-latest
23+
defaults:
24+
run:
25+
working-directory: packages/lsp-smart-contracts
2326
strategy:
2427
matrix:
2528
solc: [
@@ -75,12 +78,12 @@ jobs:
7578
- name: Compile Smart Contracts
7679
run: |
7780
if [[ "<" == "${{ steps.comparison.outputs.comparison-result }}" ]]
78-
then
81+
then
7982
solc $(ls contracts/**/*.sol | grep -v "Extension4337\|contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset") \
80-
--allow-paths $(pwd)/node_modules/ \
83+
--allow-paths $(pwd)/node_modules/,$(pwd)/packages/ \
84+
../=$(pwd)/contracts/ \
8185
@=node_modules/@ \
82-
solidity-bytes-utils/=node_modules/solidity-bytes-utils/ \
83-
../=$(pwd)/contracts/
86+
solidity-bytes-utils/=node_modules/solidity-bytes-utils/
8487
else
8588
solc contracts/**/*.sol \
8689
@=node_modules/@ \

.gitignore

+10-5
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,16 @@ forge-cache/
135135
gas_benchmark.md
136136

137137
# Exclude build output folders
138-
/common
139-
/module
140-
/contracts.ts
141-
/devdocs
142-
/userdocs
138+
/**/dist
139+
/**/contracts.ts
140+
/**/devdocs
141+
/**/userdocs
143142

144143
# test temporary folder
145144
/.test
145+
146+
# Turborepo
147+
.turbo
148+
149+
# Custom setup
150+
foundry_artifacts/

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "lib/forge-std"]
22
path = lib/forge-std
3-
url = git@github.com:foundry-rs/forge-std.git
3+
url = https://github.com/foundry-rs/forge-std.git

0 commit comments

Comments
 (0)