@chainstream-io/sdk 0.1.8 → 0.1.9

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 (114) hide show
  1. package/README.md +2 -2
  2. package/dist/esm/index.js +73 -74
  3. package/dist/esm/openapi/apis/BlockchainApi.js +61 -44
  4. package/dist/esm/openapi/apis/DefiSolanaMoonshotApi.js +67 -50
  5. package/dist/esm/openapi/apis/DefiSolanaPumpfunApi.js +38 -25
  6. package/dist/esm/openapi/apis/DexApi.js +205 -176
  7. package/dist/esm/openapi/apis/DexPoolApi.js +41 -28
  8. package/dist/esm/openapi/apis/EndpointApi.js +212 -175
  9. package/dist/esm/openapi/apis/IpfsApi.js +38 -25
  10. package/dist/esm/openapi/apis/JobsApi.js +65 -48
  11. package/dist/esm/openapi/apis/RankingApi.js +278 -249
  12. package/dist/esm/openapi/apis/RedPacketApi.js +294 -253
  13. package/dist/esm/openapi/apis/TokenApi.js +1145 -1056
  14. package/dist/esm/openapi/apis/TradeApi.js +233 -208
  15. package/dist/esm/openapi/apis/TransactionApi.js +42 -29
  16. package/dist/esm/openapi/apis/WalletApi.js +148 -123
  17. package/dist/esm/openapi/apis/WatchlistApi.js +41 -28
  18. package/dist/esm/openapi/runtime.js +119 -118
  19. package/dist/esm/stream/stream.js +36 -34
  20. package/dist/index.js +99 -96
  21. package/dist/openapi/apis/BlockchainApi.js +69 -48
  22. package/dist/openapi/apis/DefiSolanaMoonshotApi.js +74 -53
  23. package/dist/openapi/apis/DefiSolanaPumpfunApi.js +45 -28
  24. package/dist/openapi/apis/DexApi.js +217 -184
  25. package/dist/openapi/apis/DexPoolApi.js +49 -32
  26. package/dist/openapi/apis/EndpointApi.js +220 -179
  27. package/dist/openapi/apis/IpfsApi.js +44 -27
  28. package/dist/openapi/apis/JobsApi.js +72 -51
  29. package/dist/openapi/apis/RankingApi.js +306 -273
  30. package/dist/openapi/apis/RedPacketApi.js +305 -260
  31. package/dist/openapi/apis/TokenApi.js +1182 -1089
  32. package/dist/openapi/apis/TradeApi.js +256 -227
  33. package/dist/openapi/apis/TransactionApi.js +49 -32
  34. package/dist/openapi/apis/WalletApi.js +159 -130
  35. package/dist/openapi/apis/WatchlistApi.js +49 -32
  36. package/dist/openapi/apis/index.js +31 -15
  37. package/dist/openapi/index.js +19 -3
  38. package/dist/openapi/models/BlockchainDTO.js +12 -5
  39. package/dist/openapi/models/BlockchainLatestBlockDTO.js +12 -5
  40. package/dist/openapi/models/BooleanResultDTO.js +12 -5
  41. package/dist/openapi/models/CalculatePnlInput.js +12 -5
  42. package/dist/openapi/models/Candle.js +15 -8
  43. package/dist/openapi/models/ClaimRedPacketInput.js +12 -5
  44. package/dist/openapi/models/CreateEndpointInput.js +12 -5
  45. package/dist/openapi/models/CreateRedPacketInput.js +12 -5
  46. package/dist/openapi/models/CreateRedPacketReply.js +12 -5
  47. package/dist/openapi/models/CreateTokenInput.js +14 -6
  48. package/dist/openapi/models/CreateTokenReply.js +12 -5
  49. package/dist/openapi/models/DexDTO.js +12 -5
  50. package/dist/openapi/models/DexPage.js +15 -8
  51. package/dist/openapi/models/DexPoolDTO.js +12 -5
  52. package/dist/openapi/models/EndpointListResponse.js +15 -8
  53. package/dist/openapi/models/EndpointOperationResponse.js +12 -5
  54. package/dist/openapi/models/EndpointResponse.js +12 -5
  55. package/dist/openapi/models/EndpointSecretResponse.js +12 -5
  56. package/dist/openapi/models/FilterCondition.js +14 -6
  57. package/dist/openapi/models/GainersAndLosersDTO.js +12 -5
  58. package/dist/openapi/models/GainersAndLosersPage.js +15 -8
  59. package/dist/openapi/models/JobDTO.js +12 -5
  60. package/dist/openapi/models/JobStreamingDTO.js +12 -5
  61. package/dist/openapi/models/Link.js +14 -6
  62. package/dist/openapi/models/MoonshotCreateTokenInput.js +18 -10
  63. package/dist/openapi/models/MoonshotCreateTokenReply.js +12 -5
  64. package/dist/openapi/models/MoonshotSubmitCreateToken200Response.js +12 -5
  65. package/dist/openapi/models/MoonshotSubmitCreateTokenInput.js +12 -5
  66. package/dist/openapi/models/PumpCreateTokenInput.js +15 -7
  67. package/dist/openapi/models/PumpCreateTokenReply.js +12 -5
  68. package/dist/openapi/models/QuoteResponse.js +12 -5
  69. package/dist/openapi/models/RedPacketClaimDTO.js +14 -6
  70. package/dist/openapi/models/RedPacketClaimsPage.js +15 -8
  71. package/dist/openapi/models/RedPacketDTO.js +14 -6
  72. package/dist/openapi/models/RedPacketReply.js +12 -5
  73. package/dist/openapi/models/RedPacketSendTxInput.js +12 -5
  74. package/dist/openapi/models/RedPacketSendTxResponse.js +12 -5
  75. package/dist/openapi/models/RedPacketsPage.js +15 -8
  76. package/dist/openapi/models/Resolution.js +17 -9
  77. package/dist/openapi/models/SendTxInput.js +14 -6
  78. package/dist/openapi/models/SendTxResponse.js +12 -5
  79. package/dist/openapi/models/SwapInput.js +15 -7
  80. package/dist/openapi/models/SwapReply.js +12 -5
  81. package/dist/openapi/models/SwapRouteInput.js +15 -7
  82. package/dist/openapi/models/SwapRouteResponse.js +15 -8
  83. package/dist/openapi/models/Token.js +30 -23
  84. package/dist/openapi/models/TokenCreationDTO.js +14 -6
  85. package/dist/openapi/models/TokenCreationPage.js +15 -8
  86. package/dist/openapi/models/TokenCreatorsDTO.js +12 -5
  87. package/dist/openapi/models/TokenExtraDTO.js +12 -5
  88. package/dist/openapi/models/TokenHolder.js +12 -5
  89. package/dist/openapi/models/TokenHolderPage.js +15 -8
  90. package/dist/openapi/models/TokenListPage.js +15 -8
  91. package/dist/openapi/models/TokenMarketData.js +12 -5
  92. package/dist/openapi/models/TokenMetadata.js +21 -14
  93. package/dist/openapi/models/TokenPage.js +15 -8
  94. package/dist/openapi/models/TokenPriceDTO.js +12 -5
  95. package/dist/openapi/models/TokenPricePage.js +15 -8
  96. package/dist/openapi/models/TokenSocialMediasDTO.js +12 -5
  97. package/dist/openapi/models/TokenStat.js +12 -5
  98. package/dist/openapi/models/TopTradersDTO.js +12 -5
  99. package/dist/openapi/models/TopTradersPage.js +15 -8
  100. package/dist/openapi/models/TradeDetailDTO.js +12 -5
  101. package/dist/openapi/models/TradeEvent.js +15 -8
  102. package/dist/openapi/models/TradePage.js +15 -8
  103. package/dist/openapi/models/TradeType.js +17 -9
  104. package/dist/openapi/models/UpdateEndpointInput.js +12 -5
  105. package/dist/openapi/models/WalletBalanceDetailDTO.js +12 -5
  106. package/dist/openapi/models/WalletBalancesDTO.js +15 -8
  107. package/dist/openapi/models/WalletPnlDTO.js +12 -5
  108. package/dist/openapi/models/index.js +86 -70
  109. package/dist/openapi/runtime.js +153 -136
  110. package/dist/stream/index.js +19 -3
  111. package/dist/stream/stream.fields.js +11 -5
  112. package/dist/stream/stream.js +45 -39
  113. package/dist/stream/stream.model.js +13 -10
  114. package/package.json +3 -3
