@sentio/sdk 2.44.0 → 2.44.1-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -74,8 +74,8 @@ declare const InitializeMultisig: import("superstruct_solana").Struct<{
74
74
  }>;
75
75
  export type Transfer = Infer<typeof Transfer>;
76
76
  export declare const Transfer: import("superstruct_solana").Struct<{
77
- source: String;
78
77
  amount: string | number;
78
+ source: String;
79
79
  destination: String;
80
80
  signers?: String[] | undefined;
81
81
  authority?: String | undefined;
@@ -90,8 +90,8 @@ export declare const Transfer: import("superstruct_solana").Struct<{
90
90
  }>;
91
91
  export type Approve = Infer<typeof Approve>;
92
92
  declare const Approve: import("superstruct_solana").Struct<{
93
- source: String;
94
93
  amount: string | number;
94
+ source: String;
95
95
  delegate: String;
96
96
  owner?: String | undefined;
97
97
  signers?: String[] | undefined;
@@ -213,8 +213,8 @@ declare const ThawAccount: import("superstruct_solana").Struct<{
213
213
  }>;
214
214
  export type TransferChecked = Infer<typeof TransferChecked>;
215
215
  export declare const TransferChecked: import("superstruct_solana").Struct<{
216
- source: String;
217
216
  mint: String;
217
+ source: String;
218
218
  destination: String;
219
219
  tokenAmount: {
220
220
  decimals: number;
@@ -243,8 +243,8 @@ export declare const TransferChecked: import("superstruct_solana").Struct<{
243
243
  }>;
244
244
  export type ApproveChecked = Infer<typeof ApproveChecked>;
245
245
  declare const ApproveChecked: import("superstruct_solana").Struct<{
246
- source: String;
247
246
  mint: String;
247
+ source: String;
248
248
  delegate: String;
249
249
  tokenAmount: {
250
250
  decimals: number;
@@ -1,345 +1,11 @@
1
- import { PriceServiceClient } from '@sentio/protos/price';
2
1
  import { CoinID } from '@sentio/protos';
3
- import { RetryOptions } from 'nice-grpc-client-middleware-retry';
4
2
  import { ChainId } from '@sentio/chain';
5
- export declare function getPriceClient(address?: string): import("nice-grpc").RawClient<import("nice-grpc/lib/service-definitions/ts-proto.js").FromTsProtoServiceDefinition<{
6
- readonly name: "PriceService";
7
- readonly fullName: "price_service.PriceService";
8
- readonly methods: {
9
- readonly getPrice: {
10
- readonly name: "GetPrice";
11
- readonly requestType: {
12
- encode(message: import("@sentio/protos/price").GetPriceRequest, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
13
- decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos/price").GetPriceRequest;
14
- fromJSON(object: any): import("@sentio/protos/price").GetPriceRequest;
15
- toJSON(message: import("@sentio/protos/price").GetPriceRequest): unknown;
16
- create(base?: {
17
- timestamp?: Date | undefined;
18
- coinId?: {
19
- symbol?: string | undefined;
20
- address?: {
21
- address?: string | undefined;
22
- chain?: string | undefined;
23
- } | undefined;
24
- } | undefined;
25
- source?: string | undefined;
26
- }): import("@sentio/protos/price").GetPriceRequest;
27
- fromPartial(object: {
28
- timestamp?: Date | undefined;
29
- coinId?: {
30
- symbol?: string | undefined;
31
- address?: {
32
- address?: string | undefined;
33
- chain?: string | undefined;
34
- } | undefined;
35
- } | undefined;
36
- source?: string | undefined;
37
- }): import("@sentio/protos/price").GetPriceRequest;
38
- };
39
- readonly requestStream: false;
40
- readonly responseType: {
41
- encode(message: import("@sentio/protos/price").GetPriceResponse, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
42
- decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos/price").GetPriceResponse;
43
- fromJSON(object: any): import("@sentio/protos/price").GetPriceResponse;
44
- toJSON(message: import("@sentio/protos/price").GetPriceResponse): unknown;
45
- create(base?: {
46
- price?: number | undefined;
47
- timestamp?: Date | undefined;
48
- }): import("@sentio/protos/price").GetPriceResponse;
49
- fromPartial(object: {
50
- price?: number | undefined;
51
- timestamp?: Date | undefined;
52
- }): import("@sentio/protos/price").GetPriceResponse;
53
- };
54
- readonly responseStream: false;
55
- readonly options: {
56
- readonly _unknownFields: {
57
- readonly 578365826: readonly [Uint8Array];
58
- };
59
- };
60
- };
61
- readonly batchGetPrices: {
62
- readonly name: "BatchGetPrices";
63
- readonly requestType: {
64
- encode(message: import("@sentio/protos/price").BatchGetPricesRequest, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
65
- decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos/price").BatchGetPricesRequest;
66
- fromJSON(object: any): import("@sentio/protos/price").BatchGetPricesRequest;
67
- toJSON(message: import("@sentio/protos/price").BatchGetPricesRequest): unknown;
68
- create(base?: {
69
- timestamps?: Date[] | undefined;
70
- coinIds?: {
71
- symbol?: string | undefined;
72
- address?: {
73
- address?: string | undefined;
74
- chain?: string | undefined;
75
- } | undefined;
76
- }[] | undefined;
77
- }): import("@sentio/protos/price").BatchGetPricesRequest;
78
- fromPartial(object: {
79
- timestamps?: Date[] | undefined;
80
- coinIds?: {
81
- symbol?: string | undefined;
82
- address?: {
83
- address?: string | undefined;
84
- chain?: string | undefined;
85
- } | undefined;
86
- }[] | undefined;
87
- }): import("@sentio/protos/price").BatchGetPricesRequest;
88
- };
89
- readonly requestStream: false;
90
- readonly responseType: {
91
- encode(message: import("@sentio/protos/price").BatchGetPricesResponse, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
92
- decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos/price").BatchGetPricesResponse;
93
- fromJSON(object: any): import("@sentio/protos/price").BatchGetPricesResponse;
94
- toJSON(message: import("@sentio/protos/price").BatchGetPricesResponse): unknown;
95
- create(base?: {
96
- prices?: {
97
- coinId?: {
98
- symbol?: string | undefined;
99
- address?: {
100
- address?: string | undefined;
101
- chain?: string | undefined;
102
- } | undefined;
103
- } | undefined;
104
- price?: {
105
- results?: {
106
- price?: number | undefined;
107
- timestamp?: Date | undefined;
108
- }[] | undefined;
109
- } | undefined;
110
- error?: string | undefined;
111
- }[] | undefined;
112
- }): import("@sentio/protos/price").BatchGetPricesResponse;
113
- fromPartial(object: {
114
- prices?: {
115
- coinId?: {
116
- symbol?: string | undefined;
117
- address?: {
118
- address?: string | undefined;
119
- chain?: string | undefined;
120
- } | undefined;
121
- } | undefined;
122
- price?: {
123
- results?: {
124
- price?: number | undefined;
125
- timestamp?: Date | undefined;
126
- }[] | undefined;
127
- } | undefined;
128
- error?: string | undefined;
129
- }[] | undefined;
130
- }): import("@sentio/protos/price").BatchGetPricesResponse;
131
- };
132
- readonly responseStream: false;
133
- readonly options: {
134
- readonly _unknownFields: {
135
- readonly 578365826: readonly [Uint8Array];
136
- };
137
- };
138
- };
139
- readonly listCoins: {
140
- readonly name: "ListCoins";
141
- readonly requestType: {
142
- encode(message: import("@sentio/protos/price").ListCoinsRequest, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
143
- decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos/price").ListCoinsRequest;
144
- fromJSON(object: any): import("@sentio/protos/price").ListCoinsRequest;
145
- toJSON(message: import("@sentio/protos/price").ListCoinsRequest): unknown;
146
- create(base?: {
147
- limit?: number | undefined;
148
- offset?: number | undefined;
149
- searchQuery?: string | undefined;
150
- chain?: string | undefined;
151
- }): import("@sentio/protos/price").ListCoinsRequest;
152
- fromPartial(object: {
153
- limit?: number | undefined;
154
- offset?: number | undefined;
155
- searchQuery?: string | undefined;
156
- chain?: string | undefined;
157
- }): import("@sentio/protos/price").ListCoinsRequest;
158
- };
159
- readonly requestStream: false;
160
- readonly responseType: {
161
- encode(message: import("@sentio/protos/price").ListCoinsResponse, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
162
- decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos/price").ListCoinsResponse;
163
- fromJSON(object: any): import("@sentio/protos/price").ListCoinsResponse;
164
- toJSON(message: import("@sentio/protos/price").ListCoinsResponse): unknown;
165
- create(base?: {
166
- coins?: {
167
- symbol?: string | undefined;
168
- address?: {
169
- address?: string | undefined;
170
- chain?: string | undefined;
171
- } | undefined;
172
- }[] | undefined;
173
- coinAddressesInChain?: {
174
- [x: string]: {
175
- symbol?: string | undefined;
176
- address?: {
177
- address?: string | undefined;
178
- chain?: string | undefined;
179
- } | undefined;
180
- } | undefined;
181
- } | undefined;
182
- }): import("@sentio/protos/price").ListCoinsResponse;
183
- fromPartial(object: {
184
- coins?: {
185
- symbol?: string | undefined;
186
- address?: {
187
- address?: string | undefined;
188
- chain?: string | undefined;
189
- } | undefined;
190
- }[] | undefined;
191
- coinAddressesInChain?: {
192
- [x: string]: {
193
- symbol?: string | undefined;
194
- address?: {
195
- address?: string | undefined;
196
- chain?: string | undefined;
197
- } | undefined;
198
- } | undefined;
199
- } | undefined;
200
- }): import("@sentio/protos/price").ListCoinsResponse;
201
- };
202
- readonly responseStream: false;
203
- readonly options: {
204
- readonly _unknownFields: {
205
- readonly 578365826: readonly [Uint8Array];
206
- };
207
- };
208
- };
209
- readonly checkLatestPrice: {
210
- readonly name: "CheckLatestPrice";
211
- readonly requestType: {
212
- encode(_: import("@sentio/protos").Empty, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
213
- decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos").Empty;
214
- fromJSON(_: any): import("@sentio/protos").Empty;
215
- toJSON(_: import("@sentio/protos").Empty): unknown;
216
- create(base?: {}): import("@sentio/protos").Empty;
217
- fromPartial(_: {}): import("@sentio/protos").Empty;
218
- };
219
- readonly requestStream: false;
220
- readonly responseType: {
221
- encode(message: import("@sentio/protos/price").CheckLatestPriceResponse, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
222
- decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos/price").CheckLatestPriceResponse;
223
- fromJSON(object: any): import("@sentio/protos/price").CheckLatestPriceResponse;
224
- toJSON(message: import("@sentio/protos/price").CheckLatestPriceResponse): unknown;
225
- create(base?: {
226
- prices?: {
227
- coinId?: {
228
- symbol?: string | undefined;
229
- address?: {
230
- address?: string | undefined;
231
- chain?: string | undefined;
232
- } | undefined;
233
- } | undefined;
234
- price?: number | undefined;
235
- timestamp?: Date | undefined;
236
- }[] | undefined;
237
- latestPrice?: {
238
- coinId?: {
239
- symbol?: string | undefined;
240
- address?: {
241
- address?: string | undefined;
242
- chain?: string | undefined;
243
- } | undefined;
244
- } | undefined;
245
- price?: number | undefined;
246
- timestamp?: Date | undefined;
247
- } | undefined;
248
- }): import("@sentio/protos/price").CheckLatestPriceResponse;
249
- fromPartial(object: {
250
- prices?: {
251
- coinId?: {
252
- symbol?: string | undefined;
253
- address?: {
254
- address?: string | undefined;
255
- chain?: string | undefined;
256
- } | undefined;
257
- } | undefined;
258
- price?: number | undefined;
259
- timestamp?: Date | undefined;
260
- }[] | undefined;
261
- latestPrice?: {
262
- coinId?: {
263
- symbol?: string | undefined;
264
- address?: {
265
- address?: string | undefined;
266
- chain?: string | undefined;
267
- } | undefined;
268
- } | undefined;
269
- price?: number | undefined;
270
- timestamp?: Date | undefined;
271
- } | undefined;
272
- }): import("@sentio/protos/price").CheckLatestPriceResponse;
273
- };
274
- readonly responseStream: false;
275
- readonly options: {
276
- readonly _unknownFields: {
277
- readonly 578365826: readonly [Uint8Array];
278
- };
279
- };
280
- };
281
- readonly backfillCoin: {
282
- readonly name: "BackfillCoin";
283
- readonly requestType: {
284
- encode(message: import("@sentio/protos/price").BackfillCoinRequest, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
285
- decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos/price").BackfillCoinRequest;
286
- fromJSON(object: any): import("@sentio/protos/price").BackfillCoinRequest;
287
- toJSON(message: import("@sentio/protos/price").BackfillCoinRequest): unknown;
288
- create(base?: {
289
- name?: string | undefined;
290
- symbol?: string | undefined;
291
- chain?: string | undefined;
292
- address?: string | undefined;
293
- coingeckoId?: string | undefined;
294
- decimals?: number | undefined;
295
- logoUrl?: string | undefined;
296
- projectUrl?: string | undefined;
297
- accountAddress?: string | undefined;
298
- moduleName?: string | undefined;
299
- structName?: string | undefined;
300
- }): import("@sentio/protos/price").BackfillCoinRequest;
301
- fromPartial(object: {
302
- name?: string | undefined;
303
- symbol?: string | undefined;
304
- chain?: string | undefined;
305
- address?: string | undefined;
306
- coingeckoId?: string | undefined;
307
- decimals?: number | undefined;
308
- logoUrl?: string | undefined;
309
- projectUrl?: string | undefined;
310
- accountAddress?: string | undefined;
311
- moduleName?: string | undefined;
312
- structName?: string | undefined;
313
- }): import("@sentio/protos/price").BackfillCoinRequest;
314
- };
315
- readonly requestStream: false;
316
- readonly responseType: {
317
- encode(message: import("@sentio/protos/price").BackfillCoinResponse, writer?: import("protobufjs").Writer): import("protobufjs").Writer;
318
- decode(input: import("protobufjs").Reader | Uint8Array, length?: number): import("@sentio/protos/price").BackfillCoinResponse;
319
- fromJSON(object: any): import("@sentio/protos/price").BackfillCoinResponse;
320
- toJSON(message: import("@sentio/protos/price").BackfillCoinResponse): unknown;
321
- create(base?: {
322
- symbol?: string | undefined;
323
- message?: string | undefined;
324
- }): import("@sentio/protos/price").BackfillCoinResponse;
325
- fromPartial(object: {
326
- symbol?: string | undefined;
327
- message?: string | undefined;
328
- }): import("@sentio/protos/price").BackfillCoinResponse;
329
- };
330
- readonly responseStream: false;
331
- readonly options: {
332
- readonly _unknownFields: {
333
- readonly 578365826: readonly [Uint8Array];
334
- };
335
- };
336
- };
337
- };
338
- }>, RetryOptions>;
3
+ import { PriceApi } from '@sentio/api';
4
+ export declare function getPriceClient(address?: string): PriceApi;
339
5
  interface PriceOptions {
340
6
  toleranceInDays?: number;
341
7
  }
342
- export declare function getPriceByTypeOrSymbolInternal(priceClient: PriceServiceClient<RetryOptions>, date: Date, coinId: CoinID, options?: PriceOptions): Promise<number | undefined>;
8
+ export declare function getPriceByTypeOrSymbolInternal(priceClient: PriceApi, date: Date, coinId: CoinID, options?: PriceOptions): Promise<number | undefined>;
343
9
  /**
344
10
  *
345
11
  * @param chainId chain id refers to CHAIN_MAP
@@ -358,6 +24,6 @@ export declare function getPriceBySymbol(symbol: string, date: Date, options?: P
358
24
  * get coins that has price, return results are list of coin id with both symbol and address field set
359
25
  * @param chainId
360
26
  */
361
- export declare function getCoinsThatHasPrice(chainId: ChainId): Promise<import("@sentio/protos/price").CoinID[]>;
27
+ export declare function getCoinsThatHasPrice(chainId: ChainId): Promise<import("@sentio/api").PriceServiceCoinID[]>;
362
28
  export {};
363
29
  //# sourceMappingURL=price.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"price.d.ts","sourceRoot":"","sources":["../../src/utils/price.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAA0B,MAAM,sBAAsB,CAAA;AACjF,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAGvC,OAAO,EAAmB,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAEjF,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM;;;;;;;sFA6Jo1K,CAAC;8EAAwF,CAAC;;;2BAA0K,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;uFAA6R,CAAC;8EAAwF,CAAC;;;2BAA6K,CAAC;;;;;;;;;;;;;;;;;;;4FAA6iB,CAAC;8EAAwF,CAAC;;;2BAA4L,CAAC;;;;;;;;;;;;;;;;;;;;;;;6FAA2T,CAAC;8EAAwF,CAAC;;;2BAA+L,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uFAAsjB,CAAC;8EAAwF,CAAC;;;2BAA6K,CAAC;;;;;;;;;;;;;;;wFAAkS,CAAC;8EAAwF,CAAC;;;2BAAgL,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gEAA+hB,CAAC;8EAAwF,CAAC;;;2BAAiI,CAAC;;;;;+FAAwN,CAAC;8EAAwF,CAAC;;;2BAAqM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0FAAukB,CAAC;8EAAwF,CAAC;;;2BAAsL,CAAC;;;;;;;;;;;;;;;;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,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAyD7B;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,IAAI,EACV,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAW7B;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,EACV,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAE7B;AAMD;;;GAGG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,OAAO,uDAgB1D"}
@@ -1,18 +1,12 @@
1
- import { PriceServiceDefinition } from '@sentio/protos/price';
2
- import { createChannel, createClientFactory, Status } from 'nice-grpc';
3
- import { prometheusClientMiddleware } from 'nice-grpc-prometheus';
4
- import { retryMiddleware } from 'nice-grpc-client-middleware-retry';
5
- import { Endpoints } from '@sentio/runtime';
1
+ import { Status } from 'nice-grpc';
6
2
  import { LRUCache } from 'lru-cache';
3
+ import { Configuration, PriceApi } from '@sentio/api';
7
4
  export function getPriceClient(address) {
8
- if (!address) {
9
- address = Endpoints.INSTANCE.priceFeedAPI;
10
- }
11
- const channel = createChannel(address);
12
- return createClientFactory()
13
- .use(prometheusClientMiddleware())
14
- .use(retryMiddleware)
15
- .create(PriceServiceDefinition, channel);
5
+ const config = new Configuration({
6
+ apiKey: process.env.SENTIO_API_KEY
7
+ });
8
+ const api = new PriceApi(config);
9
+ return api;
16
10
  }
17
11
  const priceMap = new LRUCache({
18
12
  max: 100000,
@@ -41,10 +35,9 @@ export async function getPriceByTypeOrSymbolInternal(priceClient, date, coinId,
41
35
  }
42
36
  const response = priceClient.getPrice({
43
37
  timestamp: date,
44
- coinId
45
- }, {
46
- retry: true,
47
- retryMaxAttempts: 5
38
+ coinIdSymbol: coinId.symbol,
39
+ coinIdAddressAddress: coinId.address?.address,
40
+ coinIdAddressChain: coinId.address?.chain
48
41
  });
49
42
  price = response
50
43
  .then((res) => {
@@ -118,10 +111,13 @@ export async function getCoinsThatHasPrice(chainId) {
118
111
  if (!priceClient) {
119
112
  priceClient = getPriceClient();
120
113
  }
121
- const response = await priceClient.listCoins({
114
+ const response = await priceClient.priceListCoins({
122
115
  chain: chainId,
123
116
  limit: 1000
124
117
  });
118
+ if (!response.coinAddressesInChain) {
119
+ return [];
120
+ }
125
121
  return Object.entries(response.coinAddressesInChain).map(([symbol, coin]) => {
126
122
  coin.symbol = symbol;
127
123
  return coin;
@@ -1 +1 @@
1
- {"version":3,"file":"price.js","sourceRoot":"","sources":["../../src/utils/price.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAEjF,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,EAAE,eAAe,EAAgB,MAAM,mCAAmC,CAAA;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAA;IAC3C,CAAC;IACD,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,CAAA;IAEtC,OAAO,mBAAmB,EAAE;SACzB,GAAG,CAAC,0BAA0B,EAAE,CAAC;SACjC,GAAG,CAAC,eAAe,CAAC;SACpB,MAAM,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAA;AAC5C,CAAC;AAED,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAsC;IACjE,GAAG,EAAE,MAAM;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E,MAAM,EAAE,EAAE,OAAO,CAAC,CAAA;AAC1D,CAAC;AAED,SAAS,UAAU,CAAC,IAAU;IAC5B,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACrF,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAAgB;IACzD,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,WAAW,GAAG,cAAc,EAAE,CAAA;IAChC,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,cAAc,CAAC;QAChD,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,IAAI;KACZ,CAAC,CAAA;IAEF,IAAI,CAAC,QAAQ,CAAC,oBAAoB,EAAE,CAAC;QACnC,OAAO,EAAE,CAAA;IACX,CAAC;IACD,OAAO,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;QAC1E,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,OAAO,IAAI,CAAA;IACb,CAAC,CAAC,CAAA;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/sdk",
3
- "version": "2.44.0",
3
+ "version": "2.44.1-rc.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -54,6 +54,7 @@
54
54
  "@mysten/sui.js": "~0.54.1",
55
55
  "@project-serum/anchor": "^0.26.0",
56
56
  "@sentio/abi-wan-kanabi": "2.2.2-1",
57
+ "@sentio/api": "1.0.2-rc.11",
57
58
  "@sentio/bigdecimal": "9.1.1-patch.3",
58
59
  "@sentio/chain": "^2.1.9",
59
60
  "@sentio/ethers-v6": "^1.0.29",
@@ -84,8 +85,8 @@
84
85
  "typechain": "^8.3.2",
85
86
  "utility-types": "^3.11.0",
86
87
  "yaml": "^2.3.4",
87
- "@sentio/runtime": "^2.44.0",
88
- "@sentio/protos": "2.44.0"
88
+ "@sentio/runtime": "^2.44.1-rc.1",
89
+ "@sentio/protos": "2.44.1-rc.1"
89
90
  },
90
91
  "peerDependencies": {
91
92
  "tsup": "npm:@sentio/tsup@^6.7.5"
@@ -1,22 +1,15 @@
1
- import { PriceServiceClient, PriceServiceDefinition } from '@sentio/protos/price'
2
1
  import { CoinID } from '@sentio/protos'
3
- import { createChannel, createClientFactory, Status } from 'nice-grpc'
4
- import { prometheusClientMiddleware } from 'nice-grpc-prometheus'
5
- import { retryMiddleware, RetryOptions } from 'nice-grpc-client-middleware-retry'
6
- import { Endpoints } from '@sentio/runtime'
2
+ import { Status } from 'nice-grpc'
7
3
  import { ChainId } from '@sentio/chain'
8
4
  import { LRUCache } from 'lru-cache'
5
+ import { Configuration, PriceApi } from '@sentio/api'
9
6
 
10
7
  export function getPriceClient(address?: string) {
11
- if (!address) {
12
- address = Endpoints.INSTANCE.priceFeedAPI
13
- }
14
- const channel = createChannel(address)
15
-
16
- return createClientFactory()
17
- .use(prometheusClientMiddleware())
18
- .use(retryMiddleware)
19
- .create(PriceServiceDefinition, channel)
8
+ const config = new Configuration({
9
+ apiKey: process.env.SENTIO_API_KEY
10
+ })
11
+ const api = new PriceApi(config)
12
+ return api
20
13
  }
21
14
 
22
15
  const priceMap = new LRUCache<string, Promise<number | undefined>>({
@@ -24,7 +17,7 @@ const priceMap = new LRUCache<string, Promise<number | undefined>>({
24
17
  ttl: 1000 * 60 * 60 // 1 hour
25
18
  })
26
19
 
27
- let priceClient: PriceServiceClient<RetryOptions>
20
+ let priceClient: PriceApi
28
21
 
29
22
  interface PriceOptions {
30
23
  toleranceInDays?: number
@@ -37,7 +30,7 @@ async function getPriceByTypeOrSymbol(date: Date, coinId: CoinID, options?: Pric
37
30
  }
38
31
 
39
32
  export async function getPriceByTypeOrSymbolInternal(
40
- priceClient: PriceServiceClient<RetryOptions>,
33
+ priceClient: PriceApi,
41
34
  date: Date,
42
35
  coinId: CoinID,
43
36
  options?: PriceOptions
@@ -56,16 +49,12 @@ export async function getPriceByTypeOrSymbolInternal(
56
49
  return price
57
50
  }
58
51
 
59
- const response = priceClient.getPrice(
60
- {
61
- timestamp: date,
62
- coinId
63
- },
64
- {
65
- retry: true,
66
- retryMaxAttempts: 5
67
- }
68
- )
52
+ const response = priceClient.getPrice({
53
+ timestamp: date,
54
+ coinIdSymbol: coinId.symbol,
55
+ coinIdAddressAddress: coinId.address?.address,
56
+ coinIdAddressChain: coinId.address?.chain
57
+ })
69
58
  price = response
70
59
  .then((res) => {
71
60
  if (res.timestamp) {
@@ -154,11 +143,14 @@ export async function getCoinsThatHasPrice(chainId: ChainId) {
154
143
  if (!priceClient) {
155
144
  priceClient = getPriceClient()
156
145
  }
157
- const response = await priceClient.listCoins({
146
+ const response = await priceClient.priceListCoins({
158
147
  chain: chainId,
159
148
  limit: 1000
160
149
  })
161
150
 
151
+ if (!response.coinAddressesInChain) {
152
+ return []
153
+ }
162
154
  return Object.entries(response.coinAddressesInChain).map(([symbol, coin]) => {
163
155
  coin.symbol = symbol
164
156
  return coin