@@ -76,7 +76,7 @@ function addParents(c: ContractBuilder, opts: AccountOptions): void {
76
76
// Base
77
77
c . addParent ( {
78
78
name : 'Account' ,
79
- path : `@openzeppelin/community- contracts/account/Account.sol` ,
79
+ path : `@openzeppelin/contracts/account/Account.sol` ,
80
80
} ) ;
81
81
c . addOverride ( { name : 'Account' } , functions . _validateUserOp ) ;
82
82
@@ -93,28 +93,26 @@ function addParents(c: ContractBuilder, opts: AccountOptions): void {
93
93
}
94
94
95
95
function addSignatureValidation ( c : ContractBuilder , opts : AccountOptions ) {
96
- switch ( opts . signatureValidation ) {
97
- case 'ERC7739' :
98
- c . addParent ( {
99
- name : 'ERC7739' ,
100
- path : '@openzeppelin/community-contracts/utils/cryptography/ERC7739.sol' ,
101
- } ) ;
102
- break ;
103
- case 'ERC1271' :
104
- c . addParent ( {
105
- name : 'IERC1271' ,
106
- path : '@openzeppelin/contracts/interfaces/IERC1271.sol' ,
107
- } ) ;
108
- c . addOverride ( { name : 'IERC1271' } , functions . isValidSignature ) ;
109
- if ( ! opts . ERC7579Modules ) {
110
- c . setFunctionBody (
111
- [
112
- 'return _rawSignatureValidation(hash, signature) ? IERC1271.isValidSignature.selector : bytes4(0xffffffff);' ,
113
- ] ,
114
- functions . isValidSignature ,
115
- ) ;
116
- }
117
- break ;
96
+ if ( opts . signatureValidation === 'ERC7739' ) {
97
+ c . addParent ( {
98
+ name : 'ERC7739' ,
99
+ path : '@openzeppelin/contracts/utils/cryptography/signers/draft-ERC7739.sol' ,
100
+ } ) ;
101
+ } else if ( opts . signatureValidation === 'ERC1271' && ! opts . signatureValidation ) {
102
+ c . addParent ( {
103
+ name : 'IERC1271' ,
104
+ path : '@openzeppelin/contracts/interfaces/IERC1271.sol' ,
105
+ } ) ;
106
+ c . addOverride ( { name : 'IERC1271' } , functions . isValidSignature ) ;
107
+ c . setFunctionBody (
108
+ [
109
+ 'return _rawSignatureValidation(hash, signature) ? IERC1271.isValidSignature.selector : bytes4(0xffffffff);' ,
110
+ ] ,
111
+ functions . isValidSignature ,
112
+ ) ;
113
+ } else {
114
+ // ERC1271 is natively supported by ERC-7579, no need to expose ERC-1271 manually
115
+ // do nothing
118
116
}
119
117
}
120
118
@@ -139,7 +137,7 @@ function addBatchedExecution(c: ContractBuilder, opts: AccountOptions): void {
139
137
if ( ! opts . batchedExecution || ! ! opts . ERC7579Modules ) return ;
140
138
c . addParent ( {
141
139
name : 'ERC7821' ,
142
- path : '@openzeppelin/community- contracts/account/extensions/ERC7821.sol' ,
140
+ path : '@openzeppelin/contracts/account/extensions/draft- ERC7821.sol' ,
143
141
} ) ;
144
142
c . addOverride ( { name : 'ERC7821' } , functions . _erc7821AuthorizedExecutor ) ;
145
143
c . setFunctionBody (
@@ -152,28 +150,30 @@ function addERC7579Modules(c: ContractBuilder, opts: AccountOptions): void {
152
150
if ( ! opts . ERC7579Modules ) return ;
153
151
c . addParent ( {
154
152
name : opts . ERC7579Modules ,
155
- path : `@openzeppelin/community- contracts/account/extensions/${ opts . ERC7579Modules } .sol` ,
153
+ path : `@openzeppelin/contracts/account/extensions/draft- ${ opts . ERC7579Modules } .sol` ,
156
154
} ) ;
157
155
if ( opts . ERC7579Modules !== 'AccountERC7579' ) {
158
156
c . addImportOnly ( {
159
157
name : 'AccountERC7579' ,
160
- path : `@openzeppelin/community- contracts/account/extensions/AccountERC7579.sol` ,
158
+ path : `@openzeppelin/contracts/account/extensions/draft- AccountERC7579.sol` ,
161
159
} ) ;
162
160
}
163
161
c . addOverride ( { name : 'AccountERC7579' } , functions . isValidSignature ) ;
164
162
c . addOverride ( { name : 'AccountERC7579' } , functions . _validateUserOp ) ;
165
163
166
- if ( opts . signatureValidation !== 'ERC7739' ) return ;
167
- c . addOverride ( { name : 'ERC7739' } , functions . isValidSignature ) ;
168
- c . setFunctionBody (
169
- [
170
- '// ERC-7739 can return the ERC-1271 magic value, 0xffffffff (invalid) or 0x77390001 (detection).' ,
171
- '// If the returned value is 0xffffffff, fallback to ERC-7579 validation.' ,
172
- 'bytes4 erc7739magic = ERC7739.isValidSignature(hash, signature);' ,
173
- 'return erc7739magic == bytes4(0xffffffff) ? AccountERC7579.isValidSignature(hash, signature) : erc7739magic;' ,
174
- ] ,
175
- functions . isValidSignature ,
176
- ) ;
164
+ // ERC-7579 provides ERC-1271 interface. If ERC-7739 is enabled, we need to reconcile
165
+ if ( opts . signatureValidation === 'ERC7739' ) {
166
+ c . addOverride ( { name : 'ERC7739' } , functions . isValidSignature ) ;
167
+ c . setFunctionBody (
168
+ [
169
+ '// ERC-7739 can return the ERC-1271 magic value, 0xffffffff (invalid) or 0x77390001 (detection).' ,
170
+ '// If the returned value is 0xffffffff, fallback to ERC-7579 validation.' ,
171
+ 'bytes4 erc7739magic = ERC7739.isValidSignature(hash, signature);' ,
172
+ 'return erc7739magic == bytes4(0xffffffff) ? AccountERC7579.isValidSignature(hash, signature) : erc7739magic;' ,
173
+ ] ,
174
+ functions . isValidSignature ,
175
+ ) ;
176
+ }
177
177
}
178
178
179
179
function addMultisigFunctions ( c : ContractBuilder , opts : AccountOptions ) : void {
@@ -198,7 +198,7 @@ function addMultisigFunctions(c: ContractBuilder, opts: AccountOptions): void {
198
198
}
199
199
200
200
function addEIP712 ( c : ContractBuilder , opts : AccountOptions ) : void {
201
- if ( opts . signatureValidation != 'ERC7739' ) return ;
201
+ if ( opts . signatureValidation !== 'ERC7739' ) return ;
202
202
c . addParent (
203
203
{
204
204
name : 'EIP712' ,
@@ -224,7 +224,7 @@ function overrideRawSignatureValidation(c: ContractBuilder, opts: AccountOptions
224
224
if ( opts . signer && opts . ERC7579Modules ) {
225
225
c . addImportOnly ( {
226
226
name : 'AbstractSigner' ,
227
- path : '@openzeppelin/community- contracts/utils/cryptography/AbstractSigner.sol' ,
227
+ path : '@openzeppelin/contracts/utils/cryptography/signers /AbstractSigner.sol' ,
228
228
} ) ;
229
229
c . addOverride ( { name : 'AbstractSigner' } , signerFunctions . _rawSignatureValidation ) ;
230
230
c . addOverride ( { name : 'AccountERC7579' } , signerFunctions . _rawSignatureValidation ) ;
@@ -244,53 +244,51 @@ function overrideRawSignatureValidation(c: ContractBuilder, opts: AccountOptions
244
244
}
245
245
}
246
246
247
- const functions = {
248
- ...defineFunctions ( {
249
- isValidSignature : {
250
- kind : 'public' as const ,
251
- mutability : 'view' as const ,
252
- args : [
253
- { name : 'hash' , type : 'bytes32' } ,
254
- { name : 'signature' , type : 'bytes calldata' } ,
255
- ] ,
256
- returns : [ 'bytes4' ] ,
257
- } ,
258
- _validateUserOp : {
259
- kind : 'internal' as const ,
260
- args : [
261
- { name : 'userOp' , type : 'PackedUserOperation calldata' } ,
262
- { name : 'userOpHash' , type : 'bytes32' } ,
263
- ] ,
264
- returns : [ 'uint256' ] ,
265
- } ,
266
- _erc7821AuthorizedExecutor : {
267
- kind : 'internal' as const ,
268
- args : [
269
- { name : 'caller' , type : 'address' } ,
270
- { name : 'mode' , type : 'bytes32' } ,
271
- { name : 'executionData' , type : 'bytes calldata' } ,
272
- ] ,
273
- returns : [ 'bool' ] ,
274
- mutability : 'view' as const ,
275
- } ,
276
- addSigners : {
277
- kind : 'public' as const ,
278
- args : [ { name : 'signers' , type : 'bytes[] memory' } ] ,
279
- } ,
280
- removeSigners : {
281
- kind : 'public' as const ,
282
- args : [ { name : 'signers' , type : 'bytes[] memory' } ] ,
283
- } ,
284
- setThreshold : {
285
- kind : 'public' as const ,
286
- args : [ { name : 'threshold' , type : 'uint256' } ] ,
287
- } ,
288
- setSignerWeights : {
289
- kind : 'public' as const ,
290
- args : [
291
- { name : 'signers' , type : 'bytes[] memory' } ,
292
- { name : 'weights' , type : 'uint256[] memory' } ,
293
- ] ,
294
- } ,
295
- } ) ,
296
- } ;
247
+ const functions = defineFunctions ( {
248
+ isValidSignature : {
249
+ kind : 'public' as const ,
250
+ mutability : 'view' as const ,
251
+ args : [
252
+ { name : 'hash' , type : 'bytes32' } ,
253
+ { name : 'signature' , type : 'bytes calldata' } ,
254
+ ] ,
255
+ returns : [ 'bytes4' ] ,
256
+ } ,
257
+ _validateUserOp : {
258
+ kind : 'internal' as const ,
259
+ args : [
260
+ { name : 'userOp' , type : 'PackedUserOperation calldata' } ,
261
+ { name : 'userOpHash' , type : 'bytes32' } ,
262
+ ] ,
263
+ returns : [ 'uint256' ] ,
264
+ } ,
265
+ _erc7821AuthorizedExecutor : {
266
+ kind : 'internal' as const ,
267
+ args : [
268
+ { name : 'caller' , type : 'address' } ,
269
+ { name : 'mode' , type : 'bytes32' } ,
270
+ { name : 'executionData' , type : 'bytes calldata' } ,
271
+ ] ,
272
+ returns : [ 'bool' ] ,
273
+ mutability : 'view' as const ,
274
+ } ,
275
+ addSigners : {
276
+ kind : 'public' as const ,
277
+ args : [ { name : 'signers' , type : 'bytes[] memory' } ] ,
278
+ } ,
279
+ removeSigners : {
280
+ kind : 'public' as const ,
281
+ args : [ { name : 'signers' , type : 'bytes[] memory' } ] ,
282
+ } ,
283
+ setThreshold : {
284
+ kind : 'public' as const ,
285
+ args : [ { name : 'threshold' , type : 'uint64' } ] ,
286
+ } ,
287
+ setSignerWeights : {
288
+ kind : 'public' as const ,
289
+ args : [
290
+ { name : 'signers' , type : 'bytes[] memory' } ,
291
+ { name : 'weights' , type : 'uint64[] memory' } ,
292
+ ] ,
293
+ } ,
294
+ } ) ;
0 commit comments