@chainstream-io/sdk 0.1.18 → 0.1.20

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.
package/dist/index.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- export { q as DexAggregatorOptions, r as DexClient, p as DexRequestContext, L as LIB_VERSION, P as PostOptions, o as TokenProvider } from './index-BOKG4I08.cjs';
1
+ export { q as DexAggregatorOptions, r as DexClient, p as DexRequestContext, L as LIB_VERSION, P as PostOptions, o as TokenProvider } from './index-Rg3zipzv.cjs';
2
2
  import './WatchlistApi-18jD3YH5.cjs';
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { q as DexAggregatorOptions, r as DexClient, p as DexRequestContext, L as LIB_VERSION, P as PostOptions, o as TokenProvider } from './index-BFUtqtnx.js';
1
+ export { q as DexAggregatorOptions, r as DexClient, p as DexRequestContext, L as LIB_VERSION, P as PostOptions, o as TokenProvider } from './index-8REU_oTW.js';
2
2
  import './WatchlistApi-18jD3YH5.js';
package/dist/index.mjs CHANGED
@@ -4,6 +4,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4
4
 
5
5
  // src/stream/stream.ts
6
6
  import { Centrifuge } from "@chainstream-io/centrifuge";
7
+ import { createRequire } from "module";
7
8
 
8
9
  // src/stream/stream.fields.ts
