7
7
} from "../utils/index.js" ;
8
8
9
9
import type {
10
- BigNumberish , BytesLike
10
+ BigNumberish , BytesLike , Numeric
11
11
} from "../utils/index.js" ;
12
12
13
13
@@ -325,7 +325,7 @@ export class Signature {
325
325
assertError ( ( getBytes ( s ) [ 0 ] & 0x80 ) == 0 , "non-canonical s" ) ;
326
326
327
327
// Get v; by any means necessary (we check consistency below)
328
- const { networkV, v } = ( function ( _v ?: BigNumberish , yParityAndS ?: string , yParity ?: number ) : { networkV ?: bigint , v : 27 | 28 } {
328
+ const { networkV, v } = ( function ( _v ?: BigNumberish , yParityAndS ?: string , yParity ?: Numeric ) : { networkV ?: bigint , v : 27 | 28 } {
329
329
if ( _v != null ) {
330
330
const v = getBigInt ( _v ) ;
331
331
return {
@@ -340,7 +340,7 @@ export class Signature {
340
340
}
341
341
342
342
if ( yParity != null ) {
343
- switch ( yParity ) {
343
+ switch ( getNumber ( yParity , "sig.yParity" ) ) {
344
344
case 0 : return { v : 27 } ;
345
345
case 1 : return { v : 28 } ;
346
346
}
@@ -354,8 +354,8 @@ export class Signature {
354
354
if ( networkV ) { result . #networkV = networkV ; }
355
355
356
356
// If multiple of v, yParity, yParityAndS we given, check they match
357
- assertError ( ! ( " yParity" in sig && sig . yParity !== result . yParity ) , "yParity mismatch" ) ;
358
- assertError ( ! ( " yParityAndS" in sig && sig . yParityAndS !== result . yParityAndS ) , "yParityAndS mismatch" ) ;
357
+ assertError ( sig . yParity == null || getNumber ( sig . yParity , "sig.yParity" ) === result . yParity , "yParity mismatch" ) ;
358
+ assertError ( sig . yParityAndS == null || sig . yParityAndS === result . yParityAndS , "yParityAndS mismatch" ) ;
359
359
360
360
return result ;
361
361
}
0 commit comments