@@ -8,6 +8,13 @@ import { makeWebsocketUrl, removeLeading0xIfExists } from "./utils";
8
8
9
9
export type DurationInMs = number ;
10
10
11
+ export type PriceFeedRequestConfig = {
12
+ /* Optional verbose to request for verbose information from the service */
13
+ verbose ?: boolean ;
14
+ /* Optional binary to include the price feeds binary update data */
15
+ binary ?: boolean ;
16
+ } ;
17
+
11
18
export type PriceServiceConnectionConfig = {
12
19
/* Timeout of each request (for all of retries). Default: 5000ms */
13
20
timeout ?: DurationInMs ;
@@ -20,14 +27,17 @@ export type PriceServiceConnectionConfig = {
20
27
httpRetries ?: number ;
21
28
/* Optional logger (e.g: console or any logging library) to log internal events */
22
29
logger ?: Logger ;
23
- /* Optional verbose to request for verbose information from the service */
30
+ /* Deprecated: please use priceFeedRequestConfig. verbose instead */
24
31
verbose ?: boolean ;
32
+ /* Configuration for the price feed requests */
33
+ priceFeedRequestConfig ?: PriceFeedRequestConfig ;
25
34
} ;
26
35
27
36
type ClientMessage = {
28
37
type : "subscribe" | "unsubscribe" ;
29
38
ids : HexString [ ] ;
30
39
verbose ?: boolean ;
40
+ binary ?: boolean ;
31
41
} ;
32
42
33
43
type ServerResponse = {
@@ -54,7 +64,7 @@ export class PriceServiceConnection {
54
64
55
65
private logger : undefined | Logger ;
56
66
57
- private verbose : boolean ;
67
+ private priceFeedRequestConfig : PriceFeedRequestConfig ;
58
68
59
69
/**
60
70
* Custom handler for web socket errors (connection and message parsing).
@@ -79,9 +89,13 @@ export class PriceServiceConnection {
79
89
retryDelay : axiosRetry . exponentialDelay ,
80
90
} ) ;
81
91
82
- this . verbose = config ?. verbose || false ;
92
+ this . priceFeedRequestConfig = {
93
+ binary : config ?. priceFeedRequestConfig ?. binary ,
94
+ verbose : config ?. priceFeedRequestConfig ?. verbose ?? config ?. verbose ,
95
+ } ;
83
96
84
97
this . priceFeedCallbacks = new Map ( ) ;
98
+
85
99
this . logger = config ?. logger ;
86
100
this . onWsError = ( error : Error ) => {
87
101
this . logger ?. error ( error ) ;
@@ -107,7 +121,8 @@ export class PriceServiceConnection {
107
121
const response = await this . httpClient . get ( "/api/latest_price_feeds" , {
108
122
params : {
109
123
ids : priceIds ,
110
- verbose : this . verbose ,
124
+ verbose : this . priceFeedRequestConfig . verbose ,
125
+ binary : this . priceFeedRequestConfig . binary ,
111
126
} ,
112
127
} ) ;
113
128
const priceFeedsJson = response . data as any [ ] ;
@@ -180,7 +195,8 @@ export class PriceServiceConnection {
180
195
const message : ClientMessage = {
181
196
ids : newPriceIds ,
182
197
type : "subscribe" ,
183
- verbose : this . verbose ,
198
+ verbose : this . priceFeedRequestConfig . verbose ,
199
+ binary : this . priceFeedRequestConfig . binary ,
184
200
} ;
185
201
186
202
await this . wsClient ?. send ( JSON . stringify ( message ) ) ;
@@ -262,7 +278,8 @@ export class PriceServiceConnection {
262
278
const message : ClientMessage = {
263
279
ids : Array . from ( this . priceFeedCallbacks . keys ( ) ) ,
264
280
type : "subscribe" ,
265
- verbose : this . verbose ,
281
+ verbose : this . priceFeedRequestConfig . verbose ,
282
+ binary : this . priceFeedRequestConfig . binary ,
266
283
} ;
267
284
268
285
this . logger ?. info ( "Resubscribing to existing price feeds." ) ;
0 commit comments