Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion contracts/mocks/import.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

pragma solidity ^0.8.31;

// This file forces the compilation of contracts that are only used (as artifacts) in tests.
// This file lists the dependencies that the tests deploy. Hardhat 3 only emits artifacts for compilation roots, so
// these contracts get no artifact of their own. Importing them by name (with `exposed.imports`) makes the exposed
// plugin generate their `$`-prefixed versions, which are roots: the tests deploy these.
// forge-lint: disable-start(unused-import)
import {AccessManager} from "@openzeppelin/contracts/access/manager/AccessManager.sol";
import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import {AccountERC7913Mock} from "@openzeppelin/contracts/mocks/account/AccountMock.sol";
import {ERC20Reentrant} from "@openzeppelin/contracts/mocks/token/ERC20Reentrant.sol";
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
import {CallReceiverMock} from "@openzeppelin/contracts/mocks/CallReceiverMock.sol";
import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";
import {ERC7913P256Verifier} from "@openzeppelin/contracts/utils/cryptography/verifiers/ERC7913P256Verifier.sol";
import {ERC7913RSAVerifier} from "@openzeppelin/contracts/utils/cryptography/verifiers/ERC7913RSAVerifier.sol";
// forge-lint: disable-end(unused-import)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import {ECDSAOwnedDKIMRegistry} from "@zk-email/email-tx-builder/src/utils/ECDSAOwnedDKIMRegistry.sol";

// Hardhat 3 only emits artifacts for contracts declared in a compilation root. The exposed version of
// `ECDSAOwnedDKIMRegistry` can't be used instead: its constructor runs the initializer, so `initialize` can't be called.
contract ECDSAOwnedDKIMRegistryMock is ECDSAOwnedDKIMRegistry {}
21 changes: 4 additions & 17 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ const argv = await yargs()

