-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable partial transpilation for upgradeable package #4628
Changes from all commits
0f54291
b4a9a76
f648bfe
3910fbc
270c006
df08dd7
59746e6
e904e02
0f2bafe
8002e8d
9e2dcf1
0ff2901
5d8422f
de7a277
63acb32
5f0c801
b6476c1
448d8f6
0f7c3e2
7246dbb
ef88118
01a768b
e16c0ae
9dc5442
4771215
4ca92e2
b320373
268e17f
781d5f2
242b716
8d8030b
f63cf2d
86ebb2e
9e1ce8d
b51a866
5336454
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'openzeppelin-solidity': major | ||
--- | ||
|
||
Upgradeable Contracts: No longer transpile interfaces, libraries, and stateless contracts. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,3 @@ runs: | |
run: npm ci | ||
shell: bash | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
env: | ||
SKIP_COMPILE: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.20; | ||
|
||
// We keep these imports and a dummy contract just to we can run the test suite after transpilation. | ||
|
||
import {Address} from "../utils/Address.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 {Clones} from "../proxy/Clones.sol"; | ||
import {Create2} from "../utils/Create2.sol"; | ||
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 "../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 "../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 {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 {StorageSlot} from "../utils/StorageSlot.sol"; | ||
import {Strings} from "../utils/Strings.sol"; | ||
import {Time} from "../utils/types/Time.sol"; | ||
|
||
contract Dummy1234 {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,7 @@ module.exports = { | |
}, | ||
}, | ||
exposed: { | ||
imports: true, | ||
initializers: true, | ||
exclude: ['vendor/**/*'], | ||
}, | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,12 @@ | |
|
||
set -euo pipefail -x | ||
|
||
VERSION="$(jq -r .version contracts/package.json)" | ||
DIRNAME="$(dirname -- "${BASH_SOURCE[0]}")" | ||
|
||
bash "$DIRNAME/patch-apply.sh" | ||
sed -i "s/<package-version>/$VERSION/g" contracts/package.json | ||
git add contracts/package.json | ||
|
||
npm run clean | ||
npm run compile | ||
|
@@ -24,7 +27,8 @@ fi | |
# -p: emit public initializer | ||
# -n: use namespaces | ||
# -N: exclude from namespaces transformation | ||
npx @openzeppelin/upgrade-safe-transpiler@latest -D \ | ||
# -q: partial transpilation using @openzeppelin/contracts as peer project | ||
npx @openzeppelin/upgrade-safe-transpiler -D \ | ||
-b "$build_info" \ | ||
-i contracts/proxy/utils/Initializable.sol \ | ||
-x 'contracts-exposed/**/*' \ | ||
|
@@ -36,7 +40,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/' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Amxx Does this look right to you? We have to do this because the contract source paths already have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used to do We can change to a remaping / remapings in a further version of the transpiler |
||
|
||
# delete compilation artifacts of vanilla code | ||
npm run clean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure the build are getting in ?
The line above only gets solidity files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, the entier "files" section of this package.json is probably useless
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the root package.json, that we don't publish any more. This
"files"
field probably doesn't matter but I preferred keeping it and just removing the directory that will no longer be there.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My reasoning is that there may be some workflow that relies on
npm pack
at the root, I don't know.