@@ -50,7 +50,6 @@ import { parseContract } from '../utils/provider';
5050import { isString } from '../utils/shortString' ;
5151import {
5252 estimateFeeToBounds ,
53- formatSignature ,
5453 reduceV2 ,
5554 toFeeVersion ,
5655 toTransactionVersion ,
@@ -543,87 +542,37 @@ export class Account extends Provider implements AccountInterface {
543542 return getMessageHash ( typedData , this . address ) ;
544543 }
545544
545+ /**
546+ * @deprecated To replace by `myRpcProvider.verifyMessageInStarknet()`
547+ */
546548 public async verifyMessageHash (
547549 hash : BigNumberish ,
548550 signature : Signature ,
549551 signatureVerificationFunctionName ?: string ,
550552 signatureVerificationResponse ?: { okResponse : string [ ] ; nokResponse : string [ ] ; error : string [ ] }
551553 ) : Promise < boolean > {
552- // HOTFIX: Accounts should conform to SNIP-6
553- // (https://github.com/starknet-io/SNIPs/blob/f6998f779ee2157d5e1dea36042b08062093b3c5/SNIPS/snip-6.md?plain=1#L61),
554- // but they don't always conform. Also, the SNIP doesn't standardize the response if the signature isn't valid.
555- const knownSigVerificationFName = signatureVerificationFunctionName
556- ? [ signatureVerificationFunctionName ]
557- : [ 'isValidSignature' , 'is_valid_signature' ] ;
558- const knownSignatureResponse = signatureVerificationResponse || {
559- okResponse : [
560- // any non-nok response is true
561- ] ,
562- nokResponse : [
563- '0x0' , // Devnet
564- '0x00' , // OpenZeppelin 0.7.0 to 0.9.0 invalid signature
565- ] ,
566- error : [
567- 'argent/invalid-signature' , // ArgentX 0.3.0 to 0.3.1
568- 'is invalid, with respect to the public key' , // OpenZeppelin until 0.6.1, Braavos 0.0.11
569- 'INVALID_SIG' , // Braavos 1.0.0
570- ] ,
571- } ;
572- let error : any ;
573-
574- // eslint-disable-next-line no-restricted-syntax
575- for ( const SigVerificationFName of knownSigVerificationFName ) {
576- try {
577- // eslint-disable-next-line no-await-in-loop
578- const resp = await this . callContract ( {
579- contractAddress : this . address ,
580- entrypoint : SigVerificationFName ,
581- calldata : CallData . compile ( {
582- hash : toBigInt ( hash ) . toString ( ) ,
583- signature : formatSignature ( signature ) ,
584- } ) ,
585- } ) ;
586- // Response NOK Signature
587- if ( knownSignatureResponse . nokResponse . includes ( resp [ 0 ] . toString ( ) ) ) {
588- return false ;
589- }
590- // Response OK Signature
591- // Empty okResponse assume all non-nok responses are valid signatures
592- // OpenZeppelin 0.7.0 to 0.9.0, ArgentX 0.3.0 to 0.3.1 & Braavos Cairo 0.0.11 to 1.0.0 valid signature
593- if (
594- knownSignatureResponse . okResponse . length === 0 ||
595- knownSignatureResponse . okResponse . includes ( resp [ 0 ] . toString ( ) )
596- ) {
597- return true ;
598- }
599- throw Error ( 'signatureVerificationResponse Error: response is not part of known responses' ) ;
600- } catch ( err ) {
601- // Known NOK Errors
602- if (
603- knownSignatureResponse . error . some ( ( errMessage ) =>
604- ( err as Error ) . message . includes ( errMessage )
605- )
606- ) {
607- return false ;
608- }
609- // Unknown Error
610- error = err ;
611- }
612- }
613-
614- throw Error ( `Signature verification Error: ${ error } ` ) ;
554+ return this . verifyMessageInStarknet (
555+ hash ,
556+ signature ,
557+ this . address ,
558+ signatureVerificationFunctionName ,
559+ signatureVerificationResponse
560+ ) ;
615561 }
616562
563+ /**
564+ * @deprecated To replace by `myRpcProvider.verifyMessageInStarknet()`
565+ */
617566 public async verifyMessage (
618567 typedData : TypedData ,
619568 signature : Signature ,
620569 signatureVerificationFunctionName ?: string ,
621570 signatureVerificationResponse ?: { okResponse : string [ ] ; nokResponse : string [ ] ; error : string [ ] }
622571 ) : Promise < boolean > {
623- const hash = await this . hashMessage ( typedData ) ;
624- return this . verifyMessageHash (
625- hash ,
572+ return this . verifyMessageInStarknet (
573+ typedData ,
626574 signature ,
575+ this . address ,
627576 signatureVerificationFunctionName ,
628577 signatureVerificationResponse
629578 ) ;
0 commit comments