From 0f5429175390cfe87949406ac3c87eabd7a6ff3b Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Tue, 26 Sep 2023 22:25:16 -0300 Subject: [PATCH 01/34] enable partial transpilation --- scripts/upgradeable/transpile.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/upgradeable/transpile.sh b/scripts/upgradeable/transpile.sh index 05de96d3436..604329374df 100644 --- a/scripts/upgradeable/transpile.sh +++ b/scripts/upgradeable/transpile.sh @@ -24,6 +24,7 @@ fi # -p: emit public initializer # -n: use namespaces # -N: exclude from namespaces transformation +# -q: partial transpilation using @openzeppelin/contracts as peer project npx @openzeppelin/upgrade-safe-transpiler@latest -D \ -b "$build_info" \ -i contracts/proxy/utils/Initializable.sol \ @@ -36,7 +37,8 @@ npx @openzeppelin/upgrade-safe-transpiler@latest -D \ -x '!contracts/proxy/beacon/IBeacon.sol' \ -p 'contracts/**/presets/**/*' \ -n \ - -N 'contracts/mocks/**/*' + -N 'contracts/mocks/**/*' \ + -q '@openzeppelin/contracts' # delete compilation artifacts of vanilla code npm run clean From b4a9a76318ca6651ea2957cef8941e6670549d3f Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 00:26:18 -0300 Subject: [PATCH 02/34] refactor prepare/prepack scripts --- .github/actions/setup/action.yml | 2 -- contracts/package.json | 2 +- package.json | 2 +- scripts/prepack.sh | 17 ++++++++++++++++- scripts/prepare-contracts-package.sh | 15 --------------- scripts/prepare.sh | 10 ---------- 6 files changed, 18 insertions(+), 30 deletions(-) delete mode 100755 scripts/prepare-contracts-package.sh delete mode 100755 scripts/prepare.sh diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 84ebe823ab8..3154e9931af 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -15,5 +15,3 @@ runs: run: npm ci shell: bash if: steps.cache.outputs.cache-hit != 'true' - env: - SKIP_COMPILE: true diff --git a/contracts/package.json b/contracts/package.json index df141192d3d..9017953ca3c 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -8,7 +8,7 @@ "!/mocks/**/*" ], "scripts": { - "prepare": "bash ../scripts/prepare-contracts-package.sh", + "prepack": "bash ../scripts/prepack.sh", "prepare-docs": "cd ..; npm run prepare-docs" }, "repository": { diff --git a/package.json b/package.json index e6804c4cd96..7ba010307a6 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "openzeppelin-solidity", "description": "Secure Smart Contract library for Solidity", "version": "4.9.2", + "private": true, "files": [ "/contracts/**/*.sol", "/build/contracts/*.json", @@ -20,7 +21,6 @@ "lint:sol": "prettier --log-level warn --ignore-path .gitignore '{contracts,test}/**/*.sol' --check && solhint '{contracts,test}/**/*.sol'", "lint:sol:fix": "prettier --log-level warn --ignore-path .gitignore '{contracts,test}/**/*.sol' --write", "clean": "hardhat clean && rimraf build contracts/build", - "prepare": "scripts/prepare.sh", "prepack": "scripts/prepack.sh", "generate": "scripts/generate/run.js", "release": "scripts/release/release.sh", diff --git a/scripts/prepack.sh b/scripts/prepack.sh index 6f1bd4c32f1..19c8809a857 100755 --- a/scripts/prepack.sh +++ b/scripts/prepack.sh @@ -4,9 +4,24 @@ set -euo pipefail shopt -s globstar # cross platform `mkdir -p` -node -e 'fs.mkdirSync("build/contracts", { recursive: true })' +mkdirp() { + node -e "fs.mkdirSync('$1', { recursive: true })" +} +# cd to the root of the repo +cd "$(git rev-parse --show-toplevel)" + +npm run clean + +env COMPILE_MODE=production npm run compile + +mkdirp build/contracts cp artifacts/contracts/**/*.json build/contracts rm build/contracts/*.dbg.json node scripts/remove-ignored-artifacts.js + +cp README.md contracts/ + +mkdirp contracts/build/contracts +cp -r build/contracts/*.json contracts/build/contracts diff --git a/scripts/prepare-contracts-package.sh b/scripts/prepare-contracts-package.sh deleted file mode 100755 index 3f62fd419dd..00000000000 --- a/scripts/prepare-contracts-package.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -# cd to the root of the repo -cd "$(git rev-parse --show-toplevel)" - -# avoids re-compilation during publishing of both packages -if [[ ! -v ALREADY_COMPILED ]]; then - npm run clean - npm run prepare - npm run prepack -fi - -cp README.md contracts/ -mkdir contracts/build contracts/build/contracts -cp -r build/contracts/*.json contracts/build/contracts diff --git a/scripts/prepare.sh b/scripts/prepare.sh deleted file mode 100755 index 7014a7076ff..00000000000 --- a/scripts/prepare.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -if [ "${SKIP_COMPILE:-}" == true ]; then - exit -fi - -npm run clean -env COMPILE_MODE=production npm run compile From f648bfe2ffb98782c7f0d0412bac0ae6d5442049 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 00:42:08 -0300 Subject: [PATCH 03/34] add vanilla as dependency during upgradeable tests --- .github/workflows/checks.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 3d9b199fb70..d0fb04894b1 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -56,8 +56,16 @@ jobs: fetch-depth: 0 # Include history so patch conflicts are resolved automatically - name: Set up environment uses: ./.github/actions/setup + - name: Pack vanilla package + id: vanilla + run: | + tarball="$(npm pack --pack-destination ..)" + echo "tarball=$tarball" >> "$GITHUB_OUTPUT" + working-directory: contracts - name: Transpile to upgradeable run: bash scripts/upgradeable/transpile.sh + - name: Install vanilla as dependency + run: npm install --no-save "${{ steps.vanilla.outputs.tarball }}" - name: Run tests run: npm run test - name: Check linearisation of the inheritance graph From 3910fbc9c17bfae797d6e13697eaf3f5d36b0470 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 00:48:58 -0300 Subject: [PATCH 04/34] fix npm pack output --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index d0fb04894b1..69b14f45a4f 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -59,7 +59,7 @@ jobs: - name: Pack vanilla package id: vanilla run: | - tarball="$(npm pack --pack-destination ..)" + tarball="$(npm pack --pack-destination .. --no-foreground-scripts)" echo "tarball=$tarball" >> "$GITHUB_OUTPUT" working-directory: contracts - name: Transpile to upgradeable From 270c00696347b41aa37af455f8b3edb8bcf7d4ca Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 00:53:23 -0300 Subject: [PATCH 05/34] fix npm pack --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 69b14f45a4f..fa5d71a87cb 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -59,7 +59,7 @@ jobs: - name: Pack vanilla package id: vanilla run: | - tarball="$(npm pack --pack-destination .. --no-foreground-scripts)" + tarball="$(npm pack --pack-destination .. | tee /dev/stderr | tail -1)" echo "tarball=$tarball" >> "$GITHUB_OUTPUT" working-directory: contracts - name: Transpile to upgradeable From df08dd759fe6b32ac0f715f8f4ab902d62cd1e16 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 01:00:54 -0300 Subject: [PATCH 06/34] fix transpile command --- scripts/upgradeable/transpile.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgradeable/transpile.sh b/scripts/upgradeable/transpile.sh index 604329374df..8158897622f 100644 --- a/scripts/upgradeable/transpile.sh +++ b/scripts/upgradeable/transpile.sh @@ -38,7 +38,7 @@ npx @openzeppelin/upgrade-safe-transpiler@latest -D \ -p 'contracts/**/presets/**/*' \ -n \ -N 'contracts/mocks/**/*' \ - -q '@openzeppelin/contracts' + -q '@openzeppelin/' # delete compilation artifacts of vanilla code npm run clean From 59746e68c1f485ae30fe40906ea690adf342e766 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 01:19:40 -0300 Subject: [PATCH 07/34] change approach without using pack --- .github/workflows/checks.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index fa5d71a87cb..0aade7606e3 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -56,16 +56,16 @@ jobs: fetch-depth: 0 # Include history so patch conflicts are resolved automatically - name: Set up environment uses: ./.github/actions/setup - - name: Pack vanilla package - id: vanilla - run: | - tarball="$(npm pack --pack-destination .. | tee /dev/stderr | tail -1)" - echo "tarball=$tarball" >> "$GITHUB_OUTPUT" - working-directory: contracts - name: Transpile to upgradeable run: bash scripts/upgradeable/transpile.sh + - name: Check out copy of vanilla + uses: actions/checkout@v4 + with: + path: ${{ env.RUNNER_TEMP }}/vanilla - name: Install vanilla as dependency - run: npm install --no-save "${{ steps.vanilla.outputs.tarball }}" + run: + mkdir node_modules/@openzeppelin + ln -s ${{ env.RUNNER_TEMP }}/vanilla/contracts node_modules/@openzeppelin/contracts - name: Run tests run: npm run test - name: Check linearisation of the inheritance graph From e904e025a32cd9dfdfa38f244293da7ac23ff2f4 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 01:22:46 -0300 Subject: [PATCH 08/34] fix workflow --- .github/workflows/checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 0aade7606e3..0d783ab806a 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -61,11 +61,11 @@ jobs: - name: Check out copy of vanilla uses: actions/checkout@v4 with: - path: ${{ env.RUNNER_TEMP }}/vanilla + path: ${{ runner.temp }}/vanilla - name: Install vanilla as dependency run: mkdir node_modules/@openzeppelin - ln -s ${{ env.RUNNER_TEMP }}/vanilla/contracts node_modules/@openzeppelin/contracts + ln -s "$RUNNER_TEMP/vanilla/contracts" node_modules/@openzeppelin/contracts - name: Run tests run: npm run test - name: Check linearisation of the inheritance graph From 0f2bafe4fabc1e175cc3566715e2852e1610c124 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 01:25:29 -0300 Subject: [PATCH 09/34] fix checkout location --- .github/workflows/checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 0d783ab806a..55bfb5098fd 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -61,11 +61,11 @@ jobs: - name: Check out copy of vanilla uses: actions/checkout@v4 with: - path: ${{ runner.temp }}/vanilla + path: .vanilla - name: Install vanilla as dependency run: mkdir node_modules/@openzeppelin - ln -s "$RUNNER_TEMP/vanilla/contracts" node_modules/@openzeppelin/contracts + ln -s ".vanilla/contracts" node_modules/@openzeppelin/contracts - name: Run tests run: npm run test - name: Check linearisation of the inheritance graph From 8002e8d16ff46368645074314007c69df9ab8348 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 01:27:11 -0300 Subject: [PATCH 10/34] fix run --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 55bfb5098fd..21714d812fe 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -63,7 +63,7 @@ jobs: with: path: .vanilla - name: Install vanilla as dependency - run: + run: | mkdir node_modules/@openzeppelin ln -s ".vanilla/contracts" node_modules/@openzeppelin/contracts - name: Run tests From 9e2dcf1efdb692c3f6218a1af0b46b83159c159d Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 01:29:05 -0300 Subject: [PATCH 11/34] fix mkdir --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 21714d812fe..f5e7ba2f193 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -64,7 +64,7 @@ jobs: path: .vanilla - name: Install vanilla as dependency run: | - mkdir node_modules/@openzeppelin + mkdir -p node_modules/@openzeppelin ln -s ".vanilla/contracts" node_modules/@openzeppelin/contracts - name: Run tests run: npm run test From 0ff2901a0ebb2140ac133dfb68e836d5856a82da Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 01:29:20 -0300 Subject: [PATCH 12/34] fix ln --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index f5e7ba2f193..5c7ad1cbe6a 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -65,7 +65,7 @@ jobs: - name: Install vanilla as dependency run: | mkdir -p node_modules/@openzeppelin - ln -s ".vanilla/contracts" node_modules/@openzeppelin/contracts + ln -sr ".vanilla/contracts" node_modules/@openzeppelin/contracts - name: Run tests run: npm run test - name: Check linearisation of the inheritance graph From 5d8422f832a3b1ff8d69ec0051d4834aa23563f2 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 13:44:29 -0300 Subject: [PATCH 13/34] add transpiler as dependency] --- package-lock.json | 87 ++++++++++++++++++++++++++++++++ package.json | 1 + scripts/upgradeable/transpile.sh | 2 +- 3 files changed, 89 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index f668e9d2825..4d42554a666 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "@nomiclabs/hardhat-web3": "^2.0.0", "@openzeppelin/docs-utils": "^0.1.4", "@openzeppelin/test-helpers": "^0.5.13", + "@openzeppelin/upgrade-safe-transpiler": "^0.3.29", "@openzeppelin/upgrades-core": "^1.20.6", "array.prototype.at": "^1.1.1", "chai": "^4.2.0", @@ -2407,6 +2408,91 @@ "semver": "bin/semver" } }, + "node_modules/@openzeppelin/upgrade-safe-transpiler": { + "version": "0.3.29", + "resolved": "https://registry.npmjs.org/@openzeppelin/upgrade-safe-transpiler/-/upgrade-safe-transpiler-0.3.29.tgz", + "integrity": "sha512-CB+yWCrVh60IieEREyYajAHB3VUVJy21+tiYOWn2FRydf+qLSYwkE0UpsFU3R1mP4YSpxLsTVvfdZI1YLTGEJg==", + "dev": true, + "dependencies": { + "ajv": "^8.0.0", + "compare-versions": "^6.0.0", + "ethereum-cryptography": "^2.0.0", + "lodash": "^4.17.20", + "minimatch": "^9.0.0", + "minimist": "^1.2.5", + "solidity-ast": "^0.4.51" + }, + "bin": { + "upgrade-safe-transpiler": "dist/cli.js" + } + }, + "node_modules/@openzeppelin/upgrade-safe-transpiler/node_modules/ajv": { + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/@openzeppelin/upgrade-safe-transpiler/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@openzeppelin/upgrade-safe-transpiler/node_modules/ethereum-cryptography": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-2.1.2.tgz", + "integrity": "sha512-Z5Ba0T0ImZ8fqXrJbpHcbpAvIswRte2wGNR/KePnu8GbbvgJ47lMxT/ZZPG6i9Jaht4azPDop4HaM00J0J59ug==", + "dev": true, + "dependencies": { + "@noble/curves": "1.1.0", + "@noble/hashes": "1.3.1", + "@scure/bip32": "1.3.1", + "@scure/bip39": "1.2.1" + } + }, + "node_modules/@openzeppelin/upgrade-safe-transpiler/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + }, + "node_modules/@openzeppelin/upgrade-safe-transpiler/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@openzeppelin/upgrade-safe-transpiler/node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/@openzeppelin/upgrades-core": { "version": "1.29.0", "resolved": "https://registry.npmjs.org/@openzeppelin/upgrades-core/-/upgrades-core-1.29.0.tgz", @@ -16919,6 +17005,7 @@ }, "scripts/solhint-custom": { "name": "solhint-plugin-openzeppelin", + "version": "0.0.0", "dev": true } } diff --git a/package.json b/package.json index 7ba010307a6..db65ff27f9d 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,7 @@ "@nomiclabs/hardhat-web3": "^2.0.0", "@openzeppelin/docs-utils": "^0.1.4", "@openzeppelin/test-helpers": "^0.5.13", + "@openzeppelin/upgrade-safe-transpiler": "^0.3.29", "@openzeppelin/upgrades-core": "^1.20.6", "array.prototype.at": "^1.1.1", "chai": "^4.2.0", diff --git a/scripts/upgradeable/transpile.sh b/scripts/upgradeable/transpile.sh index 8158897622f..99ec1073458 100644 --- a/scripts/upgradeable/transpile.sh +++ b/scripts/upgradeable/transpile.sh @@ -25,7 +25,7 @@ fi # -n: use namespaces # -N: exclude from namespaces transformation # -q: partial transpilation using @openzeppelin/contracts as peer project -npx @openzeppelin/upgrade-safe-transpiler@latest -D \ +npx @openzeppelin/upgrade-safe-transpiler -D \ -b "$build_info" \ -i contracts/proxy/utils/Initializable.sol \ -x 'contracts-exposed/**/*' \ From de7a277139d7cf50a6ad57a3baa9e2f9d05c46da Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 19:27:29 -0300 Subject: [PATCH 14/34] update hardhat-exposed --- package-lock.json | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4d42554a666..6bb287754cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,7 @@ "glob": "^10.3.5", "graphlib": "^2.1.8", "hardhat": "^2.9.1", - "hardhat-exposed": "^0.3.11", + "hardhat-exposed": "^0.3.12-0", "hardhat-gas-reporter": "^1.0.4", "hardhat-ignore-warnings": "^0.2.0", "keccak256": "^1.0.2", @@ -8650,13 +8650,13 @@ } }, "node_modules/hardhat-exposed": { - "version": "0.3.12", - "resolved": "https://registry.npmjs.org/hardhat-exposed/-/hardhat-exposed-0.3.12.tgz", - "integrity": "sha512-op/shZ6YQcQzPzxT4h0oD3x7M6fBna2rM/YUuhZLzJOtsu/DF9xK2o2thPSR1LAz8enx3wbjJZxl7b2+QXyDYw==", + "version": "0.3.12-0", + "resolved": "https://registry.npmjs.org/hardhat-exposed/-/hardhat-exposed-0.3.12-0.tgz", + "integrity": "sha512-frSUYPzZ8PjUqwgtvYnkO7nTUSDpFj8uSQj55n/oTjeXwEXrGksFlBcdkfBJr8exvI7ypohqNfbVTComwKRzQQ==", "dev": true, "dependencies": { "micromatch": "^4.0.4", - "solidity-ast": "^0.4.25" + "solidity-ast": "^0.4.52" }, "peerDependencies": { "hardhat": "^2.3.0" diff --git a/package.json b/package.json index db65ff27f9d..40ce1f4e195 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "glob": "^10.3.5", "graphlib": "^2.1.8", "hardhat": "^2.9.1", - "hardhat-exposed": "^0.3.11", + "hardhat-exposed": "^0.3.12-0", "hardhat-gas-reporter": "^1.0.4", "hardhat-ignore-warnings": "^0.2.0", "keccak256": "^1.0.2", From 63acb327892faa03b1924b725a29a2f91d6b3d08 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 19:30:31 -0300 Subject: [PATCH 15/34] update transpiler --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6bb287754cd..24463fff4ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "@nomiclabs/hardhat-web3": "^2.0.0", "@openzeppelin/docs-utils": "^0.1.4", "@openzeppelin/test-helpers": "^0.5.13", - "@openzeppelin/upgrade-safe-transpiler": "^0.3.29", + "@openzeppelin/upgrade-safe-transpiler": "^0.3.30", "@openzeppelin/upgrades-core": "^1.20.6", "array.prototype.at": "^1.1.1", "chai": "^4.2.0", @@ -2409,9 +2409,9 @@ } }, "node_modules/@openzeppelin/upgrade-safe-transpiler": { - "version": "0.3.29", - "resolved": "https://registry.npmjs.org/@openzeppelin/upgrade-safe-transpiler/-/upgrade-safe-transpiler-0.3.29.tgz", - "integrity": "sha512-CB+yWCrVh60IieEREyYajAHB3VUVJy21+tiYOWn2FRydf+qLSYwkE0UpsFU3R1mP4YSpxLsTVvfdZI1YLTGEJg==", + "version": "0.3.30", + "resolved": "https://registry.npmjs.org/@openzeppelin/upgrade-safe-transpiler/-/upgrade-safe-transpiler-0.3.30.tgz", + "integrity": "sha512-nkJ4r+W+FUp0eAvE18uHh/smwD1NS3KLAGJ59+Vgmx3VlCvCDNaS0rTJ1FpwxDYD3J0Whx0ZVtHz2ySq4YsnNQ==", "dev": true, "dependencies": { "ajv": "^8.0.0", diff --git a/package.json b/package.json index 40ce1f4e195..85ae14bfb6c 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "@nomiclabs/hardhat-web3": "^2.0.0", "@openzeppelin/docs-utils": "^0.1.4", "@openzeppelin/test-helpers": "^0.5.13", - "@openzeppelin/upgrade-safe-transpiler": "^0.3.29", + "@openzeppelin/upgrade-safe-transpiler": "^0.3.30", "@openzeppelin/upgrades-core": "^1.20.6", "array.prototype.at": "^1.1.1", "chai": "^4.2.0", From 5f0c801e5ddc7f1e1d559923999a0fa23e1a09f5 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 19:33:43 -0300 Subject: [PATCH 16/34] enable exposed imports --- hardhat.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/hardhat.config.js b/hardhat.config.js index 1c87aac94b5..c089e34378a 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -93,6 +93,7 @@ module.exports = { }, }, exposed: { + import: true, initializers: true, exclude: ['vendor/**/*'], }, From b6476c11a872c1840ee2420137018b9ff724697f Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 19:36:54 -0300 Subject: [PATCH 17/34] fix config --- hardhat.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardhat.config.js b/hardhat.config.js index c089e34378a..aca9d7273ab 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -93,7 +93,7 @@ module.exports = { }, }, exposed: { - import: true, + imports: true, initializers: true, exclude: ['vendor/**/*'], }, From 448d8f6d3b605b0c831497ef01fa3549c559695a Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 19:55:21 -0300 Subject: [PATCH 18/34] add Stateless.sol --- contracts/mocks/Stateless.sol | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 contracts/mocks/Stateless.sol diff --git a/contracts/mocks/Stateless.sol b/contracts/mocks/Stateless.sol new file mode 100644 index 00000000000..6d748ff3fa0 --- /dev/null +++ b/contracts/mocks/Stateless.sol @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.8.20; + +// We keep these imports just to we can run the test suite after transpilation. + +import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; From 0f7c3e258673640671c6aec57d17460cdd573bb6 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 19:57:49 -0300 Subject: [PATCH 19/34] fix stateless --- contracts/mocks/Stateless.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/mocks/Stateless.sol b/contracts/mocks/Stateless.sol index 6d748ff3fa0..82835f98326 100644 --- a/contracts/mocks/Stateless.sol +++ b/contracts/mocks/Stateless.sol @@ -4,4 +4,4 @@ pragma solidity ^0.8.20; // We keep these imports just to we can run the test suite after transpilation. -import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol"; +import {Clones} from "../proxy/Clones.sol"; From 7246dbb430dc1a5f4ce540b9df7da9d0c4960b29 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 20:19:33 -0300 Subject: [PATCH 20/34] add dummy contract in stateless file --- contracts/mocks/Stateless.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contracts/mocks/Stateless.sol b/contracts/mocks/Stateless.sol index 82835f98326..d82e8fdd30f 100644 --- a/contracts/mocks/Stateless.sol +++ b/contracts/mocks/Stateless.sol @@ -2,6 +2,7 @@ pragma solidity ^0.8.20; -// We keep these imports just to we can run the test suite after transpilation. +// We keep these imports and a dummy contract just to we can run the test suite after transpilation. +contract Dummy1234 {} import {Clones} from "../proxy/Clones.sol"; From ef88118befc1456247c869bad961dac2137dbf8b Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 20:24:21 -0300 Subject: [PATCH 21/34] add all library imports --- contracts/mocks/Stateless.sol | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/contracts/mocks/Stateless.sol b/contracts/mocks/Stateless.sol index d82e8fdd30f..54ed05fccbf 100644 --- a/contracts/mocks/Stateless.sol +++ b/contracts/mocks/Stateless.sol @@ -3,6 +3,31 @@ pragma solidity ^0.8.20; // We keep these imports and a dummy contract just to we can run the test suite after transpilation. -contract Dummy1234 {} +import {Time} from "../utils/types/Time.sol"; +import {Strings} from "../utils/Strings.sol"; +import {SafeCast} from "../utils/math/SafeCast.sol"; +import {EnumerableMap} from "../utils/structs/EnumerableMap.sol"; +import {BitMaps} from "../utils/structs/BitMaps.sol"; +import {Address} from "../utils/Address.sol"; +import {SignatureChecker} from "../utils/cryptography/SignatureChecker.sol"; import {Clones} from "../proxy/Clones.sol"; +import {Checkpoints} from "../utils/structs/Checkpoints.sol"; +import {ECDSA} from "../utils/cryptography/ECDSA.sol"; +import {Create2} from "../utils/Create2.sol"; +import {Arrays} from "../utils/Arrays.sol"; +import {ShortStrings} from "../utils/ShortStrings.sol"; +import {MerkleProof} from "../utils/cryptography/MerkleProof.sol"; +import {ERC1967Utils} from "../proxy/ERC1967/ERC1967Utils.sol"; +import {Math} from "../utils/math/Math.sol"; +import {DoubleEndedQueue} from "../utils/structs/DoubleEndedQueue.sol"; +import {StorageSlot} from "../utils/StorageSlot.sol"; +import {SafeERC20} from "../token/ERC20/utils/SafeERC20.sol"; +import {MessageHashUtils} from "../utils/cryptography/MessageHashUtils.sol"; +import {AuthorityUtils} from "../access/manager/AuthorityUtils.sol"; +import {ERC165Checker} from "../utils/introspection/ERC165Checker.sol"; +import {EnumerableSet} from "../utils/structs/EnumerableSet.sol"; +import {SignedMath} from "../utils/math/SignedMath.sol"; +import {Base64} from "../utils/Base64.sol"; + +contract Dummy1234 {} From 01a768baa683bd090b398c05e8a01e84cb7a4be4 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 27 Sep 2023 20:31:40 -0300 Subject: [PATCH 22/34] update hardhat-exposed --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 24463fff4ef..b1b91181550 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,7 @@ "glob": "^10.3.5", "graphlib": "^2.1.8", "hardhat": "^2.9.1", - "hardhat-exposed": "^0.3.12-0", + "hardhat-exposed": "^0.3.12-1", "hardhat-gas-reporter": "^1.0.4", "hardhat-ignore-warnings": "^0.2.0", "keccak256": "^1.0.2", @@ -8650,9 +8650,9 @@ } }, "node_modules/hardhat-exposed": { - "version": "0.3.12-0", - "resolved": "https://registry.npmjs.org/hardhat-exposed/-/hardhat-exposed-0.3.12-0.tgz", - "integrity": "sha512-frSUYPzZ8PjUqwgtvYnkO7nTUSDpFj8uSQj55n/oTjeXwEXrGksFlBcdkfBJr8exvI7ypohqNfbVTComwKRzQQ==", + "version": "0.3.12-1", + "resolved": "https://registry.npmjs.org/hardhat-exposed/-/hardhat-exposed-0.3.12-1.tgz", + "integrity": "sha512-hDhh+wC6usu/OPT4v6hi+JdBxZJDgi6gVAw/45ApY7rgODCqpan7+8GuVwOtu0YK/9wPN9Y065MzAVFqJtylgA==", "dev": true, "dependencies": { "micromatch": "^4.0.4", diff --git a/package.json b/package.json index 85ae14bfb6c..e250973991b 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "glob": "^10.3.5", "graphlib": "^2.1.8", "hardhat": "^2.9.1", - "hardhat-exposed": "^0.3.12-0", + "hardhat-exposed": "^0.3.12-1", "hardhat-gas-reporter": "^1.0.4", "hardhat-ignore-warnings": "^0.2.0", "keccak256": "^1.0.2", From e16c0ae42bb437c542fed1582b758a370febacf4 Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Thu, 28 Sep 2023 12:05:57 +0200 Subject: [PATCH 23/34] mark some contracts as stateless --- contracts/mocks/Stateless.sol | 41 +++++++++++-------- .../token/ERC1155/utils/ERC1155Holder.sol | 2 + contracts/token/ERC721/utils/ERC721Holder.sol | 2 + contracts/utils/Context.sol | 2 + contracts/utils/Multicall.sol | 2 + contracts/utils/introspection/ERC165.sol | 2 + 6 files changed, 33 insertions(+), 18 deletions(-) diff --git a/contracts/mocks/Stateless.sol b/contracts/mocks/Stateless.sol index 54ed05fccbf..84aaa1a53ef 100644 --- a/contracts/mocks/Stateless.sol +++ b/contracts/mocks/Stateless.sol @@ -4,30 +4,35 @@ pragma solidity ^0.8.20; // We keep these imports and a dummy contract just to we can run the test suite after transpilation. -import {Time} from "../utils/types/Time.sol"; -import {Strings} from "../utils/Strings.sol"; -import {SafeCast} from "../utils/math/SafeCast.sol"; -import {EnumerableMap} from "../utils/structs/EnumerableMap.sol"; -import {BitMaps} from "../utils/structs/BitMaps.sol"; import {Address} from "../utils/Address.sol"; -import {SignatureChecker} from "../utils/cryptography/SignatureChecker.sol"; -import {Clones} from "../proxy/Clones.sol"; +import {Arrays} from "../utils/Arrays.sol"; +import {AuthorityUtils} from "../access/manager/AuthorityUtils.sol"; +import {Base64} from "../utils/Base64.sol"; +import {BitMaps} from "../utils/structs/BitMaps.sol"; import {Checkpoints} from "../utils/structs/Checkpoints.sol"; -import {ECDSA} from "../utils/cryptography/ECDSA.sol"; +import {Clones} from "../proxy/Clones.sol"; +import {Context} from "../utils/Context.sol"; import {Create2} from "../utils/Create2.sol"; -import {Arrays} from "../utils/Arrays.sol"; -import {ShortStrings} from "../utils/ShortStrings.sol"; -import {MerkleProof} from "../utils/cryptography/MerkleProof.sol"; +import {DoubleEndedQueue} from "../utils/structs/DoubleEndedQueue.sol"; +import {ECDSA} from "../utils/cryptography/ECDSA.sol"; +import {ERC165} from "../utils/introspection/ERC165.sol"; +import {ERC721Holder} from "../tokens/ERC721/utils/ERC721Holder.sol"; +import {ERC1155Holder} from "../tokens/ERC1155/utils/ERC1155Holder.sol"; +import {EnumerableMap} from "../utils/structs/EnumerableMap.sol"; +import {EnumerableSet} from "../utils/structs/EnumerableSet.sol"; +import {ERC165Checker} from "../utils/introspection/ERC165Checker.sol"; import {ERC1967Utils} from "../proxy/ERC1967/ERC1967Utils.sol"; import {Math} from "../utils/math/Math.sol"; -import {DoubleEndedQueue} from "../utils/structs/DoubleEndedQueue.sol"; -import {StorageSlot} from "../utils/StorageSlot.sol"; -import {SafeERC20} from "../token/ERC20/utils/SafeERC20.sol"; +import {MerkleProof} from "../utils/cryptography/MerkleProof.sol"; import {MessageHashUtils} from "../utils/cryptography/MessageHashUtils.sol"; -import {AuthorityUtils} from "../access/manager/AuthorityUtils.sol"; -import {ERC165Checker} from "../utils/introspection/ERC165Checker.sol"; -import {EnumerableSet} from "../utils/structs/EnumerableSet.sol"; +import {Multicall} from "../utils/Multicall.sol"; +import {SafeCast} from "../utils/math/SafeCast.sol"; +import {SafeERC20} from "../token/ERC20/utils/SafeERC20.sol"; +import {ShortStrings} from "../utils/ShortStrings.sol"; +import {SignatureChecker} from "../utils/cryptography/SignatureChecker.sol"; import {SignedMath} from "../utils/math/SignedMath.sol"; -import {Base64} from "../utils/Base64.sol"; +import {StorageSlot} from "../utils/StorageSlot.sol"; +import {Strings} from "../utils/Strings.sol"; +import {Time} from "../utils/types/Time.sol"; contract Dummy1234 {} diff --git a/contracts/token/ERC1155/utils/ERC1155Holder.sol b/contracts/token/ERC1155/utils/ERC1155Holder.sol index 7c8d470e03a..6f353aa5953 100644 --- a/contracts/token/ERC1155/utils/ERC1155Holder.sol +++ b/contracts/token/ERC1155/utils/ERC1155Holder.sol @@ -11,6 +11,8 @@ import {IERC1155Receiver} from "../IERC1155Receiver.sol"; * * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be * stuck. + * + * @custom:stateless */ abstract contract ERC1155Holder is ERC165, IERC1155Receiver { /** diff --git a/contracts/token/ERC721/utils/ERC721Holder.sol b/contracts/token/ERC721/utils/ERC721Holder.sol index 4ffd16146b1..a7c4b03b555 100644 --- a/contracts/token/ERC721/utils/ERC721Holder.sol +++ b/contracts/token/ERC721/utils/ERC721Holder.sol @@ -11,6 +11,8 @@ import {IERC721Receiver} from "../IERC721Receiver.sol"; * Accepts all token transfers. * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or * {IERC721-setApprovalForAll}. + * + * @custom:stateless */ abstract contract ERC721Holder is IERC721Receiver { /** diff --git a/contracts/utils/Context.sol b/contracts/utils/Context.sol index 25e1159256e..8a74f248750 100644 --- a/contracts/utils/Context.sol +++ b/contracts/utils/Context.sol @@ -12,6 +12,8 @@ pragma solidity ^0.8.20; * is concerned). * * This contract is only required for intermediate, library-like contracts. + * + * @custom:stateless */ abstract contract Context { function _msgSender() internal view virtual returns (address) { diff --git a/contracts/utils/Multicall.sol b/contracts/utils/Multicall.sol index a9a3d3acf06..aa23e635bda 100644 --- a/contracts/utils/Multicall.sol +++ b/contracts/utils/Multicall.sol @@ -7,6 +7,8 @@ import {Address} from "./Address.sol"; /** * @dev Provides a function to batch together multiple calls in a single external call. + * + * @custom:stateless */ abstract contract Multicall { /** diff --git a/contracts/utils/introspection/ERC165.sol b/contracts/utils/introspection/ERC165.sol index 71c8e4a4f6d..1963a257dad 100644 --- a/contracts/utils/introspection/ERC165.sol +++ b/contracts/utils/introspection/ERC165.sol @@ -16,6 +16,8 @@ import {IERC165} from "./IERC165.sol"; * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` + * + * @custom:stateless */ abstract contract ERC165 is IERC165 { /** From 9dc5442deb9834cefe1f2f6042127f4152c97d49 Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Thu, 28 Sep 2023 12:10:05 +0200 Subject: [PATCH 24/34] sort --- contracts/mocks/Stateless.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/mocks/Stateless.sol b/contracts/mocks/Stateless.sol index 84aaa1a53ef..dd58d785907 100644 --- a/contracts/mocks/Stateless.sol +++ b/contracts/mocks/Stateless.sol @@ -15,13 +15,13 @@ import {Context} from "../utils/Context.sol"; import {Create2} from "../utils/Create2.sol"; import {DoubleEndedQueue} from "../utils/structs/DoubleEndedQueue.sol"; import {ECDSA} from "../utils/cryptography/ECDSA.sol"; -import {ERC165} from "../utils/introspection/ERC165.sol"; -import {ERC721Holder} from "../tokens/ERC721/utils/ERC721Holder.sol"; -import {ERC1155Holder} from "../tokens/ERC1155/utils/ERC1155Holder.sol"; import {EnumerableMap} from "../utils/structs/EnumerableMap.sol"; import {EnumerableSet} from "../utils/structs/EnumerableSet.sol"; +import {ERC1155Holder} from "../tokens/ERC1155/utils/ERC1155Holder.sol"; +import {ERC165} from "../utils/introspection/ERC165.sol"; import {ERC165Checker} from "../utils/introspection/ERC165Checker.sol"; import {ERC1967Utils} from "../proxy/ERC1967/ERC1967Utils.sol"; +import {ERC721Holder} from "../tokens/ERC721/utils/ERC721Holder.sol"; import {Math} from "../utils/math/Math.sol"; import {MerkleProof} from "../utils/cryptography/MerkleProof.sol"; import {MessageHashUtils} from "../utils/cryptography/MessageHashUtils.sol"; From 4771215cc3b2c4ac4d3dc816728766bf489b1cde Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Thu, 28 Sep 2023 12:28:06 +0200 Subject: [PATCH 25/34] Add peer dependency to package.json --- scripts/upgradeable/transpile.sh | 3 +++ scripts/upgradeable/upgradeable.patch | 33 +++++++++++++++++---------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/scripts/upgradeable/transpile.sh b/scripts/upgradeable/transpile.sh index 99ec1073458..d915f6204a8 100644 --- a/scripts/upgradeable/transpile.sh +++ b/scripts/upgradeable/transpile.sh @@ -2,9 +2,12 @@ set -euo pipefail -x +VERSION=$(jq -r .version package.json) DIRNAME="$(dirname -- "${BASH_SOURCE[0]}")" bash "$DIRNAME/patch-apply.sh" +sed -i "s//$VERSION/g" package.json +git add package.json npm run clean npm run compile diff --git a/scripts/upgradeable/upgradeable.patch b/scripts/upgradeable/upgradeable.patch index 125272a258b..7bb5c2813db 100644 --- a/scripts/upgradeable/upgradeable.patch +++ b/scripts/upgradeable/upgradeable.patch @@ -1,6 +1,6 @@ diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 -index 2797a088..00000000 +index 2797a0889..000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,21 +0,0 @@ @@ -26,7 +26,7 @@ index 2797a088..00000000 - - diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml -index 4018cef2..d343a53d 100644 +index 4018cef29..d343a53d8 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,4 +1,8 @@ @@ -40,7 +40,7 @@ index 4018cef2..d343a53d 100644 about: Ask in the OpenZeppelin Forum diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 -index ff596b0c..00000000 +index ff596b0c3..000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,14 +0,0 @@ @@ -59,10 +59,10 @@ index ff596b0c..00000000 - - diff --git a/README.md b/README.md -index 38197f3a..bc934d1c 100644 +index 6446c4f7e..dce3623fd 100644 --- a/README.md +++ b/README.md -@@ -19,6 +19,9 @@ +@@ -20,6 +20,9 @@ :building_construction: **Want to scale your decentralized application?** Check out [OpenZeppelin Defender](https://openzeppelin.com/defender) — a secure platform for automating and monitoring your operations. @@ -72,7 +72,7 @@ index 38197f3a..bc934d1c 100644 ## Overview ### Installation -@@ -26,7 +29,7 @@ +@@ -27,7 +30,7 @@ #### Hardhat, Truffle (npm) ``` @@ -81,7 +81,7 @@ index 38197f3a..bc934d1c 100644 ``` OpenZeppelin Contracts features a [stable API](https://docs.openzeppelin.com/contracts/releases-stability#api-stability), which means that your contracts won't break unexpectedly when upgrading to a newer minor version. -@@ -38,10 +41,10 @@ OpenZeppelin Contracts features a [stable API](https://docs.openzeppelin.com/con +@@ -39,10 +42,10 @@ OpenZeppelin Contracts features a [stable API](https://docs.openzeppelin.com/con > **Warning** Foundry installs the latest version initially, but subsequent `forge update` commands will use the `master` branch. ``` @@ -94,7 +94,7 @@ index 38197f3a..bc934d1c 100644 ### Usage -@@ -50,10 +53,11 @@ Once installed, you can use the contracts in the library by importing them: +@@ -51,10 +54,11 @@ Once installed, you can use the contracts in the library by importing them: ```solidity pragma solidity ^0.8.20; @@ -110,7 +110,7 @@ index 38197f3a..bc934d1c 100644 } ``` diff --git a/contracts/package.json b/contracts/package.json -index df141192..1cf90ad1 100644 +index 9017953ca..c6eec1a88 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -1,5 +1,5 @@ @@ -130,7 +130,7 @@ index df141192..1cf90ad1 100644 "keywords": [ "solidity", diff --git a/contracts/utils/cryptography/EIP712.sol b/contracts/utils/cryptography/EIP712.sol -index 3800804a..90c1db78 100644 +index 644f6f531..ab8ba05ff 100644 --- a/contracts/utils/cryptography/EIP712.sol +++ b/contracts/utils/cryptography/EIP712.sol @@ -4,7 +4,6 @@ @@ -297,7 +297,7 @@ index 3800804a..90c1db78 100644 } } diff --git a/package.json b/package.json -index ffa868ac..e254d962 100644 +index e25097399..f2e8d1cee 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ @@ -309,8 +309,17 @@ index ffa868ac..e254d962 100644 }, "keywords": [ "solidity", +@@ -92,5 +92,8 @@ + "undici": "^5.22.1", + "web3": "^1.3.0", + "yargs": "^17.0.0" ++ }, ++ "peerDependencies": { ++ "@openzeppelin/contracts": "" + } + } diff --git a/test/utils/cryptography/EIP712.test.js b/test/utils/cryptography/EIP712.test.js -index 7ea535b7..32e3a370 100644 +index faf01f1a3..b25171a56 100644 --- a/test/utils/cryptography/EIP712.test.js +++ b/test/utils/cryptography/EIP712.test.js @@ -47,26 +47,6 @@ contract('EIP712', function (accounts) { From 4ca92e20fcd8f9d44d0b8beecab8cf8715ca3c36 Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Thu, 28 Sep 2023 12:33:22 +0200 Subject: [PATCH 26/34] fix import path --- contracts/mocks/Stateless.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/mocks/Stateless.sol b/contracts/mocks/Stateless.sol index dd58d785907..173a7da6326 100644 --- a/contracts/mocks/Stateless.sol +++ b/contracts/mocks/Stateless.sol @@ -17,11 +17,11 @@ import {DoubleEndedQueue} from "../utils/structs/DoubleEndedQueue.sol"; import {ECDSA} from "../utils/cryptography/ECDSA.sol"; import {EnumerableMap} from "../utils/structs/EnumerableMap.sol"; import {EnumerableSet} from "../utils/structs/EnumerableSet.sol"; -import {ERC1155Holder} from "../tokens/ERC1155/utils/ERC1155Holder.sol"; +import {ERC1155Holder} from "../token/ERC1155/utils/ERC1155Holder.sol"; import {ERC165} from "../utils/introspection/ERC165.sol"; import {ERC165Checker} from "../utils/introspection/ERC165Checker.sol"; import {ERC1967Utils} from "../proxy/ERC1967/ERC1967Utils.sol"; -import {ERC721Holder} from "../tokens/ERC721/utils/ERC721Holder.sol"; +import {ERC721Holder} from "../token/ERC721/utils/ERC721Holder.sol"; import {Math} from "../utils/math/Math.sol"; import {MerkleProof} from "../utils/cryptography/MerkleProof.sol"; import {MessageHashUtils} from "../utils/cryptography/MessageHashUtils.sol"; From b32037311da47cdc8211fd0ae4f6b718d6c49a8d Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Thu, 28 Sep 2023 13:51:27 +0200 Subject: [PATCH 27/34] cleanup --- contracts/mocks/Stateless.sol | 2 -- 1 file changed, 2 deletions(-) diff --git a/contracts/mocks/Stateless.sol b/contracts/mocks/Stateless.sol index 173a7da6326..56f5b4c6610 100644 --- a/contracts/mocks/Stateless.sol +++ b/contracts/mocks/Stateless.sol @@ -11,7 +11,6 @@ import {Base64} from "../utils/Base64.sol"; import {BitMaps} from "../utils/structs/BitMaps.sol"; import {Checkpoints} from "../utils/structs/Checkpoints.sol"; import {Clones} from "../proxy/Clones.sol"; -import {Context} from "../utils/Context.sol"; import {Create2} from "../utils/Create2.sol"; import {DoubleEndedQueue} from "../utils/structs/DoubleEndedQueue.sol"; import {ECDSA} from "../utils/cryptography/ECDSA.sol"; @@ -25,7 +24,6 @@ import {ERC721Holder} from "../token/ERC721/utils/ERC721Holder.sol"; import {Math} from "../utils/math/Math.sol"; import {MerkleProof} from "../utils/cryptography/MerkleProof.sol"; import {MessageHashUtils} from "../utils/cryptography/MessageHashUtils.sol"; -import {Multicall} from "../utils/Multicall.sol"; import {SafeCast} from "../utils/math/SafeCast.sol"; import {SafeERC20} from "../token/ERC20/utils/SafeERC20.sol"; import {ShortStrings} from "../utils/ShortStrings.sol"; From 268e17f6d0b99902cf0b09e87662709c809a199a Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Thu, 28 Sep 2023 17:41:03 +0200 Subject: [PATCH 28/34] mark UUPSUpgradeable as stateless --- contracts/proxy/utils/UUPSUpgradeable.sol | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contracts/proxy/utils/UUPSUpgradeable.sol b/contracts/proxy/utils/UUPSUpgradeable.sol index f08e61c1e8b..045d6a326a6 100644 --- a/contracts/proxy/utils/UUPSUpgradeable.sol +++ b/contracts/proxy/utils/UUPSUpgradeable.sol @@ -15,6 +15,8 @@ import {ERC1967Utils} from "../ERC1967/ERC1967Utils.sol"; * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. + * + * @custom:stateless */ abstract contract UUPSUpgradeable is IERC1822Proxiable { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable From 242b7163392f14039a0eecafbc951ed768005598 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Thu, 28 Sep 2023 13:29:39 -0300 Subject: [PATCH 29/34] add changeset --- .changeset/grumpy-poets-rush.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/grumpy-poets-rush.md diff --git a/.changeset/grumpy-poets-rush.md b/.changeset/grumpy-poets-rush.md new file mode 100644 index 00000000000..e566a10fecf --- /dev/null +++ b/.changeset/grumpy-poets-rush.md @@ -0,0 +1,5 @@ +--- +'openzeppelin-solidity': major +--- + +Upgradeable Contracts: No longer transpile interfaces, libraries, and stateless contracts. From 8d8030bed3e2d4d73a2f22c4de4ac7a0d68ec800 Mon Sep 17 00:00:00 2001 From: Francisco Date: Thu, 28 Sep 2023 16:26:50 -0300 Subject: [PATCH 30/34] Update .github/workflows/checks.yml Co-authored-by: Hadrien Croubois --- .github/workflows/checks.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 5c7ad1cbe6a..54a753b6644 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -58,14 +58,9 @@ jobs: uses: ./.github/actions/setup - name: Transpile to upgradeable run: bash scripts/upgradeable/transpile.sh - - name: Check out copy of vanilla - uses: actions/checkout@v4 - with: - path: .vanilla - - name: Install vanilla as dependency - run: | - mkdir -p node_modules/@openzeppelin - ln -sr ".vanilla/contracts" node_modules/@openzeppelin/contracts + - name: Copy non-upgradeable contracts as dependency + run: + cp -rnT contracts node_modules/@openzeppelin/contracts - name: Run tests run: npm run test - name: Check linearisation of the inheritance graph From f63cf2da50589f776a2f0eabf045c2b679d6a3ca Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Thu, 28 Sep 2023 17:01:28 -0300 Subject: [PATCH 31/34] simplify prepack --- package.json | 1 - scripts/prepack.sh | 10 +++------- scripts/remove-ignored-artifacts.js | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index e250973991b..3a1617c097d 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,6 @@ "private": true, "files": [ "/contracts/**/*.sol", - "/build/contracts/*.json", "!/contracts/mocks/**/*" ], "scripts": { diff --git a/scripts/prepack.sh b/scripts/prepack.sh index 19c8809a857..6af10329f66 100755 --- a/scripts/prepack.sh +++ b/scripts/prepack.sh @@ -15,13 +15,9 @@ npm run clean env COMPILE_MODE=production npm run compile -mkdirp build/contracts -cp artifacts/contracts/**/*.json build/contracts -rm build/contracts/*.dbg.json - +mkdirp contracts/build/contracts +cp artifacts/contracts/**/*.json contracts/build/contracts +rm contracts/build/contracts/*.dbg.json node scripts/remove-ignored-artifacts.js cp README.md contracts/ - -mkdirp contracts/build/contracts -cp -r build/contracts/*.json contracts/build/contracts diff --git a/scripts/remove-ignored-artifacts.js b/scripts/remove-ignored-artifacts.js index f3e45b8d1b2..e156032b17c 100644 --- a/scripts/remove-ignored-artifacts.js +++ b/scripts/remove-ignored-artifacts.js @@ -23,7 +23,7 @@ const ignorePatternsSubtrees = ignorePatterns .concat(ignorePatterns.map(pat => path.join(pat, '**/*'))) .map(p => p.replace(/^\//, '')); -const artifactsDir = 'build/contracts'; +const artifactsDir = 'contracts/build/contracts'; const buildinfo = 'artifacts/build-info'; const filenames = fs.readdirSync(buildinfo); From 86ebb2e54a1995079d49917492d7b1f8106f6033 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Thu, 28 Sep 2023 17:02:41 -0300 Subject: [PATCH 32/34] fix order of transpilation --- .github/workflows/checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 54a753b6644..3e7cba1201e 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -56,11 +56,11 @@ jobs: fetch-depth: 0 # Include history so patch conflicts are resolved automatically - name: Set up environment uses: ./.github/actions/setup - - name: Transpile to upgradeable - run: bash scripts/upgradeable/transpile.sh - name: Copy non-upgradeable contracts as dependency run: cp -rnT contracts node_modules/@openzeppelin/contracts + - name: Transpile to upgradeable + run: bash scripts/upgradeable/transpile.sh - name: Run tests run: npm run test - name: Check linearisation of the inheritance graph From b51a866989babff4d7e922ec69c3db4ab5872fc9 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Thu, 28 Sep 2023 17:31:06 -0300 Subject: [PATCH 33/34] fix location where peer dependency is added --- scripts/upgradeable/transpile.sh | 6 ++--- scripts/upgradeable/upgradeable.patch | 34 +++++++++++++-------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/scripts/upgradeable/transpile.sh b/scripts/upgradeable/transpile.sh index d915f6204a8..eb00bc1d67b 100644 --- a/scripts/upgradeable/transpile.sh +++ b/scripts/upgradeable/transpile.sh @@ -2,12 +2,12 @@ set -euo pipefail -x -VERSION=$(jq -r .version package.json) +VERSION="$(jq -r .version package.json)" DIRNAME="$(dirname -- "${BASH_SOURCE[0]}")" bash "$DIRNAME/patch-apply.sh" -sed -i "s//$VERSION/g" package.json -git add package.json +sed -i "s//$VERSION/g" contracts/package.json +git add contracts/package.json npm run clean npm run compile diff --git a/scripts/upgradeable/upgradeable.patch b/scripts/upgradeable/upgradeable.patch index 62abea3b58b..f25710cdec7 100644 --- a/scripts/upgradeable/upgradeable.patch +++ b/scripts/upgradeable/upgradeable.patch @@ -59,7 +59,7 @@ index ff596b0c3..000000000 - - diff --git a/README.md b/README.md -index 53c29e5f8..59f72a542 100644 +index 549891e3f..a6b24078e 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,9 @@ @@ -81,8 +81,8 @@ index 53c29e5f8..59f72a542 100644 ``` #### Foundry (git) -@@ -40,10 +43,10 @@ $ npm install @openzeppelin/contracts - > **Warning** Foundry installs the latest version initially, but subsequent `forge update` commands will use the `master` branch. +@@ -42,10 +45,10 @@ $ npm install @openzeppelin/contracts + > Foundry installs the latest version initially, but subsequent `forge update` commands will use the `master` branch. ``` -$ forge install OpenZeppelin/openzeppelin-contracts @@ -94,7 +94,7 @@ index 53c29e5f8..59f72a542 100644 ### Usage -@@ -52,10 +55,11 @@ Once installed, you can use the contracts in the library by importing them: +@@ -54,10 +57,11 @@ Once installed, you can use the contracts in the library by importing them: ```solidity pragma solidity ^0.8.20; @@ -110,7 +110,7 @@ index 53c29e5f8..59f72a542 100644 } ``` diff --git a/contracts/package.json b/contracts/package.json -index 9017953ca..c6eec1a88 100644 +index 9017953ca..f51c1d38b 100644 --- a/contracts/package.json +++ b/contracts/package.json @@ -1,5 +1,5 @@ @@ -129,6 +129,16 @@ index 9017953ca..c6eec1a88 100644 }, "keywords": [ "solidity", +@@ -28,5 +28,8 @@ + "bugs": { + "url": "https://github.com/OpenZeppelin/openzeppelin-contracts/issues" + }, +- "homepage": "https://openzeppelin.com/contracts/" ++ "homepage": "https://openzeppelin.com/contracts/", ++ "peerDependencies": { ++ "@openzeppelin/contracts": "" ++ } + } diff --git a/contracts/utils/cryptography/EIP712.sol b/contracts/utils/cryptography/EIP712.sol index 644f6f531..ab8ba05ff 100644 --- a/contracts/utils/cryptography/EIP712.sol @@ -297,10 +307,10 @@ index 644f6f531..ab8ba05ff 100644 } } diff --git a/package.json b/package.json -index e25097399..fbcc10d88 100644 +index 3a1617c09..97e59c2d9 100644 --- a/package.json +++ b/package.json -@@ -33,7 +33,7 @@ +@@ -32,7 +32,7 @@ }, "repository": { "type": "git", @@ -309,16 +319,6 @@ index e25097399..fbcc10d88 100644 }, "keywords": [ "solidity", -@@ -49,6 +49,9 @@ - "url": "https://github.com/OpenZeppelin/openzeppelin-contracts/issues" - }, - "homepage": "https://openzeppelin.com/contracts/", -+ "peerDependencies": { -+ "@openzeppelin/contracts": "" -+ }, - "devDependencies": { - "@changesets/changelog-github": "^0.4.8", - "@changesets/cli": "^2.26.0", diff --git a/test/utils/cryptography/EIP712.test.js b/test/utils/cryptography/EIP712.test.js index faf01f1a3..b25171a56 100644 --- a/test/utils/cryptography/EIP712.test.js From 5336454db307dc106b23c6f3d7bc1c2cd587ad9c Mon Sep 17 00:00:00 2001 From: Hadrien Croubois Date: Thu, 28 Sep 2023 22:50:06 +0200 Subject: [PATCH 34/34] read package version from contracts/package.json --- scripts/upgradeable/transpile.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgradeable/transpile.sh b/scripts/upgradeable/transpile.sh index eb00bc1d67b..f2126936ca7 100644 --- a/scripts/upgradeable/transpile.sh +++ b/scripts/upgradeable/transpile.sh @@ -2,7 +2,7 @@ set -euo pipefail -x -VERSION="$(jq -r .version package.json)" +VERSION="$(jq -r .version contracts/package.json)" DIRNAME="$(dirname -- "${BASH_SOURCE[0]}")" bash "$DIRNAME/patch-apply.sh"