File tree Expand file tree Collapse file tree 5 files changed +17
-16
lines changed Expand file tree Collapse file tree 5 files changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { Message, MessageID } from './Message.js';
44
55interface RPCMessage extends Message {
66 id : MessageID ;
7- correlationId : string ;
7+ correlationId : string | undefined ;
88 sender : string ; // hex encoded public key of the sender
99 content : unknown ;
1010 timestamp : Date ;
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ export const logRequestStarted = ({
1818 correlationId,
1919} : {
2020 method : string ;
21- correlationId : string ;
21+ correlationId : string | undefined ;
2222} ) => {
2323 logEvent (
2424 'provider.request.started' ,
@@ -39,7 +39,7 @@ export const logRequestError = ({
3939 errorMessage,
4040} : {
4141 method : string ;
42- correlationId : string ;
42+ correlationId : string | undefined ;
4343 signerType : SignerType | undefined ;
4444 errorMessage : string ;
4545} ) => {
@@ -64,7 +64,7 @@ export const logRequestResponded = ({
6464} : {
6565 method : string ;
6666 signerType : SignerType | undefined ;
67- correlationId : string ;
67+ correlationId : string | undefined ;
6868} ) => {
6969 logEvent (
7070 'provider.request.responded' ,
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ export const logHandshakeStarted = ({
55 correlationId,
66} : {
77 method : string ;
8- correlationId : string ;
8+ correlationId : string | undefined ;
99} ) => {
1010 logEvent (
1111 'scw_signer.handshake.started' ,
@@ -25,7 +25,7 @@ export const logHandshakeError = ({
2525 errorMessage,
2626} : {
2727 method : string ;
28- correlationId : string ;
28+ correlationId : string | undefined ;
2929 errorMessage : string ;
3030} ) => {
3131 logEvent (
@@ -46,7 +46,7 @@ export const logHandshakeCompleted = ({
4646 correlationId,
4747} : {
4848 method : string ;
49- correlationId : string ;
49+ correlationId : string | undefined ;
5050} ) => {
5151 logEvent (
5252 'scw_signer.handshake.completed' ,
@@ -65,7 +65,7 @@ export const logRequestStarted = ({
6565 correlationId,
6666} : {
6767 method : string ;
68- correlationId : string ;
68+ correlationId : string | undefined ;
6969} ) => {
7070 logEvent (
7171 'scw_signer.request.started' ,
@@ -85,7 +85,7 @@ export const logRequestError = ({
8585 errorMessage,
8686} : {
8787 method : string ;
88- correlationId : string ;
88+ correlationId : string | undefined ;
8989 errorMessage : string ;
9090} ) => {
9191 logEvent (
@@ -106,7 +106,7 @@ export const logRequestCompleted = ({
106106 correlationId,
107107} : {
108108 method : string ;
109- correlationId : string ;
109+ correlationId : string | undefined ;
110110} ) => {
111111 logEvent (
112112 'scw_signer.request.completed' ,
Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ export class SCWSigner implements Signer {
9494 method : args . method ,
9595 params : args . params ?? [ ] ,
9696 } ,
97- } ) ;
97+ } , correlationId ) ;
9898 const response : RPCResponseMessage =
9999 await this . communicator . postRequestAndWaitForResponse ( handshakeMessage ) ;
100100
@@ -441,18 +441,21 @@ export class SCWSigner implements Signer {
441441 } ,
442442 sharedSecret
443443 ) ;
444- const message = await this . createRequestMessage ( { encrypted } ) ;
444+ const correlationId = correlationIds . get ( request ) ;
445+ const message = await this . createRequestMessage ( { encrypted } , correlationId ) ;
445446
446447 return this . communicator . postRequestAndWaitForResponse ( message ) ;
447448 }
448449
449450 private async createRequestMessage (
450- content : RPCRequestMessage [ 'content' ]
451+ content : RPCRequestMessage [ 'content' ] ,
452+ correlationId : string | undefined
451453 ) : Promise < RPCRequestMessage > {
452454 const publicKey = await exportKeyToHexString ( 'public' , await this . keyManager . getOwnPublicKey ( ) ) ;
455+
453456 return {
454457 id : crypto . randomUUID ( ) ,
455- correlationId : correlationIds . get ( content ) ,
458+ correlationId,
456459 sender : publicKey ,
457460 content,
458461 timestamp : new Date ( ) ,
Original file line number Diff line number Diff line change 1- import { standardErrors } from ':core/error/errors.js' ;
21import { createStore } from 'zustand/vanilla' ;
32
43type CorrelationIdsState = {
@@ -12,7 +11,6 @@ const correlationIdsStore = createStore<CorrelationIdsState>(() => ({
1211export const correlationIds = {
1312 get : ( key : object ) => {
1413 const correlationId = correlationIdsStore . getState ( ) . correlationIds . get ( key ) ;
15- if ( ! correlationId ) throw standardErrors . rpc . internal ( 'Correlation ID not found' ) ;
1614 return correlationId ;
1715 } ,
1816 set : ( key : object , correlationId : string ) => {
You can’t perform that action at this time.
0 commit comments