@@ -359,6 +359,8 @@ describe('Sign Message, Keystore with key dedicatedToOneSA: true ', () => {
359359 accountState ,
360360 signer ,
361361 polygonNetwork ,
362+ true ,
363+ undefined ,
362364 true
363365 )
364366
@@ -658,7 +660,10 @@ describe('Sign Message, Keystore with key dedicatedToOneSA: true ', () => {
658660 smartAccount ,
659661 accountState ,
660662 signer ,
661- polygonNetwork
663+ polygonNetwork ,
664+ false ,
665+ undefined ,
666+ true
662667 )
663668 // the key should be dedicatedToOneSA, so we expect the signature to end in 00
664669 expect ( eip712Sig . signature . slice ( - 2 ) ) . toEqual ( '00' )
@@ -697,7 +702,10 @@ describe('Sign Message, Keystore with key dedicatedToOneSA: true ', () => {
697702 v1Account ,
698703 accountState ,
699704 signer ,
700- ethereumNetwork
705+ ethereumNetwork ,
706+ false ,
707+ undefined ,
708+ true
701709 )
702710 // the key is for a v1 acc so it should be 00
703711 expect ( eip712Sig . signature . slice ( - 2 ) ) . toEqual ( '00' )
@@ -752,7 +760,10 @@ describe('Sign Message, Keystore with key dedicatedToOneSA: true ', () => {
752760 v1Account ,
753761 accountState ,
754762 signer ,
755- ethereumNetwork
763+ ethereumNetwork ,
764+ false ,
765+ undefined ,
766+ true
756767 )
757768 // the key is for a v1 acc so it should be 00
758769 expect ( eip712Sig . signature . slice ( - 2 ) ) . toEqual ( '00' )
@@ -777,7 +788,16 @@ describe('Sign Message, Keystore with key dedicatedToOneSA: true ', () => {
777788 hashMessage ( 'test' )
778789 )
779790 try {
780- await getEIP712Signature ( typedData , v1Account , accountState , signer , polygonNetwork )
791+ await getEIP712Signature (
792+ typedData ,
793+ v1Account ,
794+ accountState ,
795+ signer ,
796+ polygonNetwork ,
797+ false ,
798+ undefined ,
799+ true
800+ )
781801 console . log ( 'No error was thrown for [V1 SA]: eip-712, but it should have' )
782802 expect ( true ) . toEqual ( false )
783803 } catch ( e : any ) {
@@ -855,7 +875,10 @@ describe('Sign Message, Keystore with key dedicatedToOneSA: true ', () => {
855875 smartAccount ,
856876 v2AccountState ,
857877 signer ,
858- polygonNetwork
878+ polygonNetwork ,
879+ false ,
880+ undefined ,
881+ true
859882 )
860883 expect ( eip712Sig . signature . slice ( - 2 ) ) . toEqual ( '00' )
861884
@@ -1056,7 +1079,16 @@ describe('Sign Message, Keystore with key dedicatedToOneSA: false', () => {
10561079 hashMessage ( 'test' )
10571080 )
10581081 try {
1059- await getEIP712Signature ( typedData , smartAccount , accountState , signer , polygonNetwork )
1082+ await getEIP712Signature (
1083+ typedData ,
1084+ smartAccount ,
1085+ accountState ,
1086+ signer ,
1087+ polygonNetwork ,
1088+ false ,
1089+ undefined ,
1090+ true
1091+ )
10601092 console . log ( 'No error was thrown for [Not dedicated to one SA]: eip-712, but it should have' )
10611093 expect ( true ) . toEqual ( false )
10621094 } catch ( e : any ) {
@@ -1065,6 +1097,21 @@ describe('Sign Message, Keystore with key dedicatedToOneSA: false', () => {
10651097 )
10661098 }
10671099 } )
1100+ test ( 'Signing [V2 SA]: rejects AmbireOperation typed data from untrusted sources by default' , async ( ) => {
1101+ const accountStates = await getAccountsInfo ( [ smartAccount ] )
1102+ const accountState = accountStates [ smartAccount . addr ] ! [ polygonNetwork . chainId . toString ( ) ] !
1103+ const signer = await keystore . getSigner ( eoaSigner . keyPublicAddress , 'internal' )
1104+
1105+ const typedData = getTypedData (
1106+ polygonNetwork . chainId ,
1107+ accountState . accountAddr ,
1108+ hashMessage ( 'test' )
1109+ )
1110+
1111+ await expect (
1112+ getEIP712Signature ( typedData , smartAccount , accountState , signer , polygonNetwork )
1113+ ) . rejects . toThrow ( 'Signing an AmbireOperation is not allowed' )
1114+ } )
10681115} )
10691116
10701117describe ( 'Sign Message, Safe accounts' , ( ) => {
0 commit comments