Skip to content

Commit

Permalink
Update remappings.txt for upgradeable contracts and set up submodule (#…
Browse files Browse the repository at this point in the history
…4639)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
Co-authored-by: Ernesto García <ernestognw@gmail.com>
  • Loading branch information
3 people authored Oct 2, 2023
1 parent 5ed5a86 commit abba0d0
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 34 deletions.
4 changes: 4 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ runs:
run: npm ci
shell: bash
if: steps.cache.outputs.cache-hit != 'true'
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
11 changes: 5 additions & 6 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ jobs:
- name: Set up environment
uses: ./.github/actions/setup
- name: Copy non-upgradeable contracts as dependency
run:
cp -rnT contracts node_modules/@openzeppelin/contracts
run: |
mkdir -p lib/openzeppelin-contracts
cp -rnT contracts lib/openzeppelin-contracts/contracts
- name: Transpile to upgradeable
run: bash scripts/upgradeable/transpile.sh
- name: Run tests
Expand All @@ -78,10 +79,8 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Set up environment
uses: ./.github/actions/setup
- name: Run tests
run: forge test -vv

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/upgradeable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ jobs:
- run: bash scripts/git-user-config.sh
- name: Transpile to upgradeable
run: bash scripts/upgradeable/transpile-onto.sh ${{ github.ref_name }} origin/${{ github.ref_name }}
env:
SUBMODULE_REMOTE: https://github.com/${{ github.repository }}.git
- run: git push origin ${{ github.ref_name }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ contracts-exposed

# Foundry
/out
/cache_forge

# Certora
.certora*
Expand Down
2 changes: 0 additions & 2 deletions contracts/proxy/utils/UUPSUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ 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
Expand Down
2 changes: 0 additions & 2 deletions contracts/token/ERC1155/utils/ERC1155Holder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ 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 {
/**
Expand Down
2 changes: 0 additions & 2 deletions contracts/token/ERC721/utils/ERC721Holder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ 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 {
/**
Expand Down
2 changes: 0 additions & 2 deletions contracts/utils/Context.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ 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) {
Expand Down
2 changes: 0 additions & 2 deletions contracts/utils/Multicall.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {Address} from "./Address.sol";

/**
* @dev Provides a function to batch together multiple calls in a single external call.
*
* @custom:stateless
*/
abstract contract Multicall {
/**
Expand Down
2 changes: 0 additions & 2 deletions contracts/utils/introspection/ERC165.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import {IERC165} from "./IERC165.sol";
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* @custom:stateless
*/
abstract contract ERC165 is IERC165 {
/**
Expand Down
7 changes: 7 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
[profile.default]
src = 'contracts'
out = 'out'
libs = ['node_modules', 'lib']
test = 'test'
cache_path = 'cache_forge'

[fuzz]
runs = 10000
max_test_rejects = 150000
13 changes: 12 additions & 1 deletion hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

const fs = require('fs');
const path = require('path');
const proc = require('child_process');

const argv = require('yargs/yargs')()
.env('')
.options({
Expand Down Expand Up @@ -37,6 +39,11 @@ const argv = require('yargs/yargs')()
type: 'boolean',
default: false,
},
foundry: {
alias: 'hasFoundry',
type: 'boolean',
default: hasFoundry(),
},
compiler: {
alias: 'compileVersion',
type: 'string',
Expand All @@ -51,8 +58,8 @@ const argv = require('yargs/yargs')()
require('@nomiclabs/hardhat-truffle5');
require('hardhat-ignore-warnings');
require('hardhat-exposed');

require('solidity-docgen');
argv.foundry && require('@nomicfoundation/hardhat-foundry');

for (const f of fs.readdirSync(path.join(__dirname, 'hardhat'))) {
require(path.join(__dirname, 'hardhat', f));
Expand Down Expand Up @@ -114,3 +121,7 @@ if (argv.coverage) {
require('solidity-coverage');
module.exports.networks.hardhat.initialBaseFeePerGas = 0;
}

function hasFoundry() {
return proc.spawnSync('forge', ['-V'], { stdio: 'ignore' }).error === undefined;
}
29 changes: 21 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@
"@changesets/cli": "^2.26.0",
"@changesets/pre": "^1.0.14",
"@changesets/read": "^0.5.9",
"@nomicfoundation/hardhat-foundry": "^1.1.1",
"@nomicfoundation/hardhat-network-helpers": "^1.0.3",
"@nomiclabs/hardhat-truffle5": "^2.0.5",
"@nomiclabs/hardhat-web3": "^2.0.0",
"@openzeppelin/docs-utils": "^0.1.4",
"@openzeppelin/test-helpers": "^0.5.13",
"@openzeppelin/upgrade-safe-transpiler": "^0.3.30",
"@openzeppelin/upgrade-safe-transpiler": "^0.3.32",
"@openzeppelin/upgrades-core": "^1.20.6",
"array.prototype.at": "^1.1.1",
"chai": "^4.2.0",
Expand All @@ -70,7 +71,7 @@
"glob": "^10.3.5",
"graphlib": "^2.1.8",
"hardhat": "^2.9.1",
"hardhat-exposed": "^0.3.12-1",
"hardhat-exposed": "^0.3.13",
"hardhat-gas-reporter": "^1.0.9",
"hardhat-ignore-warnings": "^0.2.0",
"keccak256": "^1.0.2",
Expand Down
20 changes: 15 additions & 5 deletions scripts/upgradeable/transpile-onto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ base="${2-}"
bash scripts/upgradeable/transpile.sh

commit="$(git rev-parse --short HEAD)"
branch="$(git rev-parse --abbrev-ref HEAD)"
start_branch="$(git rev-parse --abbrev-ref HEAD)"

git add contracts

Expand All @@ -36,9 +36,19 @@ else
fi
fi

# commit if there are changes to commit
if ! git diff --quiet --cached; then
git commit -m "Transpile $commit"
# abort if there are no changes to commit at this point
if git diff --quiet --cached; then
exit
fi

git checkout "$branch"
if [[ -v SUBMODULE_REMOTE ]]; then
lib=lib/openzeppelin-contracts
git submodule add -b "${base#origin/}" "$SUBMODULE_REMOTE" "$lib"
git -C "$lib" checkout "$commit"
git add "$lib"
fi

git commit -m "Transpile $commit"

# return to original branch
git checkout "$start_branch"
8 changes: 8 additions & 0 deletions scripts/upgradeable/upgradeable.patch
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,14 @@ index 3a1617c09..97e59c2d9 100644
},
"keywords": [
"solidity",
diff --git a/remappings.txt b/remappings.txt
index 304d1386a..a1cd63bee 100644
--- a/remappings.txt
+++ b/remappings.txt
@@ -1 +1,2 @@
-@openzeppelin/contracts/=contracts/
+@openzeppelin/contracts-upgradeable/=contracts/
+@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
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
Expand Down

0 comments on commit abba0d0

Please sign in to comment.