File tree 2 files changed +36
-1
lines changed
2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -597,6 +597,35 @@ describe('wallet', () => {
597
597
'0x68dc980608bceb5f99f691e62c32caccaee05317309015e9454eba1a14c3cd4505d1dd098b8339801239c9bcaac3c4df95569dcf307108b92f68711379be14d81c' ,
598
598
} ) ;
599
599
} ) ;
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
+ } ) ;
600
629
} ) ;
601
630
602
631
describe ( 'sign' , ( ) => {
Original file line number Diff line number Diff line change @@ -464,7 +464,13 @@ WalletMiddlewareOptions): JsonRpcMiddleware<any, Block> {
464
464
*/
465
465
function validateVerifyingContract ( data : string ) {
466
466
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/eth-json-rpc-middleware/issues/new
469
+ if (
470
+ verifyingContract &&
471
+ ( verifyingContract as string ) !== 'cosmos' &&
472
+ ! isValidHexAddress ( verifyingContract )
473
+ ) {
468
474
throw rpcErrors . invalidInput ( ) ;
469
475
}
470
476
}
You can’t perform that action at this time.
0 commit comments