@@ -1088,7 +1088,7 @@ describe("ProvideEIP712ContextTask", () => {
10881088 ) ;
10891089 } ) ;
10901090
1091- it ( "Provide proxy" , async ( ) => {
1091+ it ( "Provide proxy from clearSignContext when not in additionalContexts " , async ( ) => {
10921092 // GIVEN
10931093 const proxy : ClearSignContextSuccess < ClearSignContextType . PROXY_INFO > = {
10941094 type : ClearSignContextType . PROXY_INFO ,
@@ -1131,6 +1131,61 @@ describe("ProvideEIP712ContextTask", () => {
11311131 ) ;
11321132 } ) ;
11331133
1134+ it ( "Skip duplicate proxy from clearSignContext when already in additionalContexts" , async ( ) => {
1135+ // GIVEN
1136+ const proxy : ClearSignContextSuccess < ClearSignContextType . PROXY_INFO > = {
1137+ type : ClearSignContextType . PROXY_INFO ,
1138+ payload : "0x010203" ,
1139+ } ;
1140+ const additionalProxy : ClearSignContextSuccess < ClearSignContextType . PROXY_INFO > =
1141+ {
1142+ type : ClearSignContextType . PROXY_INFO ,
1143+ payload : "0xaabbcc" ,
1144+ } ;
1145+ const clearSignContext : TypedDataClearSignContextSuccess = {
1146+ ...TEST_CLEAR_SIGN_CONTEXT ,
1147+ proxy,
1148+ } ;
1149+ const args : ProvideEIP712ContextTaskArgs = {
1150+ deviceModelId : DeviceModelId . STAX ,
1151+ derivationPath : "44'/60'/0'/0/0" ,
1152+ types : TEST_TYPES ,
1153+ domain : TEST_DOMAIN_VALUES ,
1154+ message : TEST_MESSAGE_VALUES ,
1155+ clearSignContext : Just ( clearSignContext ) ,
1156+ calldatasPreContexts : { } ,
1157+ calldatasPostContexts : { } ,
1158+ additionalContexts : [ additionalProxy ] ,
1159+ loggerFactory : mockLoggerFactory ,
1160+ } ;
1161+
1162+ // WHEN
1163+ apiMock . sendCommand . mockResolvedValue (
1164+ CommandResultFactory ( { data : { tokenIndex : 4 } } ) ,
1165+ ) ;
1166+ await new ProvideEIP712ContextTask (
1167+ apiMock ,
1168+ contextModuleMock ,
1169+ args ,
1170+ provideContextFactoryMock ,
1171+ ) . run ( ) ;
1172+
1173+ // THEN — the clearSignContext proxy (0x010203) should NOT be sent
1174+ expect ( apiMock . sendCommand ) . not . toHaveBeenCalledWith (
1175+ new ProvideProxyInfoCommand ( {
1176+ data : hexaStringToBuffer ( "0x0003010203" ) ! ,
1177+ isFirstChunk : true ,
1178+ } ) ,
1179+ ) ;
1180+ // — the additionalContexts proxy (0xaabbcc) should have been sent
1181+ expect ( apiMock . sendCommand ) . toHaveBeenCalledWith (
1182+ new ProvideProxyInfoCommand ( {
1183+ data : hexaStringToBuffer ( "0x0003aabbcc" ) ! ,
1184+ isFirstChunk : true ,
1185+ } ) ,
1186+ ) ;
1187+ } ) ;
1188+
11341189 it ( "Send certificate from clearSignContext" , async ( ) => {
11351190 // GIVEN
11361191 const certificatePayload = new Uint8Array ( [ 0x01 , 0x02 , 0x03 , 0x04 , 0x05 ] ) ;
0 commit comments