@@ -31,7 +31,6 @@ import {
3131 Nonce ,
3232 ProviderOptions ,
3333 Signature ,
34- SignatureVerifResult ,
3534 SimulateTransactionDetails ,
3635 SimulateTransactionResponse ,
3736 TransactionType ,
@@ -549,10 +548,7 @@ export class Account extends Provider implements AccountInterface {
549548 return getMessageHash ( typedData , this . address ) ;
550549 }
551550
552- public async verifyMessageHash (
553- hash : BigNumberish ,
554- signature : Signature
555- ) : Promise < SignatureVerifResult > {
551+ public async verifyMessageHash ( hash : BigNumberish , signature : Signature ) : Promise < boolean > {
556552 try {
557553 const resp = await this . callContract ( {
558554 contractAddress : this . address ,
@@ -562,46 +558,26 @@ export class Account extends Provider implements AccountInterface {
562558 signature : formatSignature ( signature ) ,
563559 } ) ,
564560 } ) ;
565- // console.log('verifySign=', resp);
566- if ( BigInt ( resp . result [ 0 ] ) === 0n ) {
561+ if ( BigInt ( resp [ 0 ] ) === 0n ) {
567562 // OpenZeppelin 0.8.0 invalid signature
568- return {
569- isVerificationProcessed : true ,
570- isSignatureValid : false ,
571- } as SignatureVerifResult ;
563+ return false ;
572564 }
573565 // OpenZeppelin 0.8.0, ArgentX 0.3.0 & Braavos Cairo 0 valid signature
574- return {
575- isVerificationProcessed : true ,
576- isSignatureValid : true ,
577- } as SignatureVerifResult ;
566+ return true ;
578567 } catch ( err ) {
579- // console.log('verifySign error=', err);
580- if ( ( err as Error ) . message . includes ( 'argent/invalid-signature' ) ) {
581- // ArgentX 0.3.0 invalid signature
582- return {
583- isVerificationProcessed : true ,
584- isSignatureValid : false ,
585- } as SignatureVerifResult ;
586- }
587- if ( ( err as Error ) . message . includes ( 'is invalid, with respect to the public key' ) ) {
588- // Braavos Cairo 0 invalid signature
589- return {
590- isVerificationProcessed : true ,
591- isSignatureValid : false ,
592- } as SignatureVerifResult ;
568+ if (
569+ [ 'argent/invalid-signature' , 'is invalid, with respect to the public key' ] . some (
570+ ( errMessage ) => ( err as Error ) . message . includes ( errMessage )
571+ )
572+ ) {
573+ // ArgentX 0.3.0 invalid signature, Braavos Cairo 0 invalid signature
574+ return false ;
593575 }
594- return {
595- isVerificationProcessed : false ,
596- error : new Error ( 'Signature verification request is rejected by the network.' ) ,
597- } as SignatureVerifResult ;
576+ throw Error ( `Signature verification request is rejected by the network: ${ err } ` ) ;
598577 }
599578 }
600579
601- public async verifyMessage (
602- typedData : TypedData ,
603- signature : Signature
604- ) : Promise < SignatureVerifResult > {
580+ public async verifyMessage ( typedData : TypedData , signature : Signature ) : Promise < boolean > {
605581 const hash = await this . hashMessage ( typedData ) ;
606582 return this . verifyMessageHash ( hash , signature ) ;
607583 }
0 commit comments