Skip to content

Commit 5f3c6c2

Browse files
ernestognwericglau
andauthored
Add Account and increase pragma to 0.8.27 (#486)
Co-authored-by: Eric Lau <[email protected]>
1 parent 4b17b08 commit 5f3c6c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2460
-199
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@
3535
"typescript-eslint": "^8.29.0",
3636
"wsrun": "^5.2.4"
3737
}
38-
}
38+
}

packages/core/solidity/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
- Add `account` contract types for ERC-4337. ([#486](https://github.com/OpenZeppelin/contracts-wizard/pull/486))
6+
7+
- **Potentially breaking changes**:
8+
- Update pragma versions to 0.8.27. ([#486](https://github.com/OpenZeppelin/contracts-wizard/pull/486))
9+
310
## 0.5.4 (2025-04-01)
411

512
- Add validation for ERC20 premint field. ([#488](https://github.com/OpenZeppelin/contracts-wizard/pull/488))

packages/core/solidity/README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ The following contract types are supported:
1818
- `erc1155`
1919
- `stablecoin`
2020
- `realWorldAsset`
21+
- `account`
2122
- `governor`
2223
- `custom`
2324

24-
Note that `stablecoin` and `realWorldAsset` are experimental and may be subject to change.
25+
Note that `stablecoin`, `realWorldAsset`, and `account` are experimental and may be subject to change.
2526

2627
Each contract type has functions/constants as defined below.
2728

@@ -41,6 +42,9 @@ function print(opts?: ERC1155Options): string
4142
function print(opts?: StablecoinOptions): string
4243
```
4344
```js
45+
function print(opts?: AccountOptions): string
46+
```
47+
```js
4448
function print(opts?: GovernorOptions): string
4549
```
4650
```js
@@ -62,6 +66,9 @@ const defaults: Required<ERC1155Options>
6266
const defaults: Required<StablecoinOptions>
6367
```
6468
```js
69+
const defaults: Required<AccountOptions>
70+
```
71+
```js
6572
const defaults: Required<GovernorOptions>
6673
```
6774
```js
@@ -88,7 +95,10 @@ function isAccessControlRequired(opts: Partial<GovernorOptions>): boolean
8895
```js
8996
function isAccessControlRequired(opts: Partial<CustomOptions>): boolean
9097
```
91-
Whether any of the provided options require access control to be enabled. If this returns `true`, then calling `print` with the same options would cause the `access` option to default to `'ownable'` if it was `undefined` or `false`.
98+
Whether any of the provided options require access control to be enabled. If this returns `true`, then calling `print` with the same options would cause the `access` option to default to `'ownable'` if it was `undefined` or `false`.
99+
100+
> Note that contracts such as `account`, have its own way of handling permissions and do not support the `access` option.
101+
Thus, that type does not include `isAccessControlRequired`.
92102

93103
### Examples
94104

@@ -119,4 +129,4 @@ const contract = erc20.print({
119129
...erc20.defaults,
120130
upgradeable: 'uups',
121131
});
122-
```
132+
```

packages/core/solidity/hardhat.config.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,14 @@ task(TASK_COMPILE_SOLIDITY_MERGE_COMPILATION_JOBS, async ({ compilationJobs }, _
4141
* @type import('hardhat/config').HardhatUserConfig
4242
*/
4343
module.exports = {
44-
solidity: SOLIDITY_VERSION,
44+
solidity: {
45+
version: SOLIDITY_VERSION,
46+
settings: {
47+
evmVersion: 'cancun',
48+
optimizer: {
49+
enabled: true,
50+
runs: 200,
51+
},
52+
},
53+
},
4554
};

packages/core/solidity/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@
2424
},
2525
"devDependencies": {
2626
"@openzeppelin/community-contracts": "https://github.com/OpenZeppelin/openzeppelin-community-contracts",
27-
"@openzeppelin/contracts": "^5.1.0",
28-
"@openzeppelin/contracts-upgradeable": "^5.1.0",
27+
"@openzeppelin/contracts": "^5.3.0",
28+
"@openzeppelin/contracts-upgradeable": "^5.3.0",
2929
"@types/node": "^18.0.0",
3030
"@types/semver": "^7.5.7",
3131
"ava": "^6.0.0",
32-
"hardhat": "^2.1.1",
32+
"hardhat": "^2.22.11",
3333
"jszip": "^3.6.0",
3434
"rimraf": "^5.0.0",
3535
"semver": "^7.6.0",
3636
"solidity-ast": "^0.4.18",
3737
"ts-node": "^10.4.0",
3838
"typescript": "^5.0.0"
3939
}
40-
}
40+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import test from 'ava';
2+
import { account } from '.';
3+
4+
import type { AccountOptions } from './account';
5+
import { buildAccount } from './account';
6+
import { printContract } from './print';
7+
8+
/**
9+
* Tests external API for equivalence with internal API
10+
*/
11+
function testAPIEquivalence(title: string, opts?: AccountOptions) {
12+
test(title, t => {
13+
t.is(
14+
account.print(opts),
15+
printContract(
16+
buildAccount({
17+
name: 'MyAccount',
18+
signatureValidation: 'ERC7739',
19+
ERC721Holder: true,
20+
ERC1155Holder: true,
21+
batchedExecution: false,
22+
ERC7579Modules: false,
23+
...opts,
24+
}),
25+
),
26+
);
27+
});
28+
}
29+
30+
function testAccount(title: string, opts: Partial<AccountOptions>) {
31+
const fullOpts = {
32+
name: 'MyAccount',
33+
ERC1271: false as const,
34+
ERC721Holder: false,
35+
ERC1155Holder: false,
36+
ERC7821: false as const,
37+
ERC7579: false as const,
38+
...opts,
39+
};
40+
test(title, t => {
41+
const c = buildAccount(fullOpts);
42+
t.snapshot(printContract(c));
43+
});
44+
testAPIEquivalence(`${title} API equivalence`, fullOpts);
45+
}
46+
47+
testAPIEquivalence('account API default');
48+
49+
test('account API assert defaults', async t => {
50+
t.is(account.print(account.defaults), account.print());
51+
});
52+
53+
for (const signer of [undefined, 'ERC7702', 'ECDSA', 'P256', 'RSA'] as const) {
54+
let title = 'Account';
55+
if (signer) {
56+
title += ` with Signer${signer}`;
57+
}
58+
59+
testAccount(`${title} named`, {
60+
name: `Custom${title}`,
61+
signer,
62+
});
63+
64+
testAccount(`${title} with ERC1271`, {
65+
name: `Custom${title}ERC1271`,
66+
signatureValidation: 'ERC1271',
67+
signer,
68+
});
69+
70+
testAccount(`${title} with ERC7739`, {
71+
name: `Custom${title}ERC7739`,
72+
signatureValidation: 'ERC7739',
73+
signer,
74+
});
75+
76+
testAccount(`${title} with ERC721Holder`, {
77+
name: `Custom${title}ERC721Holder`,
78+
ERC721Holder: true,
79+
signer,
80+
});
81+
82+
testAccount(`${title} with ERC1155Holder`, {
83+
name: `Custom${title}ERC1155Holder`,
84+
ERC1155Holder: true,
85+
signer,
86+
});
87+
88+
testAccount(`${title} with ERC721Holder and ERC1155Holder`, {
89+
name: `Custom${title}ERC721HolderERC1155Holder`,
90+
ERC721Holder: true,
91+
ERC1155Holder: true,
92+
signer,
93+
});
94+
95+
testAccount(`${title} with ERC7821 Execution`, {
96+
signer,
97+
batchedExecution: true,
98+
});
99+
100+
testAccount(`${title} with ERC7579`, {
101+
signer,
102+
ERC7579Modules: 'AccountERC7579',
103+
});
104+
105+
testAccount(`${title} with ERC7579 hooks`, {
106+
signer,
107+
ERC7579Modules: 'AccountERC7579Hooked',
108+
});
109+
}

0 commit comments

Comments
 (0)