@@ -20,11 +20,14 @@ export type PriceServiceConnectionConfig = {
20
20
httpRetries ?: number ;
21
21
/* Optional logger (e.g: console or any logging library) to log internal events */
22
22
logger ?: Logger ;
23
+ /* Optional verbose to request for verbose information from the service */
24
+ verbose ?: boolean ;
23
25
} ;
24
26
25
27
type ClientMessage = {
26
28
type : "subscribe" | "unsubscribe" ;
27
29
ids : HexString [ ] ;
30
+ verbose ?: boolean ;
28
31
} ;
29
32
30
33
type ServerResponse = {
@@ -51,6 +54,8 @@ export class PriceServiceConnection {
51
54
52
55
private logger : undefined | Logger ;
53
56
57
+ private verbose : boolean ;
58
+
54
59
/**
55
60
* Custom handler for web socket errors (connection and message parsing).
56
61
*
@@ -74,6 +79,8 @@ export class PriceServiceConnection {
74
79
retryDelay : axiosRetry . exponentialDelay ,
75
80
} ) ;
76
81
82
+ this . verbose = config ?. verbose || false ;
83
+
77
84
this . priceFeedCallbacks = new Map ( ) ;
78
85
this . logger = config ?. logger ;
79
86
this . onWsError = ( error : Error ) => {
@@ -100,6 +107,7 @@ export class PriceServiceConnection {
100
107
const response = await this . httpClient . get ( "/api/latest_price_feeds" , {
101
108
params : {
102
109
ids : priceIds ,
110
+ verbose : this . verbose ,
103
111
} ,
104
112
} ) ;
105
113
const priceFeedsJson = response . data as any [ ] ;
@@ -128,6 +136,17 @@ export class PriceServiceConnection {
128
136
return response . data ;
129
137
}
130
138
139
+ /**
140
+ * Fetch the list of available price feed ids.
141
+ * This will throw an axios error if there is a network problem or the price service returns a non-ok response.
142
+ *
143
+ * @returns Array of hex-encoded price ids.
144
+ */
145
+ async getPriceFeedIds ( ) : Promise < HexString [ ] > {
146
+ const response = await this . httpClient . get ( "/api/price_feed_ids" ) ;
147
+ return response . data ;
148
+ }
149
+
131
150
/**
132
151
* Subscribe to updates for given price ids.
133
152
*
@@ -163,6 +182,7 @@ export class PriceServiceConnection {
163
182
const message : ClientMessage = {
164
183
ids : newPriceIds ,
165
184
type : "subscribe" ,
185
+ verbose : this . verbose ,
166
186
} ;
167
187
168
188
await this . wsClient ?. send ( JSON . stringify ( message ) ) ;
0 commit comments