@chainstream-io/sdk 0.2.11 → 0.2.12
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/{chainstream-D_kgiAfE.d.cts → chainstream-BY9CsB3h.d.cts} +92 -2
- package/dist/{chainstream-D_kgiAfE.d.ts → chainstream-BY9CsB3h.d.ts} +92 -2
- package/dist/chainstream.cjs +173 -120
- package/dist/chainstream.cjs.map +1 -1
- package/dist/chainstream.d.cts +1 -1
- package/dist/chainstream.d.ts +1 -1
- package/dist/chainstream.mjs +173 -120
- package/dist/chainstream.mjs.map +1 -1
- package/dist/index.cjs +173 -120
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +173 -120
- package/dist/index.mjs.map +1 -1
- package/dist/stream/index.cjs +171 -118
- package/dist/stream/index.cjs.map +1 -1
- package/dist/stream/index.d.cts +2 -1
- package/dist/stream/index.d.ts +2 -1
- package/dist/stream/index.mjs +171 -118
- package/dist/stream/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/chainstream.cjs
CHANGED
|
@@ -43,7 +43,7 @@ var import_axios_retry = __toESM(require("axios-retry"), 1);
|
|
|
43
43
|
var axiosInstance;
|
|
44
44
|
var currentOptions = void 0;
|
|
45
45
|
var configure = (options) => {
|
|
46
|
-
const baseURL = options.basePath || "https://api
|
|
46
|
+
const baseURL = options.basePath || "https://api.chainstream.io";
|
|
47
47
|
currentOptions = {
|
|
48
48
|
...options,
|
|
49
49
|
basePath: baseURL
|
|
@@ -267,12 +267,35 @@ var CEL_FIELD_MAPPINGS = {
|
|
|
267
267
|
balanceTagRatRatio: "btrr",
|
|
268
268
|
timestamp: "ts"
|
|
269
269
|
},
|
|
270
|
-
// New token subscription fields
|
|
270
|
+
// New token subscription fields (dex-new-token, supports CEL filter)
|
|
271
271
|
subscribeNewToken: {
|
|
272
272
|
tokenAddress: "a",
|
|
273
273
|
name: "n",
|
|
274
274
|
symbol: "s",
|
|
275
|
-
|
|
275
|
+
decimals: "dec",
|
|
276
|
+
imageUrl: "iu",
|
|
277
|
+
description: "de",
|
|
278
|
+
createdAtMs: "cts",
|
|
279
|
+
coingeckoCoinId: "cgi",
|
|
280
|
+
"socialMedia.twitter": "sm.tw",
|
|
281
|
+
"socialMedia.telegram": "sm.tg",
|
|
282
|
+
"socialMedia.website": "sm.w",
|
|
283
|
+
"socialMedia.tiktok": "sm.tt",
|
|
284
|
+
"socialMedia.discord": "sm.dc",
|
|
285
|
+
"socialMedia.facebook": "sm.fb",
|
|
286
|
+
"socialMedia.github": "sm.gh",
|
|
287
|
+
"socialMedia.instagram": "sm.ig",
|
|
288
|
+
"socialMedia.linkedin": "sm.li",
|
|
289
|
+
"socialMedia.medium": "sm.md",
|
|
290
|
+
"socialMedia.reddit": "sm.rd",
|
|
291
|
+
"socialMedia.youtube": "sm.yt",
|
|
292
|
+
"socialMedia.bitbucket": "sm.bb",
|
|
293
|
+
"launchFrom.programAddress": "lf.pa",
|
|
294
|
+
"launchFrom.protocolFamily": "lf.pf",
|
|
295
|
+
"launchFrom.protocolName": "lf.pn",
|
|
296
|
+
"migratedTo.programAddress": "mt.pa",
|
|
297
|
+
"migratedTo.protocolFamily": "mt.pf",
|
|
298
|
+
"migratedTo.protocolName": "mt.pn"
|
|
276
299
|
},
|
|
277
300
|
// Token supply subscription fields
|
|
278
301
|
subscribeTokenSupply: {
|
|
@@ -295,15 +318,65 @@ var CEL_FIELD_MAPPINGS = {
|
|
|
295
318
|
value: "v",
|
|
296
319
|
timestamp: "ts"
|
|
297
320
|
},
|
|
298
|
-
// New token metadata subscription fields
|
|
321
|
+
// New token metadata subscription fields (dex-new-tokens-metadata)
|
|
299
322
|
subscribeNewTokensMetadata: {
|
|
300
323
|
tokenAddress: "a",
|
|
301
324
|
name: "n",
|
|
325
|
+
decimals: "dec",
|
|
302
326
|
symbol: "s",
|
|
303
327
|
imageUrl: "iu",
|
|
304
328
|
description: "de",
|
|
305
|
-
|
|
306
|
-
|
|
329
|
+
createdAtMs: "cts",
|
|
330
|
+
coingeckoCoinId: "cgi",
|
|
331
|
+
"socialMedia.twitter": "sm.tw",
|
|
332
|
+
"socialMedia.telegram": "sm.tg",
|
|
333
|
+
"socialMedia.website": "sm.w",
|
|
334
|
+
"socialMedia.tiktok": "sm.tt",
|
|
335
|
+
"socialMedia.discord": "sm.dc",
|
|
336
|
+
"socialMedia.facebook": "sm.fb",
|
|
337
|
+
"socialMedia.github": "sm.gh",
|
|
338
|
+
"socialMedia.instagram": "sm.ig",
|
|
339
|
+
"socialMedia.linkedin": "sm.li",
|
|
340
|
+
"socialMedia.medium": "sm.md",
|
|
341
|
+
"socialMedia.reddit": "sm.rd",
|
|
342
|
+
"socialMedia.youtube": "sm.yt",
|
|
343
|
+
"socialMedia.bitbucket": "sm.bb",
|
|
344
|
+
"launchFrom.programAddress": "lf.pa",
|
|
345
|
+
"launchFrom.protocolFamily": "lf.pf",
|
|
346
|
+
"launchFrom.protocolName": "lf.pn",
|
|
347
|
+
"migratedTo.programAddress": "mt.pa",
|
|
348
|
+
"migratedTo.protocolFamily": "mt.pf",
|
|
349
|
+
"migratedTo.protocolName": "mt.pn"
|
|
350
|
+
},
|
|
351
|
+
// New tokens list subscription fields (dex-new-tokens)
|
|
352
|
+
subscribeNewTokens: {
|
|
353
|
+
tokenAddress: "a",
|
|
354
|
+
name: "n",
|
|
355
|
+
decimals: "dec",
|
|
356
|
+
symbol: "s",
|
|
357
|
+
imageUrl: "iu",
|
|
358
|
+
description: "de",
|
|
359
|
+
createdAtMs: "cts",
|
|
360
|
+
coingeckoCoinId: "cgi",
|
|
361
|
+
"socialMedia.twitter": "sm.tw",
|
|
362
|
+
"socialMedia.telegram": "sm.tg",
|
|
363
|
+
"socialMedia.website": "sm.w",
|
|
364
|
+
"socialMedia.tiktok": "sm.tt",
|
|
365
|
+
"socialMedia.discord": "sm.dc",
|
|
366
|
+
"socialMedia.facebook": "sm.fb",
|
|
367
|
+
"socialMedia.github": "sm.gh",
|
|
368
|
+
"socialMedia.instagram": "sm.ig",
|
|
369
|
+
"socialMedia.linkedin": "sm.li",
|
|
370
|
+
"socialMedia.medium": "sm.md",
|
|
371
|
+
"socialMedia.reddit": "sm.rd",
|
|
372
|
+
"socialMedia.youtube": "sm.yt",
|
|
373
|
+
"socialMedia.bitbucket": "sm.bb",
|
|
374
|
+
"launchFrom.programAddress": "lf.pa",
|
|
375
|
+
"launchFrom.protocolFamily": "lf.pf",
|
|
376
|
+
"launchFrom.protocolName": "lf.pn",
|
|
377
|
+
"migratedTo.programAddress": "mt.pa",
|
|
378
|
+
"migratedTo.protocolFamily": "mt.pf",
|
|
379
|
+
"migratedTo.protocolName": "mt.pn"
|
|
307
380
|
},
|
|
308
381
|
// Token trades subscription fields
|
|
309
382
|
subscribeTokenTrades: {
|
|
@@ -379,12 +452,14 @@ function replaceFilterFields(filter, methodName) {
|
|
|
379
452
|
}
|
|
380
453
|
const fieldMappings = getFieldMappings(methodName);
|
|
381
454
|
let result = filter;
|
|
382
|
-
|
|
455
|
+
const sortedEntries = Object.entries(fieldMappings).sort(([a], [b]) => b.length - a.length);
|
|
456
|
+
for (const [longField, shortField] of sortedEntries) {
|
|
457
|
+
const escapedField = longField.replace(/\./g, "\\.");
|
|
383
458
|
const patterns = [
|
|
384
|
-
// Pattern 1: fieldName (
|
|
385
|
-
new RegExp(`\\
|
|
386
|
-
// Pattern 2:
|
|
387
|
-
new RegExp(`\\
|
|
459
|
+
// Pattern 1: meta.fieldName (with meta. prefix) — check first to avoid double meta.
|
|
460
|
+
new RegExp(`\\bmeta\\.${escapedField}\\b`, "g"),
|
|
461
|
+
// Pattern 2: fieldName (without meta. prefix)
|
|
462
|
+
new RegExp(`\\b${escapedField}\\b`, "g")
|
|
388
463
|
];
|
|
389
464
|
patterns.forEach((pattern) => {
|
|
390
465
|
result = result.replace(pattern, `meta.${shortField}`);
|
|
@@ -687,6 +762,57 @@ var StreamApi = class {
|
|
|
687
762
|
[`liquidityChangeRatio${suffix}`]: this.formatScientificNotation(data[`lpc${suffix}`])
|
|
688
763
|
};
|
|
689
764
|
}
|
|
765
|
+
/**
|
|
766
|
+
* Parse social media data from short field names
|
|
767
|
+
*/
|
|
768
|
+
parseSocialMedia(sm) {
|
|
769
|
+
if (!sm) return void 0;
|
|
770
|
+
return {
|
|
771
|
+
twitter: sm.tw,
|
|
772
|
+
telegram: sm.tg,
|
|
773
|
+
website: sm.w,
|
|
774
|
+
tiktok: sm.tt,
|
|
775
|
+
discord: sm.dc,
|
|
776
|
+
facebook: sm.fb,
|
|
777
|
+
github: sm.gh,
|
|
778
|
+
instagram: sm.ig,
|
|
779
|
+
linkedin: sm.li,
|
|
780
|
+
medium: sm.md,
|
|
781
|
+
reddit: sm.rd,
|
|
782
|
+
youtube: sm.yt,
|
|
783
|
+
bitbucket: sm.bb
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* Parse DEX protocol data from short field names
|
|
788
|
+
*/
|
|
789
|
+
parseDexProtocol(lf) {
|
|
790
|
+
if (!lf) return void 0;
|
|
791
|
+
const result = {};
|
|
792
|
+
if (lf.pa) result.programAddress = lf.pa;
|
|
793
|
+
if (lf.pf) result.protocolFamily = lf.pf;
|
|
794
|
+
if (lf.pn) result.protocolName = lf.pn;
|
|
795
|
+
return result;
|
|
796
|
+
}
|
|
797
|
+
/**
|
|
798
|
+
* Parse a TokenMetadataTimeEvent from raw WebSocket data
|
|
799
|
+
*/
|
|
800
|
+
parseTokenMetadata(data) {
|
|
801
|
+
const result = {
|
|
802
|
+
tokenAddress: data.a
|
|
803
|
+
};
|
|
804
|
+
if (data.n != null) result.name = data.n;
|
|
805
|
+
if (data.dec != null) result.decimals = data.dec;
|
|
806
|
+
if (data.s != null) result.symbol = data.s;
|
|
807
|
+
if (data.iu != null) result.imageUrl = data.iu;
|
|
808
|
+
if (data.de != null) result.description = data.de;
|
|
809
|
+
if (data.sm) result.socialMedia = this.parseSocialMedia(data.sm);
|
|
810
|
+
if (data.cts != null) result.createdAtMs = data.cts;
|
|
811
|
+
if (data.cgi != null) result.coingeckoCoinId = data.cgi;
|
|
812
|
+
if (data.lf) result.launchFrom = this.parseDexProtocol(data.lf);
|
|
813
|
+
if (data.mt) result.migratedTo = this.parseDexProtocol(data.mt);
|
|
814
|
+
return result;
|
|
815
|
+
}
|
|
690
816
|
/**
|
|
691
817
|
* Subscribe to token trade statistics
|
|
692
818
|
* Channel: dex-token-stats:{chain}_{tokenAddress}
|
|
@@ -787,6 +913,10 @@ var StreamApi = class {
|
|
|
787
913
|
"subscribeTokenHolders"
|
|
788
914
|
);
|
|
789
915
|
}
|
|
916
|
+
/**
|
|
917
|
+
* Subscribe to new token events (single token per event, supports CEL filter)
|
|
918
|
+
* Channel: dex-new-token:{chain}
|
|
919
|
+
*/
|
|
790
920
|
subscribeNewToken({
|
|
791
921
|
chain,
|
|
792
922
|
callback,
|
|
@@ -802,28 +932,24 @@ var StreamApi = class {
|
|
|
802
932
|
symbol: data.s,
|
|
803
933
|
createdAtMs: data.cts
|
|
804
934
|
};
|
|
805
|
-
if (data.dec)
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
if (data.
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
result.launchFrom.programAddress = lf.pa;
|
|
813
|
-
}
|
|
814
|
-
if (lf.pf) {
|
|
815
|
-
result.launchFrom.protocolFamily = lf.pf;
|
|
816
|
-
}
|
|
817
|
-
if (lf.pn) {
|
|
818
|
-
result.launchFrom.protocolName = lf.pn;
|
|
819
|
-
}
|
|
820
|
-
}
|
|
935
|
+
if (data.dec != null) result.decimals = data.dec;
|
|
936
|
+
if (data.iu != null) result.imageUrl = data.iu;
|
|
937
|
+
if (data.de != null) result.description = data.de;
|
|
938
|
+
if (data.sm) result.socialMedia = this.parseSocialMedia(data.sm);
|
|
939
|
+
if (data.cgi != null) result.coingeckoCoinId = data.cgi;
|
|
940
|
+
if (data.lf) result.launchFrom = this.parseDexProtocol(data.lf);
|
|
941
|
+
if (data.mt) result.migratedTo = this.parseDexProtocol(data.mt);
|
|
821
942
|
callback(result);
|
|
822
943
|
},
|
|
823
944
|
filter,
|
|
824
945
|
"subscribeNewToken"
|
|
825
946
|
);
|
|
826
947
|
}
|
|
948
|
+
/**
|
|
949
|
+
* Subscribe to new tokens metadata (batch, aggregated every 1 second)
|
|
950
|
+
* Channel: dex-new-tokens-metadata:{chain}
|
|
951
|
+
* No CEL filter support
|
|
952
|
+
*/
|
|
827
953
|
subscribeNewTokensMetadata({
|
|
828
954
|
chain,
|
|
829
955
|
callback
|
|
@@ -831,35 +957,22 @@ var StreamApi = class {
|
|
|
831
957
|
const channel = `dex-new-tokens-metadata:${chain}`;
|
|
832
958
|
return this.subscribe(
|
|
833
959
|
channel,
|
|
834
|
-
(data) => callback(
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
facebook: sm.fb,
|
|
851
|
-
github: sm.gh,
|
|
852
|
-
instagram: sm.ig,
|
|
853
|
-
linkedin: sm.li,
|
|
854
|
-
medium: sm.md,
|
|
855
|
-
reddit: sm.rd,
|
|
856
|
-
youtube: sm.yt,
|
|
857
|
-
bitbucket: sm.bb
|
|
858
|
-
};
|
|
859
|
-
})(),
|
|
860
|
-
createdAtMs: it.cts
|
|
861
|
-
}))
|
|
862
|
-
)
|
|
960
|
+
(data) => callback(data.map((it) => this.parseTokenMetadata(it)))
|
|
961
|
+
);
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* Subscribe to new tokens list (batch from token-created-to-realtime-pipeline)
|
|
965
|
+
* Channel: dex-new-tokens:{chain}
|
|
966
|
+
* No CEL filter support
|
|
967
|
+
*/
|
|
968
|
+
subscribeNewTokens({
|
|
969
|
+
chain,
|
|
970
|
+
callback
|
|
971
|
+
}) {
|
|
972
|
+
const channel = `dex-new-tokens:${chain}`;
|
|
973
|
+
return this.subscribe(
|
|
974
|
+
channel,
|
|
975
|
+
(data) => callback(data.map((it) => this.parseTokenMetadata(it)))
|
|
863
976
|
);
|
|
864
977
|
}
|
|
865
978
|
subscribeTokenSupply({
|
|
@@ -1008,73 +1121,13 @@ var StreamApi = class {
|
|
|
1008
1121
|
result.metadata.createdAtMs = t.cts;
|
|
1009
1122
|
}
|
|
1010
1123
|
if (t.lf) {
|
|
1011
|
-
|
|
1012
|
-
result.metadata.launchFrom = {};
|
|
1013
|
-
if (lf.pa) {
|
|
1014
|
-
result.metadata.launchFrom.programAddress = lf.pa;
|
|
1015
|
-
}
|
|
1016
|
-
if (lf.pf) {
|
|
1017
|
-
result.metadata.launchFrom.protocolFamily = lf.pf;
|
|
1018
|
-
}
|
|
1019
|
-
if (lf.pn) {
|
|
1020
|
-
result.metadata.launchFrom.protocolName = lf.pn;
|
|
1021
|
-
}
|
|
1124
|
+
result.metadata.launchFrom = this.parseDexProtocol(t.lf);
|
|
1022
1125
|
}
|
|
1023
1126
|
if (t.mt) {
|
|
1024
|
-
|
|
1025
|
-
result.metadata.migratedTo = {};
|
|
1026
|
-
if (mt.pa) {
|
|
1027
|
-
result.metadata.migratedTo.programAddress = mt.pa;
|
|
1028
|
-
}
|
|
1029
|
-
if (mt.pf) {
|
|
1030
|
-
result.metadata.migratedTo.protocolFamily = mt.pf;
|
|
1031
|
-
}
|
|
1032
|
-
if (mt.pn) {
|
|
1033
|
-
result.metadata.migratedTo.protocolName = mt.pn;
|
|
1034
|
-
}
|
|
1127
|
+
result.metadata.migratedTo = this.parseDexProtocol(t.mt);
|
|
1035
1128
|
}
|
|
1036
1129
|
if (t.sm) {
|
|
1037
|
-
|
|
1038
|
-
result.metadata.socialMedia = {};
|
|
1039
|
-
if (sm.tw) {
|
|
1040
|
-
result.metadata.socialMedia.twitter = sm.tw;
|
|
1041
|
-
}
|
|
1042
|
-
if (sm.tg) {
|
|
1043
|
-
result.metadata.socialMedia.telegram = sm.tg;
|
|
1044
|
-
}
|
|
1045
|
-
if (sm.w) {
|
|
1046
|
-
result.metadata.socialMedia.website = sm.w;
|
|
1047
|
-
}
|
|
1048
|
-
if (sm.tt) {
|
|
1049
|
-
result.metadata.socialMedia.tiktok = sm.tt;
|
|
1050
|
-
}
|
|
1051
|
-
if (sm.dc) {
|
|
1052
|
-
result.metadata.socialMedia.discord = sm.dc;
|
|
1053
|
-
}
|
|
1054
|
-
if (sm.fb) {
|
|
1055
|
-
result.metadata.socialMedia.facebook = sm.fb;
|
|
1056
|
-
}
|
|
1057
|
-
if (sm.gh) {
|
|
1058
|
-
result.metadata.socialMedia.github = sm.gh;
|
|
1059
|
-
}
|
|
1060
|
-
if (sm.ig) {
|
|
1061
|
-
result.metadata.socialMedia.instagram = sm.ig;
|
|
1062
|
-
}
|
|
1063
|
-
if (sm.li) {
|
|
1064
|
-
result.metadata.socialMedia.linkedin = sm.li;
|
|
1065
|
-
}
|
|
1066
|
-
if (sm.md) {
|
|
1067
|
-
result.metadata.socialMedia.medium = sm.md;
|
|
1068
|
-
}
|
|
1069
|
-
if (sm.rd) {
|
|
1070
|
-
result.metadata.socialMedia.reddit = sm.rd;
|
|
1071
|
-
}
|
|
1072
|
-
if (sm.yt) {
|
|
1073
|
-
result.metadata.socialMedia.youtube = sm.yt;
|
|
1074
|
-
}
|
|
1075
|
-
if (sm.bb) {
|
|
1076
|
-
result.metadata.socialMedia.bitbucket = sm.bb;
|
|
1077
|
-
}
|
|
1130
|
+
result.metadata.socialMedia = this.parseSocialMedia(t.sm);
|
|
1078
1131
|
}
|
|
1079
1132
|
}
|
|
1080
1133
|
if (bc) {
|
|
@@ -2310,7 +2363,7 @@ var ChainStreamClient = class {
|
|
|
2310
2363
|
__publicField(this, "jobs");
|
|
2311
2364
|
__publicField(this, "kyt");
|
|
2312
2365
|
__publicField(this, "endpoint");
|
|
2313
|
-
const baseUrl = options.serverUrl ?? "https://api
|
|
2366
|
+
const baseUrl = options.serverUrl ?? "https://api.chainstream.io";
|
|
2314
2367
|
const streamUrl = options.streamUrl ?? "wss://realtime-dex.chainstream.io/connection/websocket";
|
|
2315
2368
|
this.requestCtx = { baseUrl, streamUrl, accessToken };
|
|
2316
2369
|
configure({
|