File tree 2 files changed +11
-10
lines changed
2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -349,16 +349,19 @@ class HdKeyring {
349
349
* @param opts - The options for signing the message.
350
350
* @returns The signature of the message.
351
351
*/
352
- async signTypedData < Types extends MessageTypes > (
352
+ async signTypedData <
353
+ Version extends SignTypedDataVersion ,
354
+ Types extends MessageTypes ,
355
+ Options extends { version : Version } ,
356
+ > (
353
357
withAccount : Hex ,
354
- typedData : TypedDataV1 | TypedMessage < Types > ,
355
- opts : HDKeyringAccountSelectionOptions & {
356
- version : SignTypedDataVersion ;
357
- } = { version : SignTypedDataVersion . V1 } ,
358
+ typedData : Version extends 'V1' ? TypedDataV1 : TypedMessage < Types > ,
359
+ opts ?: HDKeyringAccountSelectionOptions & Options ,
358
360
) : Promise < string > {
361
+ const options = opts ?? { version : SignTypedDataVersion . V1 } ;
359
362
// Treat invalid versions as "V1"
360
- const version = Object . keys ( SignTypedDataVersion ) . includes ( opts . version )
361
- ? opts . version
363
+ const version = Object . keys ( SignTypedDataVersion ) . includes ( options . version )
364
+ ? options . version
362
365
: SignTypedDataVersion . V1 ;
363
366
364
367
const privateKey = this . #getPrivateKeyFor( withAccount , opts ) ;
Original file line number Diff line number Diff line change @@ -156,9 +156,7 @@ export default class SimpleKeyring implements Keyring {
156
156
Options extends { version : Version } & KeyringOpt ,
157
157
> (
158
158
address : Hex ,
159
- typedData : Version extends SignTypedDataVersion . V1
160
- ? TypedDataV1
161
- : TypedMessage < Types > ,
159
+ typedData : Version extends 'V1' ? TypedDataV1 : TypedMessage < Types > ,
162
160
opts ?: Options ,
163
161
) : Promise < string > {
164
162
const options = opts ?? { version : SignTypedDataVersion . V1 } ;
You can’t perform that action at this time.
0 commit comments