9
10
  var CEL_FIELD_MAPPINGS = {
@@ -99,12 +100,54 @@ var CEL_FIELD_MAPPINGS = {
99
100
  "subscribeTokenHolders": {
100
101
  "tokenAddress": "a",
101
102
  "holders": "h",
102
- "top100Amount": "t100a",
103
- "top10Amount": "t10a",
103
+ "top100HoldersAmount": "t100a",
104
+ "top50HoldersAmount": "t50a",
105
+ "top10HoldersAmount": "t10a",
104
106
  "top100Holders": "t100h",
107
+ "top50Holders": "t50h",
105
108
  "top10Holders": "t10h",
106
- "top100Ratio": "t100r",
107
- "top10Ratio": "t10r",
109
+ "top100HoldersRatio": "t100r",
110
+ "top50HoldersRatio": "t50r",
111
+ "top10HoldersRatio": "t10r",
112
+ "creatorsHolders": "ch",
113
+ "creatorsAmount": "ca",
114
+ "creatorsRatio": "cr",
115
+ "balanceTagFreshHolders": "btfh",
116
+ "balanceTagFreshAmount": "btfa",
117
+ "balanceTagFreshRatio": "btfr",
118
+ "balanceTagSandwichHolders": "btsh",
119
+ "balanceTagSandwichAmount": "btsa",
120
+ "balanceTagSandwichRatio": "btsr",
121
+ "balanceTagBundleHolders": "btbh",
122
+ "balanceTagBundleAmount": "btba",
123
+ "balanceTagBundleRatio": "btbr",
124
+ "balanceTagSniperHolders": "btsnh",
125
+ "balanceTagSniperAmount": "btsna",
126
+ "balanceTagSniperRatio": "btsnr",
127
+ "balanceTagDevHolders": "btdh",
128
+ "balanceTagDevAmount": "btda",
129
+ "balanceTagDevRatio": "btdr",
130
+ "balanceTagProHolders": "btph",
131
+ "balanceTagProAmount": "btpa",
132
+ "balanceTagProRatio": "btpr",
133
+ "balanceTagInsiderHolders": "btih",
134
+ "balanceTagInsiderAmount": "btia",
135
+ "balanceTagInsiderRatio": "btir",
136
+ "balanceTagSmartHolders": "btsmh",
137
+ "balanceTagSmartAmount": "btsma",
138
+ "balanceTagSmartRatio": "btsmr",
139
+ "balanceTagKolHolders": "btkh",
140
+ "balanceTagKolAmount": "btka",
141
+ "balanceTagKolRatio": "btkr",
142
+ "balanceTagPhishingHolders": "btphh",
143
+ "balanceTagPhishingAmount": "btpha",
144
+ "balanceTagPhishingRatio": "btphr",
145
+ "balanceTagBluechipHolders": "btblh",
146
+ "balanceTagBluechipAmount": "btbla",
147
+ "balanceTagBluechipRatio": "btblr",
148
+ "balanceTagRatHolders": "btrh",
149
+ "balanceTagRatAmount": "btra",
150
+ "balanceTagRatRatio": "btrr",
108
151
  "timestamp": "ts"
109
152
  },
110
153
  // New token subscription fields
@@ -222,10 +265,31 @@ var StreamApi = class {
222
265
  constructor(context) {
223
266
  __publicField(this, "realtimeClient");
224
267
  __publicField(this, "listenersMap");
268
+ __publicField(this, "getTokenValue");
225
269
  const realtimeEndpoint = context.streamUrl;
270
+ this.getTokenValue = async () => {
271
+ return typeof context.accessToken === "string" ? context.accessToken : await context.accessToken.getToken();
272
+ };
273
+ let wsImpl = void 0;
274
+ if (typeof process !== "undefined" && process.versions?.node) {
275
+ try {
276
+ const require2 = createRequire(import.meta.url);
277
+ wsImpl = require2("ws");
278
+ } catch {
279
+ }
280
+ }
281
+ if (!wsImpl && typeof WebSocket !== "undefined") {
282
+ wsImpl = WebSocket;
283
+ }
226
284
  this.realtimeClient = new Centrifuge(realtimeEndpoint, {
285
+ ...wsImpl && { websocket: wsImpl },
227
286
  getToken: async (_ctx) => {
228
- return typeof context.accessToken === "string" ? context.accessToken : await context.accessToken.getToken();
287
+ const token = await this.getTokenValue();
288
+ this.realtimeClient.setHttpHeaders({
289
+ Authorization: `Bearer ${token}`,
290
+ "User-Agent": `chainstream-io/sdk/javascript`
291
+ });
292
+ return token;
229
293
  }
230
294
  });
231
295
  this.realtimeClient.on("connected", () => {
@@ -237,7 +301,11 @@ var StreamApi = class {
237
301
  });
238
302
  this.listenersMap = /* @__PURE__ */ new Map();
239
303
  }
240
- connect() {
304
+ async connect() {
305
+ const token = await this.getTokenValue();
306
+ this.realtimeClient.setHttpHeaders({
307
+ Authorization: `Bearer ${token}`
308
+ });
241
309
  this.realtimeClient.connect();
242
310
  }
243
311
  /**
@@ -438,15 +506,54 @@ var StreamApi = class {
438
506
  return this.subscribe(channel, (data) => callback({
439
507
  tokenAddress: data.a,
440
508
  holders: data.h,
441
- top100Amount: this.formatScientificNotation(data.t100a),
442
- top10Amount: this.formatScientificNotation(data.t10a),
509
+ top100HoldersAmount: this.formatScientificNotation(data.t100a),
510
+ top50HoldersAmount: this.formatScientificNotation(data.t50a),
511
+ top10HoldersAmount: this.formatScientificNotation(data.t10a),
443
512
  top100Holders: data.t100h,
513
+ top50Holders: data.t50h,
444
514
  top10Holders: data.t10h,
445
- top100Ratio: this.formatScientificNotation(data.t100r),
446
- top10Ratio: this.formatScientificNotation(data.t10r),
515
+ top100HoldersRatio: this.formatScientificNotation(data.t100r),
516
+ top50HoldersRatio: this.formatScientificNotation(data.t50r),
517
+ top10HoldersRatio: this.formatScientificNotation(data.t10r),
447
518
  creatorsHolders: data.ch,
448
519
  creatorsAmount: this.formatScientificNotation(data.ca),
449
520
  creatorsRatio: this.formatScientificNotation(data.cr),
521
+ balanceTagFreshHolders: data.btfh,
522
+ balanceTagFreshAmount: this.formatScientificNotation(data.btfa),
523
+ balanceTagFreshRatio: this.formatScientificNotation(data.btfr),
524
+ balanceTagSandwichHolders: data.btsh,
525
+ balanceTagSandwichAmount: this.formatScientificNotation(data.btsa),
526
+ balanceTagSandwichRatio: this.formatScientificNotation(data.btsr),
527
+ balanceTagBundleHolders: data.btbh,
528
+ balanceTagBundleAmount: this.formatScientificNotation(data.btba),
529
+ balanceTagBundleRatio: this.formatScientificNotation(data.btbr),
530
+ balanceTagSniperHolders: data.btsnh,
531
+ balanceTagSniperAmount: this.formatScientificNotation(data.btsna),
532
+ balanceTagSniperRatio: this.formatScientificNotation(data.btsnr),
533
+ balanceTagDevHolders: data.btdh,
534
+ balanceTagDevAmount: this.formatScientificNotation(data.btda),
535
+ balanceTagDevRatio: this.formatScientificNotation(data.btdr),
536
+ balanceTagProHolders: data.btph,
537
+ balanceTagProAmount: this.formatScientificNotation(data.btpa),
538
+ balanceTagProRatio: this.formatScientificNotation(data.btpr),
539
+ balanceTagInsiderHolders: data.btih,
540
+ balanceTagInsiderAmount: this.formatScientificNotation(data.btia),
541
+ balanceTagInsiderRatio: this.formatScientificNotation(data.btir),
542
+ balanceTagSmartHolders: data.btsmh,
543
+ balanceTagSmartAmount: this.formatScientificNotation(data.btsma),
544
+ balanceTagSmartRatio: this.formatScientificNotation(data.btsmr),
545
+ balanceTagKolHolders: data.btkh,
546
+ balanceTagKolAmount: this.formatScientificNotation(data.btka),
547
+ balanceTagKolRatio: this.formatScientificNotation(data.btkr),
548
+ balanceTagPhishingHolders: data.btphh,
549
+ balanceTagPhishingAmount: this.formatScientificNotation(data.btpha),
550
+ balanceTagPhishingRatio: this.formatScientificNotation(data.btphr),
551
+ balanceTagBluechipHolders: data.btblh,
552
+ balanceTagBluechipAmount: this.formatScientificNotation(data.btbla),
553
+ balanceTagBluechipRatio: this.formatScientificNotation(data.btblr),
554
+ balanceTagRatHolders: data.btrh,
555
+ balanceTagRatAmount: this.formatScientificNotation(data.btra),
556
+ balanceTagRatRatio: this.formatScientificNotation(data.btrr),
450
557
  timestamp: data.ts
451
558
  }), filter, "subscribeTokenHolders");
452
559
  }
@@ -735,22 +842,148 @@ var StreamApi = class {
735
842
  result.holder.holders = item.h.h;
736
843
  }
737
844
  if (item.h.t100a) {
738
- result.holder.top100Amount = this.formatScientificNotation(item.h.t100a);
845
+ result.holder.top100HoldersAmount = this.formatScientificNotation(item.h.t100a);
846
+ }
847
+ if (item.h.t50a) {
848
+ result.holder.top50HoldersAmount = this.formatScientificNotation(item.h.t50a);
739
849
  }
740
850
  if (item.h.t10a) {
741
- result.holder.top10Amount = this.formatScientificNotation(item.h.t10a);
851
+ result.holder.top10HoldersAmount = this.formatScientificNotation(item.h.t10a);
742
852
  }
743
853
  if (item.h.t100h) {
744
854
  result.holder.top100Holders = item.h.t100h;
745
855
  }
856
+ if (item.h.t50h) {
857
+ result.holder.top50Holders = item.h.t50h;
858
+ }
746
859
  if (item.h.t10h) {
747
860
  result.holder.top10Holders = item.h.t10h;
748
861
  }
749
862
  if (item.h.t100r) {
750
- result.holder.top100Ratio = this.formatScientificNotation(item.h.t100r);
863
+ result.holder.top100HoldersRatio = this.formatScientificNotation(item.h.t100r);
864
+ }
865
+ if (item.h.t50r) {
866
+ result.holder.top50HoldersRatio = this.formatScientificNotation(item.h.t50r);
751
867
  }
752
868
  if (item.h.t10r) {
753
- result.holder.top10Ratio = this.formatScientificNotation(item.h.t10r);
869
+ result.holder.top10HoldersRatio = this.formatScientificNotation(item.h.t10r);
870
+ }
871
+ if (item.h.ch) {
872
+ result.holder.creatorsHolders = item.h.ch;
873
+ }
874
+ if (item.h.ca) {
875
+ result.holder.creatorsAmount = this.formatScientificNotation(item.h.ca);
876
+ }
877
+ if (item.h.cr) {
878
+ result.holder.creatorsRatio = this.formatScientificNotation(item.h.cr);
879
+ }
880
+ if (item.h.btfh) {
881
+ result.holder.balanceTagFreshHolders = item.h.btfh;
882
+ }
883
+ if (item.h.btfa) {
884
+ result.holder.balanceTagFreshAmount = this.formatScientificNotation(item.h.btfa);
885
+ }
886
+ if (item.h.btfr) {
887
+ result.holder.balanceTagFreshRatio = this.formatScientificNotation(item.h.btfr);
888
+ }
889
+ if (item.h.btsh) {
890
+ result.holder.balanceTagSandwichHolders = item.h.btsh;
891
+ }
892
+ if (item.h.btsa) {
893
+ result.holder.balanceTagSandwichAmount = this.formatScientificNotation(item.h.btsa);
894
+ }
895
+ if (item.h.btsr) {
896
+ result.holder.balanceTagSandwichRatio = this.formatScientificNotation(item.h.btsr);
897
+ }
898
+ if (item.h.btbh) {
899
+ result.holder.balanceTagBundleHolders = item.h.btbh;
900
+ }
901
+ if (item.h.btba) {
902
+ result.holder.balanceTagBundleAmount = this.formatScientificNotation(item.h.btba);
903
+ }
904
+ if (item.h.btbr) {
905
+ result.holder.balanceTagBundleRatio = this.formatScientificNotation(item.h.btbr);
906
+ }
907
+ if (item.h.btsnh) {
908
+ result.holder.balanceTagSniperHolders = item.h.btsnh;
909
+ }
910
+ if (item.h.btsna) {
911
+ result.holder.balanceTagSniperAmount = this.formatScientificNotation(item.h.btsna);
912
+ }
913
+ if (item.h.btsnr) {
914
+ result.holder.balanceTagSniperRatio = this.formatScientificNotation(item.h.btsnr);
915
+ }
916
+ if (item.h.btdh) {
917
+ result.holder.balanceTagDevHolders = item.h.btdh;
918
+ }
919
+ if (item.h.btda) {
920
+ result.holder.balanceTagDevAmount = this.formatScientificNotation(item.h.btda);
921
+ }
922
+ if (item.h.btdr) {
923
+ result.holder.balanceTagDevRatio = this.formatScientificNotation(item.h.btdr);
924
+ }
925
+ if (item.h.btph) {
926
+ result.holder.balanceTagProHolders = item.h.btph;
927
+ }
928
+ if (item.h.btpa) {
929
+ result.holder.balanceTagProAmount = this.formatScientificNotation(item.h.btpa);
930
+ }
931
+ if (item.h.btpr) {
932
+ result.holder.balanceTagProRatio = this.formatScientificNotation(item.h.btpr);
933
+ }
934
+ if (item.h.btih) {
935
+ result.holder.balanceTagInsiderHolders = item.h.btih;
936
+ }
937
+ if (item.h.btia) {
938
+ result.holder.balanceTagInsiderAmount = this.formatScientificNotation(item.h.btia);
939
+ }
940
+ if (item.h.btir) {
941
+ result.holder.balanceTagInsiderRatio = this.formatScientificNotation(item.h.btir);
942
+ }
943
+ if (item.h.btsmh) {
944
+ result.holder.balanceTagSmartHolders = item.h.btsmh;
945
+ }
946
+ if (item.h.btsma) {
947
+ result.holder.balanceTagSmartAmount = this.formatScientificNotation(item.h.btsma);
948
+ }
949
+ if (item.h.btsmr) {
950
+ result.holder.balanceTagSmartRatio = this.formatScientificNotation(item.h.btsmr);
951
+ }
952
+ if (item.h.btkh) {
953
+ result.holder.balanceTagKolHolders = item.h.btkh;
954
+ }
955
+ if (item.h.btka) {
956
+ result.holder.balanceTagKolAmount = this.formatScientificNotation(item.h.btka);
957
+ }
958
+ if (item.h.btkr) {
959
+ result.holder.balanceTagKolRatio = this.formatScientificNotation(item.h.btkr);
960
+ }
961
+ if (item.h.btphh) {
962
+ result.holder.balanceTagPhishingHolders = item.h.btphh;
963
+ }
964
+ if (item.h.btpha) {
965
+ result.holder.balanceTagPhishingAmount = this.formatScientificNotation(item.h.btpha);
966
+ }
967
+ if (item.h.btphr) {
968
+ result.holder.balanceTagPhishingRatio = this.formatScientificNotation(item.h.btphr);
969
+ }
970
+ if (item.h.btblh) {
971
+ result.holder.balanceTagBluechipHolders = item.h.btblh;
972
+ }
973
+ if (item.h.btbla) {
974
+ result.holder.balanceTagBluechipAmount = this.formatScientificNotation(item.h.btbla);
975
+ }
976
+ if (item.h.btblr) {
977
+ result.holder.balanceTagBluechipRatio = this.formatScientificNotation(item.h.btblr);
978
+ }
979
+ if (item.h.btrh) {
980
+ result.holder.balanceTagRatHolders = item.h.btrh;
981
+ }
982
+ if (item.h.btra) {
983
+ result.holder.balanceTagRatAmount = this.formatScientificNotation(item.h.btra);
984
+ }
985
+ if (item.h.btrr) {
986
+ result.holder.balanceTagRatRatio = this.formatScientificNotation(item.h.btrr);
754
987
  }
755
988
  }
756
989
  if (item.s) {
@@ -1063,12 +1296,54 @@ var StreamApi = class {
1063
1296
  (it) => ({
1064
1297
  tokenAddress: it.a,
1065
1298
  holders: it.h,
1066
- top100Amount: this.formatScientificNotation(it.t100a),
1067
- top10Amount: this.formatScientificNotation(it.t10a),
1299
+ top100HoldersAmount: this.formatScientificNotation(it.t100a),
1300
+ top50HoldersAmount: this.formatScientificNotation(it.t50a),
1301
+ top10HoldersAmount: this.formatScientificNotation(it.t10a),
1068
1302
  top100Holders: it.t100h,
1303
+ top50Holders: it.t50h,
1069
1304
  top10Holders: it.t10h,
1070
- top100Ratio: this.formatScientificNotation(it.t100r),
1071
- top10Ratio: this.formatScientificNotation(it.t10r),
1305
+ top100HoldersRatio: this.formatScientificNotation(it.t100r),
1306
+ top50HoldersRatio: this.formatScientificNotation(it.t50r),
1307
+ top10HoldersRatio: this.formatScientificNotation(it.t10r),
1308
+ creatorsHolders: it.ch,
1309
+ creatorsAmount: this.formatScientificNotation(it.ca),
1310
+ creatorsRatio: this.formatScientificNotation(it.cr),
1311
+ balanceTagFreshHolders: it.btfh,
1312
+ balanceTagFreshAmount: this.formatScientificNotation(it.btfa),
1313
+ balanceTagFreshRatio: this.formatScientificNotation(it.btfr),
1314
+ balanceTagSandwichHolders: it.btsh,
1315
+ balanceTagSandwichAmount: this.formatScientificNotation(it.btsa),
1316
+ balanceTagSandwichRatio: this.formatScientificNotation(it.btsr),
1317
+ balanceTagBundleHolders: it.btbh,
1318
+ balanceTagBundleAmount: this.formatScientificNotation(it.btba),
1319
+ balanceTagBundleRatio: this.formatScientificNotation(it.btbr),
1320
+ balanceTagSniperHolders: it.btsnh,
1321
+ balanceTagSniperAmount: this.formatScientificNotation(it.btsna),
1322
+ balanceTagSniperRatio: this.formatScientificNotation(it.btsnr),
1323
+ balanceTagDevHolders: it.btdh,
1324
+ balanceTagDevAmount: this.formatScientificNotation(it.btda),
1325
+ balanceTagDevRatio: this.formatScientificNotation(it.btdr),
1326
+ balanceTagProHolders: it.btph,
1327
+ balanceTagProAmount: this.formatScientificNotation(it.btpa),
1328
+ balanceTagProRatio: this.formatScientificNotation(it.btpr),
1329
+ balanceTagInsiderHolders: it.btih,
1330
+ balanceTagInsiderAmount: this.formatScientificNotation(it.btia),
1331
+ balanceTagInsiderRatio: this.formatScientificNotation(it.btir),
1332
+ balanceTagSmartHolders: it.btsmh,
1333
+ balanceTagSmartAmount: this.formatScientificNotation(it.btsma),
1334
+ balanceTagSmartRatio: this.formatScientificNotation(it.btsmr),
1335
+ balanceTagKolHolders: it.btkh,
1336
+ balanceTagKolAmount: this.formatScientificNotation(it.btka),
1337
+ balanceTagKolRatio: this.formatScientificNotation(it.btkr),
1338
+ balanceTagPhishingHolders: it.btphh,
1339
+ balanceTagPhishingAmount: this.formatScientificNotation(it.btpha),
1340
+ balanceTagPhishingRatio: this.formatScientificNotation(it.btphr),
1341
+ balanceTagBluechipHolders: it.btblh,
1342
+ balanceTagBluechipAmount: this.formatScientificNotation(it.btbla),
1343
+ balanceTagBluechipRatio: this.formatScientificNotation(it.btblr),
1344
+ balanceTagRatHolders: it.btrh,
1345
+ balanceTagRatAmount: this.formatScientificNotation(it.btra),
1346
+ balanceTagRatRatio: this.formatScientificNotation(it.btrr),
1072
1347
  timestamp: it.ts
1073
1348
  })
1074
1349
  )
@@ -7888,7 +8163,7 @@ var WatchlistApi = class extends BaseAPI {
7888
8163
 
7889
8164
  // src/index.ts
7890
8165
  import { EventSourcePolyfill } from "event-source-polyfill";
7891
- var LIB_VERSION = "0.1.18";
8166
+ var LIB_VERSION = "0.1.20";
7892
8167
  var UserAgentMiddleware = class {
7893
8168
  async pre(context) {
7894
8169
  if (!context.init.headers) {