@chainstream-io/sdk 0.2.10 → 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-DLKhKJTp.d.cts → chainstream-BY9CsB3h.d.cts} +113 -5
- package/dist/{chainstream-DLKhKJTp.d.ts → chainstream-BY9CsB3h.d.ts} +113 -5
- 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/index.cjs
CHANGED
|
@@ -247,7 +247,7 @@ var import_axios_retry = __toESM(require("axios-retry"), 1);
|
|
|
247
247
|
var axiosInstance;
|
|
248
248
|
var currentOptions = void 0;
|
|
249
249
|
var configure = (options) => {
|
|
250
|
-
const baseURL = options.basePath || "https://api
|
|
250
|
+
const baseURL = options.basePath || "https://api.chainstream.io";
|
|
251
251
|
currentOptions = {
|
|
252
252
|
...options,
|
|
253
253
|
basePath: baseURL
|
|
@@ -471,12 +471,35 @@ var CEL_FIELD_MAPPINGS = {
|
|
|
471
471
|
balanceTagRatRatio: "btrr",
|
|
472
472
|
timestamp: "ts"
|
|
473
473
|
},
|
|
474
|
-
// New token subscription fields
|
|
474
|
+
// New token subscription fields (dex-new-token, supports CEL filter)
|
|
475
475
|
subscribeNewToken: {
|
|
476
476
|
tokenAddress: "a",
|
|
477
477
|
name: "n",
|
|
478
478
|
symbol: "s",
|
|
479
|
-
|
|
479
|
+
decimals: "dec",
|
|
480
|
+
imageUrl: "iu",
|
|
481
|
+
description: "de",
|
|
482
|
+
createdAtMs: "cts",
|
|
483
|
+
coingeckoCoinId: "cgi",
|
|
484
|
+
"socialMedia.twitter": "sm.tw",
|
|
485
|
+
"socialMedia.telegram": "sm.tg",
|
|
486
|
+
"socialMedia.website": "sm.w",
|
|
487
|
+
"socialMedia.tiktok": "sm.tt",
|
|
488
|
+
"socialMedia.discord": "sm.dc",
|
|
489
|
+
"socialMedia.facebook": "sm.fb",
|
|
490
|
+
"socialMedia.github": "sm.gh",
|
|
491
|
+
"socialMedia.instagram": "sm.ig",
|
|
492
|
+
"socialMedia.linkedin": "sm.li",
|
|
493
|
+
"socialMedia.medium": "sm.md",
|
|
494
|
+
"socialMedia.reddit": "sm.rd",
|
|
495
|
+
"socialMedia.youtube": "sm.yt",
|
|
496
|
+
"socialMedia.bitbucket": "sm.bb",
|
|
497
|
+
"launchFrom.programAddress": "lf.pa",
|
|
498
|
+
"launchFrom.protocolFamily": "lf.pf",
|
|
499
|
+
"launchFrom.protocolName": "lf.pn",
|
|
500
|
+
"migratedTo.programAddress": "mt.pa",
|
|
501
|
+
"migratedTo.protocolFamily": "mt.pf",
|
|
502
|
+
"migratedTo.protocolName": "mt.pn"
|
|
480
503
|
},
|
|
481
504
|
// Token supply subscription fields
|
|
482
505
|
subscribeTokenSupply: {
|
|
@@ -499,15 +522,65 @@ var CEL_FIELD_MAPPINGS = {
|
|
|
499
522
|
value: "v",
|
|
500
523
|
timestamp: "ts"
|
|
501
524
|
},
|
|
502
|
-
// New token metadata subscription fields
|
|
525
|
+
// New token metadata subscription fields (dex-new-tokens-metadata)
|
|
503
526
|
subscribeNewTokensMetadata: {
|
|
504
527
|
tokenAddress: "a",
|
|
505
528
|
name: "n",
|
|
529
|
+
decimals: "dec",
|
|
506
530
|
symbol: "s",
|
|
507
531
|
imageUrl: "iu",
|
|
508
532
|
description: "de",
|
|
509
|
-
|
|
510
|
-
|
|
533
|
+
createdAtMs: "cts",
|
|
534
|
+
coingeckoCoinId: "cgi",
|
|
535
|
+
"socialMedia.twitter": "sm.tw",
|
|
536
|
+
"socialMedia.telegram": "sm.tg",
|
|
537
|
+
"socialMedia.website": "sm.w",
|
|
538
|
+
"socialMedia.tiktok": "sm.tt",
|
|
539
|
+
"socialMedia.discord": "sm.dc",
|
|
540
|
+
"socialMedia.facebook": "sm.fb",
|
|
541
|
+
"socialMedia.github": "sm.gh",
|
|
542
|
+
"socialMedia.instagram": "sm.ig",
|
|
543
|
+
"socialMedia.linkedin": "sm.li",
|
|
544
|
+
"socialMedia.medium": "sm.md",
|
|
545
|
+
"socialMedia.reddit": "sm.rd",
|
|
546
|
+
"socialMedia.youtube": "sm.yt",
|
|
547
|
+
"socialMedia.bitbucket": "sm.bb",
|
|
548
|
+
"launchFrom.programAddress": "lf.pa",
|
|
549
|
+
"launchFrom.protocolFamily": "lf.pf",
|
|
550
|
+
"launchFrom.protocolName": "lf.pn",
|
|
551
|
+
"migratedTo.programAddress": "mt.pa",
|
|
552
|
+
"migratedTo.protocolFamily": "mt.pf",
|
|
553
|
+
"migratedTo.protocolName": "mt.pn"
|
|
554
|
+
},
|
|
555
|
+
// New tokens list subscription fields (dex-new-tokens)
|
|
556
|
+
subscribeNewTokens: {
|
|
557
|
+
tokenAddress: "a",
|
|
558
|
+
name: "n",
|
|
559
|
+
decimals: "dec",
|
|
560
|
+
symbol: "s",
|
|
561
|
+
imageUrl: "iu",
|
|
562
|
+
description: "de",
|
|
563
|
+
createdAtMs: "cts",
|
|
564
|
+
coingeckoCoinId: "cgi",
|
|
565
|
+
"socialMedia.twitter": "sm.tw",
|
|
566
|
+
"socialMedia.telegram": "sm.tg",
|
|
567
|
+
"socialMedia.website": "sm.w",
|
|
568
|
+
"socialMedia.tiktok": "sm.tt",
|
|
569
|
+
"socialMedia.discord": "sm.dc",
|
|
570
|
+
"socialMedia.facebook": "sm.fb",
|
|
571
|
+
"socialMedia.github": "sm.gh",
|
|
572
|
+
"socialMedia.instagram": "sm.ig",
|
|
573
|
+
"socialMedia.linkedin": "sm.li",
|
|
574
|
+
"socialMedia.medium": "sm.md",
|
|
575
|
+
"socialMedia.reddit": "sm.rd",
|
|
576
|
+
"socialMedia.youtube": "sm.yt",
|
|
577
|
+
"socialMedia.bitbucket": "sm.bb",
|
|
578
|
+
"launchFrom.programAddress": "lf.pa",
|
|
579
|
+
"launchFrom.protocolFamily": "lf.pf",
|
|
580
|
+
"launchFrom.protocolName": "lf.pn",
|
|
581
|
+
"migratedTo.programAddress": "mt.pa",
|
|
582
|
+
"migratedTo.protocolFamily": "mt.pf",
|
|
583
|
+
"migratedTo.protocolName": "mt.pn"
|
|
511
584
|
},
|
|
512
585
|
// Token trades subscription fields
|
|
513
586
|
subscribeTokenTrades: {
|
|
@@ -583,12 +656,14 @@ function replaceFilterFields(filter, methodName) {
|
|
|
583
656
|
}
|
|
584
657
|
const fieldMappings = getFieldMappings(methodName);
|
|
585
658
|
let result = filter;
|
|
586
|
-
|
|
659
|
+
const sortedEntries = Object.entries(fieldMappings).sort(([a], [b]) => b.length - a.length);
|
|
660
|
+
for (const [longField, shortField] of sortedEntries) {
|
|
661
|
+
const escapedField = longField.replace(/\./g, "\\.");
|
|
587
662
|
const patterns = [
|
|
588
|
-
// Pattern 1: fieldName (
|
|
589
|
-
new RegExp(`\\
|
|
590
|
-
// Pattern 2:
|
|
591
|
-
new RegExp(`\\
|
|
663
|
+
// Pattern 1: meta.fieldName (with meta. prefix) — check first to avoid double meta.
|
|
664
|
+
new RegExp(`\\bmeta\\.${escapedField}\\b`, "g"),
|
|
665
|
+
// Pattern 2: fieldName (without meta. prefix)
|
|
666
|
+
new RegExp(`\\b${escapedField}\\b`, "g")
|
|
592
667
|
];
|
|
593
668
|
patterns.forEach((pattern) => {
|
|
594
669
|
result = result.replace(pattern, `meta.${shortField}`);
|
|
@@ -895,6 +970,57 @@ var StreamApi = class {
|
|
|
895
970
|
[`liquidityChangeRatio${suffix}`]: this.formatScientificNotation(data[`lpc${suffix}`])
|
|
896
971
|
};
|
|
897
972
|
}
|
|
973
|
+
/**
|
|
974
|
+
* Parse social media data from short field names
|
|
975
|
+
*/
|
|
976
|
+
parseSocialMedia(sm) {
|
|
977
|
+
if (!sm) return void 0;
|
|
978
|
+
return {
|
|
979
|
+
twitter: sm.tw,
|
|
980
|
+
telegram: sm.tg,
|
|
981
|
+
website: sm.w,
|
|
982
|
+
tiktok: sm.tt,
|
|
983
|
+
discord: sm.dc,
|
|
984
|
+
facebook: sm.fb,
|
|
985
|
+
github: sm.gh,
|
|
986
|
+
instagram: sm.ig,
|
|
987
|
+
linkedin: sm.li,
|
|
988
|
+
medium: sm.md,
|
|
989
|
+
reddit: sm.rd,
|
|
990
|
+
youtube: sm.yt,
|
|
991
|
+
bitbucket: sm.bb
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Parse DEX protocol data from short field names
|
|
996
|
+
*/
|
|
997
|
+
parseDexProtocol(lf) {
|
|
998
|
+
if (!lf) return void 0;
|
|
999
|
+
const result = {};
|
|
1000
|
+
if (lf.pa) result.programAddress = lf.pa;
|
|
1001
|
+
if (lf.pf) result.protocolFamily = lf.pf;
|
|
1002
|
+
if (lf.pn) result.protocolName = lf.pn;
|
|
1003
|
+
return result;
|
|
1004
|
+
}
|
|
1005
|
+
/**
|
|
1006
|
+
* Parse a TokenMetadataTimeEvent from raw WebSocket data
|
|
1007
|
+
*/
|
|
1008
|
+
parseTokenMetadata(data) {
|
|
1009
|
+
const result = {
|
|
1010
|
+
tokenAddress: data.a
|
|
1011
|
+
};
|
|
1012
|
+
if (data.n != null) result.name = data.n;
|
|
1013
|
+
if (data.dec != null) result.decimals = data.dec;
|
|
1014
|
+
if (data.s != null) result.symbol = data.s;
|
|
1015
|
+
if (data.iu != null) result.imageUrl = data.iu;
|
|
1016
|
+
if (data.de != null) result.description = data.de;
|
|
1017
|
+
if (data.sm) result.socialMedia = this.parseSocialMedia(data.sm);
|
|
1018
|
+
if (data.cts != null) result.createdAtMs = data.cts;
|
|
1019
|
+
if (data.cgi != null) result.coingeckoCoinId = data.cgi;
|
|
1020
|
+
if (data.lf) result.launchFrom = this.parseDexProtocol(data.lf);
|
|
1021
|
+
if (data.mt) result.migratedTo = this.parseDexProtocol(data.mt);
|
|
1022
|
+
return result;
|
|
1023
|
+
}
|
|
898
1024
|
/**
|
|
899
1025
|
* Subscribe to token trade statistics
|
|
900
1026
|
* Channel: dex-token-stats:{chain}_{tokenAddress}
|
|
@@ -995,6 +1121,10 @@ var StreamApi = class {
|
|
|
995
1121
|
"subscribeTokenHolders"
|
|
996
1122
|
);
|
|
997
1123
|
}
|
|
1124
|
+
/**
|
|
1125
|
+
* Subscribe to new token events (single token per event, supports CEL filter)
|
|
1126
|
+
* Channel: dex-new-token:{chain}
|
|
1127
|
+
*/
|
|
998
1128
|
subscribeNewToken({
|
|
999
1129
|
chain,
|
|
1000
1130
|
callback,
|
|
@@ -1010,28 +1140,24 @@ var StreamApi = class {
|
|
|
1010
1140
|
symbol: data.s,
|
|
1011
1141
|
createdAtMs: data.cts
|
|
1012
1142
|
};
|
|
1013
|
-
if (data.dec)
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
if (data.
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
result.launchFrom.programAddress = lf.pa;
|
|
1021
|
-
}
|
|
1022
|
-
if (lf.pf) {
|
|
1023
|
-
result.launchFrom.protocolFamily = lf.pf;
|
|
1024
|
-
}
|
|
1025
|
-
if (lf.pn) {
|
|
1026
|
-
result.launchFrom.protocolName = lf.pn;
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1143
|
+
if (data.dec != null) result.decimals = data.dec;
|
|
1144
|
+
if (data.iu != null) result.imageUrl = data.iu;
|
|
1145
|
+
if (data.de != null) result.description = data.de;
|
|
1146
|
+
if (data.sm) result.socialMedia = this.parseSocialMedia(data.sm);
|
|
1147
|
+
if (data.cgi != null) result.coingeckoCoinId = data.cgi;
|
|
1148
|
+
if (data.lf) result.launchFrom = this.parseDexProtocol(data.lf);
|
|
1149
|
+
if (data.mt) result.migratedTo = this.parseDexProtocol(data.mt);
|
|
1029
1150
|
callback(result);
|
|
1030
1151
|
},
|
|
1031
1152
|
filter,
|
|
1032
1153
|
"subscribeNewToken"
|
|
1033
1154
|
);
|
|
1034
1155
|
}
|
|
1156
|
+
/**
|
|
1157
|
+
* Subscribe to new tokens metadata (batch, aggregated every 1 second)
|
|
1158
|
+
* Channel: dex-new-tokens-metadata:{chain}
|
|
1159
|
+
* No CEL filter support
|
|
1160
|
+
*/
|
|
1035
1161
|
subscribeNewTokensMetadata({
|
|
1036
1162
|
chain,
|
|
1037
1163
|
callback
|
|
@@ -1039,35 +1165,22 @@ var StreamApi = class {
|
|
|
1039
1165
|
const channel = `dex-new-tokens-metadata:${chain}`;
|
|
1040
1166
|
return this.subscribe(
|
|
1041
1167
|
channel,
|
|
1042
|
-
(data) => callback(
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
facebook: sm.fb,
|
|
1059
|
-
github: sm.gh,
|
|
1060
|
-
instagram: sm.ig,
|
|
1061
|
-
linkedin: sm.li,
|
|
1062
|
-
medium: sm.md,
|
|
1063
|
-
reddit: sm.rd,
|
|
1064
|
-
youtube: sm.yt,
|
|
1065
|
-
bitbucket: sm.bb
|
|
1066
|
-
};
|
|
1067
|
-
})(),
|
|
1068
|
-
createdAtMs: it.cts
|
|
1069
|
-
}))
|
|
1070
|
-
)
|
|
1168
|
+
(data) => callback(data.map((it) => this.parseTokenMetadata(it)))
|
|
1169
|
+
);
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
* Subscribe to new tokens list (batch from token-created-to-realtime-pipeline)
|
|
1173
|
+
* Channel: dex-new-tokens:{chain}
|
|
1174
|
+
* No CEL filter support
|
|
1175
|
+
*/
|
|
1176
|
+
subscribeNewTokens({
|
|
1177
|
+
chain,
|
|
1178
|
+
callback
|
|
1179
|
+
}) {
|
|
1180
|
+
const channel = `dex-new-tokens:${chain}`;
|
|
1181
|
+
return this.subscribe(
|
|
1182
|
+
channel,
|
|
1183
|
+
(data) => callback(data.map((it) => this.parseTokenMetadata(it)))
|
|
1071
1184
|
);
|
|
1072
1185
|
}
|
|
1073
1186
|
subscribeTokenSupply({
|
|
@@ -1216,73 +1329,13 @@ var StreamApi = class {
|
|
|
1216
1329
|
result.metadata.createdAtMs = t.cts;
|
|
1217
1330
|
}
|
|
1218
1331
|
if (t.lf) {
|
|
1219
|
-
|
|
1220
|
-
result.metadata.launchFrom = {};
|
|
1221
|
-
if (lf.pa) {
|
|
1222
|
-
result.metadata.launchFrom.programAddress = lf.pa;
|
|
1223
|
-
}
|
|
1224
|
-
if (lf.pf) {
|
|
1225
|
-
result.metadata.launchFrom.protocolFamily = lf.pf;
|
|
1226
|
-
}
|
|
1227
|
-
if (lf.pn) {
|
|
1228
|
-
result.metadata.launchFrom.protocolName = lf.pn;
|
|
1229
|
-
}
|
|
1332
|
+
result.metadata.launchFrom = this.parseDexProtocol(t.lf);
|
|
1230
1333
|
}
|
|
1231
1334
|
if (t.mt) {
|
|
1232
|
-
|
|
1233
|
-
result.metadata.migratedTo = {};
|
|
1234
|
-
if (mt.pa) {
|
|
1235
|
-
result.metadata.migratedTo.programAddress = mt.pa;
|
|
1236
|
-
}
|
|
1237
|
-
if (mt.pf) {
|
|
1238
|
-
result.metadata.migratedTo.protocolFamily = mt.pf;
|
|
1239
|
-
}
|
|
1240
|
-
if (mt.pn) {
|
|
1241
|
-
result.metadata.migratedTo.protocolName = mt.pn;
|
|
1242
|
-
}
|
|
1335
|
+
result.metadata.migratedTo = this.parseDexProtocol(t.mt);
|
|
1243
1336
|
}
|
|
1244
1337
|
if (t.sm) {
|
|
1245
|
-
|
|
1246
|
-
result.metadata.socialMedia = {};
|
|
1247
|
-
if (sm.tw) {
|
|
1248
|
-
result.metadata.socialMedia.twitter = sm.tw;
|
|
1249
|
-
}
|
|
1250
|
-
if (sm.tg) {
|
|
1251
|
-
result.metadata.socialMedia.telegram = sm.tg;
|
|
1252
|
-
}
|
|
1253
|
-
if (sm.w) {
|
|
1254
|
-
result.metadata.socialMedia.website = sm.w;
|
|
1255
|
-
}
|
|
1256
|
-
if (sm.tt) {
|
|
1257
|
-
result.metadata.socialMedia.tiktok = sm.tt;
|
|
1258
|
-
}
|
|
1259
|
-
if (sm.dc) {
|
|
1260
|
-
result.metadata.socialMedia.discord = sm.dc;
|
|
1261
|
-
}
|
|
1262
|
-
if (sm.fb) {
|
|
1263
|
-
result.metadata.socialMedia.facebook = sm.fb;
|
|
1264
|
-
}
|
|
1265
|
-
if (sm.gh) {
|
|
1266
|
-
result.metadata.socialMedia.github = sm.gh;
|
|
1267
|
-
}
|
|
1268
|
-
if (sm.ig) {
|
|
1269
|
-
result.metadata.socialMedia.instagram = sm.ig;
|
|
1270
|
-
}
|
|
1271
|
-
if (sm.li) {
|
|
1272
|
-
result.metadata.socialMedia.linkedin = sm.li;
|
|
1273
|
-
}
|
|
1274
|
-
if (sm.md) {
|
|
1275
|
-
result.metadata.socialMedia.medium = sm.md;
|
|
1276
|
-
}
|
|
1277
|
-
if (sm.rd) {
|
|
1278
|
-
result.metadata.socialMedia.reddit = sm.rd;
|
|
1279
|
-
}
|
|
1280
|
-
if (sm.yt) {
|
|
1281
|
-
result.metadata.socialMedia.youtube = sm.yt;
|
|
1282
|
-
}
|
|
1283
|
-
if (sm.bb) {
|
|
1284
|
-
result.metadata.socialMedia.bitbucket = sm.bb;
|
|
1285
|
-
}
|
|
1338
|
+
result.metadata.socialMedia = this.parseSocialMedia(t.sm);
|
|
1286
1339
|
}
|
|
1287
1340
|
}
|
|
1288
1341
|
if (bc) {
|
|
@@ -2557,7 +2610,7 @@ var ChainStreamClient = class {
|
|
|
2557
2610
|
__publicField(this, "jobs");
|
|
2558
2611
|
__publicField(this, "kyt");
|
|
2559
2612
|
__publicField(this, "endpoint");
|
|
2560
|
-
const baseUrl = options.serverUrl ?? "https://api
|
|
2613
|
+
const baseUrl = options.serverUrl ?? "https://api.chainstream.io";
|
|
2561
2614
|
const streamUrl = options.streamUrl ?? "wss://realtime-dex.chainstream.io/connection/websocket";
|
|
2562
2615
|
this.requestCtx = { baseUrl, streamUrl, accessToken };
|
|
2563
2616
|
configure({
|