@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.
@@ -37,6 +37,7 @@ module.exports = __toCommonJS(stream_exports);
37
37
 
38
38
  // src/stream/stream.ts
39
39
  var import_centrifuge = require("@chainstream-io/centrifuge");
40
+ var import_module = require("module");
40
41
 
41
42
  // src/stream/stream.fields.ts
42
43
  var CEL_FIELD_MAPPINGS = {
@@ -132,12 +133,54 @@ var CEL_FIELD_MAPPINGS = {
132
133
  "subscribeTokenHolders": {
133
134
  "tokenAddress": "a",
134
135
  "holders": "h",
135
- "top100Amount": "t100a",
136
- "top10Amount": "t10a",
136
+ "top100HoldersAmount": "t100a",
137
+ "top50HoldersAmount": "t50a",
138
+ "top10HoldersAmount": "t10a",
137
139
  "top100Holders": "t100h",
140
+ "top50Holders": "t50h",
138
141
  "top10Holders": "t10h",
139
- "top100Ratio": "t100r",
140
- "top10Ratio": "t10r",
142
+ "top100HoldersRatio": "t100r",
143
+ "top50HoldersRatio": "t50r",
144
+ "top10HoldersRatio": "t10r",
145
+ "creatorsHolders": "ch",
146
+ "creatorsAmount": "ca",
147
+ "creatorsRatio": "cr",
148
+ "balanceTagFreshHolders": "btfh",
149
+ "balanceTagFreshAmount": "btfa",
150
+ "balanceTagFreshRatio": "btfr",
151
+ "balanceTagSandwichHolders": "btsh",
152
+ "balanceTagSandwichAmount": "btsa",
153
+ "balanceTagSandwichRatio": "btsr",
154
+ "balanceTagBundleHolders": "btbh",
155
+ "balanceTagBundleAmount": "btba",
156
+ "balanceTagBundleRatio": "btbr",
157
+ "balanceTagSniperHolders": "btsnh",
158
+ "balanceTagSniperAmount": "btsna",
159
+ "balanceTagSniperRatio": "btsnr",
160
+ "balanceTagDevHolders": "btdh",
161
+ "balanceTagDevAmount": "btda",
162
+ "balanceTagDevRatio": "btdr",
163
+ "balanceTagProHolders": "btph",
164
+ "balanceTagProAmount": "btpa",
165
+ "balanceTagProRatio": "btpr",
166
+ "balanceTagInsiderHolders": "btih",
167
+ "balanceTagInsiderAmount": "btia",
168
+ "balanceTagInsiderRatio": "btir",
169
+ "balanceTagSmartHolders": "btsmh",
170
+ "balanceTagSmartAmount": "btsma",
171
+ "balanceTagSmartRatio": "btsmr",
172
+ "balanceTagKolHolders": "btkh",
173
+ "balanceTagKolAmount": "btka",
174
+ "balanceTagKolRatio": "btkr",
175
+ "balanceTagPhishingHolders": "btphh",
176
+ "balanceTagPhishingAmount": "btpha",
177
+ "balanceTagPhishingRatio": "btphr",
178
+ "balanceTagBluechipHolders": "btblh",
179
+ "balanceTagBluechipAmount": "btbla",
180
+ "balanceTagBluechipRatio": "btblr",
181
+ "balanceTagRatHolders": "btrh",
182
+ "balanceTagRatAmount": "btra",
183
+ "balanceTagRatRatio": "btrr",
141
184
  "timestamp": "ts"
142
185
  },
143
186
  // New token subscription fields
@@ -255,14 +298,36 @@ function getAvailableFields(methodName) {
255
298
  }
256
299
 
257
300
  // src/stream/stream.ts
301
+ var import_meta = {};
258
302
  var StreamApi = class {
259
303
  constructor(context) {
260
304
  __publicField(this, "realtimeClient");
261
305
  __publicField(this, "listenersMap");
306
+ __publicField(this, "getTokenValue");
262
307
  const realtimeEndpoint = context.streamUrl;
308
+ this.getTokenValue = async () => {
309
+ return typeof context.accessToken === "string" ? context.accessToken : await context.accessToken.getToken();
310
+ };
311
+ let wsImpl = void 0;
312
+ if (typeof process !== "undefined" && process.versions?.node) {
313
+ try {
314
+ const require2 = (0, import_module.createRequire)(import_meta.url);
315
+ wsImpl = require2("ws");
316
+ } catch {
317
+ }
318
+ }
319
+ if (!wsImpl && typeof WebSocket !== "undefined") {
320
+ wsImpl = WebSocket;
321
+ }
263
322
  this.realtimeClient = new import_centrifuge.Centrifuge(realtimeEndpoint, {
323
+ ...wsImpl && { websocket: wsImpl },
264
324
  getToken: async (_ctx) => {
265
- return typeof context.accessToken === "string" ? context.accessToken : await context.accessToken.getToken();
325
+ const token = await this.getTokenValue();
326
+ this.realtimeClient.setHttpHeaders({
327
+ Authorization: `Bearer ${token}`,
328
+ "User-Agent": `chainstream-io/sdk/javascript`
329
+ });
330
+ return token;
266
331
  }
267
332
  });
268
333
  this.realtimeClient.on("connected", () => {
@@ -274,7 +339,11 @@ var StreamApi = class {
274
339
  });
275
340
  this.listenersMap = /* @__PURE__ */ new Map();
276
341
  }
277
- connect() {
342
+ async connect() {
343
+ const token = await this.getTokenValue();
344
+ this.realtimeClient.setHttpHeaders({
345
+ Authorization: `Bearer ${token}`
346
+ });
278
347
  this.realtimeClient.connect();
279
348
  }
280
349
  /**
@@ -475,15 +544,54 @@ var StreamApi = class {
475
544
  return this.subscribe(channel, (data) => callback({
476
545
  tokenAddress: data.a,
477
546
  holders: data.h,
478
- top100Amount: this.formatScientificNotation(data.t100a),
479
- top10Amount: this.formatScientificNotation(data.t10a),
547
+ top100HoldersAmount: this.formatScientificNotation(data.t100a),
548
+ top50HoldersAmount: this.formatScientificNotation(data.t50a),
549
+ top10HoldersAmount: this.formatScientificNotation(data.t10a),
480
550
  top100Holders: data.t100h,
551
+ top50Holders: data.t50h,
481
552
  top10Holders: data.t10h,
482
- top100Ratio: this.formatScientificNotation(data.t100r),
483
- top10Ratio: this.formatScientificNotation(data.t10r),
553
+ top100HoldersRatio: this.formatScientificNotation(data.t100r),
554
+ top50HoldersRatio: this.formatScientificNotation(data.t50r),
555
+ top10HoldersRatio: this.formatScientificNotation(data.t10r),
484
556
  creatorsHolders: data.ch,
485
557
  creatorsAmount: this.formatScientificNotation(data.ca),
486
558
  creatorsRatio: this.formatScientificNotation(data.cr),
559
+ balanceTagFreshHolders: data.btfh,
560
+ balanceTagFreshAmount: this.formatScientificNotation(data.btfa),
561
+ balanceTagFreshRatio: this.formatScientificNotation(data.btfr),
562
+ balanceTagSandwichHolders: data.btsh,
563
+ balanceTagSandwichAmount: this.formatScientificNotation(data.btsa),
564
+ balanceTagSandwichRatio: this.formatScientificNotation(data.btsr),
565
+ balanceTagBundleHolders: data.btbh,
566
+ balanceTagBundleAmount: this.formatScientificNotation(data.btba),
567
+ balanceTagBundleRatio: this.formatScientificNotation(data.btbr),
568
+ balanceTagSniperHolders: data.btsnh,
569
+ balanceTagSniperAmount: this.formatScientificNotation(data.btsna),
570
+ balanceTagSniperRatio: this.formatScientificNotation(data.btsnr),
571
+ balanceTagDevHolders: data.btdh,
572
+ balanceTagDevAmount: this.formatScientificNotation(data.btda),
573
+ balanceTagDevRatio: this.formatScientificNotation(data.btdr),
574
+ balanceTagProHolders: data.btph,
575
+ balanceTagProAmount: this.formatScientificNotation(data.btpa),
576
+ balanceTagProRatio: this.formatScientificNotation(data.btpr),
577
+ balanceTagInsiderHolders: data.btih,
578
+ balanceTagInsiderAmount: this.formatScientificNotation(data.btia),
579
+ balanceTagInsiderRatio: this.formatScientificNotation(data.btir),
580
+ balanceTagSmartHolders: data.btsmh,
581
+ balanceTagSmartAmount: this.formatScientificNotation(data.btsma),
582
+ balanceTagSmartRatio: this.formatScientificNotation(data.btsmr),
583
+ balanceTagKolHolders: data.btkh,
584
+ balanceTagKolAmount: this.formatScientificNotation(data.btka),
585
+ balanceTagKolRatio: this.formatScientificNotation(data.btkr),
586
+ balanceTagPhishingHolders: data.btphh,
587
+ balanceTagPhishingAmount: this.formatScientificNotation(data.btpha),
588
+ balanceTagPhishingRatio: this.formatScientificNotation(data.btphr),
589
+ balanceTagBluechipHolders: data.btblh,
590
+ balanceTagBluechipAmount: this.formatScientificNotation(data.btbla),
591
+ balanceTagBluechipRatio: this.formatScientificNotation(data.btblr),
592
+ balanceTagRatHolders: data.btrh,
593
+ balanceTagRatAmount: this.formatScientificNotation(data.btra),
594
+ balanceTagRatRatio: this.formatScientificNotation(data.btrr),
487
595
  timestamp: data.ts
488
596
  }), filter, "subscribeTokenHolders");
489
597
  }
@@ -772,22 +880,148 @@ var StreamApi = class {
772
880
  result.holder.holders = item.h.h;
773
881
  }
774
882
  if (item.h.t100a) {
775
- result.holder.top100Amount = this.formatScientificNotation(item.h.t100a);
883
+ result.holder.top100HoldersAmount = this.formatScientificNotation(item.h.t100a);
884
+ }
885
+ if (item.h.t50a) {
886
+ result.holder.top50HoldersAmount = this.formatScientificNotation(item.h.t50a);
776
887
  }
777
888
  if (item.h.t10a) {
778
- result.holder.top10Amount = this.formatScientificNotation(item.h.t10a);
889
+ result.holder.top10HoldersAmount = this.formatScientificNotation(item.h.t10a);
779
890
  }
780
891
  if (item.h.t100h) {
781
892
  result.holder.top100Holders = item.h.t100h;
782
893
  }
894
+ if (item.h.t50h) {
895
+ result.holder.top50Holders = item.h.t50h;
896
+ }
783
897
  if (item.h.t10h) {
784
898
  result.holder.top10Holders = item.h.t10h;
785
899
  }
786
900
  if (item.h.t100r) {
787
- result.holder.top100Ratio = this.formatScientificNotation(item.h.t100r);
901
+ result.holder.top100HoldersRatio = this.formatScientificNotation(item.h.t100r);
902
+ }
903
+ if (item.h.t50r) {
904
+ result.holder.top50HoldersRatio = this.formatScientificNotation(item.h.t50r);
788
905
  }
789
906
  if (item.h.t10r) {
790
- result.holder.top10Ratio = this.formatScientificNotation(item.h.t10r);
907
+ result.holder.top10HoldersRatio = this.formatScientificNotation(item.h.t10r);
908
+ }
909
+ if (item.h.ch) {
910
+ result.holder.creatorsHolders = item.h.ch;
911
+ }
912
+ if (item.h.ca) {
913
+ result.holder.creatorsAmount = this.formatScientificNotation(item.h.ca);
914
+ }
915
+ if (item.h.cr) {
916
+ result.holder.creatorsRatio = this.formatScientificNotation(item.h.cr);
917
+ }
918
+ if (item.h.btfh) {
919
+ result.holder.balanceTagFreshHolders = item.h.btfh;
920
+ }
921
+ if (item.h.btfa) {
922
+ result.holder.balanceTagFreshAmount = this.formatScientificNotation(item.h.btfa);
923
+ }
924
+ if (item.h.btfr) {
925
+ result.holder.balanceTagFreshRatio = this.formatScientificNotation(item.h.btfr);
926
+ }
927
+ if (item.h.btsh) {
928
+ result.holder.balanceTagSandwichHolders = item.h.btsh;
929
+ }
930
+ if (item.h.btsa) {
931
+ result.holder.balanceTagSandwichAmount = this.formatScientificNotation(item.h.btsa);
932
+ }
933
+ if (item.h.btsr) {
934
+ result.holder.balanceTagSandwichRatio = this.formatScientificNotation(item.h.btsr);
935
+ }
936
+ if (item.h.btbh) {
937
+ result.holder.balanceTagBundleHolders = item.h.btbh;
938
+ }
939
+ if (item.h.btba) {
940
+ result.holder.balanceTagBundleAmount = this.formatScientificNotation(item.h.btba);
941
+ }
942
+ if (item.h.btbr) {
943
+ result.holder.balanceTagBundleRatio = this.formatScientificNotation(item.h.btbr);
944
+ }
945
+ if (item.h.btsnh) {
946
+ result.holder.balanceTagSniperHolders = item.h.btsnh;
947
+ }
948
+ if (item.h.btsna) {
949
+ result.holder.balanceTagSniperAmount = this.formatScientificNotation(item.h.btsna);
950
+ }
951
+ if (item.h.btsnr) {
952
+ result.holder.balanceTagSniperRatio = this.formatScientificNotation(item.h.btsnr);
953
+ }
954
+ if (item.h.btdh) {
955
+ result.holder.balanceTagDevHolders = item.h.btdh;
956
+ }
957
+ if (item.h.btda) {
958
+ result.holder.balanceTagDevAmount = this.formatScientificNotation(item.h.btda);
959
+ }
960
+ if (item.h.btdr) {
961
+ result.holder.balanceTagDevRatio = this.formatScientificNotation(item.h.btdr);
962
+ }
963
+ if (item.h.btph) {
964
+ result.holder.balanceTagProHolders = item.h.btph;
965
+ }
966
+ if (item.h.btpa) {
967
+ result.holder.balanceTagProAmount = this.formatScientificNotation(item.h.btpa);
968
+ }
969
+ if (item.h.btpr) {
970
+ result.holder.balanceTagProRatio = this.formatScientificNotation(item.h.btpr);
971
+ }
972
+ if (item.h.btih) {
973
+ result.holder.balanceTagInsiderHolders = item.h.btih;
974
+ }
975
+ if (item.h.btia) {
976
+ result.holder.balanceTagInsiderAmount = this.formatScientificNotation(item.h.btia);
977
+ }
978
+ if (item.h.btir) {
979
+ result.holder.balanceTagInsiderRatio = this.formatScientificNotation(item.h.btir);
980
+ }
981
+ if (item.h.btsmh) {
982
+ result.holder.balanceTagSmartHolders = item.h.btsmh;
983
+ }
984
+ if (item.h.btsma) {
985
+ result.holder.balanceTagSmartAmount = this.formatScientificNotation(item.h.btsma);
986
+ }
987
+ if (item.h.btsmr) {
988
+ result.holder.balanceTagSmartRatio = this.formatScientificNotation(item.h.btsmr);
989
+ }
990
+ if (item.h.btkh) {
991
+ result.holder.balanceTagKolHolders = item.h.btkh;
992
+ }
993
+ if (item.h.btka) {
994
+ result.holder.balanceTagKolAmount = this.formatScientificNotation(item.h.btka);
995
+ }
996
+ if (item.h.btkr) {
997
+ result.holder.balanceTagKolRatio = this.formatScientificNotation(item.h.btkr);
998
+ }
999
+ if (item.h.btphh) {
1000
+ result.holder.balanceTagPhishingHolders = item.h.btphh;
1001
+ }
1002
+ if (item.h.btpha) {
1003
+ result.holder.balanceTagPhishingAmount = this.formatScientificNotation(item.h.btpha);
1004
+ }
1005
+ if (item.h.btphr) {
1006
+ result.holder.balanceTagPhishingRatio = this.formatScientificNotation(item.h.btphr);
1007
+ }
1008
+ if (item.h.btblh) {
1009
+ result.holder.balanceTagBluechipHolders = item.h.btblh;
1010
+ }
1011
+ if (item.h.btbla) {
1012
+ result.holder.balanceTagBluechipAmount = this.formatScientificNotation(item.h.btbla);
1013
+ }
1014
+ if (item.h.btblr) {
1015
+ result.holder.balanceTagBluechipRatio = this.formatScientificNotation(item.h.btblr);
1016
+ }
1017
+ if (item.h.btrh) {
1018
+ result.holder.balanceTagRatHolders = item.h.btrh;
1019
+ }
1020
+ if (item.h.btra) {
1021
+ result.holder.balanceTagRatAmount = this.formatScientificNotation(item.h.btra);
1022
+ }
1023
+ if (item.h.btrr) {
1024
+ result.holder.balanceTagRatRatio = this.formatScientificNotation(item.h.btrr);
791
1025
  }
792
1026
  }
793
1027
  if (item.s) {
@@ -1100,12 +1334,54 @@ var StreamApi = class {
1100
1334
  (it) => ({
1101
1335
  tokenAddress: it.a,
1102
1336
  holders: it.h,
1103
- top100Amount: this.formatScientificNotation(it.t100a),
1104
- top10Amount: this.formatScientificNotation(it.t10a),
1337
+ top100HoldersAmount: this.formatScientificNotation(it.t100a),
1338
+ top50HoldersAmount: this.formatScientificNotation(it.t50a),
1339
+ top10HoldersAmount: this.formatScientificNotation(it.t10a),
1105
1340
  top100Holders: it.t100h,
1341
+ top50Holders: it.t50h,
1106
1342
  top10Holders: it.t10h,
1107
- top100Ratio: this.formatScientificNotation(it.t100r),
1108
- top10Ratio: this.formatScientificNotation(it.t10r),
1343
+ top100HoldersRatio: this.formatScientificNotation(it.t100r),
1344
+ top50HoldersRatio: this.formatScientificNotation(it.t50r),
1345
+ top10HoldersRatio: this.formatScientificNotation(it.t10r),
1346
+ creatorsHolders: it.ch,
1347
+ creatorsAmount: this.formatScientificNotation(it.ca),
1348
+ creatorsRatio: this.formatScientificNotation(it.cr),
1349
+ balanceTagFreshHolders: it.btfh,
1350
+ balanceTagFreshAmount: this.formatScientificNotation(it.btfa),
1351
+ balanceTagFreshRatio: this.formatScientificNotation(it.btfr),
1352
+ balanceTagSandwichHolders: it.btsh,
1353
+ balanceTagSandwichAmount: this.formatScientificNotation(it.btsa),
1354
+ balanceTagSandwichRatio: this.formatScientificNotation(it.btsr),
1355
+ balanceTagBundleHolders: it.btbh,
1356
+ balanceTagBundleAmount: this.formatScientificNotation(it.btba),
1357
+ balanceTagBundleRatio: this.formatScientificNotation(it.btbr),
1358
+ balanceTagSniperHolders: it.btsnh,
1359
+ balanceTagSniperAmount: this.formatScientificNotation(it.btsna),
1360
+ balanceTagSniperRatio: this.formatScientificNotation(it.btsnr),
1361
+ balanceTagDevHolders: it.btdh,
1362
+ balanceTagDevAmount: this.formatScientificNotation(it.btda),
1363
+ balanceTagDevRatio: this.formatScientificNotation(it.btdr),
1364
+ balanceTagProHolders: it.btph,
1365
+ balanceTagProAmount: this.formatScientificNotation(it.btpa),
1366
+ balanceTagProRatio: this.formatScientificNotation(it.btpr),
1367
+ balanceTagInsiderHolders: it.btih,
1368
+ balanceTagInsiderAmount: this.formatScientificNotation(it.btia),
1369
+ balanceTagInsiderRatio: this.formatScientificNotation(it.btir),
1370
+ balanceTagSmartHolders: it.btsmh,
1371
+ balanceTagSmartAmount: this.formatScientificNotation(it.btsma),
1372
+ balanceTagSmartRatio: this.formatScientificNotation(it.btsmr),
1373
+ balanceTagKolHolders: it.btkh,
1374
+ balanceTagKolAmount: this.formatScientificNotation(it.btka),
1375
+ balanceTagKolRatio: this.formatScientificNotation(it.btkr),
1376
+ balanceTagPhishingHolders: it.btphh,
1377
+ balanceTagPhishingAmount: this.formatScientificNotation(it.btpha),
1378
+ balanceTagPhishingRatio: this.formatScientificNotation(it.btphr),
1379
+ balanceTagBluechipHolders: it.btblh,
1380
+ balanceTagBluechipAmount: this.formatScientificNotation(it.btbla),
1381
+ balanceTagBluechipRatio: this.formatScientificNotation(it.btblr),
1382
+ balanceTagRatHolders: it.btrh,
1383
+ balanceTagRatAmount: this.formatScientificNotation(it.btra),
1384
+ balanceTagRatRatio: this.formatScientificNotation(it.btrr),
1109
1385
  timestamp: it.ts
1110
1386
  })
1111
1387
  )