@metamask/social-controllers 2.8.1 → 3.0.0
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/CHANGELOG.md +17 -1
- package/dist/{SocialController-method-action-types.d.mts → SocialController-method-action-types.d.ts} +2 -2
- package/dist/SocialController-method-action-types.d.ts.map +1 -0
- package/dist/{SocialController-method-action-types.mjs → SocialController-method-action-types.js} +1 -1
- package/dist/SocialController-method-action-types.js.map +1 -0
- package/dist/{SocialController.d.mts → SocialController.d.ts} +8 -8
- package/dist/SocialController.d.ts.map +1 -0
- package/dist/{SocialController.mjs → SocialController.js} +3 -3
- package/dist/SocialController.js.map +1 -0
- package/dist/{SocialService-method-action-types.d.cts → SocialService-method-action-types.d.ts} +2 -2
- package/dist/SocialService-method-action-types.d.ts.map +1 -0
- package/dist/{SocialService-method-action-types.mjs → SocialService-method-action-types.js} +1 -1
- package/dist/SocialService-method-action-types.js.map +1 -0
- package/dist/{SocialService.d.cts → SocialService.d.ts} +9 -9
- package/dist/SocialService.d.ts.map +1 -0
- package/dist/{SocialService.mjs → SocialService.js} +128 -131
- package/dist/SocialService.js.map +1 -0
- package/dist/{index.d.cts → index.d.ts} +10 -10
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/social-constants.d.ts +28 -0
- package/dist/social-constants.d.ts.map +1 -0
- package/dist/{social-constants.mjs → social-constants.js} +1 -1
- package/dist/social-constants.js.map +1 -0
- package/dist/{social-types.d.mts → social-types.d.ts} +14 -14
- package/dist/social-types.d.ts.map +1 -0
- package/dist/{social-types.mjs → social-types.js} +2 -2
- package/dist/social-types.js.map +1 -0
- package/package.json +17 -21
- package/dist/SocialController-method-action-types.cjs +0 -7
- package/dist/SocialController-method-action-types.cjs.map +0 -1
- package/dist/SocialController-method-action-types.d.cts +0 -71
- package/dist/SocialController-method-action-types.d.cts.map +0 -1
- package/dist/SocialController-method-action-types.d.mts.map +0 -1
- package/dist/SocialController-method-action-types.mjs.map +0 -1
- package/dist/SocialController.cjs +0 -160
- package/dist/SocialController.cjs.map +0 -1
- package/dist/SocialController.d.cts +0 -80
- package/dist/SocialController.d.cts.map +0 -1
- package/dist/SocialController.d.mts.map +0 -1
- package/dist/SocialController.mjs.map +0 -1
- package/dist/SocialService-method-action-types.cjs +0 -7
- package/dist/SocialService-method-action-types.cjs.map +0 -1
- package/dist/SocialService-method-action-types.d.cts.map +0 -1
- package/dist/SocialService-method-action-types.d.mts +0 -194
- package/dist/SocialService-method-action-types.d.mts.map +0 -1
- package/dist/SocialService-method-action-types.mjs.map +0 -1
- package/dist/SocialService.cjs +0 -635
- package/dist/SocialService.cjs.map +0 -1
- package/dist/SocialService.d.cts.map +0 -1
- package/dist/SocialService.d.mts +0 -171
- package/dist/SocialService.d.mts.map +0 -1
- package/dist/SocialService.mjs.map +0 -1
- package/dist/index.cjs +0 -14
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts +0 -10
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -5
- package/dist/index.mjs.map +0 -1
- package/dist/social-constants.cjs +0 -31
- package/dist/social-constants.cjs.map +0 -1
- package/dist/social-constants.d.cts +0 -28
- package/dist/social-constants.d.cts.map +0 -1
- package/dist/social-constants.d.mts +0 -28
- package/dist/social-constants.d.mts.map +0 -1
- package/dist/social-constants.mjs.map +0 -1
- package/dist/social-types.cjs +0 -27
- package/dist/social-types.cjs.map +0 -1
- package/dist/social-types.d.cts +0 -343
- package/dist/social-types.d.cts.map +0 -1
- package/dist/social-types.d.mts.map +0 -1
- package/dist/social-types.mjs.map +0 -1
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
-
};
|
|
12
|
-
var _SocialService_instances, _a, _SocialService_baseUrl, _SocialService_v1Url_get, _SocialService_v2Url_get, _SocialService_throwIfNotOk, _SocialService_getAuthHeaders, _SocialService_fetchPositions;
|
|
13
|
-
import { BaseDataService } from "@metamask/base-data-service";
|
|
14
|
-
import { HttpError } from "@metamask/controller-utils";
|
|
15
|
-
import { array, assign, boolean, enums, is, nullable, number, optional, record, string, type as structType } from "@metamask/superstruct";
|
|
16
|
-
import { serviceName, SocialServiceErrorMessage } from "./social-constants.mjs";
|
|
17
|
-
import { TradeStruct } from "./social-types.mjs";
|
|
1
|
+
var _a;
|
|
2
|
+
import { BaseDataService } from '@metamask/base-data-service';
|
|
3
|
+
import { HttpError } from '@metamask/controller-utils';
|
|
4
|
+
import { array, assign, boolean, enums, is, nullable, number, optional, record, string, type as structType, } from '@metamask/superstruct';
|
|
5
|
+
import { serviceName, SocialServiceErrorMessage } from './social-constants.js';
|
|
6
|
+
import { TradeStruct } from './social-types.js';
|
|
18
7
|
// ---------------------------------------------------------------------------
|
|
19
8
|
// Superstruct validation schemas
|
|
20
9
|
// ---------------------------------------------------------------------------
|
|
@@ -170,13 +159,39 @@ const MESSENGER_EXPOSED_METHODS = [
|
|
|
170
159
|
* Data service wrapping social-api endpoints.
|
|
171
160
|
*/
|
|
172
161
|
export class SocialService extends BaseDataService {
|
|
162
|
+
#baseUrl;
|
|
163
|
+
get #v1Url() {
|
|
164
|
+
return `${this.#baseUrl}/api/v1`;
|
|
165
|
+
}
|
|
166
|
+
get #v2Url() {
|
|
167
|
+
return `${this.#baseUrl}/api/v2`;
|
|
168
|
+
}
|
|
173
169
|
constructor({ messenger, baseUrl, policyOptions, }) {
|
|
174
170
|
super({ name: serviceName, messenger, policyOptions });
|
|
175
|
-
|
|
176
|
-
_SocialService_baseUrl.set(this, void 0);
|
|
177
|
-
__classPrivateFieldSet(this, _SocialService_baseUrl, baseUrl, "f");
|
|
171
|
+
this.#baseUrl = baseUrl;
|
|
178
172
|
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
179
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Throws an HttpError if the response is not ok.
|
|
176
|
+
*
|
|
177
|
+
* @param response - The fetch response to check.
|
|
178
|
+
* @param message - The error message prefix from SocialServiceErrorMessage.
|
|
179
|
+
*/
|
|
180
|
+
static #throwIfNotOk(response, message) {
|
|
181
|
+
if (!response.ok) {
|
|
182
|
+
throw new HttpError(response.status, `${message}: ${response.status}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Returns an Authorization header with a JWT bearer token obtained from the
|
|
187
|
+
* AuthenticationController.
|
|
188
|
+
*
|
|
189
|
+
* @returns A headers object containing the Authorization header.
|
|
190
|
+
*/
|
|
191
|
+
async #getAuthHeaders() {
|
|
192
|
+
const token = await this.messenger.call('AuthenticationController:getBearerToken');
|
|
193
|
+
return { Authorization: `Bearer ${token}` };
|
|
194
|
+
}
|
|
180
195
|
/**
|
|
181
196
|
* Fetches the leaderboard of top traders.
|
|
182
197
|
*
|
|
@@ -190,7 +205,7 @@ export class SocialService extends BaseDataService {
|
|
|
190
205
|
queryKey: [`${this.name}:fetchLeaderboard`, options ?? null],
|
|
191
206
|
queryFn: async () => {
|
|
192
207
|
const { sort, chains, limit } = options ?? {};
|
|
193
|
-
const url = new URL(`${
|
|
208
|
+
const url = new URL(`${this.#v1Url}/leaderboard`);
|
|
194
209
|
if (sort) {
|
|
195
210
|
url.searchParams.append('sort', sort);
|
|
196
211
|
}
|
|
@@ -202,11 +217,11 @@ export class SocialService extends BaseDataService {
|
|
|
202
217
|
if (limit !== undefined) {
|
|
203
218
|
url.searchParams.append('limit', String(limit));
|
|
204
219
|
}
|
|
205
|
-
const authHeaders = await
|
|
220
|
+
const authHeaders = await this.#getAuthHeaders();
|
|
206
221
|
const response = await fetch(url.toString(), {
|
|
207
222
|
headers: authHeaders,
|
|
208
223
|
});
|
|
209
|
-
|
|
224
|
+
_a.#throwIfNotOk(response, SocialServiceErrorMessage.FETCH_LEADERBOARD_FAILED);
|
|
210
225
|
const leaderboardData = await response.json();
|
|
211
226
|
if (!is(leaderboardData, LeaderboardResponseStruct)) {
|
|
212
227
|
throw new Error(SocialServiceErrorMessage.FETCH_LEADERBOARD_INVALID_RESPONSE);
|
|
@@ -230,10 +245,10 @@ export class SocialService extends BaseDataService {
|
|
|
230
245
|
const traderProfileResponse = await this.fetchQuery({
|
|
231
246
|
queryKey: [`${this.name}:fetchTraderProfile`, addressOrId],
|
|
232
247
|
queryFn: async () => {
|
|
233
|
-
const url = `${
|
|
234
|
-
const authHeaders = await
|
|
248
|
+
const url = `${this.#v1Url}/traders/${encodeURIComponent(addressOrId)}/profile`;
|
|
249
|
+
const authHeaders = await this.#getAuthHeaders();
|
|
235
250
|
const response = await fetch(url, { headers: authHeaders });
|
|
236
|
-
|
|
251
|
+
_a.#throwIfNotOk(response, SocialServiceErrorMessage.FETCH_TRADER_PROFILE_FAILED);
|
|
237
252
|
const traderProfileData = await response.json();
|
|
238
253
|
if (!is(traderProfileData, TraderProfileResponseStruct)) {
|
|
239
254
|
throw new Error(SocialServiceErrorMessage.FETCH_TRADER_PROFILE_INVALID_RESPONSE);
|
|
@@ -257,7 +272,7 @@ export class SocialService extends BaseDataService {
|
|
|
257
272
|
* @returns The positions response.
|
|
258
273
|
*/
|
|
259
274
|
async fetchOpenPositions(options) {
|
|
260
|
-
return
|
|
275
|
+
return this.#fetchPositions('open', options);
|
|
261
276
|
}
|
|
262
277
|
/**
|
|
263
278
|
* Fetches a trader's closed positions.
|
|
@@ -273,7 +288,7 @@ export class SocialService extends BaseDataService {
|
|
|
273
288
|
* @returns The positions response.
|
|
274
289
|
*/
|
|
275
290
|
async fetchClosedPositions(options) {
|
|
276
|
-
return
|
|
291
|
+
return this.#fetchPositions('closed', options);
|
|
277
292
|
}
|
|
278
293
|
/**
|
|
279
294
|
* Fetches a trader's MetaMask followers.
|
|
@@ -289,10 +304,10 @@ export class SocialService extends BaseDataService {
|
|
|
289
304
|
const followersResponse = await this.fetchQuery({
|
|
290
305
|
queryKey: [`${this.name}:fetchFollowers`, addressOrId],
|
|
291
306
|
queryFn: async () => {
|
|
292
|
-
const url = `${
|
|
293
|
-
const authHeaders = await
|
|
307
|
+
const url = `${this.#v1Url}/traders/${encodeURIComponent(addressOrId)}/followers`;
|
|
308
|
+
const authHeaders = await this.#getAuthHeaders();
|
|
294
309
|
const response = await fetch(url, { headers: authHeaders });
|
|
295
|
-
|
|
310
|
+
_a.#throwIfNotOk(response, SocialServiceErrorMessage.FETCH_FOLLOWERS_FAILED);
|
|
296
311
|
const followersData = await response.json();
|
|
297
312
|
if (!is(followersData, FollowersResponseStruct)) {
|
|
298
313
|
throw new Error(SocialServiceErrorMessage.FETCH_FOLLOWERS_INVALID_RESPONSE);
|
|
@@ -316,10 +331,10 @@ export class SocialService extends BaseDataService {
|
|
|
316
331
|
const positionResponse = await this.fetchQuery({
|
|
317
332
|
queryKey: [`${this.name}:fetchPositionById`, positionId],
|
|
318
333
|
queryFn: async () => {
|
|
319
|
-
const url = `${
|
|
320
|
-
const authHeaders = await
|
|
334
|
+
const url = `${this.#v1Url}/traders/position/${encodeURIComponent(positionId)}`;
|
|
335
|
+
const authHeaders = await this.#getAuthHeaders();
|
|
321
336
|
const response = await fetch(url, { headers: authHeaders });
|
|
322
|
-
|
|
337
|
+
_a.#throwIfNotOk(response, SocialServiceErrorMessage.FETCH_POSITION_BY_ID_FAILED);
|
|
323
338
|
const positionData = await response.json();
|
|
324
339
|
if (!is(positionData, PositionStruct)) {
|
|
325
340
|
throw new Error(SocialServiceErrorMessage.FETCH_POSITION_BY_ID_INVALID_RESPONSE);
|
|
@@ -354,7 +369,7 @@ export class SocialService extends BaseDataService {
|
|
|
354
369
|
staleTime: 0,
|
|
355
370
|
queryFn: async () => {
|
|
356
371
|
const { scope, chains, limit, olderThan, newerThan } = options ?? {};
|
|
357
|
-
const url = new URL(`${
|
|
372
|
+
const url = new URL(`${this.#v1Url}/feed`);
|
|
358
373
|
if (scope) {
|
|
359
374
|
url.searchParams.append('scope', scope);
|
|
360
375
|
}
|
|
@@ -372,11 +387,11 @@ export class SocialService extends BaseDataService {
|
|
|
372
387
|
if (newerThan) {
|
|
373
388
|
url.searchParams.append('newerThan', newerThan);
|
|
374
389
|
}
|
|
375
|
-
const authHeaders = await
|
|
390
|
+
const authHeaders = await this.#getAuthHeaders();
|
|
376
391
|
const response = await fetch(url.toString(), {
|
|
377
392
|
headers: authHeaders,
|
|
378
393
|
});
|
|
379
|
-
|
|
394
|
+
_a.#throwIfNotOk(response, SocialServiceErrorMessage.FETCH_FEED_FAILED);
|
|
380
395
|
const feedData = await response.json();
|
|
381
396
|
if (!is(feedData, FeedResponseStruct)) {
|
|
382
397
|
throw new Error(SocialServiceErrorMessage.FETCH_FEED_INVALID_RESPONSE);
|
|
@@ -399,10 +414,10 @@ export class SocialService extends BaseDataService {
|
|
|
399
414
|
queryKey: [`${this.name}:fetchFollowing`],
|
|
400
415
|
staleTime: 0,
|
|
401
416
|
queryFn: async () => {
|
|
402
|
-
const url = `${
|
|
403
|
-
const authHeaders = await
|
|
417
|
+
const url = `${this.#v1Url}/users/me/following`;
|
|
418
|
+
const authHeaders = await this.#getAuthHeaders();
|
|
404
419
|
const response = await fetch(url, { headers: authHeaders });
|
|
405
|
-
|
|
420
|
+
_a.#throwIfNotOk(response, SocialServiceErrorMessage.FETCH_FOLLOWING_FAILED);
|
|
406
421
|
const followingData = await response.json();
|
|
407
422
|
if (!is(followingData, FollowingResponseStruct)) {
|
|
408
423
|
throw new Error(SocialServiceErrorMessage.FETCH_FOLLOWING_INVALID_RESPONSE);
|
|
@@ -428,14 +443,14 @@ export class SocialService extends BaseDataService {
|
|
|
428
443
|
queryKey: [`${this.name}:follow`, targets],
|
|
429
444
|
staleTime: 0,
|
|
430
445
|
queryFn: async () => {
|
|
431
|
-
const url = `${
|
|
432
|
-
const authHeaders = await
|
|
446
|
+
const url = `${this.#v1Url}/users/me/follows`;
|
|
447
|
+
const authHeaders = await this.#getAuthHeaders();
|
|
433
448
|
const response = await fetch(url, {
|
|
434
449
|
method: 'PUT',
|
|
435
450
|
headers: { ...authHeaders, 'Content-Type': 'application/json' },
|
|
436
451
|
body: JSON.stringify({ targets }),
|
|
437
452
|
});
|
|
438
|
-
|
|
453
|
+
_a.#throwIfNotOk(response, SocialServiceErrorMessage.FOLLOW_FAILED);
|
|
439
454
|
const followData = await response.json();
|
|
440
455
|
if (!is(followData, FollowResponseStruct)) {
|
|
441
456
|
throw new Error(SocialServiceErrorMessage.FOLLOW_INVALID_RESPONSE);
|
|
@@ -463,16 +478,16 @@ export class SocialService extends BaseDataService {
|
|
|
463
478
|
queryKey: [`${this.name}:unfollow`, targets],
|
|
464
479
|
staleTime: 0,
|
|
465
480
|
queryFn: async () => {
|
|
466
|
-
const url = new URL(`${
|
|
481
|
+
const url = new URL(`${this.#v1Url}/users/me/follows`);
|
|
467
482
|
for (const target of targets) {
|
|
468
483
|
url.searchParams.append('targets', target);
|
|
469
484
|
}
|
|
470
|
-
const authHeaders = await
|
|
485
|
+
const authHeaders = await this.#getAuthHeaders();
|
|
471
486
|
const response = await fetch(url.toString(), {
|
|
472
487
|
method: 'DELETE',
|
|
473
488
|
headers: authHeaders,
|
|
474
489
|
});
|
|
475
|
-
|
|
490
|
+
_a.#throwIfNotOk(response, SocialServiceErrorMessage.UNFOLLOW_FAILED);
|
|
476
491
|
const unfollowData = await response.json();
|
|
477
492
|
if (!is(unfollowData, UnfollowResponseStruct)) {
|
|
478
493
|
throw new Error(SocialServiceErrorMessage.UNFOLLOW_INVALID_RESPONSE);
|
|
@@ -490,13 +505,13 @@ export class SocialService extends BaseDataService {
|
|
|
490
505
|
queryKey: [`${this.name}:optOutOfLeaderboard`],
|
|
491
506
|
staleTime: 0,
|
|
492
507
|
queryFn: async () => {
|
|
493
|
-
const url = `${
|
|
494
|
-
const authHeaders = await
|
|
508
|
+
const url = `${this.#v1Url}/leaderboard/opt-out`;
|
|
509
|
+
const authHeaders = await this.#getAuthHeaders();
|
|
495
510
|
const response = await fetch(url, {
|
|
496
511
|
method: 'POST',
|
|
497
512
|
headers: authHeaders,
|
|
498
513
|
});
|
|
499
|
-
|
|
514
|
+
_a.#throwIfNotOk(response, SocialServiceErrorMessage.LEADERBOARD_OPT_OUT_FAILED);
|
|
500
515
|
return null;
|
|
501
516
|
},
|
|
502
517
|
});
|
|
@@ -509,13 +524,13 @@ export class SocialService extends BaseDataService {
|
|
|
509
524
|
queryKey: [`${this.name}:optInToLeaderboard`],
|
|
510
525
|
staleTime: 0,
|
|
511
526
|
queryFn: async () => {
|
|
512
|
-
const url = `${
|
|
513
|
-
const authHeaders = await
|
|
527
|
+
const url = `${this.#v1Url}/leaderboard/opt-in`;
|
|
528
|
+
const authHeaders = await this.#getAuthHeaders();
|
|
514
529
|
const response = await fetch(url, {
|
|
515
530
|
method: 'POST',
|
|
516
531
|
headers: authHeaders,
|
|
517
532
|
});
|
|
518
|
-
|
|
533
|
+
_a.#throwIfNotOk(response, SocialServiceErrorMessage.LEADERBOARD_OPT_IN_FAILED);
|
|
519
534
|
return null;
|
|
520
535
|
},
|
|
521
536
|
});
|
|
@@ -541,91 +556,73 @@ export class SocialService extends BaseDataService {
|
|
|
541
556
|
queryKey: [`${this.name}:refreshNotificationPreferencesCache`],
|
|
542
557
|
staleTime: 0,
|
|
543
558
|
queryFn: async () => {
|
|
544
|
-
const url = `${
|
|
545
|
-
const authHeaders = await
|
|
559
|
+
const url = `${this.#v1Url}/notifications/preferences/cache-refresh`;
|
|
560
|
+
const authHeaders = await this.#getAuthHeaders();
|
|
546
561
|
const response = await fetch(url, {
|
|
547
562
|
method: 'POST',
|
|
548
563
|
headers: authHeaders,
|
|
549
564
|
});
|
|
550
|
-
|
|
565
|
+
_a.#throwIfNotOk(response, SocialServiceErrorMessage.NOTIFICATION_PREFERENCES_CACHE_REFRESH_FAILED);
|
|
551
566
|
return null;
|
|
552
567
|
},
|
|
553
568
|
});
|
|
554
569
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
570
|
+
/**
|
|
571
|
+
* Shared helper for fetching open/closed positions.
|
|
572
|
+
*
|
|
573
|
+
* @param status - "open" or "closed".
|
|
574
|
+
* @param options - Options bag including addressOrId and query parameters.
|
|
575
|
+
* @returns The positions response.
|
|
576
|
+
*/
|
|
577
|
+
async #fetchPositions(status, options) {
|
|
578
|
+
const { addressOrId, chain, sort, limit, page } = options;
|
|
579
|
+
const failedMessage = status === 'open'
|
|
580
|
+
? SocialServiceErrorMessage.FETCH_OPEN_POSITIONS_FAILED
|
|
581
|
+
: SocialServiceErrorMessage.FETCH_CLOSED_POSITIONS_FAILED;
|
|
582
|
+
const invalidMessage = status === 'open'
|
|
583
|
+
? SocialServiceErrorMessage.FETCH_OPEN_POSITIONS_INVALID_RESPONSE
|
|
584
|
+
: SocialServiceErrorMessage.FETCH_CLOSED_POSITIONS_INVALID_RESPONSE;
|
|
585
|
+
const positionsResponse = await this.fetchQuery({
|
|
586
|
+
queryKey: [
|
|
587
|
+
`${this.name}:fetch${status === 'open' ? 'Open' : 'Closed'}Positions`,
|
|
588
|
+
addressOrId,
|
|
589
|
+
chain ?? null,
|
|
590
|
+
// sort is not used for open positions (v2 endpoint dropped it),
|
|
591
|
+
// so exclude it from the key to avoid redundant cache entries
|
|
592
|
+
status === 'closed' ? (sort ?? null) : null,
|
|
593
|
+
limit ?? null,
|
|
594
|
+
page ?? null,
|
|
595
|
+
],
|
|
596
|
+
queryFn: async () => {
|
|
597
|
+
const baseUrl = status === 'open' ? this.#v2Url : this.#v1Url;
|
|
598
|
+
const url = new URL(`${baseUrl}/traders/${encodeURIComponent(addressOrId)}/positions/${status}`);
|
|
599
|
+
if (chain) {
|
|
600
|
+
url.searchParams.append('chain', chain);
|
|
601
|
+
}
|
|
602
|
+
// sort is not supported on the v2 open-positions endpoint
|
|
603
|
+
if (sort && status === 'closed') {
|
|
604
|
+
url.searchParams.append('sort', sort);
|
|
605
|
+
}
|
|
606
|
+
if (limit !== undefined) {
|
|
607
|
+
url.searchParams.append('limit', String(limit));
|
|
608
|
+
}
|
|
609
|
+
if (page !== undefined) {
|
|
610
|
+
url.searchParams.append('page', String(page));
|
|
611
|
+
}
|
|
612
|
+
const authHeaders = await this.#getAuthHeaders();
|
|
613
|
+
const response = await fetch(url.toString(), {
|
|
614
|
+
headers: authHeaders,
|
|
615
|
+
});
|
|
616
|
+
_a.#throwIfNotOk(response, failedMessage);
|
|
617
|
+
const positionsData = await response.json();
|
|
618
|
+
if (!is(positionsData, PositionsResponseStruct)) {
|
|
619
|
+
throw new Error(invalidMessage);
|
|
620
|
+
}
|
|
621
|
+
return positionsData;
|
|
622
|
+
},
|
|
623
|
+
});
|
|
624
|
+
return positionsResponse;
|
|
563
625
|
}
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
* AuthenticationController.
|
|
568
|
-
*
|
|
569
|
-
* @returns A headers object containing the Authorization header.
|
|
570
|
-
*/
|
|
571
|
-
async function _SocialService_getAuthHeaders() {
|
|
572
|
-
const token = await this.messenger.call('AuthenticationController:getBearerToken');
|
|
573
|
-
return { Authorization: `Bearer ${token}` };
|
|
574
|
-
}, _SocialService_fetchPositions =
|
|
575
|
-
/**
|
|
576
|
-
* Shared helper for fetching open/closed positions.
|
|
577
|
-
*
|
|
578
|
-
* @param status - "open" or "closed".
|
|
579
|
-
* @param options - Options bag including addressOrId and query parameters.
|
|
580
|
-
* @returns The positions response.
|
|
581
|
-
*/
|
|
582
|
-
async function _SocialService_fetchPositions(status, options) {
|
|
583
|
-
const { addressOrId, chain, sort, limit, page } = options;
|
|
584
|
-
const failedMessage = status === 'open'
|
|
585
|
-
? SocialServiceErrorMessage.FETCH_OPEN_POSITIONS_FAILED
|
|
586
|
-
: SocialServiceErrorMessage.FETCH_CLOSED_POSITIONS_FAILED;
|
|
587
|
-
const invalidMessage = status === 'open'
|
|
588
|
-
? SocialServiceErrorMessage.FETCH_OPEN_POSITIONS_INVALID_RESPONSE
|
|
589
|
-
: SocialServiceErrorMessage.FETCH_CLOSED_POSITIONS_INVALID_RESPONSE;
|
|
590
|
-
const positionsResponse = await this.fetchQuery({
|
|
591
|
-
queryKey: [
|
|
592
|
-
`${this.name}:fetch${status === 'open' ? 'Open' : 'Closed'}Positions`,
|
|
593
|
-
addressOrId,
|
|
594
|
-
chain ?? null,
|
|
595
|
-
// sort is not used for open positions (v2 endpoint dropped it),
|
|
596
|
-
// so exclude it from the key to avoid redundant cache entries
|
|
597
|
-
status === 'closed' ? (sort ?? null) : null,
|
|
598
|
-
limit ?? null,
|
|
599
|
-
page ?? null,
|
|
600
|
-
],
|
|
601
|
-
queryFn: async () => {
|
|
602
|
-
const baseUrl = status === 'open' ? __classPrivateFieldGet(this, _SocialService_instances, "a", _SocialService_v2Url_get) : __classPrivateFieldGet(this, _SocialService_instances, "a", _SocialService_v1Url_get);
|
|
603
|
-
const url = new URL(`${baseUrl}/traders/${encodeURIComponent(addressOrId)}/positions/${status}`);
|
|
604
|
-
if (chain) {
|
|
605
|
-
url.searchParams.append('chain', chain);
|
|
606
|
-
}
|
|
607
|
-
// sort is not supported on the v2 open-positions endpoint
|
|
608
|
-
if (sort && status === 'closed') {
|
|
609
|
-
url.searchParams.append('sort', sort);
|
|
610
|
-
}
|
|
611
|
-
if (limit !== undefined) {
|
|
612
|
-
url.searchParams.append('limit', String(limit));
|
|
613
|
-
}
|
|
614
|
-
if (page !== undefined) {
|
|
615
|
-
url.searchParams.append('page', String(page));
|
|
616
|
-
}
|
|
617
|
-
const authHeaders = await __classPrivateFieldGet(this, _SocialService_instances, "m", _SocialService_getAuthHeaders).call(this);
|
|
618
|
-
const response = await fetch(url.toString(), {
|
|
619
|
-
headers: authHeaders,
|
|
620
|
-
});
|
|
621
|
-
__classPrivateFieldGet(_a, _a, "m", _SocialService_throwIfNotOk).call(_a, response, failedMessage);
|
|
622
|
-
const positionsData = await response.json();
|
|
623
|
-
if (!is(positionsData, PositionsResponseStruct)) {
|
|
624
|
-
throw new Error(invalidMessage);
|
|
625
|
-
}
|
|
626
|
-
return positionsData;
|
|
627
|
-
},
|
|
628
|
-
});
|
|
629
|
-
return positionsResponse;
|
|
630
|
-
};
|
|
631
|
-
//# sourceMappingURL=SocialService.mjs.map
|
|
626
|
+
}
|
|
627
|
+
_a = SocialService;
|
|
628
|
+
//# sourceMappingURL=SocialService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SocialService.js","sourceRoot":"","sources":["../src/SocialService.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAGvD,OAAO,EACL,KAAK,EACL,MAAM,EACN,OAAO,EACP,KAAK,EACL,EAAE,EACF,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,MAAM,EACN,MAAM,EACN,IAAI,IAAI,UAAU,GACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAoB/E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,8EAA8E;AAC9E,iCAAiC;AACjC,8EAA8E;AAE9E,MAAM,mBAAmB,GAAG,UAAU,CAAC;IACrC,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACrC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACvC,GAAG,EAAE,QAA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iB,CAAC;IAC3B,CAAC;CACF","sourcesContent":["import type {\n DataServiceCacheUpdatedEvent,\n DataServiceGranularCacheUpdatedEvent,\n DataServiceInvalidateQueriesAction,\n} from '@metamask/base-data-service';\nimport { BaseDataService } from '@metamask/base-data-service';\nimport type { CreateServicePolicyOptions } from '@metamask/controller-utils';\nimport { HttpError } from '@metamask/controller-utils';\nimport type { Messenger } from '@metamask/messenger';\nimport type { AuthenticationController } from '@metamask/profile-sync-controller';\nimport {\n array,\n assign,\n boolean,\n enums,\n is,\n nullable,\n number,\n optional,\n record,\n string,\n type as structType,\n} from '@metamask/superstruct';\n\nimport { serviceName, SocialServiceErrorMessage } from './social-constants.js';\nimport type {\n FeedResponse,\n FetchFeedOptions,\n FetchFollowersOptions,\n FetchLeaderboardOptions,\n FetchPositionByIdOptions,\n FetchPositionsOptions,\n FetchTraderProfileOptions,\n FollowersResponse,\n FollowingResponse,\n FollowOptions,\n FollowResponse,\n LeaderboardResponse,\n Position,\n PositionsResponse,\n TraderProfileResponse,\n UnfollowOptions,\n UnfollowResponse,\n} from './social-types.js';\nimport { TradeStruct } from './social-types.js';\nimport type { SocialServiceMethodActions } from './SocialService-method-action-types.js';\n\n// ---------------------------------------------------------------------------\n// Superstruct validation schemas\n// ---------------------------------------------------------------------------\n\nconst SocialHandlesStruct = structType({\n twitter: optional(nullable(string())),\n farcaster: optional(nullable(string())),\n ens: optional(nullable(string())),\n lens: optional(nullable(string())),\n});\n\nconst ProfileSummaryStruct = structType({\n profileId: string(),\n address: string(),\n name: string(),\n imageUrl: optional(nullable(string())),\n});\n\nconst PositionStruct = structType({\n positionId: string(),\n tokenSymbol: string(),\n tokenName: string(),\n tokenAddress: string(),\n chain: string(),\n positionAmount: number(),\n isOpen: optional(boolean()),\n boughtUsd: number(),\n soldUsd: number(),\n realizedPnl: number(),\n costBasis: number(),\n trades: array(TradeStruct),\n lastTradeAt: number(),\n tokenImageUrl: optional(nullable(string())),\n currentValueUSD: optional(nullable(number())),\n pnlValueUsd: optional(nullable(number())),\n pnlPercent: optional(nullable(number())),\n perpPositionType: optional(nullable(enums(['long', 'short']))),\n perpLeverage: optional(nullable(number())),\n positionAmountWithLeverage: optional(nullable(number())),\n});\n\nconst PaginationStruct = structType({\n hasMore: boolean(),\n nextPage: optional(number()),\n});\n\nconst LeaderboardEntryStruct = structType({\n rank: number(),\n addresses: array(string()),\n profileId: string(),\n name: string(),\n imageUrl: optional(nullable(string())),\n pnl30d: number(),\n winRate30d: optional(nullable(number())),\n roiPercent30d: optional(nullable(number())),\n tradeCount30d: optional(nullable(number())),\n pnl7d: optional(nullable(number())),\n winRate7d: optional(nullable(number())),\n roiPercent7d: optional(nullable(number())),\n tradeCount7d: optional(nullable(number())),\n pnlPerChain: record(string(), number()),\n followerCount: number(),\n socialHandles: SocialHandlesStruct,\n});\n\nconst LeaderboardResponseStruct = structType({\n traders: array(LeaderboardEntryStruct),\n});\n\nconst TraderProfileStruct = structType({\n profileId: string(),\n address: string(),\n allAddresses: array(string()),\n name: string(),\n imageUrl: optional(nullable(string())),\n});\n\nconst TraderStatsStruct = structType({\n pnl30d: optional(nullable(number())),\n winRate30d: optional(nullable(number())),\n roiPercent30d: optional(nullable(number())),\n tradeCount30d: optional(nullable(number())),\n pnl7d: optional(nullable(number())),\n winRate7d: optional(nullable(number())),\n roiPercent7d: optional(nullable(number())),\n tradeCount7d: optional(nullable(number())),\n medianHoldMinutes: optional(nullable(number())),\n});\n\nconst PerChainBreakdownStruct = structType({\n perChainPnl: record(string(), number()),\n perChainRoi: record(string(), nullable(number())),\n perChainVolume: record(string(), number()),\n perChainPnl7d: optional(record(string(), number())),\n perChainRoi7d: optional(record(string(), nullable(number()))),\n perChainVolume7d: optional(record(string(), number())),\n});\n\nconst TraderProfileResponseStruct = structType({\n profile: TraderProfileStruct,\n stats: TraderStatsStruct,\n perChainBreakdown: PerChainBreakdownStruct,\n socialHandles: SocialHandlesStruct,\n followerCount: number(),\n followingCount: number(),\n});\n\nconst PositionsResponseStruct = structType({\n positions: array(PositionStruct),\n pagination: PaginationStruct,\n computedAt: optional(nullable(string())),\n});\n\n// A feed item is a position plus the trader who made the trade (`actor`) and\n// the item's creation timestamp. Reuses PositionStruct so the trade/position\n// fields stay in lockstep with the positions endpoints.\nconst FeedItemStruct = assign(\n PositionStruct,\n structType({\n actor: ProfileSummaryStruct,\n timestamp: number(),\n }),\n);\n\nconst FeedPaginationStruct = structType({\n olderCursor: nullable(string()),\n newerCursor: nullable(string()),\n});\n\nconst FeedResponseStruct = structType({\n items: array(FeedItemStruct),\n pagination: FeedPaginationStruct,\n});\n\nconst FollowersResponseStruct = structType({\n followers: array(ProfileSummaryStruct),\n count: number(),\n});\n\nconst FollowingResponseStruct = structType({\n following: array(ProfileSummaryStruct),\n count: number(),\n});\n\nconst FollowResponseStruct = structType({\n followed: array(ProfileSummaryStruct),\n});\n\nconst UnfollowResponseStruct = structType({\n unfollowed: array(ProfileSummaryStruct),\n});\n\n// ---------------------------------------------------------------------------\n// Messenger types\n// ---------------------------------------------------------------------------\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'fetchLeaderboard',\n 'fetchTraderProfile',\n 'fetchOpenPositions',\n 'fetchClosedPositions',\n 'fetchFollowers',\n 'fetchFollowing',\n 'fetchPositionById',\n 'fetchFeed',\n 'follow',\n 'unfollow',\n 'optOutOfLeaderboard',\n 'optInToLeaderboard',\n 'refreshNotificationPreferencesCache',\n] as const;\n\nexport type SocialServiceActions =\n | SocialServiceMethodActions\n | DataServiceInvalidateQueriesAction<typeof serviceName>;\n\nexport type SocialServiceEvents =\n | DataServiceCacheUpdatedEvent<typeof serviceName>\n | DataServiceGranularCacheUpdatedEvent<typeof serviceName>;\n\ntype AllowedActions =\n AuthenticationController.AuthenticationControllerGetBearerTokenAction;\n\ntype AllowedEvents = never;\n\nexport type SocialServiceMessenger = Messenger<\n typeof serviceName,\n SocialServiceActions | AllowedActions,\n SocialServiceEvents | AllowedEvents\n>;\n\n// ---------------------------------------------------------------------------\n// Service\n// ---------------------------------------------------------------------------\n\n/**\n * Data service wrapping social-api endpoints.\n */\nexport class SocialService extends BaseDataService<\n typeof serviceName,\n SocialServiceMessenger\n> {\n readonly #baseUrl: string;\n\n get #v1Url(): string {\n return `${this.#baseUrl}/api/v1`;\n }\n\n get #v2Url(): string {\n return `${this.#baseUrl}/api/v2`;\n }\n\n constructor({\n messenger,\n baseUrl,\n policyOptions,\n }: {\n messenger: SocialServiceMessenger;\n baseUrl: string;\n policyOptions?: CreateServicePolicyOptions;\n }) {\n super({ name: serviceName, messenger, policyOptions });\n this.#baseUrl = baseUrl;\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Throws an HttpError if the response is not ok.\n *\n * @param response - The fetch response to check.\n * @param message - The error message prefix from SocialServiceErrorMessage.\n */\n static #throwIfNotOk(response: Response, message: string): void {\n if (!response.ok) {\n throw new HttpError(response.status, `${message}: ${response.status}`);\n }\n }\n\n /**\n * Returns an Authorization header with a JWT bearer token obtained from the\n * AuthenticationController.\n *\n * @returns A headers object containing the Authorization header.\n */\n async #getAuthHeaders(): Promise<Record<string, string>> {\n const token = await this.messenger.call(\n 'AuthenticationController:getBearerToken',\n );\n return { Authorization: `Bearer ${token}` };\n }\n\n /**\n * Fetches the leaderboard of top traders.\n *\n * Calls `GET ${baseUrl}/leaderboard`.\n *\n * @param options - Optional query parameters for sorting, chain filtering, and limit.\n * @returns The leaderboard response with ranked traders.\n */\n async fetchLeaderboard(\n options?: FetchLeaderboardOptions,\n ): Promise<LeaderboardResponse> {\n const leaderboardResponse = await this.fetchQuery({\n queryKey: [`${this.name}:fetchLeaderboard`, options ?? null],\n queryFn: async () => {\n const { sort, chains, limit } = options ?? {};\n const url = new URL(`${this.#v1Url}/leaderboard`);\n if (sort) {\n url.searchParams.append('sort', sort);\n }\n if (chains) {\n for (const chain of chains) {\n url.searchParams.append('chains', chain);\n }\n }\n if (limit !== undefined) {\n url.searchParams.append('limit', String(limit));\n }\n\n const authHeaders = await this.#getAuthHeaders();\n const response = await fetch(url.toString(), {\n headers: authHeaders,\n });\n SocialService.#throwIfNotOk(\n response,\n SocialServiceErrorMessage.FETCH_LEADERBOARD_FAILED,\n );\n const leaderboardData = await response.json();\n if (!is(leaderboardData, LeaderboardResponseStruct)) {\n throw new Error(\n SocialServiceErrorMessage.FETCH_LEADERBOARD_INVALID_RESPONSE,\n );\n }\n return leaderboardData as LeaderboardResponse;\n },\n });\n\n return leaderboardResponse;\n }\n\n /**\n * Fetches a trader's profile by address or profile ID.\n *\n * Calls `GET ${baseUrl}/traders/${addressOrId}/profile`.\n *\n * @param options - Options bag.\n * @param options.addressOrId - Wallet address or Clicker profile ID.\n * @returns The trader profile response.\n */\n async fetchTraderProfile(\n options: FetchTraderProfileOptions,\n ): Promise<TraderProfileResponse> {\n const { addressOrId } = options;\n\n const traderProfileResponse = await this.fetchQuery({\n queryKey: [`${this.name}:fetchTraderProfile`, addressOrId],\n queryFn: async () => {\n const url = `${this.#v1Url}/traders/${encodeURIComponent(addressOrId)}/profile`;\n const authHeaders = await this.#getAuthHeaders();\n const response = await fetch(url, { headers: authHeaders });\n SocialService.#throwIfNotOk(\n response,\n SocialServiceErrorMessage.FETCH_TRADER_PROFILE_FAILED,\n );\n const traderProfileData = await response.json();\n if (!is(traderProfileData, TraderProfileResponseStruct)) {\n throw new Error(\n SocialServiceErrorMessage.FETCH_TRADER_PROFILE_INVALID_RESPONSE,\n );\n }\n return traderProfileData as TraderProfileResponse;\n },\n });\n\n return traderProfileResponse;\n }\n\n /**\n * Fetches a trader's open positions.\n *\n * Calls `GET ${baseUrl}/traders/${addressOrId}/positions/open`.\n *\n * @param options - Options bag.\n * @param options.addressOrId - Wallet address or Clicker profile ID.\n * @param options.chain - Filter by chain.\n * @param options.sort - Sort by 'value' or 'latest'.\n * @param options.limit - Number of results per page.\n * @param options.page - Page number (1-based).\n * @returns The positions response.\n */\n async fetchOpenPositions(\n options: FetchPositionsOptions,\n ): Promise<PositionsResponse> {\n return this.#fetchPositions('open', options);\n }\n\n /**\n * Fetches a trader's closed positions.\n *\n * Calls `GET ${baseUrl}/traders/${addressOrId}/positions/closed`.\n *\n * @param options - Options bag.\n * @param options.addressOrId - Wallet address or Clicker profile ID.\n * @param options.chain - Filter by chain.\n * @param options.sort - Sort by 'value' or 'latest'.\n * @param options.limit - Number of results per page.\n * @param options.page - Page number (1-based).\n * @returns The positions response.\n */\n async fetchClosedPositions(\n options: FetchPositionsOptions,\n ): Promise<PositionsResponse> {\n return this.#fetchPositions('closed', options);\n }\n\n /**\n * Fetches a trader's MetaMask followers.\n *\n * Calls `GET ${baseUrl}/traders/${addressOrId}/followers`.\n *\n * @param options - Options bag.\n * @param options.addressOrId - Wallet address or Clicker profile ID.\n * @returns The followers response.\n */\n async fetchFollowers(\n options: FetchFollowersOptions,\n ): Promise<FollowersResponse> {\n const { addressOrId } = options;\n\n const followersResponse = await this.fetchQuery({\n queryKey: [`${this.name}:fetchFollowers`, addressOrId],\n queryFn: async () => {\n const url = `${this.#v1Url}/traders/${encodeURIComponent(addressOrId)}/followers`;\n const authHeaders = await this.#getAuthHeaders();\n const response = await fetch(url, { headers: authHeaders });\n SocialService.#throwIfNotOk(\n response,\n SocialServiceErrorMessage.FETCH_FOLLOWERS_FAILED,\n );\n const followersData = await response.json();\n if (!is(followersData, FollowersResponseStruct)) {\n throw new Error(\n SocialServiceErrorMessage.FETCH_FOLLOWERS_INVALID_RESPONSE,\n );\n }\n return followersData as FollowersResponse;\n },\n });\n\n return followersResponse;\n }\n\n /**\n * Fetches a single position by its unique ID.\n *\n * Calls `GET ${baseUrl}/traders/position/${positionId}`.\n *\n * @param options - Options bag.\n * @param options.positionId - Unique position ID (UUID).\n * @returns The position.\n */\n async fetchPositionById(\n options: FetchPositionByIdOptions,\n ): Promise<Position> {\n const { positionId } = options;\n\n const positionResponse = await this.fetchQuery({\n queryKey: [`${this.name}:fetchPositionById`, positionId],\n queryFn: async () => {\n const url = `${this.#v1Url}/traders/position/${encodeURIComponent(positionId)}`;\n const authHeaders = await this.#getAuthHeaders();\n const response = await fetch(url, { headers: authHeaders });\n SocialService.#throwIfNotOk(\n response,\n SocialServiceErrorMessage.FETCH_POSITION_BY_ID_FAILED,\n );\n const positionData = await response.json();\n if (!is(positionData, PositionStruct)) {\n throw new Error(\n SocialServiceErrorMessage.FETCH_POSITION_BY_ID_INVALID_RESPONSE,\n );\n }\n return positionData as Position;\n },\n });\n\n return positionResponse;\n }\n\n /**\n * Fetches a page of the trader-activity feed.\n *\n * Calls `GET ${baseUrl}/feed`. For the `following` scope the current user is\n * identified server-side from the JWT sub claim carried in the Authorization\n * header; the `leaderboard` scope is generic and shared by all users.\n *\n * Cursor pagination supports infinite scroll: pass `pagination.olderCursor`\n * from a prior response back as `olderThan` to load older items, and\n * `pagination.newerCursor` as `newerThan` to fetch newer items.\n *\n * @param options - Options bag.\n * @param options.scope - `following` (default) or `leaderboard`.\n * @param options.chains - Filter by one or more chains.\n * @param options.limit - Number of results per page.\n * @param options.olderThan - Cursor for older items (scroll down).\n * @param options.newerThan - Cursor for newer items (refresh).\n * @returns The feed response with items and pagination cursors.\n */\n async fetchFeed(options?: FetchFeedOptions): Promise<FeedResponse> {\n const feedResponse = await this.fetchQuery({\n queryKey: [`${this.name}:fetchFeed`, options ?? null],\n staleTime: 0,\n queryFn: async () => {\n const { scope, chains, limit, olderThan, newerThan } = options ?? {};\n const url = new URL(`${this.#v1Url}/feed`);\n if (scope) {\n url.searchParams.append('scope', scope);\n }\n if (chains) {\n for (const chain of chains) {\n url.searchParams.append('chains', chain);\n }\n }\n if (limit !== undefined) {\n url.searchParams.append('limit', String(limit));\n }\n if (olderThan) {\n url.searchParams.append('olderThan', olderThan);\n }\n if (newerThan) {\n url.searchParams.append('newerThan', newerThan);\n }\n\n const authHeaders = await this.#getAuthHeaders();\n const response = await fetch(url.toString(), {\n headers: authHeaders,\n });\n SocialService.#throwIfNotOk(\n response,\n SocialServiceErrorMessage.FETCH_FEED_FAILED,\n );\n const feedData = await response.json();\n if (!is(feedData, FeedResponseStruct)) {\n throw new Error(\n SocialServiceErrorMessage.FETCH_FEED_INVALID_RESPONSE,\n );\n }\n return feedData as FeedResponse;\n },\n });\n\n return feedResponse;\n }\n\n /**\n * Fetches the list of traders the current user is following.\n *\n * Calls `GET ${baseUrl}/users/me/following`. The caller is identified\n * server-side from the JWT sub claim carried in the Authorization header.\n *\n * @returns The following response.\n */\n async fetchFollowing(): Promise<FollowingResponse> {\n const followingResponse = await this.fetchQuery({\n queryKey: [`${this.name}:fetchFollowing`],\n staleTime: 0,\n queryFn: async () => {\n const url = `${this.#v1Url}/users/me/following`;\n const authHeaders = await this.#getAuthHeaders();\n const response = await fetch(url, { headers: authHeaders });\n SocialService.#throwIfNotOk(\n response,\n SocialServiceErrorMessage.FETCH_FOLLOWING_FAILED,\n );\n const followingData = await response.json();\n if (!is(followingData, FollowingResponseStruct)) {\n throw new Error(\n SocialServiceErrorMessage.FETCH_FOLLOWING_INVALID_RESPONSE,\n );\n }\n return followingData as FollowingResponse;\n },\n });\n\n return followingResponse;\n }\n\n /**\n * Follows one or more traders on behalf of the current user.\n *\n * Calls `PUT ${baseUrl}/users/me/follows`. The caller is identified\n * server-side from the JWT sub claim carried in the Authorization header.\n *\n * @param options - Options bag.\n * @param options.targets - Array of wallet addresses or profile IDs to follow.\n * @returns The follow response with confirmed follows.\n */\n async follow(options: FollowOptions): Promise<FollowResponse> {\n const { targets } = options;\n\n const followResponse = await this.fetchQuery({\n queryKey: [`${this.name}:follow`, targets],\n staleTime: 0,\n queryFn: async () => {\n const url = `${this.#v1Url}/users/me/follows`;\n const authHeaders = await this.#getAuthHeaders();\n const response = await fetch(url, {\n method: 'PUT',\n headers: { ...authHeaders, 'Content-Type': 'application/json' },\n body: JSON.stringify({ targets }),\n });\n SocialService.#throwIfNotOk(\n response,\n SocialServiceErrorMessage.FOLLOW_FAILED,\n );\n const followData = await response.json();\n if (!is(followData, FollowResponseStruct)) {\n throw new Error(SocialServiceErrorMessage.FOLLOW_INVALID_RESPONSE);\n }\n return followData as FollowResponse;\n },\n });\n\n return followResponse;\n }\n\n /**\n * Unfollows one or more traders on behalf of the current user.\n *\n * Calls `DELETE ${baseUrl}/users/me/follows?targets=...`. Targets are sent\n * as query params because Fastify does not parse request bodies on DELETE\n * requests per RFC 9110. The caller is identified server-side from the JWT\n * sub claim carried in the Authorization header.\n *\n * @param options - Options bag.\n * @param options.targets - Array of wallet addresses or profile IDs to unfollow.\n * @returns The unfollow response with confirmed unfollows.\n */\n async unfollow(options: UnfollowOptions): Promise<UnfollowResponse> {\n const { targets } = options;\n\n const unfollowResponse = await this.fetchQuery({\n queryKey: [`${this.name}:unfollow`, targets],\n staleTime: 0,\n queryFn: async () => {\n const url = new URL(`${this.#v1Url}/users/me/follows`);\n for (const target of targets) {\n url.searchParams.append('targets', target);\n }\n const authHeaders = await this.#getAuthHeaders();\n const response = await fetch(url.toString(), {\n method: 'DELETE',\n headers: authHeaders,\n });\n SocialService.#throwIfNotOk(\n response,\n SocialServiceErrorMessage.UNFOLLOW_FAILED,\n );\n const unfollowData = await response.json();\n if (!is(unfollowData, UnfollowResponseStruct)) {\n throw new Error(SocialServiceErrorMessage.UNFOLLOW_INVALID_RESPONSE);\n }\n return unfollowData as UnfollowResponse;\n },\n });\n\n return unfollowResponse;\n }\n\n /**\n * Opts the current user out of the PnL leaderboard.\n */\n async optOutOfLeaderboard(): Promise<void> {\n await this.fetchQuery({\n queryKey: [`${this.name}:optOutOfLeaderboard`],\n staleTime: 0,\n queryFn: async () => {\n const url = `${this.#v1Url}/leaderboard/opt-out`;\n const authHeaders = await this.#getAuthHeaders();\n const response = await fetch(url, {\n method: 'POST',\n headers: authHeaders,\n });\n SocialService.#throwIfNotOk(\n response,\n SocialServiceErrorMessage.LEADERBOARD_OPT_OUT_FAILED,\n );\n return null;\n },\n });\n }\n\n /**\n * Opts the current user back into the PnL leaderboard.\n */\n async optInToLeaderboard(): Promise<void> {\n await this.fetchQuery({\n queryKey: [`${this.name}:optInToLeaderboard`],\n staleTime: 0,\n queryFn: async () => {\n const url = `${this.#v1Url}/leaderboard/opt-in`;\n const authHeaders = await this.#getAuthHeaders();\n const response = await fetch(url, {\n method: 'POST',\n headers: authHeaders,\n });\n SocialService.#throwIfNotOk(\n response,\n SocialServiceErrorMessage.LEADERBOARD_OPT_IN_FAILED,\n );\n return null;\n },\n });\n }\n\n /**\n * Asks the social-api to refresh its cached copy of the current user's\n * notification preferences.\n *\n * Calls `POST ${baseUrl}/notifications/preferences/cache-refresh`. The caller\n * is identified server-side from the JWT sub claim carried in the\n * Authorization header, so it can only ever refresh its own entry.\n *\n * The client calls this immediately after writing a preference change to\n * Authenticated User Storage (AUS), which is the source of truth. The social\n * api re-reads from AUS and repopulates its cache so the change is honoured\n * near-instantly rather than after the cache TTL lapses. It is a pure\n * optimisation on top of that bounded TTL: the write has already succeeded by\n * the time this runs, so callers should treat it as best-effort and must not\n * roll back the AUS write if it fails.\n */\n async refreshNotificationPreferencesCache(): Promise<void> {\n await this.fetchQuery({\n queryKey: [`${this.name}:refreshNotificationPreferencesCache`],\n staleTime: 0,\n queryFn: async () => {\n const url = `${this.#v1Url}/notifications/preferences/cache-refresh`;\n const authHeaders = await this.#getAuthHeaders();\n const response = await fetch(url, {\n method: 'POST',\n headers: authHeaders,\n });\n SocialService.#throwIfNotOk(\n response,\n SocialServiceErrorMessage.NOTIFICATION_PREFERENCES_CACHE_REFRESH_FAILED,\n );\n return null;\n },\n });\n }\n\n /**\n * Shared helper for fetching open/closed positions.\n *\n * @param status - \"open\" or \"closed\".\n * @param options - Options bag including addressOrId and query parameters.\n * @returns The positions response.\n */\n async #fetchPositions(\n status: 'open' | 'closed',\n options: FetchPositionsOptions,\n ): Promise<PositionsResponse> {\n const { addressOrId, chain, sort, limit, page } = options;\n\n const failedMessage =\n status === 'open'\n ? SocialServiceErrorMessage.FETCH_OPEN_POSITIONS_FAILED\n : SocialServiceErrorMessage.FETCH_CLOSED_POSITIONS_FAILED;\n const invalidMessage =\n status === 'open'\n ? SocialServiceErrorMessage.FETCH_OPEN_POSITIONS_INVALID_RESPONSE\n : SocialServiceErrorMessage.FETCH_CLOSED_POSITIONS_INVALID_RESPONSE;\n\n const positionsResponse = await this.fetchQuery({\n queryKey: [\n `${this.name}:fetch${status === 'open' ? 'Open' : 'Closed'}Positions`,\n addressOrId,\n chain ?? null,\n // sort is not used for open positions (v2 endpoint dropped it),\n // so exclude it from the key to avoid redundant cache entries\n status === 'closed' ? (sort ?? null) : null,\n limit ?? null,\n page ?? null,\n ],\n queryFn: async () => {\n const baseUrl = status === 'open' ? this.#v2Url : this.#v1Url;\n const url = new URL(\n `${baseUrl}/traders/${encodeURIComponent(addressOrId)}/positions/${status}`,\n );\n if (chain) {\n url.searchParams.append('chain', chain);\n }\n // sort is not supported on the v2 open-positions endpoint\n if (sort && status === 'closed') {\n url.searchParams.append('sort', sort);\n }\n if (limit !== undefined) {\n url.searchParams.append('limit', String(limit));\n }\n if (page !== undefined) {\n url.searchParams.append('page', String(page));\n }\n\n const authHeaders = await this.#getAuthHeaders();\n const response = await fetch(url.toString(), {\n headers: authHeaders,\n });\n SocialService.#throwIfNotOk(response, failedMessage);\n const positionsData = await response.json();\n if (!is(positionsData, PositionsResponseStruct)) {\n throw new Error(invalidMessage);\n }\n return positionsData as PositionsResponse;\n },\n });\n\n return positionsResponse;\n }\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export type { SocialControllerActions, SocialControllerEvents, SocialControllerGetStateAction, SocialControllerMessenger, SocialControllerOptions, SocialControllerStateChangeEvent, } from
|
|
2
|
-
export { SocialController, getDefaultSocialControllerState, } from
|
|
3
|
-
export type { SocialControllerFollowTraderAction, SocialControllerOptInToLeaderboardAction, SocialControllerOptOutOfLeaderboardAction, SocialControllerUnfollowTraderAction, SocialControllerUpdateFollowingAction, SocialControllerUpdateLeaderboardAction, } from
|
|
4
|
-
export type { SocialServiceActions, SocialServiceEvents, SocialServiceMessenger, } from
|
|
5
|
-
export { SocialService } from
|
|
6
|
-
export type { SocialServiceFetchClosedPositionsAction, SocialServiceFetchFeedAction, SocialServiceFetchFollowersAction, SocialServiceFetchFollowingAction, SocialServiceFetchLeaderboardAction, SocialServiceFetchOpenPositionsAction, SocialServiceFetchPositionByIdAction, SocialServiceFetchTraderProfileAction, SocialServiceFollowAction, SocialServiceOptInToLeaderboardAction, SocialServiceOptOutOfLeaderboardAction, SocialServiceRefreshNotificationPreferencesCacheAction, SocialServiceUnfollowAction, } from
|
|
7
|
-
export { TradeStruct } from
|
|
8
|
-
export type { FeedItem, FeedPagination, FeedResponse, FetchFeedOptions, FetchFollowersOptions, FetchLeaderboardOptions, FetchPositionByIdOptions, FetchPositionsOptions, FetchTraderProfileOptions, FollowersResponse, FollowingResponse, FollowOptions, FollowResponse, LeaderboardEntry, LeaderboardResponse, Pagination, PerChainBreakdown, Position, PositionsResponse, ProfileSummary, SocialControllerState, SocialHandles, Trade, TradeAction, TraderProfile, TraderProfileResponse, TraderStats, UnfollowOptions, UnfollowResponse, } from
|
|
9
|
-
export { serviceName as socialServiceName, SocialServiceErrorMessage, } from
|
|
10
|
-
//# sourceMappingURL=index.d.
|
|
1
|
+
export type { SocialControllerActions, SocialControllerEvents, SocialControllerGetStateAction, SocialControllerMessenger, SocialControllerOptions, SocialControllerStateChangeEvent, } from './SocialController.js';
|
|
2
|
+
export { SocialController, getDefaultSocialControllerState, } from './SocialController.js';
|
|
3
|
+
export type { SocialControllerFollowTraderAction, SocialControllerOptInToLeaderboardAction, SocialControllerOptOutOfLeaderboardAction, SocialControllerUnfollowTraderAction, SocialControllerUpdateFollowingAction, SocialControllerUpdateLeaderboardAction, } from './SocialController-method-action-types.js';
|
|
4
|
+
export type { SocialServiceActions, SocialServiceEvents, SocialServiceMessenger, } from './SocialService.js';
|
|
5
|
+
export { SocialService } from './SocialService.js';
|
|
6
|
+
export type { SocialServiceFetchClosedPositionsAction, SocialServiceFetchFeedAction, SocialServiceFetchFollowersAction, SocialServiceFetchFollowingAction, SocialServiceFetchLeaderboardAction, SocialServiceFetchOpenPositionsAction, SocialServiceFetchPositionByIdAction, SocialServiceFetchTraderProfileAction, SocialServiceFollowAction, SocialServiceOptInToLeaderboardAction, SocialServiceOptOutOfLeaderboardAction, SocialServiceRefreshNotificationPreferencesCacheAction, SocialServiceUnfollowAction, } from './SocialService-method-action-types.js';
|
|
7
|
+
export { TradeStruct } from './social-types.js';
|
|
8
|
+
export type { FeedItem, FeedPagination, FeedResponse, FetchFeedOptions, FetchFollowersOptions, FetchLeaderboardOptions, FetchPositionByIdOptions, FetchPositionsOptions, FetchTraderProfileOptions, FollowersResponse, FollowingResponse, FollowOptions, FollowResponse, LeaderboardEntry, LeaderboardResponse, Pagination, PerChainBreakdown, Position, PositionsResponse, ProfileSummary, SocialControllerState, SocialHandles, Trade, TradeAction, TraderProfile, TraderProfileResponse, TraderStats, UnfollowOptions, UnfollowResponse, } from './social-types.js';
|
|
9
|
+
export { serviceName as socialServiceName, SocialServiceErrorMessage, } from './social-constants.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,uBAAuB,EACvB,sBAAsB,EACtB,8BAA8B,EAC9B,yBAAyB,EACzB,uBAAuB,EACvB,gCAAgC,GACjC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,gBAAgB,EAChB,+BAA+B,GAChC,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACV,kCAAkC,EAClC,wCAAwC,EACxC,yCAAyC,EACzC,oCAAoC,EACpC,qCAAqC,EACrC,uCAAuC,GACxC,MAAM,2CAA2C,CAAC;AAEnD,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,YAAY,EACV,uCAAuC,EACvC,4BAA4B,EAC5B,iCAAiC,EACjC,iCAAiC,EACjC,mCAAmC,EACnC,qCAAqC,EACrC,oCAAoC,EACpC,qCAAqC,EACrC,yBAAyB,EACzB,qCAAqC,EACrC,sCAAsC,EACtC,sDAAsD,EACtD,2BAA2B,GAC5B,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EACV,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,yBAAyB,EACzB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,UAAU,EACV,iBAAiB,EACjB,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,KAAK,EACL,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,WAAW,EACX,eAAe,EACf,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,WAAW,IAAI,iBAAiB,EAChC,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { SocialController, getDefaultSocialControllerState, } from './SocialController.js';
|
|
2
|
+
export { SocialService } from './SocialService.js';
|
|
3
|
+
export { TradeStruct } from './social-types.js';
|
|
4
|
+
export { serviceName as socialServiceName, SocialServiceErrorMessage, } from './social-constants.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,gBAAgB,EAChB,+BAA+B,GAChC,MAAM,uBAAuB,CAAC;AAgB/B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAkBnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAiChD,OAAO,EACL,WAAW,IAAI,iBAAiB,EAChC,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC","sourcesContent":["export type {\n SocialControllerActions,\n SocialControllerEvents,\n SocialControllerGetStateAction,\n SocialControllerMessenger,\n SocialControllerOptions,\n SocialControllerStateChangeEvent,\n} from './SocialController.js';\nexport {\n SocialController,\n getDefaultSocialControllerState,\n} from './SocialController.js';\n\nexport type {\n SocialControllerFollowTraderAction,\n SocialControllerOptInToLeaderboardAction,\n SocialControllerOptOutOfLeaderboardAction,\n SocialControllerUnfollowTraderAction,\n SocialControllerUpdateFollowingAction,\n SocialControllerUpdateLeaderboardAction,\n} from './SocialController-method-action-types.js';\n\nexport type {\n SocialServiceActions,\n SocialServiceEvents,\n SocialServiceMessenger,\n} from './SocialService.js';\nexport { SocialService } from './SocialService.js';\n\nexport type {\n SocialServiceFetchClosedPositionsAction,\n SocialServiceFetchFeedAction,\n SocialServiceFetchFollowersAction,\n SocialServiceFetchFollowingAction,\n SocialServiceFetchLeaderboardAction,\n SocialServiceFetchOpenPositionsAction,\n SocialServiceFetchPositionByIdAction,\n SocialServiceFetchTraderProfileAction,\n SocialServiceFollowAction,\n SocialServiceOptInToLeaderboardAction,\n SocialServiceOptOutOfLeaderboardAction,\n SocialServiceRefreshNotificationPreferencesCacheAction,\n SocialServiceUnfollowAction,\n} from './SocialService-method-action-types.js';\n\nexport { TradeStruct } from './social-types.js';\nexport type {\n FeedItem,\n FeedPagination,\n FeedResponse,\n FetchFeedOptions,\n FetchFollowersOptions,\n FetchLeaderboardOptions,\n FetchPositionByIdOptions,\n FetchPositionsOptions,\n FetchTraderProfileOptions,\n FollowersResponse,\n FollowingResponse,\n FollowOptions,\n FollowResponse,\n LeaderboardEntry,\n LeaderboardResponse,\n Pagination,\n PerChainBreakdown,\n Position,\n PositionsResponse,\n ProfileSummary,\n SocialControllerState,\n SocialHandles,\n Trade,\n TradeAction,\n TraderProfile,\n TraderProfileResponse,\n TraderStats,\n UnfollowOptions,\n UnfollowResponse,\n} from './social-types.js';\n\nexport {\n serviceName as socialServiceName,\n SocialServiceErrorMessage,\n} from './social-constants.js';\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const serviceName = "SocialService";
|
|
2
|
+
export declare const controllerName = "SocialController";
|
|
3
|
+
export declare const SocialServiceErrorMessage: {
|
|
4
|
+
readonly FETCH_LEADERBOARD_FAILED: 'SocialService: Leaderboard request failed';
|
|
5
|
+
readonly FETCH_LEADERBOARD_INVALID_RESPONSE: 'SocialService: Leaderboard returned invalid response';
|
|
6
|
+
readonly FETCH_TRADER_PROFILE_FAILED: 'SocialService: Trader profile request failed';
|
|
7
|
+
readonly FETCH_TRADER_PROFILE_INVALID_RESPONSE: 'SocialService: Trader profile returned invalid response';
|
|
8
|
+
readonly FETCH_OPEN_POSITIONS_FAILED: 'SocialService: Open positions request failed';
|
|
9
|
+
readonly FETCH_OPEN_POSITIONS_INVALID_RESPONSE: 'SocialService: Open positions returned invalid response';
|
|
10
|
+
readonly FETCH_CLOSED_POSITIONS_FAILED: 'SocialService: Closed positions request failed';
|
|
11
|
+
readonly FETCH_CLOSED_POSITIONS_INVALID_RESPONSE: 'SocialService: Closed positions returned invalid response';
|
|
12
|
+
readonly FETCH_FOLLOWERS_FAILED: 'SocialService: Followers request failed';
|
|
13
|
+
readonly FETCH_FOLLOWERS_INVALID_RESPONSE: 'SocialService: Followers returned invalid response';
|
|
14
|
+
readonly FETCH_FOLLOWING_FAILED: 'SocialService: Following request failed';
|
|
15
|
+
readonly FETCH_FOLLOWING_INVALID_RESPONSE: 'SocialService: Following returned invalid response';
|
|
16
|
+
readonly FOLLOW_FAILED: 'SocialService: Follow request failed';
|
|
17
|
+
readonly FOLLOW_INVALID_RESPONSE: 'SocialService: Follow returned invalid response';
|
|
18
|
+
readonly UNFOLLOW_FAILED: 'SocialService: Unfollow request failed';
|
|
19
|
+
readonly UNFOLLOW_INVALID_RESPONSE: 'SocialService: Unfollow returned invalid response';
|
|
20
|
+
readonly FETCH_POSITION_BY_ID_FAILED: 'SocialService: Position request failed';
|
|
21
|
+
readonly FETCH_POSITION_BY_ID_INVALID_RESPONSE: 'SocialService: Position returned invalid response';
|
|
22
|
+
readonly LEADERBOARD_OPT_OUT_FAILED: 'SocialService: Leaderboard opt-out request failed';
|
|
23
|
+
readonly LEADERBOARD_OPT_IN_FAILED: 'SocialService: Leaderboard opt-in request failed';
|
|
24
|
+
readonly FETCH_FEED_FAILED: 'SocialService: Feed request failed';
|
|
25
|
+
readonly FETCH_FEED_INVALID_RESPONSE: 'SocialService: Feed returned invalid response';
|
|
26
|
+
readonly NOTIFICATION_PREFERENCES_CACHE_REFRESH_FAILED: 'SocialService: Notification preferences cache refresh request failed';
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=social-constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"social-constants.d.ts","sourceRoot":"","sources":["../src/social-constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,kBAAkB,CAAC;AAE3C,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAEjD,eAAO,MAAM,yBAAyB;aACpC,wBAAwB,EAAE,2CAA2C;aACrE,kCAAkC,EAChC,sDAAsD;aACxD,2BAA2B,EAAE,8CAA8C;aAC3E,qCAAqC,EACnC,yDAAyD;aAC3D,2BAA2B,EAAE,8CAA8C;aAC3E,qCAAqC,EACnC,yDAAyD;aAC3D,6BAA6B,EAC3B,gDAAgD;aAClD,uCAAuC,EACrC,2DAA2D;aAC7D,sBAAsB,EAAE,yCAAyC;aACjE,gCAAgC,EAC9B,oDAAoD;aACtD,sBAAsB,EAAE,yCAAyC;aACjE,gCAAgC,EAC9B,oDAAoD;aACtD,aAAa,EAAE,sCAAsC;aACrD,uBAAuB,EAAE,iDAAiD;aAC1E,eAAe,EAAE,wCAAwC;aACzD,yBAAyB,EACvB,mDAAmD;aACrD,2BAA2B,EAAE,wCAAwC;aACrE,qCAAqC,EACnC,mDAAmD;aACrD,0BAA0B,EACxB,mDAAmD;aACrD,yBAAyB,EAAE,kDAAkD;aAC7E,iBAAiB,EAAE,oCAAoC;aACvD,2BAA2B,EAAE,+CAA+C;aAC5E,6CAA6C,EAC3C,sEAAsE;CAChE,CAAC"}
|
|
@@ -25,4 +25,4 @@ export const SocialServiceErrorMessage = {
|
|
|
25
25
|
FETCH_FEED_INVALID_RESPONSE: 'SocialService: Feed returned invalid response',
|
|
26
26
|
NOTIFICATION_PREFERENCES_CACHE_REFRESH_FAILED: 'SocialService: Notification preferences cache refresh request failed',
|
|
27
27
|
};
|
|
28
|
-
//# sourceMappingURL=social-constants.
|
|
28
|
+
//# sourceMappingURL=social-constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"social-constants.js","sourceRoot":"","sources":["../src/social-constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC;AAE3C,MAAM,CAAC,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAEjD,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,wBAAwB,EAAE,2CAA2C;IACrE,kCAAkC,EAChC,sDAAsD;IACxD,2BAA2B,EAAE,8CAA8C;IAC3E,qCAAqC,EACnC,yDAAyD;IAC3D,2BAA2B,EAAE,8CAA8C;IAC3E,qCAAqC,EACnC,yDAAyD;IAC3D,6BAA6B,EAC3B,gDAAgD;IAClD,uCAAuC,EACrC,2DAA2D;IAC7D,sBAAsB,EAAE,yCAAyC;IACjE,gCAAgC,EAC9B,oDAAoD;IACtD,sBAAsB,EAAE,yCAAyC;IACjE,gCAAgC,EAC9B,oDAAoD;IACtD,aAAa,EAAE,sCAAsC;IACrD,uBAAuB,EAAE,iDAAiD;IAC1E,eAAe,EAAE,wCAAwC;IACzD,yBAAyB,EACvB,mDAAmD;IACrD,2BAA2B,EAAE,wCAAwC;IACrE,qCAAqC,EACnC,mDAAmD;IACrD,0BAA0B,EACxB,mDAAmD;IACrD,yBAAyB,EAAE,kDAAkD;IAC7E,iBAAiB,EAAE,oCAAoC;IACvD,2BAA2B,EAAE,+CAA+C;IAC5E,6CAA6C,EAC3C,sEAAsE;CAChE,CAAC","sourcesContent":["export const serviceName = 'SocialService';\n\nexport const controllerName = 'SocialController';\n\nexport const SocialServiceErrorMessage = {\n FETCH_LEADERBOARD_FAILED: 'SocialService: Leaderboard request failed',\n FETCH_LEADERBOARD_INVALID_RESPONSE:\n 'SocialService: Leaderboard returned invalid response',\n FETCH_TRADER_PROFILE_FAILED: 'SocialService: Trader profile request failed',\n FETCH_TRADER_PROFILE_INVALID_RESPONSE:\n 'SocialService: Trader profile returned invalid response',\n FETCH_OPEN_POSITIONS_FAILED: 'SocialService: Open positions request failed',\n FETCH_OPEN_POSITIONS_INVALID_RESPONSE:\n 'SocialService: Open positions returned invalid response',\n FETCH_CLOSED_POSITIONS_FAILED:\n 'SocialService: Closed positions request failed',\n FETCH_CLOSED_POSITIONS_INVALID_RESPONSE:\n 'SocialService: Closed positions returned invalid response',\n FETCH_FOLLOWERS_FAILED: 'SocialService: Followers request failed',\n FETCH_FOLLOWERS_INVALID_RESPONSE:\n 'SocialService: Followers returned invalid response',\n FETCH_FOLLOWING_FAILED: 'SocialService: Following request failed',\n FETCH_FOLLOWING_INVALID_RESPONSE:\n 'SocialService: Following returned invalid response',\n FOLLOW_FAILED: 'SocialService: Follow request failed',\n FOLLOW_INVALID_RESPONSE: 'SocialService: Follow returned invalid response',\n UNFOLLOW_FAILED: 'SocialService: Unfollow request failed',\n UNFOLLOW_INVALID_RESPONSE:\n 'SocialService: Unfollow returned invalid response',\n FETCH_POSITION_BY_ID_FAILED: 'SocialService: Position request failed',\n FETCH_POSITION_BY_ID_INVALID_RESPONSE:\n 'SocialService: Position returned invalid response',\n LEADERBOARD_OPT_OUT_FAILED:\n 'SocialService: Leaderboard opt-out request failed',\n LEADERBOARD_OPT_IN_FAILED: 'SocialService: Leaderboard opt-in request failed',\n FETCH_FEED_FAILED: 'SocialService: Feed request failed',\n FETCH_FEED_INVALID_RESPONSE: 'SocialService: Feed returned invalid response',\n NOTIFICATION_PREFERENCES_CACHE_REFRESH_FAILED:\n 'SocialService: Notification preferences cache refresh request failed',\n} as const;\n"]}
|