diff --git a/packages/core/solidity/src/account.test.ts b/packages/core/solidity/src/account.test.ts index fbf809721..0b7a766fe 100644 --- a/packages/core/solidity/src/account.test.ts +++ b/packages/core/solidity/src/account.test.ts @@ -2,7 +2,7 @@ import test from 'ava'; import { account } from '.'; import type { AccountOptions } from './account'; -import { buildAccount } from './account'; +import { buildAccount, buildFactory } from './account'; import { printContract } from './print'; /** @@ -12,7 +12,7 @@ function testAPIEquivalence(title: string, opts?: AccountOptions) { test(title, t => { t.is( account.print(opts), - printContract( + printContract([ buildAccount({ name: 'MyAccount', signatureValidation: 'ERC7739', @@ -22,7 +22,16 @@ function testAPIEquivalence(title: string, opts?: AccountOptions) { ERC7579Modules: false, ...opts, }), - ), + buildFactory({ + name: 'MyAccount', + signatureValidation: 'ERC7739', + ERC721Holder: true, + ERC1155Holder: true, + batchedExecution: false, + ERC7579Modules: false, + ...opts, + }), + ].filter(c => c !== null)), ); }); } @@ -38,8 +47,7 @@ function testAccount(title: string, opts: Partial) { ...opts, }; test(title, t => { - const c = buildAccount(fullOpts); - t.snapshot(printContract(c)); + t.snapshot(account.print(fullOpts)); }); testAPIEquivalence(`${title} API equivalence`, fullOpts); } diff --git a/packages/core/solidity/src/account.test.ts.md b/packages/core/solidity/src/account.test.ts.md index da256f549..d7d1b332f 100644 --- a/packages/core/solidity/src/account.test.ts.md +++ b/packages/core/solidity/src/account.test.ts.md @@ -752,6 +752,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerECDSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerECDSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerECDSA is Initializable, Account, EIP712, ERC7739, SignerECDSA {␊ @@ -759,10 +760,33 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeECDSA(address signer) public initializer {␊ + function initialize(address signer) public initializer {␊ _setSigner(signer);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerECDSAFactory {␊ + CustomAccountWithSignerECDSA public immutable implementation = new CustomAccountWithSignerECDSA();␊ + ␊ + function create(address signer, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(signer, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerECDSA(instance).initialize(signer);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(address signer, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signer, salt));␊ + }␊ + ␊ + function _salt(address signer, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(signer, salt));␊ + }␊ + }␊ ` ## Account with SignerECDSA with ERC1271 @@ -777,6 +801,7 @@ Generated by [AVA](https://avajs.dev). import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerECDSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerECDSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerECDSAERC1271 is Initializable, Account, IERC1271, SignerECDSA {␊ @@ -793,10 +818,33 @@ Generated by [AVA](https://avajs.dev). return _rawSignatureValidation(hash, signature) ? IERC1271.isValidSignature.selector : bytes4(0xffffffff);␊ }␊ ␊ - function initializeECDSA(address signer) public initializer {␊ + function initialize(address signer) public initializer {␊ _setSigner(signer);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerECDSAERC1271Factory {␊ + CustomAccountWithSignerECDSAERC1271 public immutable implementation = new CustomAccountWithSignerECDSAERC1271();␊ + ␊ + function create(address signer, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(signer, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerECDSAERC1271(instance).initialize(signer);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(address signer, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signer, salt));␊ + }␊ + ␊ + function _salt(address signer, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(signer, salt));␊ + }␊ + }␊ ` ## Account with SignerECDSA with ERC7739 @@ -812,6 +860,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerECDSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerECDSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerECDSAERC7739 is Initializable, Account, EIP712, ERC7739, SignerECDSA {␊ @@ -819,10 +868,33 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeECDSA(address signer) public initializer {␊ + function initialize(address signer) public initializer {␊ _setSigner(signer);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerECDSAERC7739Factory {␊ + CustomAccountWithSignerECDSAERC7739 public immutable implementation = new CustomAccountWithSignerECDSAERC7739();␊ + ␊ + function create(address signer, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(signer, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerECDSAERC7739(instance).initialize(signer);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(address signer, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signer, salt));␊ + }␊ + ␊ + function _salt(address signer, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(signer, salt));␊ + }␊ + }␊ ` ## Account with SignerECDSA with ERC721Holder @@ -839,6 +911,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerECDSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerECDSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerECDSAERC721Holder is Initializable, Account, EIP712, ERC7739, SignerECDSA, ERC721Holder {␊ @@ -846,10 +919,33 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeECDSA(address signer) public initializer {␊ + function initialize(address signer) public initializer {␊ _setSigner(signer);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerECDSAERC721HolderFactory {␊ + CustomAccountWithSignerECDSAERC721Holder public immutable implementation = new CustomAccountWithSignerECDSAERC721Holder();␊ + ␊ + function create(address signer, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(signer, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerECDSAERC721Holder(instance).initialize(signer);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(address signer, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signer, salt));␊ + }␊ + ␊ + function _salt(address signer, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(signer, salt));␊ + }␊ + }␊ ` ## Account with SignerECDSA with ERC1155Holder @@ -866,6 +962,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerECDSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerECDSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerECDSAERC1155Holder is Initializable, Account, EIP712, ERC7739, SignerECDSA, ERC1155Holder {␊ @@ -873,10 +970,33 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeECDSA(address signer) public initializer {␊ + function initialize(address signer) public initializer {␊ _setSigner(signer);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerECDSAERC1155HolderFactory {␊ + CustomAccountWithSignerECDSAERC1155Holder public immutable implementation = new CustomAccountWithSignerECDSAERC1155Holder();␊ + ␊ + function create(address signer, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(signer, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerECDSAERC1155Holder(instance).initialize(signer);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(address signer, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signer, salt));␊ + }␊ + ␊ + function _salt(address signer, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(signer, salt));␊ + }␊ + }␊ ` ## Account with SignerECDSA with ERC721Holder and ERC1155Holder @@ -894,6 +1014,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerECDSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerECDSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerECDSAERC721HolderERC1155Holder is Initializable, Account, EIP712, ERC7739, SignerECDSA, ERC721Holder, ERC1155Holder {␊ @@ -903,10 +1024,33 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeECDSA(address signer) public initializer {␊ + function initialize(address signer) public initializer {␊ _setSigner(signer);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerECDSAERC721HolderERC1155HolderFactory {␊ + CustomAccountWithSignerECDSAERC721HolderERC1155Holder public immutable implementation = new CustomAccountWithSignerECDSAERC721HolderERC1155Holder();␊ + ␊ + function create(address signer, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(signer, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerECDSAERC721HolderERC1155Holder(instance).initialize(signer);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(address signer, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signer, salt));␊ + }␊ + ␊ + function _salt(address signer, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(signer, salt));␊ + }␊ + }␊ ` ## Account with SignerECDSA with ERC7821 Execution @@ -923,6 +1067,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7821} from "@openzeppelin/community-contracts/account/extensions/ERC7821.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerECDSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerECDSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, SignerECDSA, ERC7821 {␊ @@ -930,7 +1075,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeECDSA(address signer) public initializer {␊ + function initialize(address signer) public initializer {␊ _setSigner(signer);␊ }␊ ␊ @@ -943,6 +1088,29 @@ Generated by [AVA](https://avajs.dev). return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(address signer, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(signer, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(signer);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(address signer, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signer, salt));␊ + }␊ + ␊ + function _salt(address signer, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(signer, salt));␊ + }␊ + }␊ ` ## Account with SignerECDSA with ERC7579 @@ -961,6 +1129,7 @@ Generated by [AVA](https://avajs.dev). import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ import {SignerECDSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerECDSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, AccountERC7579, SignerECDSA {␊ @@ -980,7 +1149,7 @@ Generated by [AVA](https://avajs.dev). return erc7739magic == bytes4(0xffffffff) ? AccountERC7579.isValidSignature(hash, signature) : erc7739magic;␊ }␊ ␊ - function initializeECDSA(address signer) public initializer {␊ + function initialize(address signer) public initializer {␊ _setSigner(signer);␊ }␊ ␊ @@ -1007,6 +1176,29 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(address signer, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(signer, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(signer);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(address signer, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signer, salt));␊ + }␊ + ␊ + function _salt(address signer, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(signer, salt));␊ + }␊ + }␊ ` ## Account with SignerECDSA with ERC7579 with ERC1271 @@ -1024,6 +1216,7 @@ Generated by [AVA](https://avajs.dev). import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ import {SignerECDSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerECDSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, IERC1271, AccountERC7579, SignerECDSA {␊ @@ -1031,7 +1224,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeECDSA(address signer) public initializer {␊ + function initialize(address signer) public initializer {␊ _setSigner(signer);␊ }␊ ␊ @@ -1067,6 +1260,29 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(address signer, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(signer, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(signer);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(address signer, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signer, salt));␊ + }␊ + ␊ + function _salt(address signer, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(signer, salt));␊ + }␊ + }␊ ` ## Account with SignerECDSA with ERC7579 with ERC7739 @@ -1085,6 +1301,7 @@ Generated by [AVA](https://avajs.dev). import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ import {SignerECDSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerECDSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, AccountERC7579, SignerECDSA {␊ @@ -1104,7 +1321,7 @@ Generated by [AVA](https://avajs.dev). return erc7739magic == bytes4(0xffffffff) ? AccountERC7579.isValidSignature(hash, signature) : erc7739magic;␊ }␊ ␊ - function initializeECDSA(address signer) public initializer {␊ + function initialize(address signer) public initializer {␊ _setSigner(signer);␊ }␊ ␊ @@ -1131,6 +1348,29 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(address signer, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(signer, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(signer);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(address signer, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signer, salt));␊ + }␊ + ␊ + function _salt(address signer, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(signer, salt));␊ + }␊ + }␊ ` ## Account with SignerECDSA with ERC7579 hooks @@ -1150,6 +1390,7 @@ Generated by [AVA](https://avajs.dev). import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ import {SignerECDSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerECDSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, AccountERC7579Hooked, SignerECDSA {␊ @@ -1169,7 +1410,7 @@ Generated by [AVA](https://avajs.dev). return erc7739magic == bytes4(0xffffffff) ? AccountERC7579.isValidSignature(hash, signature) : erc7739magic;␊ }␊ ␊ - function initializeECDSA(address signer) public initializer {␊ + function initialize(address signer) public initializer {␊ _setSigner(signer);␊ }␊ ␊ @@ -1196,6 +1437,29 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(address signer, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(signer, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(signer);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(address signer, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signer, salt));␊ + }␊ + ␊ + function _salt(address signer, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(signer, salt));␊ + }␊ + }␊ ` ## Account with SignerP256 named @@ -1211,6 +1475,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerP256} from "@openzeppelin/community-contracts/utils/cryptography/SignerP256.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerP256 is Initializable, Account, EIP712, ERC7739, SignerP256 {␊ @@ -1218,10 +1483,33 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeP256(bytes32 qx, bytes32 qy) public initializer {␊ + function initialize(bytes32 qx, bytes32 qy) public initializer {␊ _setSigner(qx, qy);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerP256Factory {␊ + CustomAccountWithSignerP256 public immutable implementation = new CustomAccountWithSignerP256();␊ + ␊ + function create(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(qx, qy, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerP256(instance).initialize(qx, qy);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(qx, qy, salt));␊ + }␊ + ␊ + function _salt(bytes32 qx, bytes32 qy, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(qx, qy, salt));␊ + }␊ + }␊ ` ## Account with SignerP256 with ERC1271 @@ -1236,6 +1524,7 @@ Generated by [AVA](https://avajs.dev). import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerP256} from "@openzeppelin/community-contracts/utils/cryptography/SignerP256.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerP256ERC1271 is Initializable, Account, IERC1271, SignerP256 {␊ @@ -1252,10 +1541,33 @@ Generated by [AVA](https://avajs.dev). return _rawSignatureValidation(hash, signature) ? IERC1271.isValidSignature.selector : bytes4(0xffffffff);␊ }␊ ␊ - function initializeP256(bytes32 qx, bytes32 qy) public initializer {␊ + function initialize(bytes32 qx, bytes32 qy) public initializer {␊ _setSigner(qx, qy);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerP256ERC1271Factory {␊ + CustomAccountWithSignerP256ERC1271 public immutable implementation = new CustomAccountWithSignerP256ERC1271();␊ + ␊ + function create(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(qx, qy, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerP256ERC1271(instance).initialize(qx, qy);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(qx, qy, salt));␊ + }␊ + ␊ + function _salt(bytes32 qx, bytes32 qy, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(qx, qy, salt));␊ + }␊ + }␊ ` ## Account with SignerP256 with ERC7739 @@ -1271,6 +1583,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerP256} from "@openzeppelin/community-contracts/utils/cryptography/SignerP256.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerP256ERC7739 is Initializable, Account, EIP712, ERC7739, SignerP256 {␊ @@ -1278,10 +1591,33 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeP256(bytes32 qx, bytes32 qy) public initializer {␊ + function initialize(bytes32 qx, bytes32 qy) public initializer {␊ _setSigner(qx, qy);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerP256ERC7739Factory {␊ + CustomAccountWithSignerP256ERC7739 public immutable implementation = new CustomAccountWithSignerP256ERC7739();␊ + ␊ + function create(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(qx, qy, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerP256ERC7739(instance).initialize(qx, qy);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(qx, qy, salt));␊ + }␊ + ␊ + function _salt(bytes32 qx, bytes32 qy, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(qx, qy, salt));␊ + }␊ + }␊ ` ## Account with SignerP256 with ERC721Holder @@ -1298,6 +1634,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerP256} from "@openzeppelin/community-contracts/utils/cryptography/SignerP256.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerP256ERC721Holder is Initializable, Account, EIP712, ERC7739, SignerP256, ERC721Holder {␊ @@ -1305,10 +1642,33 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeP256(bytes32 qx, bytes32 qy) public initializer {␊ + function initialize(bytes32 qx, bytes32 qy) public initializer {␊ _setSigner(qx, qy);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerP256ERC721HolderFactory {␊ + CustomAccountWithSignerP256ERC721Holder public immutable implementation = new CustomAccountWithSignerP256ERC721Holder();␊ + ␊ + function create(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(qx, qy, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerP256ERC721Holder(instance).initialize(qx, qy);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(qx, qy, salt));␊ + }␊ + ␊ + function _salt(bytes32 qx, bytes32 qy, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(qx, qy, salt));␊ + }␊ + }␊ ` ## Account with SignerP256 with ERC1155Holder @@ -1325,6 +1685,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerP256} from "@openzeppelin/community-contracts/utils/cryptography/SignerP256.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerP256ERC1155Holder is Initializable, Account, EIP712, ERC7739, SignerP256, ERC1155Holder {␊ @@ -1332,10 +1693,33 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeP256(bytes32 qx, bytes32 qy) public initializer {␊ + function initialize(bytes32 qx, bytes32 qy) public initializer {␊ _setSigner(qx, qy);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerP256ERC1155HolderFactory {␊ + CustomAccountWithSignerP256ERC1155Holder public immutable implementation = new CustomAccountWithSignerP256ERC1155Holder();␊ + ␊ + function create(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(qx, qy, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerP256ERC1155Holder(instance).initialize(qx, qy);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(qx, qy, salt));␊ + }␊ + ␊ + function _salt(bytes32 qx, bytes32 qy, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(qx, qy, salt));␊ + }␊ + }␊ ` ## Account with SignerP256 with ERC721Holder and ERC1155Holder @@ -1353,6 +1737,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerP256} from "@openzeppelin/community-contracts/utils/cryptography/SignerP256.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerP256ERC721HolderERC1155Holder is Initializable, Account, EIP712, ERC7739, SignerP256, ERC721Holder, ERC1155Holder {␊ @@ -1362,10 +1747,33 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeP256(bytes32 qx, bytes32 qy) public initializer {␊ + function initialize(bytes32 qx, bytes32 qy) public initializer {␊ _setSigner(qx, qy);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerP256ERC721HolderERC1155HolderFactory {␊ + CustomAccountWithSignerP256ERC721HolderERC1155Holder public immutable implementation = new CustomAccountWithSignerP256ERC721HolderERC1155Holder();␊ + ␊ + function create(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(qx, qy, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerP256ERC721HolderERC1155Holder(instance).initialize(qx, qy);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(qx, qy, salt));␊ + }␊ + ␊ + function _salt(bytes32 qx, bytes32 qy, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(qx, qy, salt));␊ + }␊ + }␊ ` ## Account with SignerP256 with ERC7821 Execution @@ -1382,6 +1790,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7821} from "@openzeppelin/community-contracts/account/extensions/ERC7821.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerP256} from "@openzeppelin/community-contracts/utils/cryptography/SignerP256.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, SignerP256, ERC7821 {␊ @@ -1389,7 +1798,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeP256(bytes32 qx, bytes32 qy) public initializer {␊ + function initialize(bytes32 qx, bytes32 qy) public initializer {␊ _setSigner(qx, qy);␊ }␊ ␊ @@ -1402,6 +1811,29 @@ Generated by [AVA](https://avajs.dev). return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(qx, qy, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(qx, qy);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(qx, qy, salt));␊ + }␊ + ␊ + function _salt(bytes32 qx, bytes32 qy, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(qx, qy, salt));␊ + }␊ + }␊ ` ## Account with SignerP256 with ERC7579 @@ -1420,6 +1852,7 @@ Generated by [AVA](https://avajs.dev). import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ import {SignerP256} from "@openzeppelin/community-contracts/utils/cryptography/SignerP256.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, AccountERC7579, SignerP256 {␊ @@ -1439,7 +1872,7 @@ Generated by [AVA](https://avajs.dev). return erc7739magic == bytes4(0xffffffff) ? AccountERC7579.isValidSignature(hash, signature) : erc7739magic;␊ }␊ ␊ - function initializeP256(bytes32 qx, bytes32 qy) public initializer {␊ + function initialize(bytes32 qx, bytes32 qy) public initializer {␊ _setSigner(qx, qy);␊ }␊ ␊ @@ -1466,6 +1899,29 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(qx, qy, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(qx, qy);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(qx, qy, salt));␊ + }␊ + ␊ + function _salt(bytes32 qx, bytes32 qy, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(qx, qy, salt));␊ + }␊ + }␊ ` ## Account with SignerP256 with ERC7579 with ERC1271 @@ -1483,6 +1939,7 @@ Generated by [AVA](https://avajs.dev). import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ import {SignerP256} from "@openzeppelin/community-contracts/utils/cryptography/SignerP256.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, IERC1271, AccountERC7579, SignerP256 {␊ @@ -1490,7 +1947,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeP256(bytes32 qx, bytes32 qy) public initializer {␊ + function initialize(bytes32 qx, bytes32 qy) public initializer {␊ _setSigner(qx, qy);␊ }␊ ␊ @@ -1526,6 +1983,29 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(qx, qy, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(qx, qy);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(qx, qy, salt));␊ + }␊ + ␊ + function _salt(bytes32 qx, bytes32 qy, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(qx, qy, salt));␊ + }␊ + }␊ ` ## Account with SignerP256 with ERC7579 with ERC7739 @@ -1544,6 +2024,7 @@ Generated by [AVA](https://avajs.dev). import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ import {SignerP256} from "@openzeppelin/community-contracts/utils/cryptography/SignerP256.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, AccountERC7579, SignerP256 {␊ @@ -1563,7 +2044,7 @@ Generated by [AVA](https://avajs.dev). return erc7739magic == bytes4(0xffffffff) ? AccountERC7579.isValidSignature(hash, signature) : erc7739magic;␊ }␊ ␊ - function initializeP256(bytes32 qx, bytes32 qy) public initializer {␊ + function initialize(bytes32 qx, bytes32 qy) public initializer {␊ _setSigner(qx, qy);␊ }␊ ␊ @@ -1590,6 +2071,29 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(qx, qy, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(qx, qy);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(qx, qy, salt));␊ + }␊ + ␊ + function _salt(bytes32 qx, bytes32 qy, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(qx, qy, salt));␊ + }␊ + }␊ ` ## Account with SignerP256 with ERC7579 hooks @@ -1609,6 +2113,7 @@ Generated by [AVA](https://avajs.dev). import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ import {SignerP256} from "@openzeppelin/community-contracts/utils/cryptography/SignerP256.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, AccountERC7579Hooked, SignerP256 {␊ @@ -1628,7 +2133,7 @@ Generated by [AVA](https://avajs.dev). return erc7739magic == bytes4(0xffffffff) ? AccountERC7579.isValidSignature(hash, signature) : erc7739magic;␊ }␊ ␊ - function initializeP256(bytes32 qx, bytes32 qy) public initializer {␊ + function initialize(bytes32 qx, bytes32 qy) public initializer {␊ _setSigner(qx, qy);␊ }␊ ␊ @@ -1655,6 +2160,29 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + bytes32 effectiveSalt = _salt(qx, qy, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(qx, qy);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes32 qx, bytes32 qy, bytes32 salt) public returns (address) {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(qx, qy, salt));␊ + }␊ + ␊ + function _salt(bytes32 qx, bytes32 qy, bytes32 salt) internal returns (bytes32) {␊ + return keccak256(abi.encode(qx, qy, salt));␊ + }␊ + }␊ ` ## Account with SignerRSA named @@ -1670,6 +2198,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerRSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerRSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerRSA is Initializable, Account, EIP712, ERC7739, SignerRSA {␊ @@ -1677,10 +2206,42 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeRSA(bytes memory e, bytes memory n) public initializer {␊ + function initialize(bytes memory e, bytes memory n) public initializer {␊ _setSigner(e, n);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerRSAFactory {␊ + CustomAccountWithSignerRSA public immutable implementation = new CustomAccountWithSignerRSA();␊ + ␊ + function create(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(e, n, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerRSA(instance).initialize(e, n);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(e, n, salt));␊ + }␊ + ␊ + function _salt(bytes memory e, bytes memory n, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(e, n, salt));␊ + }␊ + }␊ ` ## Account with SignerRSA with ERC1271 @@ -1695,6 +2256,7 @@ Generated by [AVA](https://avajs.dev). import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerRSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerRSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerRSAERC1271 is Initializable, Account, IERC1271, SignerRSA {␊ @@ -1711,10 +2273,42 @@ Generated by [AVA](https://avajs.dev). return _rawSignatureValidation(hash, signature) ? IERC1271.isValidSignature.selector : bytes4(0xffffffff);␊ }␊ ␊ - function initializeRSA(bytes memory e, bytes memory n) public initializer {␊ + function initialize(bytes memory e, bytes memory n) public initializer {␊ _setSigner(e, n);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerRSAERC1271Factory {␊ + CustomAccountWithSignerRSAERC1271 public immutable implementation = new CustomAccountWithSignerRSAERC1271();␊ + ␊ + function create(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(e, n, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerRSAERC1271(instance).initialize(e, n);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(e, n, salt));␊ + }␊ + ␊ + function _salt(bytes memory e, bytes memory n, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(e, n, salt));␊ + }␊ + }␊ ` ## Account with SignerRSA with ERC7739 @@ -1730,6 +2324,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerRSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerRSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerRSAERC7739 is Initializable, Account, EIP712, ERC7739, SignerRSA {␊ @@ -1737,10 +2332,42 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeRSA(bytes memory e, bytes memory n) public initializer {␊ + function initialize(bytes memory e, bytes memory n) public initializer {␊ _setSigner(e, n);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerRSAERC7739Factory {␊ + CustomAccountWithSignerRSAERC7739 public immutable implementation = new CustomAccountWithSignerRSAERC7739();␊ + ␊ + function create(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(e, n, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerRSAERC7739(instance).initialize(e, n);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(e, n, salt));␊ + }␊ + ␊ + function _salt(bytes memory e, bytes memory n, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(e, n, salt));␊ + }␊ + }␊ ` ## Account with SignerRSA with ERC721Holder @@ -1757,6 +2384,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerRSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerRSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerRSAERC721Holder is Initializable, Account, EIP712, ERC7739, SignerRSA, ERC721Holder {␊ @@ -1764,10 +2392,42 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeRSA(bytes memory e, bytes memory n) public initializer {␊ + function initialize(bytes memory e, bytes memory n) public initializer {␊ _setSigner(e, n);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerRSAERC721HolderFactory {␊ + CustomAccountWithSignerRSAERC721Holder public immutable implementation = new CustomAccountWithSignerRSAERC721Holder();␊ + ␊ + function create(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(e, n, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerRSAERC721Holder(instance).initialize(e, n);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(e, n, salt));␊ + }␊ + ␊ + function _salt(bytes memory e, bytes memory n, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(e, n, salt));␊ + }␊ + }␊ ` ## Account with SignerRSA with ERC1155Holder @@ -1784,6 +2444,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerRSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerRSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerRSAERC1155Holder is Initializable, Account, EIP712, ERC7739, SignerRSA, ERC1155Holder {␊ @@ -1791,10 +2452,42 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeRSA(bytes memory e, bytes memory n) public initializer {␊ + function initialize(bytes memory e, bytes memory n) public initializer {␊ _setSigner(e, n);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerRSAERC1155HolderFactory {␊ + CustomAccountWithSignerRSAERC1155Holder public immutable implementation = new CustomAccountWithSignerRSAERC1155Holder();␊ + ␊ + function create(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(e, n, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerRSAERC1155Holder(instance).initialize(e, n);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(e, n, salt));␊ + }␊ + ␊ + function _salt(bytes memory e, bytes memory n, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(e, n, salt));␊ + }␊ + }␊ ` ## Account with SignerRSA with ERC721Holder and ERC1155Holder @@ -1812,6 +2505,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerRSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerRSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerRSAERC721HolderERC1155Holder is Initializable, Account, EIP712, ERC7739, SignerRSA, ERC721Holder, ERC1155Holder {␊ @@ -1821,10 +2515,42 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeRSA(bytes memory e, bytes memory n) public initializer {␊ + function initialize(bytes memory e, bytes memory n) public initializer {␊ _setSigner(e, n);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerRSAERC721HolderERC1155HolderFactory {␊ + CustomAccountWithSignerRSAERC721HolderERC1155Holder public immutable implementation = new CustomAccountWithSignerRSAERC721HolderERC1155Holder();␊ + ␊ + function create(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(e, n, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerRSAERC721HolderERC1155Holder(instance).initialize(e, n);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(e, n, salt));␊ + }␊ + ␊ + function _salt(bytes memory e, bytes memory n, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(e, n, salt));␊ + }␊ + }␊ ` ## Account with SignerRSA with ERC7821 Execution @@ -1841,6 +2567,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7821} from "@openzeppelin/community-contracts/account/extensions/ERC7821.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {SignerRSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerRSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, SignerRSA, ERC7821 {␊ @@ -1848,7 +2575,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeRSA(bytes memory e, bytes memory n) public initializer {␊ + function initialize(bytes memory e, bytes memory n) public initializer {␊ _setSigner(e, n);␊ }␊ ␊ @@ -1861,6 +2588,38 @@ Generated by [AVA](https://avajs.dev). return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(e, n, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(e, n);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(e, n, salt));␊ + }␊ + ␊ + function _salt(bytes memory e, bytes memory n, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(e, n, salt));␊ + }␊ + }␊ ` ## Account with SignerRSA with ERC7579 @@ -1879,6 +2638,7 @@ Generated by [AVA](https://avajs.dev). import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ import {SignerRSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerRSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, AccountERC7579, SignerRSA {␊ @@ -1898,7 +2658,7 @@ Generated by [AVA](https://avajs.dev). return erc7739magic == bytes4(0xffffffff) ? AccountERC7579.isValidSignature(hash, signature) : erc7739magic;␊ }␊ ␊ - function initializeRSA(bytes memory e, bytes memory n) public initializer {␊ + function initialize(bytes memory e, bytes memory n) public initializer {␊ _setSigner(e, n);␊ }␊ ␊ @@ -1925,6 +2685,38 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(e, n, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(e, n);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(e, n, salt));␊ + }␊ + ␊ + function _salt(bytes memory e, bytes memory n, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(e, n, salt));␊ + }␊ + }␊ ` ## Account with SignerRSA with ERC7579 with ERC1271 @@ -1942,6 +2734,7 @@ Generated by [AVA](https://avajs.dev). import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ import {SignerRSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerRSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, IERC1271, AccountERC7579, SignerRSA {␊ @@ -1949,7 +2742,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeRSA(bytes memory e, bytes memory n) public initializer {␊ + function initialize(bytes memory e, bytes memory n) public initializer {␊ _setSigner(e, n);␊ }␊ ␊ @@ -1985,6 +2778,38 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(e, n, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(e, n);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(e, n, salt));␊ + }␊ + ␊ + function _salt(bytes memory e, bytes memory n, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(e, n, salt));␊ + }␊ + }␊ ` ## Account with SignerRSA with ERC7579 with ERC7739 @@ -2003,6 +2828,7 @@ Generated by [AVA](https://avajs.dev). import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ import {SignerRSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerRSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, AccountERC7579, SignerRSA {␊ @@ -2022,7 +2848,7 @@ Generated by [AVA](https://avajs.dev). return erc7739magic == bytes4(0xffffffff) ? AccountERC7579.isValidSignature(hash, signature) : erc7739magic;␊ }␊ ␊ - function initializeRSA(bytes memory e, bytes memory n) public initializer {␊ + function initialize(bytes memory e, bytes memory n) public initializer {␊ _setSigner(e, n);␊ }␊ ␊ @@ -2049,6 +2875,38 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(e, n, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(e, n);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(e, n, salt));␊ + }␊ + ␊ + function _salt(bytes memory e, bytes memory n, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(e, n, salt));␊ + }␊ + }␊ ` ## Account with SignerRSA with ERC7579 hooks @@ -2068,6 +2926,7 @@ Generated by [AVA](https://avajs.dev). import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ import {SignerRSA} from "@openzeppelin/community-contracts/utils/cryptography/SignerRSA.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, AccountERC7579Hooked, SignerRSA {␊ @@ -2087,7 +2946,7 @@ Generated by [AVA](https://avajs.dev). return erc7739magic == bytes4(0xffffffff) ? AccountERC7579.isValidSignature(hash, signature) : erc7739magic;␊ }␊ ␊ - function initializeRSA(bytes memory e, bytes memory n) public initializer {␊ + function initialize(bytes memory e, bytes memory n) public initializer {␊ _setSigner(e, n);␊ }␊ ␊ @@ -2114,6 +2973,38 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(e, n, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(e, n);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes memory e, bytes memory n, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(e, n, salt));␊ + }␊ + ␊ + function _salt(bytes memory e, bytes memory n, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(e, n, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisig named @@ -2129,6 +3020,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {MultiSignerERC7913} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerMultisig is Initializable, Account, EIP712, ERC7739, MultiSignerERC7913 {␊ @@ -2136,7 +3028,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeMultisig(bytes[] memory signers, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -2156,6 +3048,38 @@ Generated by [AVA](https://avajs.dev). _setThreshold(threshold);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerMultisigFactory {␊ + CustomAccountWithSignerMultisig public immutable implementation = new CustomAccountWithSignerMultisig();␊ + ␊ + function create(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerMultisig(instance).initialize(signers, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisig with ERC1271 @@ -2170,6 +3094,7 @@ Generated by [AVA](https://avajs.dev). import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {MultiSignerERC7913} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerMultisigERC1271 is Initializable, Account, IERC1271, MultiSignerERC7913 {␊ @@ -2186,7 +3111,7 @@ Generated by [AVA](https://avajs.dev). return _rawSignatureValidation(hash, signature) ? IERC1271.isValidSignature.selector : bytes4(0xffffffff);␊ }␊ ␊ - function initializeMultisig(bytes[] memory signers, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -2206,6 +3131,38 @@ Generated by [AVA](https://avajs.dev). _setThreshold(threshold);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerMultisigERC1271Factory {␊ + CustomAccountWithSignerMultisigERC1271 public immutable implementation = new CustomAccountWithSignerMultisigERC1271();␊ + ␊ + function create(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerMultisigERC1271(instance).initialize(signers, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisig with ERC7739 @@ -2221,6 +3178,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {MultiSignerERC7913} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerMultisigERC7739 is Initializable, Account, EIP712, ERC7739, MultiSignerERC7913 {␊ @@ -2228,7 +3186,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeMultisig(bytes[] memory signers, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -2248,6 +3206,38 @@ Generated by [AVA](https://avajs.dev). _setThreshold(threshold);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerMultisigERC7739Factory {␊ + CustomAccountWithSignerMultisigERC7739 public immutable implementation = new CustomAccountWithSignerMultisigERC7739();␊ + ␊ + function create(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerMultisigERC7739(instance).initialize(signers, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisig with ERC721Holder @@ -2264,6 +3254,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {MultiSignerERC7913} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerMultisigERC721Holder is Initializable, Account, EIP712, ERC7739, MultiSignerERC7913, ERC721Holder {␊ @@ -2271,7 +3262,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeMultisig(bytes[] memory signers, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -2287,8 +3278,40 @@ Generated by [AVA](https://avajs.dev). _removeSigners(signers);␊ }␊ ␊ - function setThreshold(uint256 threshold) public onlyEntryPointOrSelf {␊ - _setThreshold(threshold);␊ + function setThreshold(uint256 threshold) public onlyEntryPointOrSelf {␊ + _setThreshold(threshold);␊ + }␊ + }␊ + ␊ + contract CustomAccountWithSignerMultisigERC721HolderFactory {␊ + CustomAccountWithSignerMultisigERC721Holder public immutable implementation = new CustomAccountWithSignerMultisigERC721Holder();␊ + ␊ + function create(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerMultisigERC721Holder(instance).initialize(signers, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, threshold, salt));␊ }␊ }␊ ` @@ -2307,6 +3330,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {MultiSignerERC7913} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerMultisigERC1155Holder is Initializable, Account, EIP712, ERC7739, MultiSignerERC7913, ERC1155Holder {␊ @@ -2314,7 +3338,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeMultisig(bytes[] memory signers, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -2334,6 +3358,38 @@ Generated by [AVA](https://avajs.dev). _setThreshold(threshold);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerMultisigERC1155HolderFactory {␊ + CustomAccountWithSignerMultisigERC1155Holder public immutable implementation = new CustomAccountWithSignerMultisigERC1155Holder();␊ + ␊ + function create(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerMultisigERC1155Holder(instance).initialize(signers, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisig with ERC721Holder and ERC1155Holder @@ -2351,6 +3407,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {MultiSignerERC7913} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerMultisigERC721HolderERC1155Holder is Initializable, Account, EIP712, ERC7739, MultiSignerERC7913, ERC721Holder, ERC1155Holder {␊ @@ -2360,7 +3417,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeMultisig(bytes[] memory signers, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -2380,6 +3437,38 @@ Generated by [AVA](https://avajs.dev). _setThreshold(threshold);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerMultisigERC721HolderERC1155HolderFactory {␊ + CustomAccountWithSignerMultisigERC721HolderERC1155Holder public immutable implementation = new CustomAccountWithSignerMultisigERC721HolderERC1155Holder();␊ + ␊ + function create(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerMultisigERC721HolderERC1155Holder(instance).initialize(signers, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisig with ERC7821 Execution @@ -2396,6 +3485,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7821} from "@openzeppelin/community-contracts/account/extensions/ERC7821.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {MultiSignerERC7913} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, MultiSignerERC7913, ERC7821 {␊ @@ -2403,7 +3493,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeMultisig(bytes[] memory signers, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -2432,6 +3522,38 @@ Generated by [AVA](https://avajs.dev). return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(signers, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisig with ERC7579 @@ -2450,6 +3572,7 @@ Generated by [AVA](https://avajs.dev). import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {MultiSignerERC7913} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, AccountERC7579, MultiSignerERC7913 {␊ @@ -2469,7 +3592,7 @@ Generated by [AVA](https://avajs.dev). return erc7739magic == bytes4(0xffffffff) ? AccountERC7579.isValidSignature(hash, signature) : erc7739magic;␊ }␊ ␊ - function initializeMultisig(bytes[] memory signers, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -2512,6 +3635,38 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(signers, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisig with ERC7579 with ERC1271 @@ -2529,6 +3684,7 @@ Generated by [AVA](https://avajs.dev). import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {MultiSignerERC7913} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, IERC1271, AccountERC7579, MultiSignerERC7913 {␊ @@ -2536,7 +3692,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeMultisig(bytes[] memory signers, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -2588,6 +3744,38 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(signers, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisig with ERC7579 with ERC7739 @@ -2606,6 +3794,7 @@ Generated by [AVA](https://avajs.dev). import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {MultiSignerERC7913} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, AccountERC7579, MultiSignerERC7913 {␊ @@ -2625,7 +3814,7 @@ Generated by [AVA](https://avajs.dev). return erc7739magic == bytes4(0xffffffff) ? AccountERC7579.isValidSignature(hash, signature) : erc7739magic;␊ }␊ ␊ - function initializeMultisig(bytes[] memory signers, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -2668,6 +3857,38 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(signers, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisig with ERC7579 hooks @@ -2687,6 +3908,7 @@ Generated by [AVA](https://avajs.dev). import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {MultiSignerERC7913} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, AccountERC7579Hooked, MultiSignerERC7913 {␊ @@ -2706,7 +3928,7 @@ Generated by [AVA](https://avajs.dev). return erc7739magic == bytes4(0xffffffff) ? AccountERC7579.isValidSignature(hash, signature) : erc7739magic;␊ }␊ ␊ - function initializeMultisig(bytes[] memory signers, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -2749,6 +3971,38 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(signers, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisigWeighted named @@ -2764,6 +4018,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {MultiSignerERC7913Weighted} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913Weighted.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerMultisigWeighted is Initializable, Account, EIP712, ERC7739, MultiSignerERC7913Weighted {␊ @@ -2771,7 +4026,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeMultisigWeighted(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -2799,6 +4054,38 @@ Generated by [AVA](https://avajs.dev). _setThreshold(threshold);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerMultisigWeightedFactory {␊ + CustomAccountWithSignerMultisigWeighted public immutable implementation = new CustomAccountWithSignerMultisigWeighted();␊ + ␊ + function create(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, weights, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerMultisigWeighted(instance).initialize(signers, weights, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, weights, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, weights, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisigWeighted with ERC1271 @@ -2813,6 +4100,7 @@ Generated by [AVA](https://avajs.dev). import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {MultiSignerERC7913Weighted} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913Weighted.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerMultisigWeightedERC1271 is Initializable, Account, IERC1271, MultiSignerERC7913Weighted {␊ @@ -2829,7 +4117,7 @@ Generated by [AVA](https://avajs.dev). return _rawSignatureValidation(hash, signature) ? IERC1271.isValidSignature.selector : bytes4(0xffffffff);␊ }␊ ␊ - function initializeMultisigWeighted(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -2857,6 +4145,38 @@ Generated by [AVA](https://avajs.dev). _setThreshold(threshold);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerMultisigWeightedERC1271Factory {␊ + CustomAccountWithSignerMultisigWeightedERC1271 public immutable implementation = new CustomAccountWithSignerMultisigWeightedERC1271();␊ + ␊ + function create(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, weights, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerMultisigWeightedERC1271(instance).initialize(signers, weights, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, weights, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, weights, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisigWeighted with ERC7739 @@ -2872,6 +4192,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {MultiSignerERC7913Weighted} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913Weighted.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerMultisigWeightedERC7739 is Initializable, Account, EIP712, ERC7739, MultiSignerERC7913Weighted {␊ @@ -2881,7 +4202,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeMultisigWeighted(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -2909,6 +4230,38 @@ Generated by [AVA](https://avajs.dev). _setThreshold(threshold);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerMultisigWeightedERC7739Factory {␊ + CustomAccountWithSignerMultisigWeightedERC7739 public immutable implementation = new CustomAccountWithSignerMultisigWeightedERC7739();␊ + ␊ + function create(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, weights, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerMultisigWeightedERC7739(instance).initialize(signers, weights, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, weights, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, weights, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisigWeighted with ERC721Holder @@ -2925,6 +4278,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {MultiSignerERC7913Weighted} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913Weighted.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerMultisigWeightedERC721Holder is Initializable, Account, EIP712, ERC7739, MultiSignerERC7913Weighted, ERC721Holder {␊ @@ -2934,7 +4288,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeMultisigWeighted(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -2962,6 +4316,38 @@ Generated by [AVA](https://avajs.dev). _setThreshold(threshold);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerMultisigWeightedERC721HolderFactory {␊ + CustomAccountWithSignerMultisigWeightedERC721Holder public immutable implementation = new CustomAccountWithSignerMultisigWeightedERC721Holder();␊ + ␊ + function create(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, weights, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerMultisigWeightedERC721Holder(instance).initialize(signers, weights, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, weights, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, weights, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisigWeighted with ERC1155Holder @@ -2978,6 +4364,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {MultiSignerERC7913Weighted} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913Weighted.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerMultisigWeightedERC1155Holder is Initializable, Account, EIP712, ERC7739, MultiSignerERC7913Weighted, ERC1155Holder {␊ @@ -2987,7 +4374,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeMultisigWeighted(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -3015,6 +4402,38 @@ Generated by [AVA](https://avajs.dev). _setThreshold(threshold);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerMultisigWeightedERC1155HolderFactory {␊ + CustomAccountWithSignerMultisigWeightedERC1155Holder public immutable implementation = new CustomAccountWithSignerMultisigWeightedERC1155Holder();␊ + ␊ + function create(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, weights, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerMultisigWeightedERC1155Holder(instance).initialize(signers, weights, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, weights, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, weights, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisigWeighted with ERC721Holder and ERC1155Holder @@ -3032,6 +4451,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7739} from "@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {MultiSignerERC7913Weighted} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913Weighted.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract CustomAccountWithSignerMultisigWeightedERC721HolderERC1155Holder is Initializable, Account, EIP712, ERC7739, MultiSignerERC7913Weighted, ERC721Holder, ERC1155Holder {␊ @@ -3041,7 +4461,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeMultisigWeighted(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -3069,6 +4489,38 @@ Generated by [AVA](https://avajs.dev). _setThreshold(threshold);␊ }␊ }␊ + ␊ + contract CustomAccountWithSignerMultisigWeightedERC721HolderERC1155HolderFactory {␊ + CustomAccountWithSignerMultisigWeightedERC721HolderERC1155Holder public immutable implementation = new CustomAccountWithSignerMultisigWeightedERC721HolderERC1155Holder();␊ + ␊ + function create(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, weights, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + CustomAccountWithSignerMultisigWeightedERC721HolderERC1155Holder(instance).initialize(signers, weights, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, weights, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, weights, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisigWeighted with ERC7821 Execution @@ -3085,6 +4537,7 @@ Generated by [AVA](https://avajs.dev). import {ERC7821} from "@openzeppelin/community-contracts/account/extensions/ERC7821.sol";␊ import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";␊ import {MultiSignerERC7913Weighted} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913Weighted.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, MultiSignerERC7913Weighted, ERC7821 {␊ @@ -3092,7 +4545,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeMultisigWeighted(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -3129,6 +4582,38 @@ Generated by [AVA](https://avajs.dev). return caller == address(entryPoint()) || super._erc7821AuthorizedExecutor(caller, mode, executionData);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, weights, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(signers, weights, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, weights, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, weights, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisigWeighted with ERC7579 @@ -3148,6 +4633,7 @@ Generated by [AVA](https://avajs.dev). import {MultiSignerERC7913} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913.sol";␊ import {MultiSignerERC7913Weighted} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913Weighted.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, AccountERC7579, MultiSignerERC7913Weighted {␊ @@ -3167,7 +4653,7 @@ Generated by [AVA](https://avajs.dev). return erc7739magic == bytes4(0xffffffff) ? AccountERC7579.isValidSignature(hash, signature) : erc7739magic;␊ }␊ ␊ - function initializeMultisigWeighted(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -3218,6 +4704,38 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, weights, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(signers, weights, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, weights, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, weights, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisigWeighted with ERC7579 with ERC1271 @@ -3236,6 +4754,7 @@ Generated by [AVA](https://avajs.dev). import {MultiSignerERC7913} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913.sol";␊ import {MultiSignerERC7913Weighted} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913Weighted.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, IERC1271, AccountERC7579, MultiSignerERC7913Weighted {␊ @@ -3243,7 +4762,7 @@ Generated by [AVA](https://avajs.dev). _disableInitializers();␊ }␊ ␊ - function initializeMultisigWeighted(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -3303,6 +4822,38 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, weights, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(signers, weights, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, weights, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, weights, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisigWeighted with ERC7579 with ERC7739 @@ -3322,6 +4873,7 @@ Generated by [AVA](https://avajs.dev). import {MultiSignerERC7913} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913.sol";␊ import {MultiSignerERC7913Weighted} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913Weighted.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, AccountERC7579, MultiSignerERC7913Weighted {␊ @@ -3341,7 +4893,7 @@ Generated by [AVA](https://avajs.dev). return erc7739magic == bytes4(0xffffffff) ? AccountERC7579.isValidSignature(hash, signature) : erc7739magic;␊ }␊ ␊ - function initializeMultisigWeighted(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -3392,6 +4944,38 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, weights, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(signers, weights, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, weights, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, weights, threshold, salt));␊ + }␊ + }␊ ` ## Account with SignerMultisigWeighted with ERC7579 hooks @@ -3412,6 +4996,7 @@ Generated by [AVA](https://avajs.dev). import {MultiSignerERC7913} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913.sol";␊ import {MultiSignerERC7913Weighted} from "@openzeppelin/community-contracts/utils/cryptography/MultiSignerERC7913Weighted.sol";␊ import {PackedUserOperation} from "@openzeppelin/contracts/interfaces/draft-IERC4337.sol";␊ + import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";␊ ␊ /// @custom:oz-upgrades-unsafe-allow constructor␊ contract MyAccount is Initializable, Account, EIP712, ERC7739, AccountERC7579Hooked, MultiSignerERC7913Weighted {␊ @@ -3431,7 +5016,7 @@ Generated by [AVA](https://avajs.dev). return erc7739magic == bytes4(0xffffffff) ? AccountERC7579.isValidSignature(hash, signature) : erc7739magic;␊ }␊ ␊ - function initializeMultisigWeighted(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ + function initialize(bytes[] memory signers, uint256[] memory weights, uint256 threshold)␊ public␊ initializer␊ {␊ @@ -3482,4 +5067,36 @@ Generated by [AVA](https://avajs.dev). return super._rawSignatureValidation(hash, signature);␊ }␊ }␊ + ␊ + contract MyAccountFactory {␊ + MyAccount public immutable implementation = new MyAccount();␊ + ␊ + function create(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + bytes32 effectiveSalt = _salt(signers, weights, threshold, salt);␊ + address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);␊ + if (instance.code.length) {␊ + Clones.cloneDeterministic(address(implementation), effectiveSalt);␊ + MyAccount(instance).initialize(signers, weights, threshold);␊ + }␊ + return instance;␊ + ␊ + }␊ + ␊ + function predict(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + public␊ + returns (address)␊ + {␊ + return Clones.predictDeterministicAddress(address(implementation), _salt(signers, weights, threshold, salt));␊ + }␊ + ␊ + function _salt(bytes[] memory signers, uint256[] memory weights, uint256 threshold, bytes32 salt)␊ + internal␊ + returns (bytes32)␊ + {␊ + return keccak256(abi.encode(signers, weights, threshold, salt));␊ + }␊ + }␊ ` diff --git a/packages/core/solidity/src/account.test.ts.snap b/packages/core/solidity/src/account.test.ts.snap index 13cd60956..4f9c18b27 100644 Binary files a/packages/core/solidity/src/account.test.ts.snap and b/packages/core/solidity/src/account.test.ts.snap differ diff --git a/packages/core/solidity/src/account.ts b/packages/core/solidity/src/account.ts index da79a0809..6c52acabe 100644 --- a/packages/core/solidity/src/account.ts +++ b/packages/core/solidity/src/account.ts @@ -5,6 +5,8 @@ import { printContract } from './print'; import { defaults as commonDefaults, withCommonDefaults, type CommonOptions } from './common-options'; import { setInfo } from './set-info'; import { addSigner, signerFunctions, signers, type SignerOptions } from './signer'; +import { formatLines } from './utils/format-lines'; +import { toIdentifier } from './utils/to-identifier'; export const defaults: Required = { ...commonDefaults, @@ -47,13 +49,16 @@ function withDefaults(opts: AccountOptions): Required { } export function printAccount(opts: AccountOptions = defaults): string { - return printContract(buildAccount(opts)); + return printContract([ + buildAccount(opts), + buildFactory(opts), // Todo: enable/disable factory from opts + ].filter(c => c !== null)); } export function buildAccount(opts: AccountOptions): Contract { const allOpts = withDefaults(opts); - allOpts.upgradeable = false; // Upgradeability is not yet available for the community contracts + allOpts.upgradeable = false; // Upgradeability is not yet available for the accounts contracts allOpts.access = false; // Access control options are not used for Account const c = new ContractBuilder(allOpts.name); @@ -244,53 +249,105 @@ function overrideRawSignatureValidation(c: ContractBuilder, opts: AccountOptions } } -const functions = { - ...defineFunctions({ - isValidSignature: { - kind: 'public' as const, - mutability: 'view' as const, - args: [ - { name: 'hash', type: 'bytes32' }, - { name: 'signature', type: 'bytes calldata' }, - ], - returns: ['bytes4'], - }, - _validateUserOp: { - kind: 'internal' as const, - args: [ - { name: 'userOp', type: 'PackedUserOperation calldata' }, - { name: 'userOpHash', type: 'bytes32' }, - ], - returns: ['uint256'], - }, - _erc7821AuthorizedExecutor: { - kind: 'internal' as const, - args: [ - { name: 'caller', type: 'address' }, - { name: 'mode', type: 'bytes32' }, - { name: 'executionData', type: 'bytes calldata' }, - ], - returns: ['bool'], - mutability: 'view' as const, - }, - addSigners: { - kind: 'public' as const, - args: [{ name: 'signers', type: 'bytes[] memory' }], - }, - removeSigners: { - kind: 'public' as const, - args: [{ name: 'signers', type: 'bytes[] memory' }], - }, - setThreshold: { - kind: 'public' as const, - args: [{ name: 'threshold', type: 'uint256' }], - }, - setSignerWeights: { - kind: 'public' as const, - args: [ - { name: 'signers', type: 'bytes[] memory' }, - { name: 'weights', type: 'uint256[] memory' }, +export function buildFactory(opts: AccountOptions): Contract | null { + const allOpts = withDefaults(opts); + + if (!allOpts.signer || allOpts.signer === "ERC7702") return null; + + allOpts.upgradeable = false; // Upgradeability is not yet available for the accounts contracts + allOpts.access = false; // Access control options are not used for Account + + const c = new ContractBuilder(allOpts.name + 'Factory'); + + const accountName = toIdentifier(allOpts.name); + const accountInitializer = signerFunctions.initialize[allOpts.signer]; + const args = [ ...accountInitializer.args, { name: 'salt', type: 'bytes32' }]; + + // Non upgradeable accounts + c.addImportOnly({ + name: 'Clones', + path: '@openzeppelin/contracts/proxy/Clones.sol', + }); + + // Implementation address + c.addVariable(`${accountName} public immutable implementation = new ${accountName}();`); + + // Functions - create + c.setFunctionBody( + formatLines([ + `bytes32 effectiveSalt = _salt(${args.map(arg => arg.name).join(', ')});`, + `address instance = Clones.predictDeterministicAddress(address(implementation), effectiveSalt);`, + `if (instance.code.length) {`, + [ + `Clones.cloneDeterministic(address(implementation), effectiveSalt);`, + `${accountName}(instance).${accountInitializer.name}(${accountInitializer.args.map(arg => arg.name).join(', ')});`, ], - }, - }), -}; + `}`, + `return instance;`, + ]).split('\n'), + { name: 'create', kind: 'public' as const, args, returns: [ 'address' ] }, + ); + + // Functions - predict + c.addFunctionCode( + `return Clones.predictDeterministicAddress(address(implementation), _salt(${args.map(arg => arg.name).join(', ')}));`, + { name: 'predict', kind: 'public' as const, args, returns: [ 'address' ] }, + ); + + // Functions - _salt + c.addFunctionCode( + `return keccak256(abi.encode(${args.map(arg => arg.name).join(', ')}));`, + { name: '_salt', kind: 'internal' as const, args, returns: [ 'bytes32' ] }, + ); + + return c; +} + +const functions = defineFunctions({ + isValidSignature: { + kind: 'public' as const, + mutability: 'view' as const, + args: [ + { name: 'hash', type: 'bytes32' }, + { name: 'signature', type: 'bytes calldata' }, + ], + returns: ['bytes4'], + }, + _validateUserOp: { + kind: 'internal' as const, + args: [ + { name: 'userOp', type: 'PackedUserOperation calldata' }, + { name: 'userOpHash', type: 'bytes32' }, + ], + returns: ['uint256'], + }, + _erc7821AuthorizedExecutor: { + kind: 'internal' as const, + args: [ + { name: 'caller', type: 'address' }, + { name: 'mode', type: 'bytes32' }, + { name: 'executionData', type: 'bytes calldata' }, + ], + returns: ['bool'], + mutability: 'view' as const, + }, + addSigners: { + kind: 'public' as const, + args: [{ name: 'signers', type: 'bytes[] memory' }], + }, + removeSigners: { + kind: 'public' as const, + args: [{ name: 'signers', type: 'bytes[] memory' }], + }, + setThreshold: { + kind: 'public' as const, + args: [{ name: 'threshold', type: 'uint256' }], + }, + setSignerWeights: { + kind: 'public' as const, + args: [ + { name: 'signers', type: 'bytes[] memory' }, + { name: 'weights', type: 'uint256[] memory' }, + ], + }, +}); diff --git a/packages/core/solidity/src/print.ts b/packages/core/solidity/src/print.ts index c9e85615a..0ba102432 100644 --- a/packages/core/solidity/src/print.ts +++ b/packages/core/solidity/src/print.ts @@ -18,39 +18,46 @@ import { inferTranspiled } from './infer-transpiled'; import { compatibleContractsSemver } from './utils/version'; import { stringifyUnicodeSafe } from './utils/sanitize'; -export function printContract(contract: Contract, opts?: Options): string { - const helpers = withHelpers(contract, opts); - - const fns = mapValues(sortedFunctions(contract), fns => fns.map(fn => printFunction(fn, helpers))); - - const hasOverrides = fns.override.some(l => l.length > 0); +export function printContract(contracts: Contract | Contract [], opts?: Options): string { + contracts = Array.isArray(contracts) ? contracts : [ contracts ]; + if (contracts.length == 0) throw new Error('no contract'); + if (contracts.some(c1 => contracts.some(c2 => c1.license != c2.license))) throw new Error('multiple licences'); return formatLines( ...spaceBetween( + // Header [ - `// SPDX-License-Identifier: ${contract.license}`, + `// SPDX-License-Identifier: ${contracts.at(0)!.license}`, `// Compatible with OpenZeppelin Contracts ${compatibleContractsSemver}`, `pragma solidity ^${SOLIDITY_VERSION};`, ], - printImports(contract.imports, helpers), - - [ - ...printNatspecTags(contract.natspecTags), - [`contract ${contract.name}`, ...printInheritance(contract, helpers), '{'].join(' '), - - spaceBetween( - contract.variables, - printConstructor(contract, helpers), - ...fns.code, - ...fns.modifiers, - hasOverrides ? [`// The following functions are overrides required by Solidity.`] : [], - ...fns.override, - ), - - `}`, - ], - ), + // Imports + // TODO: consolidate imports from same file + contracts + .flatMap(contract => printImports(contract.imports, withHelpers(contract, opts))) + .filter((line, i, lines) => lines.indexOf(line) === i), + + // contracts + ...contracts.map(contract => { + const helpers = withHelpers(contract, opts); + const fns = mapValues(sortedFunctions(contract), fns => fns.map(fn => printFunction(fn, helpers))); + const hasOverrides = fns.override.some(l => l.length > 0); + return [ + ...printNatspecTags(contract.natspecTags), + [`contract ${contract.name}`, ...printInheritance(contract, helpers), '{'].join(' '), + spaceBetween( + contract.variables, + printConstructor(contract, helpers), + ...fns.code, + ...fns.modifiers, + hasOverrides ? [`// The following functions are overrides required by Solidity.`] : [], + ...fns.override, + ), + `}`, + ]; + }) + ) ); } diff --git a/packages/core/solidity/src/signer.ts b/packages/core/solidity/src/signer.ts index 09e2cd111..3aebc4079 100644 --- a/packages/core/solidity/src/signer.ts +++ b/packages/core/solidity/src/signer.ts @@ -26,7 +26,7 @@ export function addSigner(c: ContractBuilder, signer: SignerOptions): void { c.addConstructorCode(`_disableInitializers();`); // Add initializer - const fn = signerFunctions[`initialize${signer}`]; + const fn = signerFunctions.initialize[signer]; c.addModifier('initializer', fn); switch (signer) { @@ -73,41 +73,49 @@ export const signers = { }, }; -export const signerFunctions = defineFunctions({ - initializeECDSA: { - kind: 'public' as const, - args: [{ name: 'signer', type: 'address' }], - }, - initializeP256: { - kind: 'public' as const, - args: [ - { name: 'qx', type: 'bytes32' }, - { name: 'qy', type: 'bytes32' }, - ], - }, - initializeRSA: { - kind: 'public' as const, - args: [ - { name: 'e', type: 'bytes memory' }, - { name: 'n', type: 'bytes memory' }, - ], - }, - initializeMultisig: { - kind: 'public' as const, - args: [ - { name: 'signers', type: 'bytes[] memory' }, - { name: 'threshold', type: 'uint256' }, - ], - }, - initializeMultisigWeighted: { - kind: 'public' as const, - args: [ - { name: 'signers', type: 'bytes[] memory' }, - { name: 'weights', type: 'uint256[] memory' }, - { name: 'threshold', type: 'uint256' }, - ], +export const signerFunctions = { + initialize: { + ECDSA: { + name: 'initialize', + kind: 'public' as const, + args: [{ name: 'signer', type: 'address' }], + }, + P256: { + name: 'initialize', + kind: 'public' as const, + args: [ + { name: 'qx', type: 'bytes32' }, + { name: 'qy', type: 'bytes32' }, + ], + }, + RSA: { + name: 'initialize', + kind: 'public' as const, + args: [ + { name: 'e', type: 'bytes memory' }, + { name: 'n', type: 'bytes memory' }, + ], + }, + Multisig: { + name: 'initialize', + kind: 'public' as const, + args: [ + { name: 'signers', type: 'bytes[] memory' }, + { name: 'threshold', type: 'uint256' }, + ], + }, + MultisigWeighted: { + name: 'initialize', + kind: 'public' as const, + args: [ + { name: 'signers', type: 'bytes[] memory' }, + { name: 'weights', type: 'uint256[] memory' }, + { name: 'threshold', type: 'uint256' }, + ], + }, }, _rawSignatureValidation: { + name: '_rawSignatureValidation', kind: 'internal' as const, args: [ { name: 'hash', type: 'bytes32' }, @@ -116,4 +124,4 @@ export const signerFunctions = defineFunctions({ returns: ['bool'], mutability: 'view' as const, }, -}); +};