@@ -33,97 +33,121 @@ describe('SignatureChecker (ERC1271)', function () {
33
33
34
34
describe ( 'EOA account' , function ( ) {
35
35
it ( 'with matching signer and signature' , async function ( ) {
36
- await expect ( this . mock . $isValidSignatureNow ( this . signer , TEST_MESSAGE_HASH , this . signature ) ) . to . eventually . be
37
- . true ;
36
+ await expect (
37
+ this . mock . $isValidSignatureNow ( ethers . Typed . address ( this . signer . address ) , TEST_MESSAGE_HASH , this . signature ) ,
38
+ ) . to . eventually . be . true ;
38
39
} ) ;
39
40
40
41
it ( 'with invalid signer' , async function ( ) {
41
- await expect ( this . mock . $isValidSignatureNow ( this . other , TEST_MESSAGE_HASH , this . signature ) ) . to . eventually . be
42
- . false ;
42
+ await expect (
43
+ this . mock . $isValidSignatureNow ( ethers . Typed . address ( this . other . address ) , TEST_MESSAGE_HASH , this . signature ) ,
44
+ ) . to . eventually . be . false ;
43
45
} ) ;
44
46
45
47
it ( 'with invalid signature' , async function ( ) {
46
- await expect ( this . mock . $isValidSignatureNow ( this . signer , WRONG_MESSAGE_HASH , this . signature ) ) . to . eventually . be
47
- . false ;
48
+ await expect (
49
+ this . mock . $isValidSignatureNow ( ethers . Typed . address ( this . signer . address ) , WRONG_MESSAGE_HASH , this . signature ) ,
50
+ ) . to . eventually . be . false ;
48
51
} ) ;
49
52
} ) ;
50
53
51
54
describe ( 'ERC1271 wallet' , function ( ) {
52
55
for ( const fn of [ 'isValidERC1271SignatureNow' , 'isValidSignatureNow' ] ) {
53
56
describe ( fn , function ( ) {
54
57
it ( 'with matching signer and signature' , async function ( ) {
55
- await expect ( this . mock . getFunction ( `$${ fn } ` ) ( this . wallet , TEST_MESSAGE_HASH , this . signature ) ) . to . eventually . be
56
- . true ;
58
+ await expect (
59
+ this . mock . getFunction ( `$${ fn } ` ) (
60
+ ethers . Typed . address ( this . wallet . target ) ,
61
+ TEST_MESSAGE_HASH ,
62
+ this . signature ,
63
+ ) ,
64
+ ) . to . eventually . be . true ;
57
65
} ) ;
58
66
59
67
it ( 'with invalid signer' , async function ( ) {
60
- await expect ( this . mock . getFunction ( `$${ fn } ` ) ( this . mock , TEST_MESSAGE_HASH , this . signature ) ) . to . eventually . be
61
- . false ;
68
+ await expect (
69
+ this . mock . getFunction ( `$${ fn } ` ) ( ethers . Typed . address ( this . mock . target ) , TEST_MESSAGE_HASH , this . signature ) ,
70
+ ) . to . eventually . be . false ;
62
71
} ) ;
63
72
64
73
it ( 'with identity precompile' , async function ( ) {
65
- await expect ( this . mock . getFunction ( `$${ fn } ` ) ( precompile . identity , TEST_MESSAGE_HASH , this . signature ) ) . to
66
- . eventually . be . false ;
74
+ await expect (
75
+ this . mock . getFunction ( `$${ fn } ` ) (
76
+ ethers . Typed . address ( precompile . identity ) ,
77
+ TEST_MESSAGE_HASH ,
78
+ this . signature ,
79
+ ) ,
80
+ ) . to . eventually . be . false ;
67
81
} ) ;
68
82
69
83
it ( 'with invalid signature' , async function ( ) {
70
- await expect ( this . mock . getFunction ( `$${ fn } ` ) ( this . wallet , WRONG_MESSAGE_HASH , this . signature ) ) . to . eventually
71
- . be . false ;
84
+ await expect (
85
+ this . mock . getFunction ( `$${ fn } ` ) (
86
+ ethers . Typed . address ( this . wallet . target ) ,
87
+ WRONG_MESSAGE_HASH ,
88
+ this . signature ,
89
+ ) ,
90
+ ) . to . eventually . be . false ;
72
91
} ) ;
73
92
74
93
it ( 'with malicious wallet' , async function ( ) {
75
- await expect ( this . mock . getFunction ( `$${ fn } ` ) ( this . malicious , TEST_MESSAGE_HASH , this . signature ) ) . to . eventually
76
- . be . false ;
94
+ await expect (
95
+ this . mock . getFunction ( `$${ fn } ` ) (
96
+ ethers . Typed . address ( this . malicious . target ) ,
97
+ TEST_MESSAGE_HASH ,
98
+ this . signature ,
99
+ ) ,
100
+ ) . to . eventually . be . false ;
77
101
} ) ;
78
102
} ) ;
79
103
}
80
104
} ) ;
81
105
82
106
describe ( 'ERC7913' , function ( ) {
83
- describe ( 'isValidERC7913SignatureNow ' , function ( ) {
107
+ describe ( 'isValidSignatureNow ' , function ( ) {
84
108
describe ( 'with EOA signer' , function ( ) {
85
109
it ( 'with matching signer and signature' , async function ( ) {
86
110
const eoaSigner = ethers . zeroPadValue ( this . signer . address , 20 ) ;
87
111
const signature = await this . signer . signMessage ( TEST_MESSAGE ) ;
88
- await expect ( this . mock . $isValidERC7913SignatureNow ( eoaSigner , TEST_MESSAGE_HASH , signature ) ) . to . eventually . be
89
- . true ;
112
+ await expect ( this . mock . $isValidSignatureNow ( ethers . Typed . bytes ( eoaSigner ) , TEST_MESSAGE_HASH , signature ) ) . to
113
+ . eventually . be . true ;
90
114
} ) ;
91
115
92
116
it ( 'with invalid signer' , async function ( ) {
93
117
const eoaSigner = ethers . zeroPadValue ( this . other . address , 20 ) ;
94
118
const signature = await this . signer . signMessage ( TEST_MESSAGE ) ;
95
- await expect ( this . mock . $isValidERC7913SignatureNow ( eoaSigner , TEST_MESSAGE_HASH , signature ) ) . to . eventually . be
96
- . false ;
119
+ await expect ( this . mock . $isValidSignatureNow ( ethers . Typed . bytes ( eoaSigner ) , TEST_MESSAGE_HASH , signature ) ) . to
120
+ . eventually . be . false ;
97
121
} ) ;
98
122
99
123
it ( 'with invalid signature' , async function ( ) {
100
124
const eoaSigner = ethers . zeroPadValue ( this . signer . address , 20 ) ;
101
125
const signature = await this . signer . signMessage ( TEST_MESSAGE ) ;
102
- await expect ( this . mock . $isValidERC7913SignatureNow ( eoaSigner , WRONG_MESSAGE_HASH , signature ) ) . to . eventually . be
103
- . false ;
126
+ await expect ( this . mock . $isValidSignatureNow ( ethers . Typed . bytes ( eoaSigner ) , WRONG_MESSAGE_HASH , signature ) ) . to
127
+ . eventually . be . false ;
104
128
} ) ;
105
129
} ) ;
106
130
107
131
describe ( 'with ERC-1271 wallet' , function ( ) {
108
132
it ( 'with matching signer and signature' , async function ( ) {
109
133
const walletSigner = ethers . zeroPadValue ( this . wallet . target , 20 ) ;
110
134
const signature = await this . signer . signMessage ( TEST_MESSAGE ) ;
111
- await expect ( this . mock . $isValidERC7913SignatureNow ( walletSigner , TEST_MESSAGE_HASH , signature ) ) . to . eventually
112
- . be . true ;
135
+ await expect ( this . mock . $isValidSignatureNow ( ethers . Typed . bytes ( walletSigner ) , TEST_MESSAGE_HASH , signature ) )
136
+ . to . eventually . be . true ;
113
137
} ) ;
114
138
115
139
it ( 'with invalid signer' , async function ( ) {
116
140
const walletSigner = ethers . zeroPadValue ( this . mock . target , 20 ) ;
117
141
const signature = await this . signer . signMessage ( TEST_MESSAGE ) ;
118
- await expect ( this . mock . $isValidERC7913SignatureNow ( walletSigner , TEST_MESSAGE_HASH , signature ) ) . to . eventually
119
- . be . false ;
142
+ await expect ( this . mock . $isValidSignatureNow ( ethers . Typed . bytes ( walletSigner ) , TEST_MESSAGE_HASH , signature ) )
143
+ . to . eventually . be . false ;
120
144
} ) ;
121
145
122
146
it ( 'with invalid signature' , async function ( ) {
123
147
const walletSigner = ethers . zeroPadValue ( this . wallet . target , 20 ) ;
124
148
const signature = await this . signer . signMessage ( TEST_MESSAGE ) ;
125
- await expect ( this . mock . $isValidERC7913SignatureNow ( walletSigner , WRONG_MESSAGE_HASH , signature ) ) . to . eventually
126
- . be . false ;
149
+ await expect ( this . mock . $isValidSignatureNow ( ethers . Typed . bytes ( walletSigner ) , WRONG_MESSAGE_HASH , signature ) )
150
+ . to . eventually . be . false ;
127
151
} ) ;
128
152
} ) ;
129
153
@@ -136,8 +160,8 @@ describe('SignatureChecker (ERC1271)', function () {
136
160
] ) ;
137
161
const signature = await aliceP256 . signMessage ( TEST_MESSAGE ) ;
138
162
139
- await expect ( this . mock . $isValidERC7913SignatureNow ( signer , TEST_MESSAGE_HASH , signature ) ) . to . eventually . be
140
- . true ;
163
+ await expect ( this . mock . $isValidSignatureNow ( ethers . Typed . bytes ( signer ) , TEST_MESSAGE_HASH , signature ) ) . to
164
+ . eventually . be . true ;
141
165
} ) ;
142
166
143
167
it ( 'with invalid verifier' , async function ( ) {
@@ -148,16 +172,16 @@ describe('SignatureChecker (ERC1271)', function () {
148
172
] ) ;
149
173
const signature = await aliceP256 . signMessage ( TEST_MESSAGE ) ;
150
174
151
- await expect ( this . mock . $isValidERC7913SignatureNow ( signer , TEST_MESSAGE_HASH , signature ) ) . to . eventually . be
152
- . false ;
175
+ await expect ( this . mock . $isValidSignatureNow ( ethers . Typed . bytes ( signer ) , TEST_MESSAGE_HASH , signature ) ) . to
176
+ . eventually . be . false ;
153
177
} ) ;
154
178
155
179
it ( 'with invalid key' , async function ( ) {
156
180
const signer = ethers . concat ( [ this . verifier . target , ethers . randomBytes ( 32 ) ] ) ;
157
181
const signature = await aliceP256 . signMessage ( TEST_MESSAGE ) ;
158
182
159
- await expect ( this . mock . $isValidERC7913SignatureNow ( signer , TEST_MESSAGE_HASH , signature ) ) . to . eventually . be
160
- . false ;
183
+ await expect ( this . mock . $isValidSignatureNow ( ethers . Typed . bytes ( signer ) , TEST_MESSAGE_HASH , signature ) ) . to
184
+ . eventually . be . false ;
161
185
} ) ;
162
186
163
187
it ( 'with invalid signature' , async function ( ) {
@@ -168,29 +192,28 @@ describe('SignatureChecker (ERC1271)', function () {
168
192
] ) ;
169
193
const signature = ethers . randomBytes ( 65 ) ; // invalid (random) signature
170
194
171
- await expect ( this . mock . $isValidERC7913SignatureNow ( signer , TEST_MESSAGE_HASH , signature ) ) . to . eventually . be
172
- . false ;
195
+ await expect ( this . mock . $isValidSignatureNow ( ethers . Typed . bytes ( signer ) , TEST_MESSAGE_HASH , signature ) ) . to
196
+ . eventually . be . false ;
173
197
} ) ;
174
198
175
199
it ( 'with signer too short' , async function ( ) {
176
200
const signer = ethers . randomBytes ( 19 ) ; // too short
177
201
const signature = await aliceP256 . signMessage ( TEST_MESSAGE ) ;
178
- await expect ( this . mock . $isValidERC7913SignatureNow ( signer , TEST_MESSAGE_HASH , signature ) ) . to . eventually . be
179
- . false ;
202
+ await expect ( this . mock . $isValidSignatureNow ( ethers . Typed . bytes ( signer ) , TEST_MESSAGE_HASH , signature ) ) . to
203
+ . eventually . be . false ;
180
204
} ) ;
181
205
} ) ;
182
206
} ) ;
183
207
184
- describe ( 'areValidERC7913SignaturesNow ' , function ( ) {
208
+ describe ( 'areValidSignaturesNow ' , function ( ) {
185
209
const sortSigners = ( ...signers ) =>
186
210
signers . sort ( ( { signer : a } , { signer : b } ) => ethers . keccak256 ( b ) - ethers . keccak256 ( a ) ) ;
187
211
188
212
it ( 'should validate a single signature' , async function ( ) {
189
213
const signer = ethers . zeroPadValue ( this . signer . address , 20 ) ;
190
214
const signature = await this . signer . signMessage ( TEST_MESSAGE ) ;
191
215
192
- await expect ( this . mock . $areValidERC7913SignaturesNow ( TEST_MESSAGE_HASH , [ signer ] , [ signature ] ) ) . to . eventually . be
193
- . true ;
216
+ await expect ( this . mock . $areValidSignaturesNow ( TEST_MESSAGE_HASH , [ signer ] , [ signature ] ) ) . to . eventually . be . true ;
194
217
} ) ;
195
218
196
219
it ( 'should validate multiple signatures with different signer types' , async function ( ) {
@@ -214,7 +237,7 @@ describe('SignatureChecker (ERC1271)', function () {
214
237
) ;
215
238
216
239
await expect (
217
- this . mock . $areValidERC7913SignaturesNow (
240
+ this . mock . $areValidSignaturesNow (
218
241
TEST_MESSAGE_HASH ,
219
242
signers . map ( ( { signer } ) => signer ) ,
220
243
signers . map ( ( { signature } ) => signature ) ,
@@ -235,7 +258,7 @@ describe('SignatureChecker (ERC1271)', function () {
235
258
) ;
236
259
237
260
await expect (
238
- this . mock . $areValidERC7913SignaturesNow (
261
+ this . mock . $areValidSignaturesNow (
239
262
TEST_MESSAGE_HASH ,
240
263
signers . map ( ( { signer } ) => signer ) ,
241
264
signers . map ( ( { signature } ) => signature ) ,
@@ -256,7 +279,7 @@ describe('SignatureChecker (ERC1271)', function () {
256
279
) ;
257
280
258
281
await expect (
259
- this . mock . $areValidERC7913SignaturesNow (
282
+ this . mock . $areValidSignaturesNow (
260
283
TEST_MESSAGE_HASH ,
261
284
signers . map ( ( { signer } ) => signer ) ,
262
285
signers . map ( ( { signature } ) => signature ) ,
@@ -285,7 +308,7 @@ describe('SignatureChecker (ERC1271)', function () {
285
308
) ;
286
309
287
310
await expect (
288
- this . mock . $areValidERC7913SignaturesNow (
311
+ this . mock . $areValidSignaturesNow (
289
312
TEST_MESSAGE_HASH ,
290
313
signers . map ( ( { signer } ) => signer ) ,
291
314
signers . map ( ( { signature } ) => signature ) ,
@@ -314,7 +337,7 @@ describe('SignatureChecker (ERC1271)', function () {
314
337
) . reverse ( ) ; // reverse
315
338
316
339
await expect (
317
- this . mock . $areValidERC7913SignaturesNow (
340
+ this . mock . $areValidSignaturesNow (
318
341
TEST_MESSAGE_HASH ,
319
342
signers . map ( ( { signer } ) => signer ) ,
320
343
signers . map ( ( { signature } ) => signature ) ,
@@ -335,7 +358,7 @@ describe('SignatureChecker (ERC1271)', function () {
335
358
) ;
336
359
337
360
await expect (
338
- this . mock . $areValidERC7913SignaturesNow (
361
+ this . mock . $areValidSignaturesNow (
339
362
TEST_MESSAGE_HASH ,
340
363
signers . map ( ( { signer } ) => signer ) ,
341
364
signers . map ( ( { signature } ) => signature ) ,
@@ -356,7 +379,7 @@ describe('SignatureChecker (ERC1271)', function () {
356
379
) ;
357
380
358
381
await expect (
359
- this . mock . $areValidERC7913SignaturesNow (
382
+ this . mock . $areValidSignaturesNow (
360
383
TEST_MESSAGE_HASH ,
361
384
signers . map ( ( { signer } ) => signer ) ,
362
385
signers . map ( ( { signature } ) => signature ) ,
@@ -377,7 +400,7 @@ describe('SignatureChecker (ERC1271)', function () {
377
400
) ;
378
401
379
402
await expect (
380
- this . mock . $areValidERC7913SignaturesNow (
403
+ this . mock . $areValidSignaturesNow (
381
404
TEST_MESSAGE_HASH ,
382
405
signers . map ( ( { signer } ) => signer ) ,
383
406
signers . map ( ( { signature } ) => signature ) . slice ( 1 ) ,
@@ -386,7 +409,7 @@ describe('SignatureChecker (ERC1271)', function () {
386
409
} ) ;
387
410
388
411
it ( 'should pass with empty arrays' , async function ( ) {
389
- await expect ( this . mock . $areValidERC7913SignaturesNow ( TEST_MESSAGE_HASH , [ ] , [ ] ) ) . to . eventually . be . true ;
412
+ await expect ( this . mock . $areValidSignaturesNow ( TEST_MESSAGE_HASH , [ ] , [ ] ) ) . to . eventually . be . true ;
390
413
} ) ;
391
414
} ) ;
392
415
} ) ;
0 commit comments