@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.
@@ -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
@@ -226,10 +269,31 @@ var StreamApi = class {
226
269
  constructor(context) {
227
270
  __publicField(this, "realtimeClient");
228
271
  __publicField(this, "listenersMap");
272
+ __publicField(this, "getTokenValue");
229
273
  const realtimeEndpoint = context.streamUrl;
274
+ this.getTokenValue = async () => {
275
+ return typeof context.accessToken === "string" ? context.accessToken : await context.accessToken.getToken();
276
+ };
277
+ let wsImpl = void 0;
278
+ if (typeof process !== "undefined" && process.versions?.node) {
279
+ try {
280
+ const require2 = createRequire(import.meta.url);
281
+ wsImpl = require2("ws");
282
+ } catch {
283
+ }
284
+ }
285
+ if (!wsImpl && typeof WebSocket !== "undefined") {
286
+ wsImpl = WebSocket;
287
+ }
230
288
  this.realtimeClient = new Centrifuge(realtimeEndpoint, {
289
+ ...wsImpl && { websocket: wsImpl },
231
290
  getToken: async (_ctx) => {
232
- return typeof context.accessToken === "string" ? context.accessToken : await context.accessToken.getToken();
291
+ const token = await this.getTokenValue();
292
+ this.realtimeClient.setHttpHeaders({
293
+ Authorization: `Bearer ${token}`,
294
+ "User-Agent": `chainstream-io/sdk/javascript`
295
+ });
296
+ return token;
233
297
  }
234
298
  });
235
299
  this.realtimeClient.on("connected", () => {
@@ -241,7 +305,11 @@ var StreamApi = class {
241
305
  });
242
306
  this.listenersMap = /* @__PURE__ */ new Map();
243
307
  }
244
- connect() {
308
+ async connect() {
309
+ const token = await this.getTokenValue();
310
+ this.realtimeClient.setHttpHeaders({
311
+ Authorization: `Bearer ${token}`
312
+ });
245
313
  this.realtimeClient.connect();
246
314
  }
247
315
  /**
@@ -442,15 +510,54 @@ var StreamApi = class {
442
510
  return this.subscribe(channel, (data) => callback({
443
511
  tokenAddress: data.a,
444
512
  holders: data.h,
445
- top100Amount: this.formatScientificNotation(data.t100a),
446
- top10Amount: this.formatScientificNotation(data.t10a),
513
+ top100HoldersAmount: this.formatScientificNotation(data.t100a),
514
+ top50HoldersAmount: this.formatScientificNotation(data.t50a),
515
+ top10HoldersAmount: this.formatScientificNotation(data.t10a),
447
516
  top100Holders: data.t100h,
517
+ top50Holders: data.t50h,
448
518
  top10Holders: data.t10h,
449
- top100Ratio: this.formatScientificNotation(data.t100r),
450
- top10Ratio: this.formatScientificNotation(data.t10r),
519
+ top100HoldersRatio: this.formatScientificNotation(data.t100r),
520
+ top50HoldersRatio: this.formatScientificNotation(data.t50r),
521
+ top10HoldersRatio: this.formatScientificNotation(data.t10r),
451
522
  creatorsHolders: data.ch,
452
523
  creatorsAmount: this.formatScientificNotation(data.ca),
453
524
  creatorsRatio: this.formatScientificNotation(data.cr),
525
+ balanceTagFreshHolders: data.btfh,
526
+ balanceTagFreshAmount: this.formatScientificNotation(data.btfa),
527
+ balanceTagFreshRatio: this.formatScientificNotation(data.btfr),
528
+ balanceTagSandwichHolders: data.btsh,
529
+ balanceTagSandwichAmount: this.formatScientificNotation(data.btsa),
530
+ balanceTagSandwichRatio: this.formatScientificNotation(data.btsr),
531
+ balanceTagBundleHolders: data.btbh,
532
+ balanceTagBundleAmount: this.formatScientificNotation(data.btba),
533
+ balanceTagBundleRatio: this.formatScientificNotation(data.btbr),
534
+ balanceTagSniperHolders: data.btsnh,
535
+ balanceTagSniperAmount: this.formatScientificNotation(data.btsna),
536
+ balanceTagSniperRatio: this.formatScientificNotation(data.btsnr),
537
+ balanceTagDevHolders: data.btdh,
538
+ balanceTagDevAmount: this.formatScientificNotation(data.btda),
539
+ balanceTagDevRatio: this.formatScientificNotation(data.btdr),
540
+ balanceTagProHolders: data.btph,
541
+ balanceTagProAmount: this.formatScientificNotation(data.btpa),
542
+ balanceTagProRatio: this.formatScientificNotation(data.btpr),
543
+ balanceTagInsiderHolders: data.btih,
544
+ balanceTagInsiderAmount: this.formatScientificNotation(data.btia),
545
+ balanceTagInsiderRatio: this.formatScientificNotation(data.btir),
546
+ balanceTagSmartHolders: data.btsmh,
547
+ balanceTagSmartAmount: this.formatScientificNotation(data.btsma),
548
+ balanceTagSmartRatio: this.formatScientificNotation(data.btsmr),
549
+ balanceTagKolHolders: data.btkh,
550
+ balanceTagKolAmount: this.formatScientificNotation(data.btka),
551
+ balanceTagKolRatio: this.formatScientificNotation(data.btkr),
552
+ balanceTagPhishingHolders: data.btphh,
553
+ balanceTagPhishingAmount: this.formatScientificNotation(data.btpha),
554
+ balanceTagPhishingRatio: this.formatScientificNotation(data.btphr),
555
+ balanceTagBluechipHolders: data.btblh,
556
+ balanceTagBluechipAmount: this.formatScientificNotation(data.btbla),
557
+ balanceTagBluechipRatio: this.formatScientificNotation(data.btblr),
558
+ balanceTagRatHolders: data.btrh,
559
+ balanceTagRatAmount: this.formatScientificNotation(data.btra),
560
+ balanceTagRatRatio: this.formatScientificNotation(data.btrr),
454
561
  timestamp: data.ts
455
562
  }), filter, "subscribeTokenHolders");
456
563
  }
@@ -739,22 +846,148 @@ var StreamApi = class {
739
846
  result.holder.holders = item.h.h;
740
847
  }
741
848
  if (item.h.t100a) {
742
- result.holder.top100Amount = this.formatScientificNotation(item.h.t100a);
849
+ result.holder.top100HoldersAmount = this.formatScientificNotation(item.h.t100a);
850
+ }
851
+ if (item.h.t50a) {
852
+ result.holder.top50HoldersAmount = this.formatScientificNotation(item.h.t50a);
743
853
  }
744
854
  if (item.h.t10a) {
745
- result.holder.top10Amount = this.formatScientificNotation(item.h.t10a);
855
+ result.holder.top10HoldersAmount = this.formatScientificNotation(item.h.t10a);
746
856
  }
747
857
  if (item.h.t100h) {
748
858
  result.holder.top100Holders = item.h.t100h;
749
859
  }
860
+ if (item.h.t50h) {
861
+ result.holder.top50Holders = item.h.t50h;
862
+ }
750
863
  if (item.h.t10h) {
751
864
  result.holder.top10Holders = item.h.t10h;
752
865
  }
753
866
  if (item.h.t100r) {
754
- result.holder.top100Ratio = this.formatScientificNotation(item.h.t100r);
867
+ result.holder.top100HoldersRatio = this.formatScientificNotation(item.h.t100r);
868
+ }
869
+ if (item.h.t50r) {
870
+ result.holder.top50HoldersRatio = this.formatScientificNotation(item.h.t50r);
755
871
  }
756
872
  if (item.h.t10r) {
757
- result.holder.top10Ratio = this.formatScientificNotation(item.h.t10r);
873
+ result.holder.top10HoldersRatio = this.formatScientificNotation(item.h.t10r);
874
+ }
875
+ if (item.h.ch) {
876
+ result.holder.creatorsHolders = item.h.ch;
877
+ }
878
+ if (item.h.ca) {
879
+ result.holder.creatorsAmount = this.formatScientificNotation(item.h.ca);
880
+ }
881
+ if (item.h.cr) {
882
+ result.holder.creatorsRatio = this.formatScientificNotation(item.h.cr);
883
+ }
884
+ if (item.h.btfh) {
885
+ result.holder.balanceTagFreshHolders = item.h.btfh;
886
+ }
887
+ if (item.h.btfa) {
888
+ result.holder.balanceTagFreshAmount = this.formatScientificNotation(item.h.btfa);
889
+ }
890
+ if (item.h.btfr) {
891
+ result.holder.balanceTagFreshRatio = this.formatScientificNotation(item.h.btfr);
892
+ }
893
+ if (item.h.btsh) {
894
+ result.holder.balanceTagSandwichHolders = item.h.btsh;
895
+ }
896
+ if (item.h.btsa) {
897
+ result.holder.balanceTagSandwichAmount = this.formatScientificNotation(item.h.btsa);
898
+ }
899
+ if (item.h.btsr) {
900
+ result.holder.balanceTagSandwichRatio = this.formatScientificNotation(item.h.btsr);
901
+ }
902
+ if (item.h.btbh) {
903
+ result.holder.balanceTagBundleHolders = item.h.btbh;
904
+ }
905
+ if (item.h.btba) {
906
+ result.holder.balanceTagBundleAmount = this.formatScientificNotation(item.h.btba);
907
+ }
908
+ if (item.h.btbr) {
909
+ result.holder.balanceTagBundleRatio = this.formatScientificNotation(item.h.btbr);
910
+ }
911
+ if (item.h.btsnh) {
912
+ result.holder.balanceTagSniperHolders = item.h.btsnh;
913
+ }
914
+ if (item.h.btsna) {
915
+ result.holder.balanceTagSniperAmount = this.formatScientificNotation(item.h.btsna);
916
+ }
917
+ if (item.h.btsnr) {
918
+ result.holder.balanceTagSniperRatio = this.formatScientificNotation(item.h.btsnr);
919
+ }
920
+ if (item.h.btdh) {
921
+ result.holder.balanceTagDevHolders = item.h.btdh;
922
+ }
923
+ if (item.h.btda) {
924
+ result.holder.balanceTagDevAmount = this.formatScientificNotation(item.h.btda);
925
+ }
926
+ if (item.h.btdr) {
927
+ result.holder.balanceTagDevRatio = this.formatScientificNotation(item.h.btdr);
928
+ }
929
+ if (item.h.btph) {
930
+ result.holder.balanceTagProHolders = item.h.btph;
931
+ }
932
+ if (item.h.btpa) {
933
+ result.holder.balanceTagProAmount = this.formatScientificNotation(item.h.btpa);
934
+ }
935
+ if (item.h.btpr) {
936
+ result.holder.balanceTagProRatio = this.formatScientificNotation(item.h.btpr);
937
+ }
938
+ if (item.h.btih) {
939
+ result.holder.balanceTagInsiderHolders = item.h.btih;
940
+ }
941
+ if (item.h.btia) {
942
+ result.holder.balanceTagInsiderAmount = this.formatScientificNotation(item.h.btia);
943
+ }
944
+ if (item.h.btir) {
945
+ result.holder.balanceTagInsiderRatio = this.formatScientificNotation(item.h.btir);
946
+ }
947
+ if (item.h.btsmh) {
948
+ result.holder.balanceTagSmartHolders = item.h.btsmh;
949
+ }
950
+ if (item.h.btsma) {
951
+ result.holder.balanceTagSmartAmount = this.formatScientificNotation(item.h.btsma);
952
+ }
953
+ if (item.h.btsmr) {
954
+ result.holder.balanceTagSmartRatio = this.formatScientificNotation(item.h.btsmr);
955
+ }
956
+ if (item.h.btkh) {
957
+ result.holder.balanceTagKolHolders = item.h.btkh;
958
+ }
959
+ if (item.h.btka) {
960
+ result.holder.balanceTagKolAmount = this.formatScientificNotation(item.h.btka);
961
+ }
962
+ if (item.h.btkr) {
963
+ result.holder.balanceTagKolRatio = this.formatScientificNotation(item.h.btkr);
964
+ }
965
+ if (item.h.btphh) {
966
+ result.holder.balanceTagPhishingHolders = item.h.btphh;
967
+ }
968
+ if (item.h.btpha) {
969
+ result.holder.balanceTagPhishingAmount = this.formatScientificNotation(item.h.btpha);
970
+ }
971
+ if (item.h.btphr) {
972
+ result.holder.balanceTagPhishingRatio = this.formatScientificNotation(item.h.btphr);
973
+ }
974
+ if (item.h.btblh) {
975
+ result.holder.balanceTagBluechipHolders = item.h.btblh;
976
+ }
977
+ if (item.h.btbla) {
978
+ result.holder.balanceTagBluechipAmount = this.formatScientificNotation(item.h.btbla);
979
+ }
980
+ if (item.h.btblr) {
981
+ result.holder.balanceTagBluechipRatio = this.formatScientificNotation(item.h.btblr);
982
+ }
983
+ if (item.h.btrh) {
984
+ result.holder.balanceTagRatHolders = item.h.btrh;
985
+ }
986
+ if (item.h.btra) {
987
+ result.holder.balanceTagRatAmount = this.formatScientificNotation(item.h.btra);
988
+ }
989
+ if (item.h.btrr) {
990
+ result.holder.balanceTagRatRatio = this.formatScientificNotation(item.h.btrr);
758
991
  }
759
992
  }
760
993
  if (item.s) {
@@ -1067,12 +1300,54 @@ var StreamApi = class {
1067
1300
  (it) => ({
1068
1301
  tokenAddress: it.a,
1069
1302
  holders: it.h,
1070
- top100Amount: this.formatScientificNotation(it.t100a),
1071
- top10Amount: this.formatScientificNotation(it.t10a),
1303
+ top100HoldersAmount: this.formatScientificNotation(it.t100a),
1304
+ top50HoldersAmount: this.formatScientificNotation(it.t50a),
1305
+ top10HoldersAmount: this.formatScientificNotation(it.t10a),
1072
1306
  top100Holders: it.t100h,
1307
+ top50Holders: it.t50h,
1073
1308
  top10Holders: it.t10h,
1074
- top100Ratio: this.formatScientificNotation(it.t100r),
1075
- top10Ratio: this.formatScientificNotation(it.t10r),
1309
+ top100HoldersRatio: this.formatScientificNotation(it.t100r),
1310
+ top50HoldersRatio: this.formatScientificNotation(it.t50r),
1311
+ top10HoldersRatio: this.formatScientificNotation(it.t10r),
1312
+ creatorsHolders: it.ch,
1313
+ creatorsAmount: this.formatScientificNotation(it.ca),
1314
+ creatorsRatio: this.formatScientificNotation(it.cr),
1315
+ balanceTagFreshHolders: it.btfh,
1316
+ balanceTagFreshAmount: this.formatScientificNotation(it.btfa),
1317
+ balanceTagFreshRatio: this.formatScientificNotation(it.btfr),
1318
+ balanceTagSandwichHolders: it.btsh,
1319
+ balanceTagSandwichAmount: this.formatScientificNotation(it.btsa),
1320
+ balanceTagSandwichRatio: this.formatScientificNotation(it.btsr),
1321
+ balanceTagBundleHolders: it.btbh,
1322
+ balanceTagBundleAmount: this.formatScientificNotation(it.btba),
1323
+ balanceTagBundleRatio: this.formatScientificNotation(it.btbr),
1324
+ balanceTagSniperHolders: it.btsnh,
1325
+ balanceTagSniperAmount: this.formatScientificNotation(it.btsna),
1326
+ balanceTagSniperRatio: this.formatScientificNotation(it.btsnr),
1327
+ balanceTagDevHolders: it.btdh,
1328
+ balanceTagDevAmount: this.formatScientificNotation(it.btda),
1329
+ balanceTagDevRatio: this.formatScientificNotation(it.btdr),
1330
+ balanceTagProHolders: it.btph,
1331
+ balanceTagProAmount: this.formatScientificNotation(it.btpa),
1332
+ balanceTagProRatio: this.formatScientificNotation(it.btpr),
1333
+ balanceTagInsiderHolders: it.btih,
1334
+ balanceTagInsiderAmount: this.formatScientificNotation(it.btia),
1335
+ balanceTagInsiderRatio: this.formatScientificNotation(it.btir),
1336
+ balanceTagSmartHolders: it.btsmh,
1337
+ balanceTagSmartAmount: this.formatScientificNotation(it.btsma),
1338
+ balanceTagSmartRatio: this.formatScientificNotation(it.btsmr),
1339
+ balanceTagKolHolders: it.btkh,
1340
+ balanceTagKolAmount: this.formatScientificNotation(it.btka),
1341
+ balanceTagKolRatio: this.formatScientificNotation(it.btkr),
1342
+ balanceTagPhishingHolders: it.btphh,
1343
+ balanceTagPhishingAmount: this.formatScientificNotation(it.btpha),
1344
+ balanceTagPhishingRatio: this.formatScientificNotation(it.btphr),
1345
+ balanceTagBluechipHolders: it.btblh,
1346
+ balanceTagBluechipAmount: this.formatScientificNotation(it.btbla),
1347
+ balanceTagBluechipRatio: this.formatScientificNotation(it.btblr),
1348
+ balanceTagRatHolders: it.btrh,
1349
+ balanceTagRatAmount: this.formatScientificNotation(it.btra),
1350
+ balanceTagRatRatio: this.formatScientificNotation(it.btrr),
1076
1351
  timestamp: it.ts
1077
1352
  })
1078
1353
  )