@sentio/sdk 4.1.0-rc.1 → 4.1.0-rc.2

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.
@@ -87,8 +87,8 @@ export declare const InitializeMultisig: import("superstruct").Struct<{
87
87
  export type Transfer = Infer<typeof Transfer>;
88
88
  export declare const Transfer: import("superstruct").Struct<{
89
89
  amount: string | number;
90
- destination: String;
91
90
  source: String;
91
+ destination: String;
92
92
  signers?: String[] | undefined;
93
93
  authority?: String | undefined;
94
94
  multisigAuthority?: String | undefined;
@@ -227,9 +227,9 @@ export declare const ThawAccount: import("superstruct").Struct<{
227
227
  }>;
228
228
  export type TransferChecked = Infer<typeof TransferChecked>;
229
229
  export declare const TransferChecked: import("superstruct").Struct<{
230
+ source: String;
230
231
  mint: String;
231
232
  destination: String;
232
- source: String;
233
233
  tokenAmount: {
234
234
  amount: string;
235
235
  decimals: number;
@@ -257,8 +257,8 @@ export declare const TransferChecked: import("superstruct").Struct<{
257
257
  }>;
258
258
  export type ApproveChecked = Infer<typeof ApproveChecked>;
259
259
  export declare const ApproveChecked: import("superstruct").Struct<{
260
- mint: String;
261
260
  source: String;
261
+ mint: String;
262
262
  delegate: String;
263
263
  tokenAmount: {
264
264
  amount: string;
@@ -721,9 +721,9 @@ export type DepositConfidentialTransfer = Infer<typeof DepositConfidentialTransf
721
721
  export declare const DepositConfidentialTransfer: import("superstruct").Struct<{
722
722
  amount: string | number;
723
723
  decimals: number;
724
+ source: String;
724
725
  mint: String;
725
726
  destination: String;
726
- source: String;
727
727
  owner?: String | undefined;
728
728
  signers?: String[] | undefined;
729
729
  multisigOwner?: String | undefined;
@@ -741,9 +741,9 @@ export type WithdrawConfidentialTransfer = Infer<typeof WithdrawConfidentialTran
741
741
  export declare const WithdrawConfidentialTransfer: import("superstruct").Struct<{
742
742
  amount: string | number;
743
743
  decimals: number;
744
+ source: String;
744
745
  mint: String;
745
746
  destination: String;
746
- source: String;
747
747
  equalityProofInstructionOffset: number;
748
748
  newDecryptableAvailableBalance: string;
749
749
  rangeProofInstructionOffset: number;
@@ -775,9 +775,9 @@ export declare const WithdrawConfidentialTransfer: import("superstruct").Struct<
775
775
  }>;
776
776
  export type ConfidentialTransfer = Infer<typeof ConfidentialTransfer>;
777
777
  export declare const ConfidentialTransfer: import("superstruct").Struct<{
778
+ source: String;
778
779
  mint: String;
779
780
  destination: String;
780
- source: String;
781
781
  equalityProofInstructionOffset: number;
782
782
  rangeProofInstructionOffset: number;
783
783
  ciphertextValidityProofInstructionOffset: number;
@@ -813,9 +813,9 @@ export declare const ConfidentialTransfer: import("superstruct").Struct<{
813
813
  }>;
814
814
  export type ConfidentialTransferWithFee = Infer<typeof ConfidentialTransferWithFee>;
815
815
  export declare const ConfidentialTransferWithFee: import("superstruct").Struct<{
816
+ source: String;
816
817
  mint: String;
817
818
  destination: String;
818
- source: String;
819
819
  equalityProofInstructionOffset: number;
820
820
  rangeProofInstructionOffset: number;
821
821
  newSourceDecryptableAvailableBalance: string;
@@ -892,8 +892,8 @@ export declare const ConfidentialTransferCreditsToggle: import("superstruct").St
892
892
  export type ConfigureConfidentialAccountWithRegistry = Infer<typeof ConfigureConfidentialAccountWithRegistry>;
893
893
  export declare const ConfigureConfidentialAccountWithRegistry: import("superstruct").Struct<{
894
894
  account: String;
895
- mint: String;
896
895
  registry: String;
896
+ mint: String;
897
897
  }, {
898
898
  account: import("superstruct").Struct<String, null>;
899
899
  mint: import("superstruct").Struct<String, null>;
@@ -901,8 +901,8 @@ export declare const ConfigureConfidentialAccountWithRegistry: import("superstru
901
901
  }>;
902
902
  export type WithdrawExcessLamports = Infer<typeof WithdrawExcessLamports>;
903
903
  export declare const WithdrawExcessLamports: import("superstruct").Struct<{
904
- destination: String;
905
904
  source: String;
905
+ destination: String;
906
906
  signers?: String[] | undefined;
907
907
  authority?: String | undefined;
908
908
  multisigAuthority?: String | undefined;
@@ -1023,8 +1023,8 @@ export declare const IX_STRUCTS: {
1023
1023
  source: import("superstruct").Struct<String, null>;
1024
1024
  }>;
1025
1025
  approve2: import("superstruct").Struct<{
1026
- mint: String;
1027
1026
  source: String;
1027
+ mint: String;
1028
1028
  delegate: String;
1029
1029
  tokenAmount: {
1030
1030
  amount: string;
@@ -1052,8 +1052,8 @@ export declare const IX_STRUCTS: {
1052
1052
  }>;
1053
1053
  }>;
1054
1054
  approveChecked: import("superstruct").Struct<{
1055
- mint: String;
1056
1055
  source: String;
1056
+ mint: String;
1057
1057
  delegate: String;
1058
1058
  tokenAmount: {
1059
1059
  amount: string;
@@ -1172,9 +1172,9 @@ export declare const IX_STRUCTS: {
1172
1172
  signers: import("superstruct").Struct<String[] | undefined, import("superstruct").Struct<String, null>>;
1173
1173
  }>;
1174
1174
  confidentialTransfer: import("superstruct").Struct<{
1175
+ source: String;
1175
1176
  mint: String;
1176
1177
  destination: String;
1177
- source: String;
1178
1178
  equalityProofInstructionOffset: number;
1179
1179
  rangeProofInstructionOffset: number;
1180
1180
  ciphertextValidityProofInstructionOffset: number;
@@ -1209,9 +1209,9 @@ export declare const IX_STRUCTS: {
1209
1209
  source: import("superstruct").Struct<String, null>;
1210
1210
  }>;
1211
1211
  confidentialTransferWithFee: import("superstruct").Struct<{
1212
+ source: String;
1212
1213
  mint: String;
1213
1214
  destination: String;
1214
- source: String;
1215
1215
  equalityProofInstructionOffset: number;
1216
1216
  rangeProofInstructionOffset: number;
1217
1217
  newSourceDecryptableAvailableBalance: string;
@@ -1259,8 +1259,8 @@ export declare const IX_STRUCTS: {
1259
1259
  }>;
1260
1260
  configureConfidentialAccountWithRegistry: import("superstruct").Struct<{
1261
1261
  account: String;
1262
- mint: String;
1263
1262
  registry: String;
1263
+ mint: String;
1264
1264
  }, {
1265
1265
  account: import("superstruct").Struct<String, null>;
1266
1266
  mint: import("superstruct").Struct<String, null>;
@@ -1312,9 +1312,9 @@ export declare const IX_STRUCTS: {
1312
1312
  depositConfidentialTransfer: import("superstruct").Struct<{
1313
1313
  amount: string | number;
1314
1314
  decimals: number;
1315
+ source: String;
1315
1316
  mint: String;
1316
1317
  destination: String;
1317
- source: String;
1318
1318
  owner?: String | undefined;
1319
1319
  signers?: String[] | undefined;
1320
1320
  multisigOwner?: String | undefined;
@@ -1748,8 +1748,8 @@ export declare const IX_STRUCTS: {
1748
1748
  }>;
1749
1749
  transfer: import("superstruct").Struct<{
1750
1750
  amount: string | number;
1751
- destination: String;
1752
1751
  source: String;
1752
+ destination: String;
1753
1753
  signers?: String[] | undefined;
1754
1754
  authority?: String | undefined;
1755
1755
  multisigAuthority?: String | undefined;
@@ -1762,9 +1762,9 @@ export declare const IX_STRUCTS: {
1762
1762
  source: import("superstruct").Struct<String, null>;
1763
1763
  }>;
1764
1764
  transfer2: import("superstruct").Struct<{
1765
+ source: String;
1765
1766
  mint: String;
1766
1767
  destination: String;
1767
- source: String;
1768
1768
  tokenAmount: {
1769
1769
  amount: string;
1770
1770
  decimals: number;
@@ -1791,9 +1791,9 @@ export declare const IX_STRUCTS: {
1791
1791
  }>;
1792
1792
  }>;
1793
1793
  transferChecked: import("superstruct").Struct<{
1794
+ source: String;
1794
1795
  mint: String;
1795
1796
  destination: String;
1796
- source: String;
1797
1797
  tokenAmount: {
1798
1798
  amount: string;
1799
1799
  decimals: number;
@@ -1927,9 +1927,9 @@ export declare const IX_STRUCTS: {
1927
1927
  withdrawConfidentialTransfer: import("superstruct").Struct<{
1928
1928
  amount: string | number;
1929
1929
  decimals: number;
1930
+ source: String;
1930
1931
  mint: String;
1931
1932
  destination: String;
1932
- source: String;
1933
1933
  equalityProofInstructionOffset: number;
1934
1934
  newDecryptableAvailableBalance: string;
1935
1935
  rangeProofInstructionOffset: number;
@@ -1960,8 +1960,8 @@ export declare const IX_STRUCTS: {
1960
1960
  source: import("superstruct").Struct<String, null>;
1961
1961
  }>;
1962
1962
  withdrawExcessLamports: import("superstruct").Struct<{
1963
- destination: String;
1964
1963
  source: String;
1964
+ destination: String;
1965
1965
  signers?: String[] | undefined;
1966
1966
  authority?: String | undefined;
1967
1967
  multisigAuthority?: String | undefined;
@@ -1,8 +1,8 @@
1
1
  import { type CoinID } from '@sentio/protos';
2
2
  import { ChainId } from '@sentio/chain';
3
- import { PriceService } from '@sentio/api';
4
- export declare function getPriceClient(basePath?: string): typeof PriceService;
5
- type PriceApi = typeof PriceService;
3
+ import { type Client, PriceService } from '@sentio/api';
4
+ export declare function getPriceClient(basePath?: string): PriceApi;
5
+ type PriceApi = Client<typeof PriceService>;
6
6
  interface PriceOptions {
7
7
  toleranceInDays?: number;
8
8
  }
@@ -22,9 +22,13 @@ export declare function getPriceByType(chainId: ChainId, coinType: string, date:
22
22
  */
23
23
  export declare function getPriceBySymbol(symbol: string, date: Date, options?: PriceOptions): Promise<number | undefined>;
24
24
  /**
25
- * get coins that has price, return results are list of coin id with both symbol and address field set
25
+ * get coins that has price, return results as a list of `{ symbol, coin }`
26
+ * pairs where `coin` is the address-keyed CoinID for that symbol on the chain
26
27
  * @param chainId
27
28
  */
28
- export declare function getCoinsThatHasPrice(chainId: ChainId): Promise<import("@sentio/api").PriceServiceCoinId[]>;
29
+ export declare function getCoinsThatHasPrice(chainId: ChainId): Promise<{
30
+ symbol: string;
31
+ coin: import("@sentio/api/gen/service/price/protos/price_pb.js").CoinID;
32
+ }[]>;
29
33
  export {};
30
34
  //# 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,KAAK,MAAM,EAAgB,MAAM,gBAAgB,CAAA;AAG1D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAU,YAAY,EAAE,MAAM,aAAa,CAAA;AAalD,wBAAgB,cAAc,CAAC,QAAQ,SAAkC,uBAYxE;AAOD,KAAK,QAAQ,GAAG,OAAO,YAAY,CAAA;AAGnC,UAAU,YAAY;IACpB,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAQD,wB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C,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,IAAI,EACV,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAc7B;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;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,OAAO;;;KAU1D"}
@@ -1,8 +1,10 @@
1
1
  import { CoinIDSchema } from '@sentio/protos';
2
2
  import { create } from '@bufbuild/protobuf';
3
+ import { timestampDate, timestampFromDate } from '@bufbuild/protobuf/wkt';
3
4
  import { Endpoints, processMetrics } from '@sentio/runtime';
4
5
  import { LRUCache } from 'lru-cache';
5
- import { client, PriceService } from '@sentio/api';
6
+ import { createSentioClient, PriceService } from '@sentio/api';
7
+ import { Code, ConnectError } from '@connectrpc/connect';
6
8
  import path from 'path';
7
9
  import fs from 'fs';
8
10
  import os from 'os';
@@ -21,11 +23,10 @@ export function getPriceClient(basePath = Endpoints.INSTANCE.priceFeedAPI) {
21
23
  if (basePath.endsWith('/')) {
22
24
  basePath = basePath.slice(0, -1);
23
25
  }
24
- client.setConfig({
26
+ return createSentioClient(PriceService, {
25
27
  baseUrl: basePath || 'https://api.sentio.xyz',
26
- auth: getApiKey()
28
+ apiKey: getApiKey()
27
29
  });
28
- return PriceService;
29
30
  }
30
31
  const priceMap = new LRUCache({
31
32
  max: 100000,
@@ -56,18 +57,17 @@ export async function getPriceByTypeOrSymbolInternal(priceClient, date, coinId,
56
57
  }
57
58
  processMetrics.process_pricecall_count.add(1);
58
59
  const response = priceClient.getPrice({
59
- query: {
60
- timestamp: date.toISOString(),
61
- 'coinId.symbol': symbol,
62
- 'coinId.address.address': address?.address,
63
- 'coinId.address.chain': address?.chain
60
+ timestamp: timestampFromDate(date),
61
+ coinId: {
62
+ id: symbol
63
+ ? { case: 'symbol', value: symbol }
64
+ : { case: 'address', value: { address: address?.address ?? '', chain: address?.chain ?? '' } }
64
65
  }
65
66
  });
66
67
  price = response
67
68
  .then((res) => {
68
- const { data } = res;
69
- if (data?.timestamp) {
70
- const responseDate = new Date(data.timestamp);
69
+ if (res.timestamp) {
70
+ const responseDate = timestampDate(res.timestamp);
71
71
  const responseDateString = dateString(responseDate);
72
72
  if (responseDateString === todayDateString) {
73
73
  priceMap.delete(key);
@@ -86,13 +86,13 @@ export async function getPriceByTypeOrSymbolInternal(priceClient, date, coinId,
86
86
  else {
87
87
  priceMap.delete(key);
88
88
  }
89
- return data?.price;
89
+ return res.price;
90
90
  })
91
91
  .catch((e) => {
92
92
  setTimeout(() => {
93
93
  priceMap.delete(key);
94
94
  }, 1000);
95
- if (e.response?.status === 404) {
95
+ if (e instanceof ConnectError && e.code === Code.NotFound) {
96
96
  console.error('price not found for ', JSON.stringify(coinId), ' at ', dateStr);
97
97
  return undefined;
98
98
  }
@@ -133,25 +133,18 @@ function dateString(date) {
133
133
  return [date.getHours(), date.getUTCDate(), date.getUTCMonth() + 1, date.getUTCFullYear()].join('-');
134
134
  }
135
135
  /**
136
- * get coins that has price, return results are list of coin id with both symbol and address field set
136
+ * get coins that has price, return results as a list of `{ symbol, coin }`
137
+ * pairs where `coin` is the address-keyed CoinID for that symbol on the chain
137
138
  * @param chainId
138
139
  */
139
140
  export async function getCoinsThatHasPrice(chainId) {
140
141
  if (!priceClient) {
141
142
  priceClient = getPriceClient();
142
143
  }
143
- const { data } = await priceClient.priceListCoins({
144
- query: {
145
- chain: chainId,
146
- limit: 1000
147
- }
148
- });
149
- if (!data?.coinAddressesInChain) {
150
- return [];
151
- }
152
- return Object.entries(data.coinAddressesInChain).map(([symbol, coin]) => {
153
- coin.symbol = symbol;
154
- return coin;
144
+ const res = await priceClient.listCoins({
145
+ chain: chainId,
146
+ limit: 1000
155
147
  });
148
+ return Object.entries(res.coinAddressesInChain).map(([symbol, coin]) => ({ symbol, coin }));
156
149
  }
157
150
  //# sourceMappingURL=price.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"price.js","sourceRoot":"","sources":["../../src/utils/price.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,SAAS,SAAS;IAChB,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,aAAa,CAAC,EAAE,MAAM,CAAC,CAAA;QAC1F,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAClC,OAAO,MAAM,CAAC,wBAAwB,CAAC,EAAE,QAAQ,CAAA;IACnD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,CAAA,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,QAAQ,GAAG,SAAS,CAAC,QAAQ,CAAC,YAAY;IACvE,IAAI,QAAQ,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7C,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAA;IACjC,CAAC;IACD,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,QAAQ,GAAG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R,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAc,EACd,IAAU,EACV,OAAsB;IAEtB,OAAO,sBAAsB,CAAC,IAAI,EAAE,MAAM,CAAC,YAAY,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAA;AAC/G,CAAC;AAED,SAAS,UAAU,CAAC,IAAU;IAC5B,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACtG,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,OAAgB;IACzD,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,WAAW,GAAG,cAAc,EAAE,CAAA;IAChC,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,SAAS,CAAC;QACtC,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,IAAI;KACZ,CAAC,CAAA;IAEF,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AAC7F,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/sdk",
3
- "version": "4.1.0-rc.1",
3
+ "version": "4.1.0-rc.2",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -65,12 +65,12 @@
65
65
  "@anchor-lang/core": "^1.0.2",
66
66
  "@aptos-labs/ts-sdk": "~7.1.0",
67
67
  "@bufbuild/protobuf": "^2.12.0",
68
- "@connectrpc/connect": "^2.0.0",
68
+ "@connectrpc/connect": "^2.1.2",
69
69
  "@iota/iota-sdk": "~1.14.0",
70
70
  "@mysten/sui": "~2.20.0",
71
71
  "@prettier/sync": "^0.6.0",
72
72
  "@protobuf-ts/grpcweb-transport": "^2.11.1",
73
- "@sentio/api": "1.0.2",
73
+ "@sentio/api": "~2.0.3",
74
74
  "@sentio/bigdecimal": "9.1.1-patch.3",
75
75
  "@sentio/chain": "~3.4.29",
76
76
  "@sentio/ethers-v6": "^1.0.29",
@@ -97,8 +97,8 @@
97
97
  "typechain": "^8.3.2",
98
98
  "utility-types": "^3.11.0",
99
99
  "yaml": "^2.3.4",
100
- "@sentio/protos": "4.1.0-rc.1",
101
- "@sentio/runtime": "^4.1.0-rc.1"
100
+ "@sentio/protos": "4.1.0-rc.2",
101
+ "@sentio/runtime": "^4.1.0-rc.2"
102
102
  },
103
103
  "peerDependencies": {
104
104
  "tsdown": "^0.22.3"
@@ -1,9 +1,11 @@
1
1
  import { type CoinID, CoinIDSchema } from '@sentio/protos'
2
2
  import { create } from '@bufbuild/protobuf'
3
+ import { timestampDate, timestampFromDate } from '@bufbuild/protobuf/wkt'
3
4
  import { Endpoints, processMetrics } from '@sentio/runtime'
4
5
  import { ChainId } from '@sentio/chain'
5
6
  import { LRUCache } from 'lru-cache'
6
- import { client, PriceService } from '@sentio/api'
7
+ import { type Client, createSentioClient, PriceService } from '@sentio/api'
8
+ import { Code, ConnectError } from '@connectrpc/connect'
7
9
  import path from 'path'
8
10
  import fs from 'fs'
9
11
  import os from 'os'
@@ -16,18 +18,17 @@ function getApiKey() {
16
18
  } catch (e) {}
17
19
  }
18
20
 
19
- export function getPriceClient(basePath = Endpoints.INSTANCE.priceFeedAPI) {
21
+ export function getPriceClient(basePath = Endpoints.INSTANCE.priceFeedAPI): PriceApi {
20
22
  if (basePath && !basePath.startsWith('http')) {
21
23
  basePath = 'http://' + basePath
22
24
  }
23
25
  if (basePath.endsWith('/')) {
24
26
  basePath = basePath.slice(0, -1)
25
27
  }
26
- client.setConfig({
28
+ return createSentioClient(PriceService, {
27
29
  baseUrl: basePath || 'https://api.sentio.xyz',
28
- auth: getApiKey()
30
+ apiKey: getApiKey()
29
31
  })
30
- return PriceService
31
32
  }
32
33
 
33
34
  const priceMap = new LRUCache<string, Promise<number | undefined>>({
@@ -35,7 +36,7 @@ const priceMap = new LRUCache<string, Promise<number | undefined>>({
35
36
  ttl: 1000 * 60 * 5 // 5 minutes
36
37
  })
37
38
 
38
- type PriceApi = typeof PriceService
39
+ type PriceApi = Client<typeof PriceService>
39
40
  let priceClient: PriceApi
40
41
 
41
42
  interface PriceOptions {
@@ -73,18 +74,17 @@ export async function getPriceByTypeOrSymbolInternal(
73
74
 
74
75
  processMetrics.process_pricecall_count.add(1)
75
76
  const response = priceClient.getPrice({
76
- query: {
77
- timestamp: date.toISOString(),
78
- 'coinId.symbol': symbol,
79
- 'coinId.address.address': address?.address,
80
- 'coinId.address.chain': address?.chain
77
+ timestamp: timestampFromDate(date),
78
+ coinId: {
79
+ id: symbol
80
+ ? { case: 'symbol', value: symbol }
81
+ : { case: 'address', value: { address: address?.address ?? '', chain: address?.chain ?? '' } }
81
82
  }
82
83
  })
83
84
  price = response
84
85
  .then((res) => {
85
- const { data } = res
86
- if (data?.timestamp) {
87
- const responseDate = new Date(data.timestamp)
86
+ if (res.timestamp) {
87
+ const responseDate = timestampDate(res.timestamp)
88
88
  const responseDateString = dateString(responseDate)
89
89
  if (responseDateString === todayDateString) {
90
90
  priceMap.delete(key)
@@ -101,14 +101,14 @@ export async function getPriceByTypeOrSymbolInternal(
101
101
  } else {
102
102
  priceMap.delete(key)
103
103
  }
104
- return data?.price
104
+ return res.price
105
105
  })
106
106
  .catch((e) => {
107
107
  setTimeout(() => {
108
108
  priceMap.delete(key)
109
109
  }, 1000)
110
110
 
111
- if (e.response?.status === 404) {
111
+ if (e instanceof ConnectError && e.code === Code.NotFound) {
112
112
  console.error('price not found for ', JSON.stringify(coinId), ' at ', dateStr)
113
113
  return undefined
114
114
  }
@@ -166,25 +166,18 @@ function dateString(date: Date) {
166
166
  }
167
167
 
168
168
  /**
169
- * get coins that has price, return results are list of coin id with both symbol and address field set
169
+ * get coins that has price, return results as a list of `{ symbol, coin }`
170
+ * pairs where `coin` is the address-keyed CoinID for that symbol on the chain
170
171
  * @param chainId
171
172
  */
172
173
  export async function getCoinsThatHasPrice(chainId: ChainId) {
173
174
  if (!priceClient) {
174
175
  priceClient = getPriceClient()
175
176
  }
176
- const { data } = await priceClient.priceListCoins({
177
- query: {
178
- chain: chainId,
179
- limit: 1000
180
- }
177
+ const res = await priceClient.listCoins({
178
+ chain: chainId,
179
+ limit: 1000
181
180
  })
182
181
 
183
- if (!data?.coinAddressesInChain) {
184
- return []
185
- }
186
- return Object.entries(data.coinAddressesInChain).map(([symbol, coin]) => {
187
- coin.symbol = symbol
188
- return coin
189
- })
182
+ return Object.entries(res.coinAddressesInChain).map(([symbol, coin]) => ({ symbol, coin }))
190
183
  }