@sentio/sdk-bundle 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.
Files changed (38) hide show
  1. package/lib/aptos/builtin/0x1.js +1 -1
  2. package/lib/aptos/builtin/0x3.js +1 -1
  3. package/lib/aptos/builtin/index.js +1 -1
  4. package/lib/aptos/ext/index.js +1 -1
  5. package/lib/aptos/index.js +1 -1
  6. package/lib/chunk-F6O7Z5YC.js +6 -0
  7. package/lib/chunk-F6O7Z5YC.js.map +1 -0
  8. package/lib/{chunk-QTRTXIKL.js → chunk-FAZ3MF2Y.js} +2 -2
  9. package/lib/{chunk-TVLODLMF.js → chunk-KJU5FRRJ.js} +2 -2
  10. package/lib/{chunk-43AULYHS.js → chunk-NCOPZM3S.js} +2 -2
  11. package/lib/chunk-TTZSFKIM.js +16 -0
  12. package/lib/chunk-TTZSFKIM.js.map +1 -0
  13. package/lib/{chunk-HRWNB6TA.js → chunk-UNDTHQXJ.js} +2 -2
  14. package/lib/{chunk-FOPG6CCD.js → chunk-VQRG4IVB.js} +2 -2
  15. package/lib/{chunk-GJZNIDSI.js → chunk-Y5C3UST2.js} +2 -2
  16. package/lib/solana/builtin/types.d.ts +4 -4
  17. package/lib/sui/builtin/0x1.js +1 -1
  18. package/lib/sui/builtin/0x2.js +1 -1
  19. package/lib/sui/builtin/0x3.js +1 -1
  20. package/lib/sui/builtin/index.js +1 -1
  21. package/lib/sui/ext/index.js +1 -1
  22. package/lib/sui/index.js +1 -1
  23. package/lib/testing/index.js +1 -1
  24. package/lib/utils/index.js +1 -1
  25. package/lib/utils/price.d.ts +4 -338
  26. package/lib/utils/price.d.ts.map +1 -1
  27. package/package.json +2 -2
  28. package/src/utils/price.ts +19 -27
  29. package/lib/chunk-GELZJPWE.js +0 -6
  30. package/lib/chunk-GELZJPWE.js.map +0 -1
  31. package/lib/chunk-RFCXI7MC.js +0 -16
  32. package/lib/chunk-RFCXI7MC.js.map +0 -1
  33. /package/lib/{chunk-QTRTXIKL.js.map → chunk-FAZ3MF2Y.js.map} +0 -0
  34. /package/lib/{chunk-TVLODLMF.js.map → chunk-KJU5FRRJ.js.map} +0 -0
  35. /package/lib/{chunk-43AULYHS.js.map → chunk-NCOPZM3S.js.map} +0 -0
  36. /package/lib/{chunk-HRWNB6TA.js.map → chunk-UNDTHQXJ.js.map} +0 -0
  37. /package/lib/{chunk-FOPG6CCD.js.map → chunk-VQRG4IVB.js.map} +0 -0
  38. /package/lib/{chunk-GJZNIDSI.js.map → chunk-Y5C3UST2.js.map} +0 -0
@@ -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