// `remappings.txt` points `@openzeppelin/contracts` to the submodule, which is what Foundry (and projects that install
// this repository with `forge install`) need. Hardhat must instead resolve it through `node_modules`, as an npm
// package, for `npmFilesToBuild` to accept its files and for every dependency to share a single copy (the
// `zk-email-verify` submodule resolves `@openzeppelin/contracts` through npm). These remappings take precedence over
// the ones of `remappings.txt` for Hardhat only.
// package, so that every dependency shares a single copy (the `zk-email-verify` submodule resolves
// `@openzeppelin/contracts` through npm). These remappings take precedence over the ones of `remappings.txt` for
// Hardhat only.
const hardhatRemappings = [
'@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/contracts/',
'lib/@openzeppelin-contracts-upgradeable/contracts/:@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/contracts/',
Expand All @@ -55,11 +55,7 @@ export default defineConfig({
hardhatRemappingsPlugin(hardhatRemappings),
],
paths: {
// `ECDSAOwnedDKIMRegistry` is needed (as-is, not exposed) by the tests. It lives in a submodule reached through a
// remappings.txt entry, so it is a project file that no compilation root imports by name: `npmFilesToBuild` cannot
// reach it (HHE901), and being imported is not enough for Hardhat 3 to emit an artifact. Building its directory as
// a source directory is what makes those artifacts appear.
sources: [argv.src, 'lib/email-tx-builder/packages/contracts/src/utils'],
sources: argv.src,
},
solidity: {
version: argv.compiler,
Expand All @@ -68,15 +64,6 @@ export default defineConfig({
// files, which points `@openzeppelin/contracts` to a nested copy. The last entry of `remappings.txt` (and of
// `hardhatRemappings`) uses a more specific context so that the submodule uses the same copy as the rest of the
// project. (Comments are not allowed in `remappings.txt` as Foundry rejects them.)
//
// Dependencies that the tests deploy directly. Hardhat 3 only emits artifacts for compilation roots, so importing
// them from a solidity file (the old `contracts/mocks/import.sol` trick) is not enough anymore.
npmFilesToBuild: [
'@openzeppelin/contracts/mocks/CallReceiverMock.sol',
'@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol',
'@openzeppelin/contracts/utils/cryptography/verifiers/ERC7913P256Verifier.sol',
'@openzeppelin/contracts/utils/cryptography/verifiers/ERC7913RSAVerifier.sol',
],
settings: {
optimizer: {
enabled: true,
Expand Down
31 changes: 23 additions & 8 deletions scripts/upgradeable/upgradeable.patch
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,23 @@ index dbce31e2..074338a3 100644
## Overview

This repository contains contracts and libraries in the following categories:
diff --git a/contracts/mocks/utils/cryptography/ECDSAOwnedDKIMRegistryMock.sol b/contracts/mocks/utils/cryptography/ECDSAOwnedDKIMRegistryMock.sol
deleted file mode 100644
index 42f38173..00000000
--- a/contracts/mocks/utils/cryptography/ECDSAOwnedDKIMRegistryMock.sol
+++ /dev/null
@@ -1,9 +0,0 @@
-// SPDX-License-Identifier: MIT
-
-pragma solidity ^0.8.20;
-
-import {ECDSAOwnedDKIMRegistry} from "@zk-email/email-tx-builder/src/utils/ECDSAOwnedDKIMRegistry.sol";
-
-// Hardhat 3 only emits artifacts for contracts declared in a compilation root. The exposed version of
-// `ECDSAOwnedDKIMRegistry` can't be used instead: its constructor runs the initializer, so `initialize` can't be called.
-contract ECDSAOwnedDKIMRegistryMock is ECDSAOwnedDKIMRegistry {}
diff --git a/hardhat.config.ts b/hardhat.config.ts
index 04f89f0c..bb081161 100644
index 3a1398a4..20f84513 100644
--- a/hardhat.config.ts
+++ b/hardhat.config.ts
@@ -35,6 +35,7 @@ const argv = await yargs()
Expand All @@ -26,16 +41,16 @@ index 04f89f0c..bb081161 100644
];

// Configuration
@@ -59,7 +60,7 @@ export default defineConfig({
// remappings.txt entry, so it is a project file that no compilation root imports by name: `npmFilesToBuild` cannot
// reach it (HHE901), and being imported is not enough for Hardhat 3 to emit an artifact. Building its directory as
// a source directory is what makes those artifacts appear.
- sources: [argv.src, 'lib/email-tx-builder/packages/contracts/src/utils'],
+ sources: [argv.src, 'lib/openzeppelin-community-contracts/contracts', 'lib/email-tx-builder/packages/contracts/src/utils'],
@@ -55,7 +56,7 @@ export default defineConfig({
hardhatRemappingsPlugin(hardhatRemappings),
],
paths: {
- sources: argv.src,
+ sources: [argv.src, 'lib/openzeppelin-community-contracts/contracts'],
},
solidity: {
version: argv.compiler,
@@ -127,7 +128,7 @@ export default defineConfig({
@@ -114,7 +115,7 @@ export default defineConfig({
exposed: {
imports: true,
initializers: true,
Expand Down
4 changes: 2 additions & 2 deletions test/account/AccountERC7913.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ const signerZKEmail = new NonNativeSigner(
async function fixture() {
// EOAs and environment
const [admin, beneficiary, other] = await ethers.getSigners();
const target = await ethers.deployContract('CallReceiverMock');
const target = await ethers.deployContract('$CallReceiverMock');

// DKIM Registry for ZKEmail
const dkim = await ethers.deployContract('ECDSAOwnedDKIMRegistry');
const dkim = await ethers.deployContract('ECDSAOwnedDKIMRegistryMock');
await dkim.initialize(admin, admin);
await dkim
.SET_PREFIX()
Expand Down
4 changes: 2 additions & 2 deletions test/account/AccountZKEmail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ const SIGN_HASH_COMMAND = 'signHash';
async function fixture() {
// EOAs and environment
const [admin, beneficiary, other] = await ethers.getSigners();
const target = await ethers.deployContract('CallReceiverMock');
const target = await ethers.deployContract('$CallReceiverMock');

// Registry
const dkim = await ethers.deployContract('ECDSAOwnedDKIMRegistry');
const dkim = await ethers.deployContract('ECDSAOwnedDKIMRegistryMock');
await dkim.initialize(admin, admin);
await dkim
.SET_PREFIX()
Expand Down
2 changes: 1 addition & 1 deletion test/account/RoleAccountFactory.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describe('RoleAccountFactory', function () {

describe('ERC-7821 execution', function () {
beforeEach(async function () {
this.target = await ethers.deployContract('CallReceiverMock');
this.target = await ethers.deployContract('$CallReceiverMock');
this.mode = encodeMode({ callType: CALL_TYPE_BATCH });
this.data = encodeBatch([this.target, 0n, this.target.interface.encodeFunctionData('mockFunction')]);
});
Expand Down
2 changes: 1 addition & 1 deletion test/account/modules/ERC7579DelayedExecutor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async function fixture() {

// Deploy ERC-7579 validator module
const mock = await ethers.deployContract('$ERC7579DelayedExecutorMock');
const target = await ethers.deployContract('CallReceiverMock');
const target = await ethers.deployContract('$CallReceiverMock');

// ERC-4337 env
const helper = new ERC4337Helper(connection);
Expand Down
2 changes: 1 addition & 1 deletion test/account/modules/ERC7579Executor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const {
async function fixture() {
// Deploy ERC-7579 validator module
const mock = await ethers.deployContract('$ERC7579ExecutorMock');
const target = await ethers.deployContract('CallReceiverMock');
const target = await ethers.deployContract('$CallReceiverMock');

// ERC-4337 env
const helper = new ERC4337Helper(connection);
Expand Down
2 changes: 1 addition & 1 deletion test/account/modules/ERC7579Multisig.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const signerECDSA4 = ethers.Wallet.createRandom(); // Unauthorized signer
async function fixture() {
// Deploy ERC-7579 multisig module
const mock = await ethers.deployContract('$ERC7579MultisigExecutorMock', ['MultisigExecutor', '1']);
const target = await ethers.deployContract('CallReceiverMock');
const target = await ethers.deployContract('$CallReceiverMock');

// ERC-4337 env
const helper = new ERC4337Helper(connection);
Expand Down
2 changes: 1 addition & 1 deletion test/account/modules/ERC7579MultisigStorage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const signerECDSA4 = ethers.Wallet.createRandom(); // Unauthorized signer
async function fixture() {
// Deploy ERC-7579 multisig storage module
const mock = await ethers.deployContract('$ERC7579MultisigStorageExecutorMock', ['MultisigStorageExecutor', '1']);
const target = await ethers.deployContract('CallReceiverMock');
const target = await ethers.deployContract('$CallReceiverMock');

// ERC-4337 env
const helper = new ERC4337Helper(connection);
Expand Down
2 changes: 1 addition & 1 deletion test/account/modules/ERC7579MultisigWeighted.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const signerECDSA4 = ethers.Wallet.createRandom(); // Unauthorized signer
async function fixture() {
// Deploy ERC-7579 multisig weighted module
const mock = await ethers.deployContract('$ERC7579MultisigWeightedExecutorMock', ['MultisigWeightedExecutor', '1']);
const target = await ethers.deployContract('CallReceiverMock');
const target = await ethers.deployContract('$CallReceiverMock');

// ERC-4337 env
const helper = new ERC4337Helper(connection);
Expand Down
2 changes: 1 addition & 1 deletion test/account/modules/ERC7579SelectorExecutor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const {
async function fixture() {
// Deploy ERC-7579 selector executor module
const mock = await ethers.deployContract('$ERC7579SelectorExecutor');
const target = await ethers.deployContract('CallReceiverMock');
const target = await ethers.deployContract('$CallReceiverMock');

// ERC-4337 env
const helper = new ERC4337Helper(connection);
Expand Down
4 changes: 2 additions & 2 deletions test/account/modules/ERC7579SignatureValidator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ async function fixture() {
const mock = await ethers.deployContract('$ERC7579Signature');

// ERC-7913 verifiers
const verifierP256 = await ethers.deployContract('ERC7913P256Verifier');
const verifierRSA = await ethers.deployContract('ERC7913RSAVerifier');
const verifierP256 = await ethers.deployContract('$ERC7913P256Verifier');
const verifierRSA = await ethers.deployContract('$ERC7913RSAVerifier');

// ERC-4337 env
const helper = new ERC4337Helper(connection);
Expand Down
2 changes: 1 addition & 1 deletion test/proxy/HybridProxy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function fixture() {
const implementation1 = await ethers.deployContract('UpgradeableImplementationMock', [1]);
const implementation2 = await ethers.deployContract('UpgradeableImplementationMock', [2]);
const implementation3 = await ethers.deployContract('UpgradeableImplementationMock', [3]);
const beacon = await ethers.deployContract('UpgradeableBeacon', [implementation1, admin]);
const beacon = await ethers.deployContract('$UpgradeableBeacon', [implementation1, admin]);
const proxy = await ethers
.deployContract('HybridProxy', [beacon, '0x'])
.then(({ target }) => implementation1.attach(target));
Expand Down
2 changes: 1 addition & 1 deletion test/utils/cryptography/ZKEmailUtils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async function fixture() {
const [admin, other, ...accounts] = await ethers.getSigners();

// Registry
const dkim = await ethers.deployContract('ECDSAOwnedDKIMRegistry');
const dkim = await ethers.deployContract('ECDSAOwnedDKIMRegistryMock');
await dkim.initialize(admin, admin);
await dkim
.SET_PREFIX()
Expand Down
Loading