@chainstream-io/sdk 0.1.8 → 0.1.9
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/README.md +2 -2
- package/dist/esm/index.js +73 -74
- package/dist/esm/openapi/apis/BlockchainApi.js +61 -44
- package/dist/esm/openapi/apis/DefiSolanaMoonshotApi.js +67 -50
- package/dist/esm/openapi/apis/DefiSolanaPumpfunApi.js +38 -25
- package/dist/esm/openapi/apis/DexApi.js +205 -176
- package/dist/esm/openapi/apis/DexPoolApi.js +41 -28
- package/dist/esm/openapi/apis/EndpointApi.js +212 -175
- package/dist/esm/openapi/apis/IpfsApi.js +38 -25
- package/dist/esm/openapi/apis/JobsApi.js +65 -48
- package/dist/esm/openapi/apis/RankingApi.js +278 -249
- package/dist/esm/openapi/apis/RedPacketApi.js +294 -253
- package/dist/esm/openapi/apis/TokenApi.js +1145 -1056
- package/dist/esm/openapi/apis/TradeApi.js +233 -208
- package/dist/esm/openapi/apis/TransactionApi.js +42 -29
- package/dist/esm/openapi/apis/WalletApi.js +148 -123
- package/dist/esm/openapi/apis/WatchlistApi.js +41 -28
- package/dist/esm/openapi/runtime.js +119 -118
- package/dist/esm/stream/stream.js +36 -34
- package/dist/index.js +99 -96
- package/dist/openapi/apis/BlockchainApi.js +69 -48
- package/dist/openapi/apis/DefiSolanaMoonshotApi.js +74 -53
- package/dist/openapi/apis/DefiSolanaPumpfunApi.js +45 -28
- package/dist/openapi/apis/DexApi.js +217 -184
- package/dist/openapi/apis/DexPoolApi.js +49 -32
- package/dist/openapi/apis/EndpointApi.js +220 -179
- package/dist/openapi/apis/IpfsApi.js +44 -27
- package/dist/openapi/apis/JobsApi.js +72 -51
- package/dist/openapi/apis/RankingApi.js +306 -273
- package/dist/openapi/apis/RedPacketApi.js +305 -260
- package/dist/openapi/apis/TokenApi.js +1182 -1089
- package/dist/openapi/apis/TradeApi.js +256 -227
- package/dist/openapi/apis/TransactionApi.js +49 -32
- package/dist/openapi/apis/WalletApi.js +159 -130
- package/dist/openapi/apis/WatchlistApi.js +49 -32
- package/dist/openapi/apis/index.js +31 -15
- package/dist/openapi/index.js +19 -3
- package/dist/openapi/models/BlockchainDTO.js +12 -5
- package/dist/openapi/models/BlockchainLatestBlockDTO.js +12 -5
- package/dist/openapi/models/BooleanResultDTO.js +12 -5
- package/dist/openapi/models/CalculatePnlInput.js +12 -5
- package/dist/openapi/models/Candle.js +15 -8
- package/dist/openapi/models/ClaimRedPacketInput.js +12 -5
- package/dist/openapi/models/CreateEndpointInput.js +12 -5
- package/dist/openapi/models/CreateRedPacketInput.js +12 -5
- package/dist/openapi/models/CreateRedPacketReply.js +12 -5
- package/dist/openapi/models/CreateTokenInput.js +14 -6
- package/dist/openapi/models/CreateTokenReply.js +12 -5
- package/dist/openapi/models/DexDTO.js +12 -5
- package/dist/openapi/models/DexPage.js +15 -8
- package/dist/openapi/models/DexPoolDTO.js +12 -5
- package/dist/openapi/models/EndpointListResponse.js +15 -8
- package/dist/openapi/models/EndpointOperationResponse.js +12 -5
- package/dist/openapi/models/EndpointResponse.js +12 -5
- package/dist/openapi/models/EndpointSecretResponse.js +12 -5
- package/dist/openapi/models/FilterCondition.js +14 -6
- package/dist/openapi/models/GainersAndLosersDTO.js +12 -5
- package/dist/openapi/models/GainersAndLosersPage.js +15 -8
- package/dist/openapi/models/JobDTO.js +12 -5
- package/dist/openapi/models/JobStreamingDTO.js +12 -5
- package/dist/openapi/models/Link.js +14 -6
- package/dist/openapi/models/MoonshotCreateTokenInput.js +18 -10
- package/dist/openapi/models/MoonshotCreateTokenReply.js +12 -5
- package/dist/openapi/models/MoonshotSubmitCreateToken200Response.js +12 -5
- package/dist/openapi/models/MoonshotSubmitCreateTokenInput.js +12 -5
- package/dist/openapi/models/PumpCreateTokenInput.js +15 -7
- package/dist/openapi/models/PumpCreateTokenReply.js +12 -5
- package/dist/openapi/models/QuoteResponse.js +12 -5
- package/dist/openapi/models/RedPacketClaimDTO.js +14 -6
- package/dist/openapi/models/RedPacketClaimsPage.js +15 -8
- package/dist/openapi/models/RedPacketDTO.js +14 -6
- package/dist/openapi/models/RedPacketReply.js +12 -5
- package/dist/openapi/models/RedPacketSendTxInput.js +12 -5
- package/dist/openapi/models/RedPacketSendTxResponse.js +12 -5
- package/dist/openapi/models/RedPacketsPage.js +15 -8
- package/dist/openapi/models/Resolution.js +17 -9
- package/dist/openapi/models/SendTxInput.js +14 -6
- package/dist/openapi/models/SendTxResponse.js +12 -5
- package/dist/openapi/models/SwapInput.js +15 -7
- package/dist/openapi/models/SwapReply.js +12 -5
- package/dist/openapi/models/SwapRouteInput.js +15 -7
- package/dist/openapi/models/SwapRouteResponse.js +15 -8
- package/dist/openapi/models/Token.js +30 -23
- package/dist/openapi/models/TokenCreationDTO.js +14 -6
- package/dist/openapi/models/TokenCreationPage.js +15 -8
- package/dist/openapi/models/TokenCreatorsDTO.js +12 -5
- package/dist/openapi/models/TokenExtraDTO.js +12 -5
- package/dist/openapi/models/TokenHolder.js +12 -5
- package/dist/openapi/models/TokenHolderPage.js +15 -8
- package/dist/openapi/models/TokenListPage.js +15 -8
- package/dist/openapi/models/TokenMarketData.js +12 -5
- package/dist/openapi/models/TokenMetadata.js +21 -14
- package/dist/openapi/models/TokenPage.js +15 -8
- package/dist/openapi/models/TokenPriceDTO.js +12 -5
- package/dist/openapi/models/TokenPricePage.js +15 -8
- package/dist/openapi/models/TokenSocialMediasDTO.js +12 -5
- package/dist/openapi/models/TokenStat.js +12 -5
- package/dist/openapi/models/TopTradersDTO.js +12 -5
- package/dist/openapi/models/TopTradersPage.js +15 -8
- package/dist/openapi/models/TradeDetailDTO.js +12 -5
- package/dist/openapi/models/TradeEvent.js +15 -8
- package/dist/openapi/models/TradePage.js +15 -8
- package/dist/openapi/models/TradeType.js +17 -9
- package/dist/openapi/models/UpdateEndpointInput.js +12 -5
- package/dist/openapi/models/WalletBalanceDetailDTO.js +12 -5
- package/dist/openapi/models/WalletBalancesDTO.js +15 -8
- package/dist/openapi/models/WalletPnlDTO.js +12 -5
- package/dist/openapi/models/index.js +86 -70
- package/dist/openapi/runtime.js +153 -136
- package/dist/stream/index.js +19 -3
- package/dist/stream/stream.fields.js +11 -5
- package/dist/stream/stream.js +45 -39
- package/dist/stream/stream.model.js +13 -10
- package/package.json +3 -3
|
@@ -11,9 +11,17 @@
|
|
|
11
11
|
* https://openapi-generator.tech
|
|
12
12
|
* Do not edit the class manually.
|
|
13
13
|
*/
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
14
23
|
export const BASE_PATH = "https://api-dex.chainstream.io".replace(/\/+$/, "");
|
|
15
24
|
export class Configuration {
|
|
16
|
-
configuration;
|
|
17
25
|
constructor(configuration = {}) {
|
|
18
26
|
this.configuration = configuration;
|
|
19
27
|
}
|
|
@@ -48,7 +56,7 @@ export class Configuration {
|
|
|
48
56
|
get accessToken() {
|
|
49
57
|
const accessToken = this.configuration.accessToken;
|
|
50
58
|
if (accessToken) {
|
|
51
|
-
return typeof accessToken === 'function' ? accessToken :
|
|
59
|
+
return typeof accessToken === 'function' ? accessToken : () => __awaiter(this, void 0, void 0, function* () { return accessToken; });
|
|
52
60
|
}
|
|
53
61
|
return undefined;
|
|
54
62
|
}
|
|
@@ -64,11 +72,52 @@ export const DefaultConfig = new Configuration();
|
|
|
64
72
|
* This is the base class for all generated API classes.
|
|
65
73
|
*/
|
|
66
74
|
export class BaseAPI {
|
|
67
|
-
configuration;
|
|
68
|
-
static jsonRegex = new RegExp('^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i');
|
|
69
|
-
middleware;
|
|
70
75
|
constructor(configuration = DefaultConfig) {
|
|
71
76
|
this.configuration = configuration;
|
|
77
|
+
this.fetchApi = (url, init) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
let fetchParams = { url, init };
|
|
79
|
+
for (const middleware of this.middleware) {
|
|
80
|
+
if (middleware.pre) {
|
|
81
|
+
fetchParams = (yield middleware.pre(Object.assign({ fetch: this.fetchApi }, fetchParams))) || fetchParams;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
let response = undefined;
|
|
85
|
+
try {
|
|
86
|
+
response = yield (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
for (const middleware of this.middleware) {
|
|
90
|
+
if (middleware.onError) {
|
|
91
|
+
response = (yield middleware.onError({
|
|
92
|
+
fetch: this.fetchApi,
|
|
93
|
+
url: fetchParams.url,
|
|
94
|
+
init: fetchParams.init,
|
|
95
|
+
error: e,
|
|
96
|
+
response: response ? response.clone() : undefined,
|
|
97
|
+
})) || response;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (response === undefined) {
|
|
101
|
+
if (e instanceof Error) {
|
|
102
|
+
throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response');
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
throw e;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
for (const middleware of this.middleware) {
|
|
110
|
+
if (middleware.post) {
|
|
111
|
+
response = (yield middleware.post({
|
|
112
|
+
fetch: this.fetchApi,
|
|
113
|
+
url: fetchParams.url,
|
|
114
|
+
init: fetchParams.init,
|
|
115
|
+
response: response.clone(),
|
|
116
|
+
})) || response;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return response;
|
|
120
|
+
});
|
|
72
121
|
this.middleware = configuration.middleware;
|
|
73
122
|
}
|
|
74
123
|
withMiddleware(...middlewares) {
|
|
@@ -100,105 +149,56 @@ export class BaseAPI {
|
|
|
100
149
|
}
|
|
101
150
|
return BaseAPI.jsonRegex.test(mime);
|
|
102
151
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
152
|
+
request(context, initOverrides) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
const { url, init } = yield this.createFetchParams(context, initOverrides);
|
|
155
|
+
const response = yield this.fetchApi(url, init);
|
|
156
|
+
if (response && (response.status >= 200 && response.status < 300)) {
|
|
157
|
+
return response;
|
|
158
|
+
}
|
|
159
|
+
throw new ResponseError(response, 'Response returned an error code');
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
createFetchParams(context, initOverrides) {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
let url = this.configuration.basePath + context.path;
|
|
165
|
+
if (context.query !== undefined && Object.keys(context.query).length !== 0) {
|
|
166
|
+
// only add the querystring to the URL if there are query parameters.
|
|
167
|
+
// this is done to avoid urls ending with a "?" character which buggy webservers
|
|
168
|
+
// do not handle correctly sometimes.
|
|
169
|
+
url += '?' + this.configuration.queryParamsStringify(context.query);
|
|
170
|
+
}
|
|
171
|
+
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
|
172
|
+
Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {});
|
|
173
|
+
const initOverrideFn = typeof initOverrides === "function"
|
|
174
|
+
? initOverrides
|
|
175
|
+
: () => __awaiter(this, void 0, void 0, function* () { return initOverrides; });
|
|
176
|
+
const initParams = {
|
|
177
|
+
method: context.method,
|
|
178
|
+
headers,
|
|
179
|
+
body: context.body,
|
|
180
|
+
credentials: this.configuration.credentials,
|
|
181
|
+
};
|
|
182
|
+
const overriddenInit = Object.assign(Object.assign({}, initParams), (yield initOverrideFn({
|
|
133
183
|
init: initParams,
|
|
134
184
|
context,
|
|
135
|
-
}))
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
body = overriddenInit.body;
|
|
142
|
-
}
|
|
143
|
-
else if (this.isJsonMime(headers['Content-Type'])) {
|
|
144
|
-
body = JSON.stringify(overriddenInit.body);
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
body = overriddenInit.body;
|
|
148
|
-
}
|
|
149
|
-
const init = {
|
|
150
|
-
...overriddenInit,
|
|
151
|
-
body
|
|
152
|
-
};
|
|
153
|
-
return { url, init };
|
|
154
|
-
}
|
|
155
|
-
fetchApi = async (url, init) => {
|
|
156
|
-
let fetchParams = { url, init };
|
|
157
|
-
for (const middleware of this.middleware) {
|
|
158
|
-
if (middleware.pre) {
|
|
159
|
-
fetchParams = await middleware.pre({
|
|
160
|
-
fetch: this.fetchApi,
|
|
161
|
-
...fetchParams,
|
|
162
|
-
}) || fetchParams;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
let response = undefined;
|
|
166
|
-
try {
|
|
167
|
-
response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
|
|
168
|
-
}
|
|
169
|
-
catch (e) {
|
|
170
|
-
for (const middleware of this.middleware) {
|
|
171
|
-
if (middleware.onError) {
|
|
172
|
-
response = await middleware.onError({
|
|
173
|
-
fetch: this.fetchApi,
|
|
174
|
-
url: fetchParams.url,
|
|
175
|
-
init: fetchParams.init,
|
|
176
|
-
error: e,
|
|
177
|
-
response: response ? response.clone() : undefined,
|
|
178
|
-
}) || response;
|
|
179
|
-
}
|
|
185
|
+
})));
|
|
186
|
+
let body;
|
|
187
|
+
if (isFormData(overriddenInit.body)
|
|
188
|
+
|| (overriddenInit.body instanceof URLSearchParams)
|
|
189
|
+
|| isBlob(overriddenInit.body)) {
|
|
190
|
+
body = overriddenInit.body;
|
|
180
191
|
}
|
|
181
|
-
if (
|
|
182
|
-
|
|
183
|
-
throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response');
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
throw e;
|
|
187
|
-
}
|
|
192
|
+
else if (this.isJsonMime(headers['Content-Type'])) {
|
|
193
|
+
body = JSON.stringify(overriddenInit.body);
|
|
188
194
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if (middleware.post) {
|
|
192
|
-
response = await middleware.post({
|
|
193
|
-
fetch: this.fetchApi,
|
|
194
|
-
url: fetchParams.url,
|
|
195
|
-
init: fetchParams.init,
|
|
196
|
-
response: response.clone(),
|
|
197
|
-
}) || response;
|
|
195
|
+
else {
|
|
196
|
+
body = overriddenInit.body;
|
|
198
197
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
198
|
+
const init = Object.assign(Object.assign({}, overriddenInit), { body });
|
|
199
|
+
return { url, init };
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
202
|
/**
|
|
203
203
|
* Create a shallow clone of `this` by constructing a new instance
|
|
204
204
|
* and then shallow cloning data members.
|
|
@@ -210,6 +210,7 @@ export class BaseAPI {
|
|
|
210
210
|
return next;
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
|
+
BaseAPI.jsonRegex = new RegExp('^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i');
|
|
213
214
|
;
|
|
214
215
|
function isBlob(value) {
|
|
215
216
|
return typeof Blob !== 'undefined' && value instanceof Blob;
|
|
@@ -218,27 +219,24 @@ function isFormData(value) {
|
|
|
218
219
|
return typeof FormData !== "undefined" && value instanceof FormData;
|
|
219
220
|
}
|
|
220
221
|
export class ResponseError extends Error {
|
|
221
|
-
response;
|
|
222
|
-
name = "ResponseError";
|
|
223
222
|
constructor(response, msg) {
|
|
224
223
|
super(msg);
|
|
225
224
|
this.response = response;
|
|
225
|
+
this.name = "ResponseError";
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
export class FetchError extends Error {
|
|
229
|
-
cause;
|
|
230
|
-
name = "FetchError";
|
|
231
229
|
constructor(cause, msg) {
|
|
232
230
|
super(msg);
|
|
233
231
|
this.cause = cause;
|
|
232
|
+
this.name = "FetchError";
|
|
234
233
|
}
|
|
235
234
|
}
|
|
236
235
|
export class RequiredError extends Error {
|
|
237
|
-
field;
|
|
238
|
-
name = "RequiredError";
|
|
239
236
|
constructor(field, msg) {
|
|
240
237
|
super(msg);
|
|
241
238
|
this.field = field;
|
|
239
|
+
this.name = "RequiredError";
|
|
242
240
|
}
|
|
243
241
|
}
|
|
244
242
|
export const COLLECTION_FORMATS = {
|
|
@@ -292,42 +290,45 @@ export function canConsumeForm(consumes) {
|
|
|
292
290
|
return false;
|
|
293
291
|
}
|
|
294
292
|
export class JSONApiResponse {
|
|
295
|
-
raw;
|
|
296
|
-
transformer;
|
|
297
293
|
constructor(raw, transformer = (jsonValue) => jsonValue) {
|
|
298
294
|
this.raw = raw;
|
|
299
295
|
this.transformer = transformer;
|
|
300
296
|
}
|
|
301
|
-
|
|
302
|
-
return this
|
|
297
|
+
value() {
|
|
298
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
299
|
+
return this.transformer(yield this.raw.json());
|
|
300
|
+
});
|
|
303
301
|
}
|
|
304
302
|
}
|
|
305
303
|
export class VoidApiResponse {
|
|
306
|
-
raw;
|
|
307
304
|
constructor(raw) {
|
|
308
305
|
this.raw = raw;
|
|
309
306
|
}
|
|
310
|
-
|
|
311
|
-
return
|
|
307
|
+
value() {
|
|
308
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
309
|
+
return undefined;
|
|
310
|
+
});
|
|
312
311
|
}
|
|
313
312
|
}
|
|
314
313
|
export class BlobApiResponse {
|
|
315
|
-
raw;
|
|
316
314
|
constructor(raw) {
|
|
317
315
|
this.raw = raw;
|
|
318
316
|
}
|
|
319
|
-
|
|
320
|
-
return
|
|
317
|
+
value() {
|
|
318
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
319
|
+
return yield this.raw.blob();
|
|
320
|
+
});
|
|
321
321
|
}
|
|
322
322
|
;
|
|
323
323
|
}
|
|
324
324
|
export class TextApiResponse {
|
|
325
|
-
raw;
|
|
326
325
|
constructor(raw) {
|
|
327
326
|
this.raw = raw;
|
|
328
327
|
}
|
|
329
|
-
|
|
330
|
-
return
|
|
328
|
+
value() {
|
|
329
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
330
|
+
return yield this.raw.text();
|
|
331
|
+
});
|
|
331
332
|
}
|
|
332
333
|
;
|
|
333
334
|
}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { Centrifuge } from "@chainstream-io/centrifuge";
|
|
2
11
|
import { replaceFilterFields } from "./stream.fields";
|
|
3
12
|
export class StreamApi {
|
|
4
|
-
realtimeClient;
|
|
5
|
-
listenersMap;
|
|
6
13
|
constructor(context) {
|
|
7
14
|
const realtimeEndpoint = context.streamUrl;
|
|
8
15
|
this.realtimeClient = new Centrifuge(realtimeEndpoint, {
|
|
9
|
-
getToken:
|
|
16
|
+
getToken: (_ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
10
17
|
return typeof context.accessToken === "string"
|
|
11
18
|
? context.accessToken
|
|
12
|
-
:
|
|
13
|
-
},
|
|
19
|
+
: yield context.accessToken.getToken();
|
|
20
|
+
}),
|
|
14
21
|
});
|
|
15
22
|
this.realtimeClient
|
|
16
23
|
.on("connected", () => {
|
|
@@ -81,10 +88,7 @@ export class StreamApi {
|
|
|
81
88
|
console.log("[xrealtime] create new sub: ", channel);
|
|
82
89
|
// Process filter expression with method-specific field mappings
|
|
83
90
|
const processedFilter = filter && methodName ? replaceFilterFields(filter, methodName) : filter;
|
|
84
|
-
sub = this.realtimeClient.newSubscription(channel, {
|
|
85
|
-
delta: "fossil",
|
|
86
|
-
...(processedFilter && { filter: processedFilter }),
|
|
87
|
-
});
|
|
91
|
+
sub = this.realtimeClient.newSubscription(channel, Object.assign({ delta: "fossil" }, (processedFilter && { filter: processedFilter })));
|
|
88
92
|
sub
|
|
89
93
|
.on("subscribed", () => {
|
|
90
94
|
console.log("[xrealtime] subscribed", channel);
|
|
@@ -94,11 +98,11 @@ export class StreamApi {
|
|
|
94
98
|
})
|
|
95
99
|
.on("publication", (ctx) => {
|
|
96
100
|
// console.log('[xrealtime] publication, ctx.data: ', ctx.data);
|
|
97
|
-
listeners
|
|
101
|
+
listeners === null || listeners === void 0 ? void 0 : listeners.forEach((it) => it(ctx.data));
|
|
98
102
|
})
|
|
99
103
|
.subscribe();
|
|
100
104
|
}
|
|
101
|
-
listeners
|
|
105
|
+
listeners === null || listeners === void 0 ? void 0 : listeners.add(fn);
|
|
102
106
|
return new StreamUnsubscrible(this, channel, fn);
|
|
103
107
|
}
|
|
104
108
|
unsubscribe(channel, fn) {
|
|
@@ -269,44 +273,45 @@ export class StreamApi {
|
|
|
269
273
|
imageUrl: it.iu,
|
|
270
274
|
description: it.de,
|
|
271
275
|
socialMedia: (() => {
|
|
276
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
272
277
|
const socialMedia = {};
|
|
273
|
-
if (it.sm
|
|
278
|
+
if ((_a = it.sm) === null || _a === void 0 ? void 0 : _a.tw) {
|
|
274
279
|
socialMedia.twitter = it.sm.tw;
|
|
275
280
|
}
|
|
276
|
-
if (it.sm
|
|
281
|
+
if ((_b = it.sm) === null || _b === void 0 ? void 0 : _b.tg) {
|
|
277
282
|
socialMedia.telegram = it.sm.tg;
|
|
278
283
|
}
|
|
279
|
-
if (it.sm
|
|
284
|
+
if ((_c = it.sm) === null || _c === void 0 ? void 0 : _c.w) {
|
|
280
285
|
socialMedia.website = it.sm.w;
|
|
281
286
|
}
|
|
282
|
-
if (it.sm
|
|
287
|
+
if ((_d = it.sm) === null || _d === void 0 ? void 0 : _d.tt) {
|
|
283
288
|
socialMedia.tiktok = it.sm.tt;
|
|
284
289
|
}
|
|
285
|
-
if (it.sm
|
|
290
|
+
if ((_e = it.sm) === null || _e === void 0 ? void 0 : _e.dc) {
|
|
286
291
|
socialMedia.discord = it.sm.dc;
|
|
287
292
|
}
|
|
288
|
-
if (it.sm
|
|
293
|
+
if ((_f = it.sm) === null || _f === void 0 ? void 0 : _f.fb) {
|
|
289
294
|
socialMedia.facebook = it.sm.fb;
|
|
290
295
|
}
|
|
291
|
-
if (it.sm
|
|
296
|
+
if ((_g = it.sm) === null || _g === void 0 ? void 0 : _g.gh) {
|
|
292
297
|
socialMedia.github = it.sm.gh;
|
|
293
298
|
}
|
|
294
|
-
if (it.sm
|
|
299
|
+
if ((_h = it.sm) === null || _h === void 0 ? void 0 : _h.ig) {
|
|
295
300
|
socialMedia.instagram = it.sm.ig;
|
|
296
301
|
}
|
|
297
|
-
if (it.sm
|
|
302
|
+
if ((_j = it.sm) === null || _j === void 0 ? void 0 : _j.li) {
|
|
298
303
|
socialMedia.linkedin = it.sm.li;
|
|
299
304
|
}
|
|
300
|
-
if (it.sm
|
|
305
|
+
if ((_k = it.sm) === null || _k === void 0 ? void 0 : _k.md) {
|
|
301
306
|
socialMedia.medium = it.sm.md;
|
|
302
307
|
}
|
|
303
|
-
if (it.sm
|
|
308
|
+
if ((_l = it.sm) === null || _l === void 0 ? void 0 : _l.rd) {
|
|
304
309
|
socialMedia.reddit = it.sm.rd;
|
|
305
310
|
}
|
|
306
|
-
if (it.sm
|
|
311
|
+
if ((_m = it.sm) === null || _m === void 0 ? void 0 : _m.yt) {
|
|
307
312
|
socialMedia.youtube = it.sm.yt;
|
|
308
313
|
}
|
|
309
|
-
if (it.sm
|
|
314
|
+
if ((_o = it.sm) === null || _o === void 0 ? void 0 : _o.bb) {
|
|
310
315
|
socialMedia.bitbucket = it.sm.bb;
|
|
311
316
|
}
|
|
312
317
|
return socialMedia;
|
|
@@ -357,7 +362,7 @@ export class StreamApi {
|
|
|
357
362
|
}
|
|
358
363
|
subscribeRankingTokensLiquidity({ chain, channelType, callback, }) {
|
|
359
364
|
const channel = `dex-ranking-token-general_stat_num-list:${chain}_${channelType}`;
|
|
360
|
-
return this.subscribe(channel, (data) => callback(data
|
|
365
|
+
return this.subscribe(channel, (data) => callback(data === null || data === void 0 ? void 0 : data.map((it) => ({
|
|
361
366
|
tokenAddress: it.a,
|
|
362
367
|
metricType: it.t,
|
|
363
368
|
value: it.v,
|
|
@@ -368,7 +373,7 @@ export class StreamApi {
|
|
|
368
373
|
const channel = dex
|
|
369
374
|
? `dex-ranking-list:${chain}_${ranking_type}_${dex}`
|
|
370
375
|
: `dex-ranking-list:${chain}_${ranking_type}`;
|
|
371
|
-
return this.subscribe(channel, (data) => callback(data
|
|
376
|
+
return this.subscribe(channel, (data) => callback(data === null || data === void 0 ? void 0 : data.map((item) => {
|
|
372
377
|
const result = {};
|
|
373
378
|
// TokenMetadata (t)
|
|
374
379
|
if (item.t) {
|
|
@@ -723,7 +728,7 @@ export class StreamApi {
|
|
|
723
728
|
}
|
|
724
729
|
subscribeRankingTokensStats({ chain, channelType, callback, }) {
|
|
725
730
|
const channel = `dex-ranking-token-stats-list:${chain}_${channelType}`;
|
|
726
|
-
return this.subscribe(channel, (data) => callback(data
|
|
731
|
+
return this.subscribe(channel, (data) => callback(data === null || data === void 0 ? void 0 : data.map((it) => ({
|
|
727
732
|
address: it.a,
|
|
728
733
|
timestamp: it.t,
|
|
729
734
|
buys1m: it.b1m,
|
|
@@ -794,7 +799,7 @@ export class StreamApi {
|
|
|
794
799
|
}
|
|
795
800
|
subscribeRankingTokensHolders({ chain, channelType, callback, }) {
|
|
796
801
|
const channel = `dex-ranking-token-holding-list:${chain}_${channelType}`;
|
|
797
|
-
return this.subscribe(channel, (data) => callback(data
|
|
802
|
+
return this.subscribe(channel, (data) => callback(data === null || data === void 0 ? void 0 : data.map((it) => ({
|
|
798
803
|
tokenAddress: it.a,
|
|
799
804
|
holders: it.h,
|
|
800
805
|
top100Amount: this.formatScientificNotation(it.t100a),
|
|
@@ -808,7 +813,7 @@ export class StreamApi {
|
|
|
808
813
|
}
|
|
809
814
|
subscribeRankingTokensSupply({ chain, channelType, callback, }) {
|
|
810
815
|
const channel = `dex-ranking-token-supply-list:${chain}_${channelType}`;
|
|
811
|
-
return this.subscribe(channel, (data) => callback(data
|
|
816
|
+
return this.subscribe(channel, (data) => callback(data === null || data === void 0 ? void 0 : data.map((it) => ({
|
|
812
817
|
tokenAddress: it.a,
|
|
813
818
|
supply: it.s,
|
|
814
819
|
marketCapInUsd: it.mc,
|
|
@@ -817,7 +822,7 @@ export class StreamApi {
|
|
|
817
822
|
}
|
|
818
823
|
subscribeRankingTokensBondingCurve({ chain, callback, }) {
|
|
819
824
|
const channel = `dex-ranking-token-bounding-curve-list:${chain}_new`;
|
|
820
|
-
return this.subscribe(channel, (data) => callback(data
|
|
825
|
+
return this.subscribe(channel, (data) => callback(data === null || data === void 0 ? void 0 : data.map((it) => ({
|
|
821
826
|
tokenAddress: it.a,
|
|
822
827
|
progressRatio: it.pr,
|
|
823
828
|
}))));
|
|
@@ -900,7 +905,7 @@ export class StreamApi {
|
|
|
900
905
|
}
|
|
901
906
|
subscribeWalletPnlList({ chain, walletAddress, callback, }) {
|
|
902
907
|
const channel = `dex-wallet-pnl-list:${chain}_${walletAddress}`;
|
|
903
|
-
return this.subscribe(channel, (data) => callback(data
|
|
908
|
+
return this.subscribe(channel, (data) => callback(data === null || data === void 0 ? void 0 : data.map((it) => ({
|
|
904
909
|
walletAddress: it.a,
|
|
905
910
|
buys: it.bs,
|
|
906
911
|
buyAmount: it.ba,
|
|
@@ -974,9 +979,6 @@ export class StreamApi {
|
|
|
974
979
|
}
|
|
975
980
|
}
|
|
976
981
|
class StreamUnsubscrible {
|
|
977
|
-
streamApi;
|
|
978
|
-
channel;
|
|
979
|
-
fn;
|
|
980
982
|
constructor(streamApi, channel, fn) {
|
|
981
983
|
this.streamApi = streamApi;
|
|
982
984
|
this.channel = channel;
|