@@ -432,6 +432,50 @@ describe('wallet', () => {
432432 const promise = pify ( engine . handle ) . call ( engine , payload ) ;
433433 await expect ( promise ) . rejects . toThrow ( 'Invalid input.' ) ;
434434 } ) ;
435+
436+ it ( 'should not throw if verifyingContract is undefined' , async ( ) => {
437+ const { engine } = createTestSetup ( ) ;
438+ const getAccounts = async ( ) => testAddresses . slice ( ) ;
439+ const witnessedMsgParams : TypedMessageParams [ ] = [ ] ;
440+ const processTypedMessageV3 = async ( msgParams : TypedMessageParams ) => {
441+ witnessedMsgParams . push ( msgParams ) ;
442+ // Assume testMsgSig is the expected signature result
443+ return testMsgSig ;
444+ } ;
445+
446+ engine . push (
447+ createWalletMiddleware ( { getAccounts, processTypedMessageV3 } ) ,
448+ ) ;
449+
450+ const message = {
451+ types : {
452+ EIP712Domain : [
453+ { name : 'name' , type : 'string' } ,
454+ { name : 'version' , type : 'string' } ,
455+ { name : 'chainId' , type : 'uint256' } ,
456+ { name : 'verifyingContract' , type : 'address' } ,
457+ ] ,
458+ } ,
459+ primaryType : 'EIP712Domain' ,
460+ message : { } ,
461+ } ;
462+
463+ const stringifiedMessage = JSON . stringify ( message ) ;
464+
465+ const payload = {
466+ method : 'eth_signTypedData_v3' ,
467+ params : [ testAddresses [ 0 ] , stringifiedMessage ] , // Assuming testAddresses[0] is a valid address from your setup
468+ } ;
469+
470+ const promise = pify ( engine . handle ) . call ( engine , payload ) ;
471+ const result = await promise ;
472+ expect ( result ) . toStrictEqual ( {
473+ id : undefined ,
474+ jsonrpc : undefined ,
475+ result :
476+ '0x68dc980608bceb5f99f691e62c32caccaee05317309015e9454eba1a14c3cd4505d1dd098b8339801239c9bcaac3c4df95569dcf307108b92f68711379be14d81c' ,
477+ } ) ;
478+ } ) ;
435479 } ) ;
436480
437481 describe ( 'signTypedDataV4' , ( ) => {
@@ -524,6 +568,35 @@ describe('wallet', () => {
524568 const promise = pify ( engine . handle ) . call ( engine , payload ) ;
525569 await expect ( promise ) . rejects . toThrow ( 'Invalid input.' ) ;
526570 } ) ;
571+
572+ it ( 'should not throw if request is permit with undefined value for verifyingContract address' , async ( ) => {
573+ const { engine } = createTestSetup ( ) ;
574+ const getAccounts = async ( ) => testAddresses . slice ( ) ;
575+ const witnessedMsgParams : TypedMessageParams [ ] = [ ] ;
576+ const processTypedMessageV4 = async ( msgParams : TypedMessageParams ) => {
577+ witnessedMsgParams . push ( msgParams ) ;
578+ // Assume testMsgSig is the expected signature result
579+ return testMsgSig ;
580+ } ;
581+
582+ engine . push (
583+ createWalletMiddleware ( { getAccounts, processTypedMessageV4 } ) ,
584+ ) ;
585+
586+ const payload = {
587+ method : 'eth_signTypedData_v4' ,
588+ params : [ testAddresses [ 0 ] , JSON . stringify ( getMsgParams ( ) ) ] ,
589+ } ;
590+
591+ const promise = pify ( engine . handle ) . call ( engine , payload ) ;
592+ const result = await promise ;
593+ expect ( result ) . toStrictEqual ( {
594+ id : undefined ,
595+ jsonrpc : undefined ,
596+ result :
597+ '0x68dc980608bceb5f99f691e62c32caccaee05317309015e9454eba1a14c3cd4505d1dd098b8339801239c9bcaac3c4df95569dcf307108b92f68711379be14d81c' ,
598+ } ) ;
599+ } ) ;
527600 } ) ;
528601
529602 describe ( 'sign' , ( ) => {
0 commit comments