@@ -1,16 +1,26 @@
1
- import { Centrifuge } from "@chainstream-io/centrifuge";
2
- import { replaceFilterFields } from "./stream.fields";
3
- export class StreamApi {
4
- realtimeClient;
5
- listenersMap;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.StreamApi = void 0;
13
+ const centrifuge_1 = require("@chainstream-io/centrifuge");
14
+ const stream_fields_1 = require("./stream.fields");
15
+ class StreamApi {
6
16
  constructor(context) {
7
17
  const realtimeEndpoint = context.streamUrl;
8
- this.realtimeClient = new Centrifuge(realtimeEndpoint, {
9
- getToken: async (_ctx) => {
18
+ this.realtimeClient = new centrifuge_1.Centrifuge(realtimeEndpoint, {
19
+ getToken: (_ctx) => __awaiter(this, void 0, void 0, function* () {
10
20
  return typeof context.accessToken === "string"
11
21
  ? context.accessToken
12
- : await context.accessToken.getToken();
13
- },
22
+ : yield context.accessToken.getToken();
23
+ }),
14
24
  });
15
25
  this.realtimeClient
16
26
  .on("connected", () => {
@@ -80,11 +90,8 @@ export class StreamApi {
80
90
  this.listenersMap.set(channel, listeners);
81
91
  console.log("[xrealtime] create new sub: ", channel);
82
92
  // Process filter expression with method-specific field mappings
83
- const processedFilter = filter && methodName ? replaceFilterFields(filter, methodName) : filter;
84
- sub = this.realtimeClient.newSubscription(channel, {
85
- delta: "fossil",
86
- ...(processedFilter && { filter: processedFilter }),
87
- });
93
+ const processedFilter = filter && methodName ? (0, stream_fields_1.replaceFilterFields)(filter, methodName) : filter;
94
+ sub = this.realtimeClient.newSubscription(channel, Object.assign({ delta: "fossil" }, (processedFilter && { filter: processedFilter })));
88
95
  sub
89
96
  .on("subscribed", () => {
90
97
  console.log("[xrealtime] subscribed", channel);
@@ -94,11 +101,11 @@ export class StreamApi {
94
101
  })
95
102
  .on("publication", (ctx) => {
96
103
  // console.log('[xrealtime] publication, ctx.data: ', ctx.data);
97
- listeners?.forEach((it) => it(ctx.data));
104
+ listeners === null || listeners === void 0 ? void 0 : listeners.forEach((it) => it(ctx.data));
98
105
  })
99
106
  .subscribe();
100
107
  }
101
- listeners?.add(fn);
108
+ listeners === null || listeners === void 0 ? void 0 : listeners.add(fn);
102
109
  return new StreamUnsubscrible(this, channel, fn);
103
110
  }
104
111
  unsubscribe(channel, fn) {
@@ -269,44 +276,45 @@ export class StreamApi {
269
276
  imageUrl: it.iu,
270
277
  description: it.de,
271
278
  socialMedia: (() => {
279
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
272
280
  const socialMedia = {};
273
- if (it.sm?.tw) {
281
+ if ((_a = it.sm) === null || _a === void 0 ? void 0 : _a.tw) {
274
282
  socialMedia.twitter = it.sm.tw;
275
283
  }
276
- if (it.sm?.tg) {
284
+ if ((_b = it.sm) === null || _b === void 0 ? void 0 : _b.tg) {
277
285
  socialMedia.telegram = it.sm.tg;
278
286
  }
279
- if (it.sm?.w) {
287
+ if ((_c = it.sm) === null || _c === void 0 ? void 0 : _c.w) {
280
288
  socialMedia.website = it.sm.w;
281
289
  }
282
- if (it.sm?.tt) {
290
+ if ((_d = it.sm) === null || _d === void 0 ? void 0 : _d.tt) {
283
291
  socialMedia.tiktok = it.sm.tt;
284
292
  }
285
- if (it.sm?.dc) {
293
+ if ((_e = it.sm) === null || _e === void 0 ? void 0 : _e.dc) {
286
294
  socialMedia.discord = it.sm.dc;
287
295
  }
288
- if (it.sm?.fb) {
296
+ if ((_f = it.sm) === null || _f === void 0 ? void 0 : _f.fb) {
289
297
  socialMedia.facebook = it.sm.fb;
290
298
  }
291
- if (it.sm?.gh) {
299
+ if ((_g = it.sm) === null || _g === void 0 ? void 0 : _g.gh) {
292
300
  socialMedia.github = it.sm.gh;
293
301
  }
294
- if (it.sm?.ig) {
302
+ if ((_h = it.sm) === null || _h === void 0 ? void 0 : _h.ig) {
295
303
  socialMedia.instagram = it.sm.ig;
296
304
  }
297
- if (it.sm?.li) {
305
+ if ((_j = it.sm) === null || _j === void 0 ? void 0 : _j.li) {
298
306
  socialMedia.linkedin = it.sm.li;
299
307
  }
300
- if (it.sm?.md) {
308
+ if ((_k = it.sm) === null || _k === void 0 ? void 0 : _k.md) {
301
309
  socialMedia.medium = it.sm.md;
302
310
  }
303
- if (it.sm?.rd) {
311
+ if ((_l = it.sm) === null || _l === void 0 ? void 0 : _l.rd) {
304
312
  socialMedia.reddit = it.sm.rd;
305
313
  }
306
- if (it.sm?.yt) {
314
+ if ((_m = it.sm) === null || _m === void 0 ? void 0 : _m.yt) {
307
315
  socialMedia.youtube = it.sm.yt;
308
316
  }
309
- if (it.sm?.bb) {
317
+ if ((_o = it.sm) === null || _o === void 0 ? void 0 : _o.bb) {
310
318
  socialMedia.bitbucket = it.sm.bb;
311
319
  }
312
320
  return socialMedia;
@@ -357,7 +365,7 @@ export class StreamApi {
357
365
  }
358
366
  subscribeRankingTokensLiquidity({ chain, channelType, callback, }) {
359
367
  const channel = `dex-ranking-token-general_stat_num-list:${chain}_${channelType}`;
360
- return this.subscribe(channel, (data) => callback(data?.map((it) => ({
368
+ return this.subscribe(channel, (data) => callback(data === null || data === void 0 ? void 0 : data.map((it) => ({
361
369
  tokenAddress: it.a,
362
370
  metricType: it.t,
363
371
  value: it.v,
@@ -368,7 +376,7 @@ export class StreamApi {
368
376
  const channel = dex
369
377
  ? `dex-ranking-list:${chain}_${ranking_type}_${dex}`
370
378
  : `dex-ranking-list:${chain}_${ranking_type}`;
371
- return this.subscribe(channel, (data) => callback(data?.map((item) => {
379
+ return this.subscribe(channel, (data) => callback(data === null || data === void 0 ? void 0 : data.map((item) => {
372
380
  const result = {};
373
381
  // TokenMetadata (t)
374
382
  if (item.t) {
@@ -723,7 +731,7 @@ export class StreamApi {
723
731
  }
724
732
  subscribeRankingTokensStats({ chain, channelType, callback, }) {
725
733
  const channel = `dex-ranking-token-stats-list:${chain}_${channelType}`;
726
- return this.subscribe(channel, (data) => callback(data?.map((it) => ({
734
+ return this.subscribe(channel, (data) => callback(data === null || data === void 0 ? void 0 : data.map((it) => ({
727
735
  address: it.a,
728
736
  timestamp: it.t,
729
737
  buys1m: it.b1m,
@@ -794,7 +802,7 @@ export class StreamApi {
794
802
  }
795
803
  subscribeRankingTokensHolders({ chain, channelType, callback, }) {
796
804
  const channel = `dex-ranking-token-holding-list:${chain}_${channelType}`;
797
- return this.subscribe(channel, (data) => callback(data?.map((it) => ({
805
+ return this.subscribe(channel, (data) => callback(data === null || data === void 0 ? void 0 : data.map((it) => ({
798
806
  tokenAddress: it.a,
799
807
  holders: it.h,
800
808
  top100Amount: this.formatScientificNotation(it.t100a),
@@ -808,7 +816,7 @@ export class StreamApi {
808
816
  }
809
817
  subscribeRankingTokensSupply({ chain, channelType, callback, }) {
810
818
  const channel = `dex-ranking-token-supply-list:${chain}_${channelType}`;
811
- return this.subscribe(channel, (data) => callback(data?.map((it) => ({
819
+ return this.subscribe(channel, (data) => callback(data === null || data === void 0 ? void 0 : data.map((it) => ({
812
820
  tokenAddress: it.a,
813
821
  supply: it.s,
814
822
  marketCapInUsd: it.mc,
@@ -817,7 +825,7 @@ export class StreamApi {
817
825
  }
818
826
  subscribeRankingTokensBondingCurve({ chain, callback, }) {
819
827
  const channel = `dex-ranking-token-bounding-curve-list:${chain}_new`;
820
- return this.subscribe(channel, (data) => callback(data?.map((it) => ({
828
+ return this.subscribe(channel, (data) => callback(data === null || data === void 0 ? void 0 : data.map((it) => ({
821
829
  tokenAddress: it.a,
822
830
  progressRatio: it.pr,
823
831
  }))));
@@ -900,7 +908,7 @@ export class StreamApi {
900
908
  }
901
909
  subscribeWalletPnlList({ chain, walletAddress, callback, }) {
902
910
  const channel = `dex-wallet-pnl-list:${chain}_${walletAddress}`;
903
- return this.subscribe(channel, (data) => callback(data?.map((it) => ({
911
+ return this.subscribe(channel, (data) => callback(data === null || data === void 0 ? void 0 : data.map((it) => ({
904
912
  walletAddress: it.a,
905
913
  buys: it.bs,
906
914
  buyAmount: it.ba,
@@ -973,10 +981,8 @@ export class StreamApi {
973
981
  }));
974
982
  }
975
983
  }
984
+ exports.StreamApi = StreamApi;
976
985
  class StreamUnsubscrible {
977
- streamApi;
978
- channel;
979
- fn;
980
986
  constructor(streamApi, channel, fn) {
981
987
  this.streamApi = streamApi;
982
988
  this.channel = channel;
@@ -1,32 +1,35 @@
1
- export var TokenActivityType;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Dex = exports.RankingType = exports.MetricType = exports.ChannelType = exports.TokenActivityType = void 0;
4
+ var TokenActivityType;
2
5
  (function (TokenActivityType) {
3
6
  TokenActivityType["Sell"] = "sell";
4
7
  TokenActivityType["Buy"] = "buy";
5
8
  TokenActivityType["AddLiquidity"] = "add_liquidity";
6
9
  TokenActivityType["RemoveLiquidity"] = "remove_liquidity";
7
- })(TokenActivityType || (TokenActivityType = {}));
8
- export var ChannelType;
10
+ })(TokenActivityType || (exports.TokenActivityType = TokenActivityType = {}));
11
+ var ChannelType;
9
12
  (function (ChannelType) {
10
13
  ChannelType["New"] = "new";
11
14
  ChannelType["HOT"] = "trending";
12
15
  ChannelType["US_STOCKS"] = "us_stocks";
13
16
  ChannelType["COMPLETED"] = "completed";
14
17
  ChannelType["GRADUATED"] = "graduated";
15
- })(ChannelType || (ChannelType = {}));
16
- export var MetricType;
18
+ })(ChannelType || (exports.ChannelType = ChannelType = {}));
19
+ var MetricType;
17
20
  (function (MetricType) {
18
21
  MetricType["LIQUIDITY_IN_USD"] = "liquidity_in_usd";
19
22
  MetricType["MIGRATED_RATIO"] = "migrated_ratio";
20
- })(MetricType || (MetricType = {}));
21
- export var RankingType;
23
+ })(MetricType || (exports.MetricType = MetricType = {}));
24
+ var RankingType;
22
25
  (function (RankingType) {
23
26
  RankingType["NEW"] = "new";
24
27
  RankingType["HOT"] = "trending";
25
28
  RankingType["STOCKS"] = "stocks";
26
29
  RankingType["FINALSTRETCH"] = "completed";
27
30
  RankingType["MIGRATED"] = "graduated";
28
- })(RankingType || (RankingType = {}));
29
- export var Dex;
31
+ })(RankingType || (exports.RankingType = RankingType = {}));
32
+ var Dex;
30
33
  (function (Dex) {
31
34
  Dex["PUMP_FUN"] = "pump_fun";
32
35
  Dex["RAYDIUM_LAUNCHPAD"] = "raydium_launchpad";
@@ -34,4 +37,4 @@ export var Dex;
34
37
  Dex["BONK_FUN"] = "bonk_fun";
35
38
  Dex["BOOP_FUN"] = "boop_fun";
36
39
  Dex["MOONIT_FUN"] = "moonit_fun";
37
- })(Dex || (Dex = {}));
40
+ })(Dex || (exports.Dex = Dex = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainstream-io/sdk",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "API and Stream client for ChainStream",
5
5
  "author": "ChainStream",
6
6
  "repository": {
@@ -24,12 +24,12 @@
24
24
  "require": "./dist/index.js",
25
25
  "types": "./dist/index.d.ts"
26
26
  },
27
- "openapi": {
27
+ "./openapi": {
28
28
  "import": "./dist/esm/openapi/index.js",
29
29
  "require": "./dist/openapi/index.js",
30
30
  "types": "./dist/openapi/index.d.ts"
31
31
  },
32
- "stream": {
32
+ "./stream": {
33
33
  "import": "./dist/esm/stream/index.js",
34
34
  "require": "./dist/stream/index.js",
35
35
  "types": "./dist/stream/index.d.ts"