This repository was archived by the owner on Oct 16, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -597,6 +597,35 @@ describe('wallet', () => {
597597 '0x68dc980608bceb5f99f691e62c32caccaee05317309015e9454eba1a14c3cd4505d1dd098b8339801239c9bcaac3c4df95569dcf307108b92f68711379be14d81c' ,
598598 } ) ;
599599 } ) ;
600+
601+ it ( 'should not throw if request is permit with verifyingContract address equal to "cosmos"' , async ( ) => {
602+ const { engine } = createTestSetup ( ) ;
603+ const getAccounts = async ( ) => testAddresses . slice ( ) ;
604+ const witnessedMsgParams : TypedMessageParams [ ] = [ ] ;
605+ const processTypedMessageV4 = async ( msgParams : TypedMessageParams ) => {
606+ witnessedMsgParams . push ( msgParams ) ;
607+ // Assume testMsgSig is the expected signature result
608+ return testMsgSig ;
609+ } ;
610+
611+ engine . push (
612+ createWalletMiddleware ( { getAccounts, processTypedMessageV4 } ) ,
613+ ) ;
614+
615+ const payload = {
616+ method : 'eth_signTypedData_v4' ,
617+ params : [ testAddresses [ 0 ] , JSON . stringify ( getMsgParams ( 'cosmos' ) ) ] ,
618+ } ;
619+
620+ const promise = pify ( engine . handle ) . call ( engine , payload ) ;
621+ const result = await promise ;
622+ expect ( result ) . toStrictEqual ( {
623+ id : undefined ,
624+ jsonrpc : undefined ,
625+ result :
626+ '0x68dc980608bceb5f99f691e62c32caccaee05317309015e9454eba1a14c3cd4505d1dd098b8339801239c9bcaac3c4df95569dcf307108b92f68711379be14d81c' ,
627+ } ) ;
628+ } ) ;
600629 } ) ;
601630
602631 describe ( 'sign' , ( ) => {
Original file line number Diff line number Diff line change @@ -464,7 +464,13 @@ WalletMiddlewareOptions): JsonRpcMiddleware<any, Block> {
464464 */
465465function validateVerifyingContract ( data : string ) {
466466 const { domain : { verifyingContract } = { } } = parseTypedMessage ( data ) ;
467- if ( verifyingContract && ! isValidHexAddress ( verifyingContract ) ) {
467+ // Explicit check for cosmos here has been added to address this issue
468+ // https://github.com/MetaMask/metamask-extension/issues/26980
469+ if (
470+ verifyingContract &&
471+ ( verifyingContract as string ) !== 'cosmos' &&
472+ ! isValidHexAddress ( verifyingContract )
473+ ) {
468474 throw rpcErrors . invalidInput ( ) ;
469475 }
470476}
You can’t perform that action at this time.
0 commit comments