Skip to content

Commit

Permalink
No remapping for hardhat (#142)
Browse files Browse the repository at this point in the history
To test it, run npx hardhat compile and then one more time. Caching should hit in, then.

Background: We want to get rid of the remapping usages in hardhat, as it has bugs. The solution is: we just install the deps twice: once via git submodule for foundry and once via npm for hardhat.
We use in the contract only the npm packages, but allow foundry to remap to submodules for its purposes.

Longterm we wanna switch to hardhat tests and away from foundry
  • Loading branch information
josojo authored Jan 3, 2024
1 parent 4147dfc commit 602a291
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 125 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ tests/python/venv/
yarn-error.log
venv

contracts/hardhat-dependency-compiler/
records.json
stats.json
.awcache
Expand Down
21 changes: 3 additions & 18 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = {
dependencyCompiler: {
paths: [
'@openzeppelin/contracts/token/ERC20/presets/ERC20PresetFixedSupply.sol',
'@openzeppelin/contracts/mocks/ERC20PermitMock.sol',
'@RealityETH/zkevm-contracts/contracts/mocks/ERC20PermitMock.sol',
'@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol',
'@RealityETH/zkevm-contracts/contracts/deployment/PolygonZkEVMDeployer.sol',
'@RealityETH/zkevm-contracts/contracts/PolygonZkEVMGlobalExitRootL2.sol',
Expand All @@ -40,23 +40,8 @@ module.exports = {
'@RealityETH/zkevm-contracts/contracts/mocks/PolygonZkEVMMock.sol',
'@RealityETH/zkevm-contracts/contracts/verifiers/FflonkVerifier.sol',
'@RealityETH/zkevm-contracts/contracts/PolygonZkEVMBridgeWrapper.sol',
], // ,
// keep: true
},
preprocess: {
eachLine: (hre) => ({
transform: (line) => {
if (line.match(/^\s*import /i)) {
for (const [from, to] of getRemappings()) {
if (line.includes(from)) {
line = line.replace(from, to);
break;
}
}
}
return line;
},
}),
],
keep: true,
},
paths: {
sources: './contracts/',
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@
"ethereum-waffle": "^3.4.4",
"ethers": "^5.7.2",
"forge": "^2.3.0",
"hardhat": "^2.13.0"
"hardhat": "^2.19.4"
},
"devDependencies": {
"@0xpolygonhermez/zkevm-commonjs": "github:0xPolygonHermez/zkevm-commonjs#v3.0.0-fork.6",
"@nomiclabs/hardhat-ethers": "^2.2.2",
"@nomiclabs/hardhat-ethers": "^2.2.3",
"@nomiclabs/hardhat-etherscan": "^3.1.7",
"@nomiclabs/hardhat-waffle": "^2.0.6",
"@RealityETH/zkevm-contracts": "github:RealityETH/zkevm-contracts#v3.0.0-RealityETH",
"@openzeppelin/contracts": "4.8.2",
"@openzeppelin/contracts-upgradeable": "4.8.2",
"@openzeppelin/hardhat-upgrades": "1.22.1",
Expand Down
Loading

0 comments on commit 602a291

Please sign in to comment.