Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
5 changes: 5 additions & 0 deletions .changeset/sour-poems-stop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openzeppelin/wizard': patch
---

Add missing imports for modular accounts without a signer
1,222 changes: 617 additions & 605 deletions packages/core/solidity/src/account.test.ts.md

Large diffs are not rendered by default.

Binary file modified packages/core/solidity/src/account.test.ts.snap
Binary file not shown.
10 changes: 10 additions & 0 deletions packages/core/solidity/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ function addERC7579Modules(c: ContractBuilder, opts: AccountOptions): void {

// Accounts that use ERC7579 without a signer must be constructed with at least one module (executor of validation)
if (!opts.signer) {
c.addImportOnly({
name: 'MODULE_TYPE_VALIDATOR',
path: '@openzeppelin/contracts/interfaces/draft-IERC7579.sol',
transpiled: false, // name doesn't start with "I" so its not recognized as an "interface object"
});
c.addImportOnly({
name: 'MODULE_TYPE_EXECUTOR',
path: '@openzeppelin/contracts/interfaces/draft-IERC7579.sol',
transpiled: false, // name doesn't start with "I" so its not recognized as an "interface object"
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik we have a test that checks whether the contracts compile in packages/core/solidity/src/test.ts, how come it missed it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solidity/src/test.ts does not check the compilation.

This zip tests do check compilation ...and a bit more (deployment)

So I tried to add zip tests that include a account with 7579 and no module. It was a pain and in the end was blocked by the tests script failling because they need a valid ERC7579 module to run the construction/initialization.

AFAIK, we don't have tests that check compilation without also deploying the contract (and proxy).

Copy link
Member

@ericglau ericglau Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solidity/src/test.ts does compilation tests, but the signer option was missing the false case in the generator.

Added it (by using exported options defined elsewhere, so any new values in the future won't be missed) in 88cf4c8.

However, this now reveals compile warnings due to the below, which fails the tests. For example, this occurs when no options are selected:
Warning: Function state mutability can be restricted to pure

    function _rawSignatureValidation(bytes32 hash, bytes calldata signature)
        internal
        view
        override
        returns (bool)
    {
        // Custom validation logic
        return false;
    }

Should we ignore these warnings in the tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I got confused between test.ts and account.test.ts

Copy link
Contributor Author

@Amxx Amxx Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are multiple options to make that warning go away, I'm not sure which one is best:

  1. make the function pure: if someone start filling the code, they may get error. Is it obvious that they can safelly change pure to view ?

  2. make the function "virtual override" instead of just "override". Will people be confused by the virtual keyword ?

  3. Add a line to is view, and does nothing. Not example msg.sender;. Possibly with a comment. I think its probably more confusing than options 1 and 2.

  4. Just refuse to build a contract that doesn't support module AND doesn't have a signer.

  5. Somehow disable that warning

Copy link
Member

@ericglau ericglau Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or selectively ignore the warnings our tests by filtering them in hardhat.config.ts. However, users will still see the warning in their projects and might be confused.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Just refuse to build a contract that doesn't support module AND doesn't have a signer.

Is there any use case for a contract that doesn't support module AND doesn't have a signer? If not, then I think we should go with this option.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any use case for a contract that doesn't support module AND doesn't have a signer? If not, then I think we should go with this option.

I think the usecase is "wizard giving something incomplete that users will have to finish". Otherwize, contract is unusable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or selectively ignore the warnings our tests by filtering them in hardhat.config.ts. However, users will still see the warning in their projects and might be confused.

That is what I meant in 5.

Copy link
Member

@ericglau ericglau Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the usecase is "wizard giving something incomplete that users will have to finish". Otherwize, contract is unusable.

For comparison, ERC20 can also be "incomplete" if users do not have either Premint or Mintable, but we don't give an error.

In the case of Account, since Wizard is a dev tool rather than a deployment tool, I think the "incomplete" case is acceptable. However, we should add a clearly actionable TODO comment for _rawSignatureValidation, explaining that it must be implemented and also referencing the security warning from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.4.0/contracts/utils/cryptography/signers/AbstractSigner.sol#L22 . In this case, the function state mutability compilation warning might be acceptable, as it is more obvious that the function is incomplete.

c.addConstructorArgument({ type: 'uint256', name: 'moduleTypeId' });
c.addConstructorArgument({ type: 'address', name: 'module' });
c.addConstructorArgument({ type: 'bytes calldata', name: 'initData' });
Expand Down
4 changes: 2 additions & 2 deletions packages/core/solidity/src/custom.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ Generated by [AVA](https://avajs.dev).
// Compatible with OpenZeppelin Contracts ^5.4.0␊
pragma solidity ^0.8.27;␊
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";␊
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";␊
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";␊
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";␊
contract MyContract is Initializable, OwnableUpgradeable, UUPSUpgradeable {␊
Expand Down Expand Up @@ -168,8 +168,8 @@ Generated by [AVA](https://avajs.dev).
// Compatible with OpenZeppelin Contracts ^5.4.0␊
pragma solidity ^0.8.27;␊
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";␊
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";␊
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";␊
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";␊
contract MyContract is Initializable, OwnableUpgradeable, UUPSUpgradeable {␊
Expand Down
Binary file modified packages/core/solidity/src/custom.test.ts.snap
Binary file not shown.
22 changes: 11 additions & 11 deletions packages/core/solidity/src/erc1155.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Generated by [AVA](https://avajs.dev).
// Compatible with OpenZeppelin Contracts ^5.4.0␊
pragma solidity ^0.8.27;␊
import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";␊
import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
contract MyToken is ERC1155, Ownable {␊
constructor(address initialOwner)␊
Expand All @@ -35,8 +35,8 @@ Generated by [AVA](https://avajs.dev).
// Compatible with OpenZeppelin Contracts ^5.4.0␊
pragma solidity ^0.8.27;␊
import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";␊
import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
contract MyTokec is ERC1155, Ownable {␊
constructor(address initialOwner)␊
Expand Down Expand Up @@ -135,9 +135,9 @@ Generated by [AVA](https://avajs.dev).
// Compatible with OpenZeppelin Contracts ^5.4.0␊
pragma solidity ^0.8.27;␊
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";␊
import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
import {ERC1155Burnable} from "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Burnable.sol";␊
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";␊
contract MyToken is ERC1155, Ownable, ERC1155Burnable {␊
constructor(address initialOwner)␊
Expand All @@ -159,9 +159,9 @@ Generated by [AVA](https://avajs.dev).
// Compatible with OpenZeppelin Contracts ^5.4.0␊
pragma solidity ^0.8.27;␊
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";␊
import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
import {ERC1155Pausable} from "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Pausable.sol";␊
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";␊
contract MyToken is ERC1155, Ownable, ERC1155Pausable {␊
constructor(address initialOwner)␊
Expand Down Expand Up @@ -200,8 +200,8 @@ Generated by [AVA](https://avajs.dev).
// Compatible with OpenZeppelin Contracts ^5.4.0␊
pragma solidity ^0.8.27;␊
import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";␊
import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
contract MyToken is ERC1155, Ownable {␊
constructor(address initialOwner)␊
Expand Down Expand Up @@ -327,9 +327,9 @@ Generated by [AVA](https://avajs.dev).
// Compatible with OpenZeppelin Contracts ^5.4.0␊
pragma solidity ^0.8.27;␊
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";␊
import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";␊
import {ERC1155Supply} from "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol";␊
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";␊
contract MyToken is ERC1155, Ownable, ERC1155Supply {␊
constructor(address initialOwner)␊
Expand Down Expand Up @@ -361,10 +361,10 @@ Generated by [AVA](https://avajs.dev).
pragma solidity ^0.8.27;␊
import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";␊
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";␊
import {ERC1155Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol";␊
import {ERC1155BurnableUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol";␊
import {ERC1155PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155PausableUpgradeable.sol";␊
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";␊
contract MyToken is Initializable, ERC1155Upgradeable, AccessControlUpgradeable, ERC1155PausableUpgradeable, ERC1155BurnableUpgradeable {␊
bytes32 public constant URI_SETTER_ROLE = keccak256("URI_SETTER_ROLE");␊
Expand Down Expand Up @@ -445,11 +445,11 @@ Generated by [AVA](https://avajs.dev).
pragma solidity ^0.8.27;␊
import {AccessControlUpgradeable} from "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";␊
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";␊
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";␊
import {ERC1155Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol";␊
import {ERC1155BurnableUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol";␊
import {ERC1155PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155PausableUpgradeable.sol";␊
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";␊
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";␊
contract MyToken is Initializable, ERC1155Upgradeable, AccessControlUpgradeable, ERC1155PausableUpgradeable, ERC1155BurnableUpgradeable, UUPSUpgradeable {␊
bytes32 public constant URI_SETTER_ROLE = keccak256("URI_SETTER_ROLE");␊
Expand Down Expand Up @@ -539,11 +539,11 @@ Generated by [AVA](https://avajs.dev).
pragma solidity ^0.8.27;␊
import {AccessManagedUpgradeable} from "@openzeppelin/contracts-upgradeable/access/manager/AccessManagedUpgradeable.sol";␊
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";␊
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";␊
import {ERC1155Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol";␊
import {ERC1155BurnableUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol";␊
import {ERC1155PausableUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155PausableUpgradeable.sol";␊
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";␊
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";␊
contract MyToken is Initializable, ERC1155Upgradeable, AccessManagedUpgradeable, ERC1155PausableUpgradeable, ERC1155BurnableUpgradeable, UUPSUpgradeable {␊
/// @custom:oz-upgrades-unsafe-allow constructor␊
Expand Down
Binary file modified packages/core/solidity/src/erc1155.test.ts.snap
Binary file not shown.
Loading
Loading