@metamask/social-controllers 0.1.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 +24 -0
- package/LICENSE +20 -0
- package/README.md +15 -0
- package/dist/SocialController-method-action-types.cjs +7 -0
- package/dist/SocialController-method-action-types.cjs.map +1 -0
- package/dist/SocialController-method-action-types.d.cts +56 -0
- package/dist/SocialController-method-action-types.d.cts.map +1 -0
- package/dist/SocialController-method-action-types.d.mts +56 -0
- package/dist/SocialController-method-action-types.d.mts.map +1 -0
- package/dist/SocialController-method-action-types.mjs +6 -0
- package/dist/SocialController-method-action-types.mjs.map +1 -0
- package/dist/SocialController.cjs +129 -0
- package/dist/SocialController.cjs.map +1 -0
- package/dist/SocialController.d.cts +71 -0
- package/dist/SocialController.d.cts.map +1 -0
- package/dist/SocialController.d.mts +71 -0
- package/dist/SocialController.d.mts.map +1 -0
- package/dist/SocialController.mjs +124 -0
- package/dist/SocialController.mjs.map +1 -0
- package/dist/SocialService-method-action-types.cjs +7 -0
- package/dist/SocialService-method-action-types.cjs.map +1 -0
- package/dist/SocialService-method-action-types.d.cts +125 -0
- package/dist/SocialService-method-action-types.d.cts.map +1 -0
- package/dist/SocialService-method-action-types.d.mts +125 -0
- package/dist/SocialService-method-action-types.d.mts.map +1 -0
- package/dist/SocialService-method-action-types.mjs +6 -0
- package/dist/SocialService-method-action-types.mjs.map +1 -0
- package/dist/SocialService.cjs +434 -0
- package/dist/SocialService.cjs.map +1 -0
- package/dist/SocialService.d.cts +113 -0
- package/dist/SocialService.d.cts.map +1 -0
- package/dist/SocialService.d.mts +113 -0
- package/dist/SocialService.d.mts.map +1 -0
- package/dist/SocialService.mjs +430 -0
- package/dist/SocialService.mjs.map +1 -0
- package/dist/index.cjs +12 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +9 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +4 -0
- package/dist/index.mjs.map +1 -0
- package/dist/social-constants.cjs +24 -0
- package/dist/social-constants.cjs.map +1 -0
- package/dist/social-constants.d.cts +21 -0
- package/dist/social-constants.d.cts.map +1 -0
- package/dist/social-constants.d.mts +21 -0
- package/dist/social-constants.d.mts.map +1 -0
- package/dist/social-constants.mjs +21 -0
- package/dist/social-constants.mjs.map +1 -0
- package/dist/social-types.cjs +6 -0
- package/dist/social-types.cjs.map +1 -0
- package/dist/social-types.d.cts +212 -0
- package/dist/social-types.d.cts.map +1 -0
- package/dist/social-types.d.mts +212 -0
- package/dist/social-types.d.mts.map +1 -0
- package/dist/social-types.mjs +5 -0
- package/dist/social-types.mjs.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SocialController.mjs","sourceRoot":"","sources":["../src/SocialController.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAG3D,OAAO,EAAE,cAAc,EAAE,+BAA2B;AAoBpD,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG;IAChC,mBAAmB;IACnB,cAAc;IACd,gBAAgB;IAChB,iBAAiB;CACT,CAAC;AA+CX,wBAAwB;AAExB;;;;GAIG;AACH,MAAM,UAAU,+BAA+B;IAC7C,OAAO;QACL,kBAAkB,EAAE,EAAE;QACtB,kBAAkB,EAAE,EAAE;KACvB,CAAC;AACJ,CAAC;AAED,yBAAyB;AAEzB,MAAM,wBAAwB,GAAyC;IACrE,kBAAkB,EAAE;QAClB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,KAAK;QACzB,QAAQ,EAAE,IAAI;KACf;IACD,kBAAkB,EAAE;QAClB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,KAAK;QACzB,QAAQ,EAAE,IAAI;KACf;CACF,CAAC;AAEF,qBAAqB;AAErB;;;;;;;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port { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport { controllerName } from './social-constants';\nimport type {\n FetchFollowingOptions,\n FetchLeaderboardOptions,\n FollowOptions,\n FollowResponse,\n FollowingResponse,\n LeaderboardResponse,\n SocialControllerState,\n UnfollowOptions,\n UnfollowResponse,\n} from './social-types';\nimport type { SocialControllerMethodActions } from './SocialController-method-action-types';\nimport type {\n SocialServiceFetchFollowingAction,\n SocialServiceFetchLeaderboardAction,\n SocialServiceFollowAction,\n SocialServiceUnfollowAction,\n} from './SocialService-method-action-types';\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'updateLeaderboard',\n 'followTrader',\n 'unfollowTrader',\n 'updateFollowing',\n] as const;\n\n// === ACTION TYPES ===\n\nexport type SocialControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n SocialControllerState\n>;\n\nexport type SocialControllerActions =\n | SocialControllerGetStateAction\n | SocialControllerMethodActions;\n\n// === EVENT TYPES ===\n\nexport type SocialControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n SocialControllerState\n>;\n\nexport type SocialControllerEvents = SocialControllerStateChangeEvent;\n\n// === ALLOWED ACTIONS/EVENTS ===\n\ntype AllowedActions =\n | SocialServiceFetchLeaderboardAction\n | SocialServiceFollowAction\n | SocialServiceUnfollowAction\n | SocialServiceFetchFollowingAction;\n\ntype AllowedEvents = never;\n\n// === MESSENGER TYPE ===\n\nexport type SocialControllerMessenger = Messenger<\n typeof controllerName,\n SocialControllerActions | AllowedActions,\n SocialControllerEvents | AllowedEvents\n>;\n\n// === OPTIONS ===\n\nexport type SocialControllerOptions = {\n messenger: SocialControllerMessenger;\n state?: Partial<SocialControllerState>;\n};\n\n// === DEFAULT STATE ===\n\n/**\n * Returns the default state for the SocialController.\n *\n * @returns A fresh default state object.\n */\nexport function getDefaultSocialControllerState(): SocialControllerState {\n return {\n leaderboardEntries: [],\n followingAddresses: [],\n };\n}\n\n// === STATE METADATA ===\n\nconst socialControllerMetadata: StateMetadata<SocialControllerState> = {\n leaderboardEntries: {\n persist: true,\n includeInDebugSnapshot: false,\n includeInStateLogs: false,\n usedInUi: true,\n },\n followingAddresses: {\n persist: true,\n includeInDebugSnapshot: false,\n includeInStateLogs: false,\n usedInUi: true,\n },\n};\n\n// === CONTROLLER ===\n\n/**\n * Controller that manages social trading state for the extension UI.\n *\n * Acts as a simple store with no TTL or eviction — the UI decides when\n * to re-fetch, and the social-api's own cache layer handles upstream\n * rate-limiting. State is persisted across sessions so the UI can render\n * immediately on startup while a fresh fetch is in flight.\n */\nexport class SocialController extends BaseController<\n typeof controllerName,\n SocialControllerState,\n SocialControllerMessenger\n> {\n constructor({ messenger, state }: SocialControllerOptions) {\n super({\n name: controllerName,\n metadata: socialControllerMetadata,\n state: {\n ...getDefaultSocialControllerState(),\n ...state,\n },\n messenger,\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Fetches the leaderboard and persists the entries to state.\n *\n * @param options - Optional leaderboard query parameters.\n * @returns The leaderboard response from the social-api.\n */\n async updateLeaderboard(\n options?: FetchLeaderboardOptions,\n ): Promise<LeaderboardResponse> {\n const leaderboardResponse = await this.messenger.call(\n 'SocialService:fetchLeaderboard',\n options,\n );\n\n this.update((state) => {\n state.leaderboardEntries = leaderboardResponse.traders;\n });\n\n return leaderboardResponse;\n }\n\n /**\n * Follows one or more traders and updates the following list in state.\n *\n * @param options - Options bag.\n * @param options.addressOrUid - Wallet address or Clicker profile ID of the current user.\n * @param options.targets - Addresses or profile IDs to follow.\n * @returns The follow response with confirmed follows.\n */\n async followTrader(options: FollowOptions): Promise<FollowResponse> {\n const followResponse = await this.messenger.call(\n 'SocialService:follow',\n options,\n );\n\n const newAddresses = [\n ...new Set(followResponse.followed.map((profile) => profile.address)),\n ];\n\n this.update((state) => {\n const existing = new Set(state.followingAddresses);\n const uniqueNewAddresses = newAddresses.filter(\n (address) => !existing.has(address),\n );\n state.followingAddresses.push(...uniqueNewAddresses);\n });\n\n return followResponse;\n }\n\n /**\n * Unfollows one or more traders and updates the following list in state.\n *\n * @param options - Options bag.\n * @param options.addressOrUid - Wallet address or Clicker profile ID of the current user.\n * @param options.targets - Addresses or profile IDs to unfollow.\n * @returns The unfollow response with confirmed unfollows.\n */\n async unfollowTrader(options: UnfollowOptions): Promise<UnfollowResponse> {\n const unfollowResponse = await this.messenger.call(\n 'SocialService:unfollow',\n options,\n );\n\n const removedAddresses = new Set(\n unfollowResponse.unfollowed.map((profile) => profile.address),\n );\n\n this.update((state) => {\n state.followingAddresses = state.followingAddresses.filter(\n (address) => !removedAddresses.has(address),\n );\n });\n\n return unfollowResponse;\n }\n\n /**\n * Fetches the list of traders the current user follows and replaces\n * the following addresses in state.\n *\n * @param options - Options bag.\n * @param options.addressOrUid - Wallet address or Clicker profile ID of the current user.\n * @returns The following response.\n */\n async updateFollowing(\n options: FetchFollowingOptions,\n ): Promise<FollowingResponse> {\n const followingResponse = await this.messenger.call(\n 'SocialService:fetchFollowing',\n options,\n );\n\n this.update((state) => {\n state.followingAddresses = followingResponse.following.map(\n (profile) => profile.address,\n );\n });\n\n return followingResponse;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SocialService-method-action-types.cjs","sourceRoot":"","sources":["../src/SocialService-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SocialService } from './SocialService';\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 */\nexport type SocialServiceFetchLeaderboardAction = {\n type: `SocialService:fetchLeaderboard`;\n handler: SocialService['fetchLeaderboard'];\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 */\nexport type SocialServiceFetchTraderProfileAction = {\n type: `SocialService:fetchTraderProfile`;\n handler: SocialService['fetchTraderProfile'];\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 */\nexport type SocialServiceFetchOpenPositionsAction = {\n type: `SocialService:fetchOpenPositions`;\n handler: SocialService['fetchOpenPositions'];\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 */\nexport type SocialServiceFetchClosedPositionsAction = {\n type: `SocialService:fetchClosedPositions`;\n handler: SocialService['fetchClosedPositions'];\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 */\nexport type SocialServiceFetchFollowersAction = {\n type: `SocialService:fetchFollowers`;\n handler: SocialService['fetchFollowers'];\n};\n\n/**\n * Fetches the list of traders a user is following.\n *\n * Calls `GET ${baseUrl}/users/${addressOrUid}/following`.\n *\n * @param options - Options bag.\n * @param options.addressOrUid - Wallet address or Clicker profile ID.\n * @returns The following response.\n */\nexport type SocialServiceFetchFollowingAction = {\n type: `SocialService:fetchFollowing`;\n handler: SocialService['fetchFollowing'];\n};\n\n/**\n * Follows one or more traders.\n *\n * Calls `PUT ${baseUrl}/users/${addressOrUid}/follows`.\n *\n * @param options - Options bag.\n * @param options.addressOrUid - Wallet address or Clicker profile ID of the user.\n * @param options.targets - Array of wallet addresses or profile IDs to follow.\n * @returns The follow response with confirmed follows.\n */\nexport type SocialServiceFollowAction = {\n type: `SocialService:follow`;\n handler: SocialService['follow'];\n};\n\n/**\n * Unfollows one or more traders.\n *\n * Calls `DELETE ${baseUrl}/users/${addressOrUid}/follows?targets=...`.\n * Targets are sent as query params because Fastify does not parse\n * request bodies on DELETE requests per RFC 9110.\n *\n * @param options - Options bag.\n * @param options.addressOrUid - Wallet address or Clicker profile ID of the user.\n * @param options.targets - Array of wallet addresses or profile IDs to unfollow.\n * @returns The unfollow response with confirmed unfollows.\n */\nexport type SocialServiceUnfollowAction = {\n type: `SocialService:unfollow`;\n handler: SocialService['unfollow'];\n};\n\n/**\n * Union of all SocialService action types.\n */\nexport type SocialServiceMethodActions =\n | SocialServiceFetchLeaderboardAction\n | SocialServiceFetchTraderProfileAction\n | SocialServiceFetchOpenPositionsAction\n | SocialServiceFetchClosedPositionsAction\n | SocialServiceFetchFollowersAction\n | SocialServiceFetchFollowingAction\n | SocialServiceFollowAction\n | SocialServiceUnfollowAction;\n"]}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto generated.
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { SocialService } from "./SocialService.cjs";
|
|
6
|
+
/**
|
|
7
|
+
* Fetches the leaderboard of top traders.
|
|
8
|
+
*
|
|
9
|
+
* Calls `GET ${baseUrl}/leaderboard`.
|
|
10
|
+
*
|
|
11
|
+
* @param options - Optional query parameters for sorting, chain filtering, and limit.
|
|
12
|
+
* @returns The leaderboard response with ranked traders.
|
|
13
|
+
*/
|
|
14
|
+
export type SocialServiceFetchLeaderboardAction = {
|
|
15
|
+
type: `SocialService:fetchLeaderboard`;
|
|
16
|
+
handler: SocialService['fetchLeaderboard'];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Fetches a trader's profile by address or profile ID.
|
|
20
|
+
*
|
|
21
|
+
* Calls `GET ${baseUrl}/traders/${addressOrId}/profile`.
|
|
22
|
+
*
|
|
23
|
+
* @param options - Options bag.
|
|
24
|
+
* @param options.addressOrId - Wallet address or Clicker profile ID.
|
|
25
|
+
* @returns The trader profile response.
|
|
26
|
+
*/
|
|
27
|
+
export type SocialServiceFetchTraderProfileAction = {
|
|
28
|
+
type: `SocialService:fetchTraderProfile`;
|
|
29
|
+
handler: SocialService['fetchTraderProfile'];
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Fetches a trader's open positions.
|
|
33
|
+
*
|
|
34
|
+
* Calls `GET ${baseUrl}/traders/${addressOrId}/positions/open`.
|
|
35
|
+
*
|
|
36
|
+
* @param options - Options bag.
|
|
37
|
+
* @param options.addressOrId - Wallet address or Clicker profile ID.
|
|
38
|
+
* @param options.chain - Filter by chain.
|
|
39
|
+
* @param options.sort - Sort by 'value' or 'latest'.
|
|
40
|
+
* @param options.limit - Number of results per page.
|
|
41
|
+
* @param options.page - Page number (1-based).
|
|
42
|
+
* @returns The positions response.
|
|
43
|
+
*/
|
|
44
|
+
export type SocialServiceFetchOpenPositionsAction = {
|
|
45
|
+
type: `SocialService:fetchOpenPositions`;
|
|
46
|
+
handler: SocialService['fetchOpenPositions'];
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Fetches a trader's closed positions.
|
|
50
|
+
*
|
|
51
|
+
* Calls `GET ${baseUrl}/traders/${addressOrId}/positions/closed`.
|
|
52
|
+
*
|
|
53
|
+
* @param options - Options bag.
|
|
54
|
+
* @param options.addressOrId - Wallet address or Clicker profile ID.
|
|
55
|
+
* @param options.chain - Filter by chain.
|
|
56
|
+
* @param options.sort - Sort by 'value' or 'latest'.
|
|
57
|
+
* @param options.limit - Number of results per page.
|
|
58
|
+
* @param options.page - Page number (1-based).
|
|
59
|
+
* @returns The positions response.
|
|
60
|
+
*/
|
|
61
|
+
export type SocialServiceFetchClosedPositionsAction = {
|
|
62
|
+
type: `SocialService:fetchClosedPositions`;
|
|
63
|
+
handler: SocialService['fetchClosedPositions'];
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Fetches a trader's MetaMask followers.
|
|
67
|
+
*
|
|
68
|
+
* Calls `GET ${baseUrl}/traders/${addressOrId}/followers`.
|
|
69
|
+
*
|
|
70
|
+
* @param options - Options bag.
|
|
71
|
+
* @param options.addressOrId - Wallet address or Clicker profile ID.
|
|
72
|
+
* @returns The followers response.
|
|
73
|
+
*/
|
|
74
|
+
export type SocialServiceFetchFollowersAction = {
|
|
75
|
+
type: `SocialService:fetchFollowers`;
|
|
76
|
+
handler: SocialService['fetchFollowers'];
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Fetches the list of traders a user is following.
|
|
80
|
+
*
|
|
81
|
+
* Calls `GET ${baseUrl}/users/${addressOrUid}/following`.
|
|
82
|
+
*
|
|
83
|
+
* @param options - Options bag.
|
|
84
|
+
* @param options.addressOrUid - Wallet address or Clicker profile ID.
|
|
85
|
+
* @returns The following response.
|
|
86
|
+
*/
|
|
87
|
+
export type SocialServiceFetchFollowingAction = {
|
|
88
|
+
type: `SocialService:fetchFollowing`;
|
|
89
|
+
handler: SocialService['fetchFollowing'];
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Follows one or more traders.
|
|
93
|
+
*
|
|
94
|
+
* Calls `PUT ${baseUrl}/users/${addressOrUid}/follows`.
|
|
95
|
+
*
|
|
96
|
+
* @param options - Options bag.
|
|
97
|
+
* @param options.addressOrUid - Wallet address or Clicker profile ID of the user.
|
|
98
|
+
* @param options.targets - Array of wallet addresses or profile IDs to follow.
|
|
99
|
+
* @returns The follow response with confirmed follows.
|
|
100
|
+
*/
|
|
101
|
+
export type SocialServiceFollowAction = {
|
|
102
|
+
type: `SocialService:follow`;
|
|
103
|
+
handler: SocialService['follow'];
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Unfollows one or more traders.
|
|
107
|
+
*
|
|
108
|
+
* Calls `DELETE ${baseUrl}/users/${addressOrUid}/follows?targets=...`.
|
|
109
|
+
* Targets are sent as query params because Fastify does not parse
|
|
110
|
+
* request bodies on DELETE requests per RFC 9110.
|
|
111
|
+
*
|
|
112
|
+
* @param options - Options bag.
|
|
113
|
+
* @param options.addressOrUid - Wallet address or Clicker profile ID of the user.
|
|
114
|
+
* @param options.targets - Array of wallet addresses or profile IDs to unfollow.
|
|
115
|
+
* @returns The unfollow response with confirmed unfollows.
|
|
116
|
+
*/
|
|
117
|
+
export type SocialServiceUnfollowAction = {
|
|
118
|
+
type: `SocialService:unfollow`;
|
|
119
|
+
handler: SocialService['unfollow'];
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Union of all SocialService action types.
|
|
123
|
+
*/
|
|
124
|
+
export type SocialServiceMethodActions = SocialServiceFetchLeaderboardAction | SocialServiceFetchTraderProfileAction | SocialServiceFetchOpenPositionsAction | SocialServiceFetchClosedPositionsAction | SocialServiceFetchFollowersAction | SocialServiceFetchFollowingAction | SocialServiceFollowAction | SocialServiceUnfollowAction;
|
|
125
|
+
//# sourceMappingURL=SocialService-method-action-types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SocialService-method-action-types.d.cts","sourceRoot":"","sources":["../src/SocialService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,4BAAwB;AAErD;;;;;;;GAOG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;CAC5C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,C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
*/
|
|
5
|
+
import type { SocialService } from "./SocialService.mjs";
|
|
6
|
+
/**
|
|
7
|
+
* Fetches the leaderboard of top traders.
|
|
8
|
+
*
|
|
9
|
+
* Calls `GET ${baseUrl}/leaderboard`.
|
|
10
|
+
*
|
|
11
|
+
* @param options - Optional query parameters for sorting, chain filtering, and limit.
|
|
12
|
+
* @returns The leaderboard response with ranked traders.
|
|
13
|
+
*/
|
|
14
|
+
export type SocialServiceFetchLeaderboardAction = {
|
|
15
|
+
type: `SocialService:fetchLeaderboard`;
|
|
16
|
+
handler: SocialService['fetchLeaderboard'];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Fetches a trader's profile by address or profile ID.
|
|
20
|
+
*
|
|
21
|
+
* Calls `GET ${baseUrl}/traders/${addressOrId}/profile`.
|
|
22
|
+
*
|
|
23
|
+
* @param options - Options bag.
|
|
24
|
+
* @param options.addressOrId - Wallet address or Clicker profile ID.
|
|
25
|
+
* @returns The trader profile response.
|
|
26
|
+
*/
|
|
27
|
+
export type SocialServiceFetchTraderProfileAction = {
|
|
28
|
+
type: `SocialService:fetchTraderProfile`;
|
|
29
|
+
handler: SocialService['fetchTraderProfile'];
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Fetches a trader's open positions.
|
|
33
|
+
*
|
|
34
|
+
* Calls `GET ${baseUrl}/traders/${addressOrId}/positions/open`.
|
|
35
|
+
*
|
|
36
|
+
* @param options - Options bag.
|
|
37
|
+
* @param options.addressOrId - Wallet address or Clicker profile ID.
|
|
38
|
+
* @param options.chain - Filter by chain.
|
|
39
|
+
* @param options.sort - Sort by 'value' or 'latest'.
|
|
40
|
+
* @param options.limit - Number of results per page.
|
|
41
|
+
* @param options.page - Page number (1-based).
|
|
42
|
+
* @returns The positions response.
|
|
43
|
+
*/
|
|
44
|
+
export type SocialServiceFetchOpenPositionsAction = {
|
|
45
|
+
type: `SocialService:fetchOpenPositions`;
|
|
46
|
+
handler: SocialService['fetchOpenPositions'];
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Fetches a trader's closed positions.
|
|
50
|
+
*
|
|
51
|
+
* Calls `GET ${baseUrl}/traders/${addressOrId}/positions/closed`.
|
|
52
|
+
*
|
|
53
|
+
* @param options - Options bag.
|
|
54
|
+
* @param options.addressOrId - Wallet address or Clicker profile ID.
|
|
55
|
+
* @param options.chain - Filter by chain.
|
|
56
|
+
* @param options.sort - Sort by 'value' or 'latest'.
|
|
57
|
+
* @param options.limit - Number of results per page.
|
|
58
|
+
* @param options.page - Page number (1-based).
|
|
59
|
+
* @returns The positions response.
|
|
60
|
+
*/
|
|
61
|
+
export type SocialServiceFetchClosedPositionsAction = {
|
|
62
|
+
type: `SocialService:fetchClosedPositions`;
|
|
63
|
+
handler: SocialService['fetchClosedPositions'];
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Fetches a trader's MetaMask followers.
|
|
67
|
+
*
|
|
68
|
+
* Calls `GET ${baseUrl}/traders/${addressOrId}/followers`.
|
|
69
|
+
*
|
|
70
|
+
* @param options - Options bag.
|
|
71
|
+
* @param options.addressOrId - Wallet address or Clicker profile ID.
|
|
72
|
+
* @returns The followers response.
|
|
73
|
+
*/
|
|
74
|
+
export type SocialServiceFetchFollowersAction = {
|
|
75
|
+
type: `SocialService:fetchFollowers`;
|
|
76
|
+
handler: SocialService['fetchFollowers'];
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Fetches the list of traders a user is following.
|
|
80
|
+
*
|
|
81
|
+
* Calls `GET ${baseUrl}/users/${addressOrUid}/following`.
|
|
82
|
+
*
|
|
83
|
+
* @param options - Options bag.
|
|
84
|
+
* @param options.addressOrUid - Wallet address or Clicker profile ID.
|
|
85
|
+
* @returns The following response.
|
|
86
|
+
*/
|
|
87
|
+
export type SocialServiceFetchFollowingAction = {
|
|
88
|
+
type: `SocialService:fetchFollowing`;
|
|
89
|
+
handler: SocialService['fetchFollowing'];
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Follows one or more traders.
|
|
93
|
+
*
|
|
94
|
+
* Calls `PUT ${baseUrl}/users/${addressOrUid}/follows`.
|
|
95
|
+
*
|
|
96
|
+
* @param options - Options bag.
|
|
97
|
+
* @param options.addressOrUid - Wallet address or Clicker profile ID of the user.
|
|
98
|
+
* @param options.targets - Array of wallet addresses or profile IDs to follow.
|
|
99
|
+
* @returns The follow response with confirmed follows.
|
|
100
|
+
*/
|
|
101
|
+
export type SocialServiceFollowAction = {
|
|
102
|
+
type: `SocialService:follow`;
|
|
103
|
+
handler: SocialService['follow'];
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Unfollows one or more traders.
|
|
107
|
+
*
|
|
108
|
+
* Calls `DELETE ${baseUrl}/users/${addressOrUid}/follows?targets=...`.
|
|
109
|
+
* Targets are sent as query params because Fastify does not parse
|
|
110
|
+
* request bodies on DELETE requests per RFC 9110.
|
|
111
|
+
*
|
|
112
|
+
* @param options - Options bag.
|
|
113
|
+
* @param options.addressOrUid - Wallet address or Clicker profile ID of the user.
|
|
114
|
+
* @param options.targets - Array of wallet addresses or profile IDs to unfollow.
|
|
115
|
+
* @returns The unfollow response with confirmed unfollows.
|
|
116
|
+
*/
|
|
117
|
+
export type SocialServiceUnfollowAction = {
|
|
118
|
+
type: `SocialService:unfollow`;
|
|
119
|
+
handler: SocialService['unfollow'];
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Union of all SocialService action types.
|
|
123
|
+
*/
|
|
124
|
+
export type SocialServiceMethodActions = SocialServiceFetchLeaderboardAction | SocialServiceFetchTraderProfileAction | SocialServiceFetchOpenPositionsAction | SocialServiceFetchClosedPositionsAction | SocialServiceFetchFollowersAction | SocialServiceFetchFollowingAction | SocialServiceFollowAction | SocialServiceUnfollowAction;
|
|
125
|
+
//# sourceMappingURL=SocialService-method-action-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SocialService-method-action-types.d.mts","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AwB,CAAC;IAC/B,OAAO,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAClC,mCAAmC,GACnC,qCAAqC,GACrC,qCAAqC,GACrC,uCAAuC,GACvC,iCAAiC,GACjC,iCAAiC,GACjC,yBAAyB,GACzB,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SocialService-method-action-types.mjs","sourceRoot":"","sources":["../src/SocialService-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SocialService } from './SocialService';\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 */\nexport type SocialServiceFetchLeaderboardAction = {\n type: `SocialService:fetchLeaderboard`;\n handler: SocialService['fetchLeaderboard'];\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 */\nexport type SocialServiceFetchTraderProfileAction = {\n type: `SocialService:fetchTraderProfile`;\n handler: SocialService['fetchTraderProfile'];\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 */\nexport type SocialServiceFetchOpenPositionsAction = {\n type: `SocialService:fetchOpenPositions`;\n handler: SocialService['fetchOpenPositions'];\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 */\nexport type SocialServiceFetchClosedPositionsAction = {\n type: `SocialService:fetchClosedPositions`;\n handler: SocialService['fetchClosedPositions'];\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 */\nexport type SocialServiceFetchFollowersAction = {\n type: `SocialService:fetchFollowers`;\n handler: SocialService['fetchFollowers'];\n};\n\n/**\n * Fetches the list of traders a user is following.\n *\n * Calls `GET ${baseUrl}/users/${addressOrUid}/following`.\n *\n * @param options - Options bag.\n * @param options.addressOrUid - Wallet address or Clicker profile ID.\n * @returns The following response.\n */\nexport type SocialServiceFetchFollowingAction = {\n type: `SocialService:fetchFollowing`;\n handler: SocialService['fetchFollowing'];\n};\n\n/**\n * Follows one or more traders.\n *\n * Calls `PUT ${baseUrl}/users/${addressOrUid}/follows`.\n *\n * @param options - Options bag.\n * @param options.addressOrUid - Wallet address or Clicker profile ID of the user.\n * @param options.targets - Array of wallet addresses or profile IDs to follow.\n * @returns The follow response with confirmed follows.\n */\nexport type SocialServiceFollowAction = {\n type: `SocialService:follow`;\n handler: SocialService['follow'];\n};\n\n/**\n * Unfollows one or more traders.\n *\n * Calls `DELETE ${baseUrl}/users/${addressOrUid}/follows?targets=...`.\n * Targets are sent as query params because Fastify does not parse\n * request bodies on DELETE requests per RFC 9110.\n *\n * @param options - Options bag.\n * @param options.addressOrUid - Wallet address or Clicker profile ID of the user.\n * @param options.targets - Array of wallet addresses or profile IDs to unfollow.\n * @returns The unfollow response with confirmed unfollows.\n */\nexport type SocialServiceUnfollowAction = {\n type: `SocialService:unfollow`;\n handler: SocialService['unfollow'];\n};\n\n/**\n * Union of all SocialService action types.\n */\nexport type SocialServiceMethodActions =\n | SocialServiceFetchLeaderboardAction\n | SocialServiceFetchTraderProfileAction\n | SocialServiceFetchOpenPositionsAction\n | SocialServiceFetchClosedPositionsAction\n | SocialServiceFetchFollowersAction\n | SocialServiceFetchFollowingAction\n | SocialServiceFollowAction\n | SocialServiceUnfollowAction;\n"]}
|