@metamask-previews/social-controllers 2.3.1-preview-e82188855 → 2.3.1-preview-99313eb

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/SocialController-method-action-types.cjs.map +1 -1
  3. package/dist/SocialController-method-action-types.d.cts +15 -1
  4. package/dist/SocialController-method-action-types.d.cts.map +1 -1
  5. package/dist/SocialController-method-action-types.d.mts +15 -1
  6. package/dist/SocialController-method-action-types.d.mts.map +1 -1
  7. package/dist/SocialController-method-action-types.mjs.map +1 -1
  8. package/dist/SocialController.cjs +14 -0
  9. package/dist/SocialController.cjs.map +1 -1
  10. package/dist/SocialController.d.cts +10 -2
  11. package/dist/SocialController.d.cts.map +1 -1
  12. package/dist/SocialController.d.mts +10 -2
  13. package/dist/SocialController.d.mts.map +1 -1
  14. package/dist/SocialController.mjs +14 -0
  15. package/dist/SocialController.mjs.map +1 -1
  16. package/dist/SocialService-method-action-types.cjs.map +1 -1
  17. package/dist/SocialService-method-action-types.d.cts +15 -1
  18. package/dist/SocialService-method-action-types.d.cts.map +1 -1
  19. package/dist/SocialService-method-action-types.d.mts +15 -1
  20. package/dist/SocialService-method-action-types.d.mts.map +1 -1
  21. package/dist/SocialService-method-action-types.mjs.map +1 -1
  22. package/dist/SocialService.cjs +40 -0
  23. package/dist/SocialService.cjs.map +1 -1
  24. package/dist/SocialService.d.cts +8 -0
  25. package/dist/SocialService.d.cts.map +1 -1
  26. package/dist/SocialService.d.mts +8 -0
  27. package/dist/SocialService.d.mts.map +1 -1
  28. package/dist/SocialService.mjs +40 -0
  29. package/dist/SocialService.mjs.map +1 -1
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +2 -2
  32. package/dist/index.d.cts.map +1 -1
  33. package/dist/index.d.mts +2 -2
  34. package/dist/index.d.mts.map +1 -1
  35. package/dist/index.mjs.map +1 -1
  36. package/dist/social-constants.cjs +2 -0
  37. package/dist/social-constants.cjs.map +1 -1
  38. package/dist/social-constants.d.cts +2 -0
  39. package/dist/social-constants.d.cts.map +1 -1
  40. package/dist/social-constants.d.mts +2 -0
  41. package/dist/social-constants.d.mts.map +1 -1
  42. package/dist/social-constants.mjs +2 -0
  43. package/dist/social-constants.mjs.map +1 -1
  44. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Added
11
+
12
+ - Add `optOutOfLeaderboard` and `optInToLeaderboard` methods to `SocialController` and `SocialService`, with corresponding messenger actions (`SocialController:optOutOfLeaderboard`, `SocialController:optInToLeaderboard`, `SocialService:optOutOfLeaderboard`, `SocialService:optInToLeaderboard`). These call `POST /leaderboard/opt-out` and `POST /leaderboard/opt-in` respectively (JWT-authed, `204 No Content` on success) ([#9354](https://github.com/MetaMask/core/pull/9354))
13
+
10
14
  ### Changed
11
15
 
12
16
  - Bump `@metamask/controller-utils` from `^12.2.0` to `^12.3.0` ([#9218](https://github.com/MetaMask/core/pull/9218))
@@ -1 +1 @@
1
- {"version":3,"file":"SocialController-method-action-types.cjs","sourceRoot":"","sources":["../src/SocialController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SocialController } from './SocialController';\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 */\nexport type SocialControllerUpdateLeaderboardAction = {\n type: `SocialController:updateLeaderboard`;\n handler: SocialController['updateLeaderboard'];\n};\n\n/**\n * Follows one or more traders on behalf of the current user and updates\n * the following list in state. The caller is identified server-side from\n * the JWT attached by the SocialService.\n *\n * @param options - Options bag.\n * @param options.targets - Addresses or profile IDs to follow.\n * @returns The follow response with confirmed follows.\n */\nexport type SocialControllerFollowTraderAction = {\n type: `SocialController:followTrader`;\n handler: SocialController['followTrader'];\n};\n\n/**\n * Unfollows one or more traders on behalf of the current user and updates\n * the following list in state. The caller is identified server-side from\n * the JWT attached by the SocialService.\n *\n * @param options - Options bag.\n * @param options.targets - Addresses or profile IDs to unfollow.\n * @returns The unfollow response with confirmed unfollows.\n */\nexport type SocialControllerUnfollowTraderAction = {\n type: `SocialController:unfollowTrader`;\n handler: SocialController['unfollowTrader'];\n};\n\n/**\n * Fetches the list of traders the current user follows and replaces\n * the following addresses in state. The caller is identified server-side\n * from the JWT attached by the SocialService.\n *\n * @returns The following response.\n */\nexport type SocialControllerUpdateFollowingAction = {\n type: `SocialController:updateFollowing`;\n handler: SocialController['updateFollowing'];\n};\n\n/**\n * Union of all SocialController action types.\n */\nexport type SocialControllerMethodActions =\n | SocialControllerUpdateLeaderboardAction\n | SocialControllerFollowTraderAction\n | SocialControllerUnfollowTraderAction\n | SocialControllerUpdateFollowingAction;\n"]}
1
+ {"version":3,"file":"SocialController-method-action-types.cjs","sourceRoot":"","sources":["../src/SocialController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SocialController } from './SocialController';\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 */\nexport type SocialControllerUpdateLeaderboardAction = {\n type: `SocialController:updateLeaderboard`;\n handler: SocialController['updateLeaderboard'];\n};\n\n/**\n * Follows one or more traders on behalf of the current user and updates\n * the following list in state. The caller is identified server-side from\n * the JWT attached by the SocialService.\n *\n * @param options - Options bag.\n * @param options.targets - Addresses or profile IDs to follow.\n * @returns The follow response with confirmed follows.\n */\nexport type SocialControllerFollowTraderAction = {\n type: `SocialController:followTrader`;\n handler: SocialController['followTrader'];\n};\n\n/**\n * Unfollows one or more traders on behalf of the current user and updates\n * the following list in state. The caller is identified server-side from\n * the JWT attached by the SocialService.\n *\n * @param options - Options bag.\n * @param options.targets - Addresses or profile IDs to unfollow.\n * @returns The unfollow response with confirmed unfollows.\n */\nexport type SocialControllerUnfollowTraderAction = {\n type: `SocialController:unfollowTrader`;\n handler: SocialController['unfollowTrader'];\n};\n\n/**\n * Fetches the list of traders the current user follows and replaces\n * the following addresses in state. The caller is identified server-side\n * from the JWT attached by the SocialService.\n *\n * @returns The following response.\n */\nexport type SocialControllerUpdateFollowingAction = {\n type: `SocialController:updateFollowing`;\n handler: SocialController['updateFollowing'];\n};\n\n/**\n * Opts the current user out of the PnL leaderboard.\n */\nexport type SocialControllerOptOutOfLeaderboardAction = {\n type: `SocialController:optOutOfLeaderboard`;\n handler: SocialController['optOutOfLeaderboard'];\n};\n\n/**\n * Opts the current user back into the PnL leaderboard.\n */\nexport type SocialControllerOptInToLeaderboardAction = {\n type: `SocialController:optInToLeaderboard`;\n handler: SocialController['optInToLeaderboard'];\n};\n\n/**\n * Union of all SocialController action types.\n */\nexport type SocialControllerMethodActions =\n | SocialControllerUpdateLeaderboardAction\n | SocialControllerFollowTraderAction\n | SocialControllerUnfollowTraderAction\n | SocialControllerUpdateFollowingAction\n | SocialControllerOptOutOfLeaderboardAction\n | SocialControllerOptInToLeaderboardAction;\n"]}
@@ -50,8 +50,22 @@ export type SocialControllerUpdateFollowingAction = {
50
50
  type: `SocialController:updateFollowing`;
51
51
  handler: SocialController['updateFollowing'];
52
52
  };
53
+ /**
54
+ * Opts the current user out of the PnL leaderboard.
55
+ */
56
+ export type SocialControllerOptOutOfLeaderboardAction = {
57
+ type: `SocialController:optOutOfLeaderboard`;
58
+ handler: SocialController['optOutOfLeaderboard'];
59
+ };
60
+ /**
61
+ * Opts the current user back into the PnL leaderboard.
62
+ */
63
+ export type SocialControllerOptInToLeaderboardAction = {
64
+ type: `SocialController:optInToLeaderboard`;
65
+ handler: SocialController['optInToLeaderboard'];
66
+ };
53
67
  /**
54
68
  * Union of all SocialController action types.
55
69
  */
56
- export type SocialControllerMethodActions = SocialControllerUpdateLeaderboardAction | SocialControllerFollowTraderAction | SocialControllerUnfollowTraderAction | SocialControllerUpdateFollowingAction;
70
+ export type SocialControllerMethodActions = SocialControllerUpdateLeaderboardAction | SocialControllerFollowTraderAction | SocialControllerUnfollowTraderAction | SocialControllerUpdateFollowingAction | SocialControllerOptOutOfLeaderboardAction | SocialControllerOptInToLeaderboardAction;
57
71
  //# sourceMappingURL=SocialController-method-action-types.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SocialController-method-action-types.d.cts","sourceRoot":"","sources":["../src/SocialController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,+BAA2B;AAE3D;;;;;GAKG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;CAChD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,uCAAuC,GACvC,kCAAkC,GAClC,oCAAoC,GACpC,qCAAqC,CAAC"}
1
+ {"version":3,"file":"SocialController-method-action-types.d.cts","sourceRoot":"","sources":["../src/SocialController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,+BAA2B;AAE3D;;;;;GAKG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;CAChD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;CAClD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,uCAAuC,GACvC,kCAAkC,GAClC,oCAAoC,GACpC,qCAAqC,GACrC,yCAAyC,GACzC,wCAAwC,CAAC"}
@@ -50,8 +50,22 @@ export type SocialControllerUpdateFollowingAction = {
50
50
  type: `SocialController:updateFollowing`;
51
51
  handler: SocialController['updateFollowing'];
52
52
  };
53
+ /**
54
+ * Opts the current user out of the PnL leaderboard.
55
+ */
56
+ export type SocialControllerOptOutOfLeaderboardAction = {
57
+ type: `SocialController:optOutOfLeaderboard`;
58
+ handler: SocialController['optOutOfLeaderboard'];
59
+ };
60
+ /**
61
+ * Opts the current user back into the PnL leaderboard.
62
+ */
63
+ export type SocialControllerOptInToLeaderboardAction = {
64
+ type: `SocialController:optInToLeaderboard`;
65
+ handler: SocialController['optInToLeaderboard'];
66
+ };
53
67
  /**
54
68
  * Union of all SocialController action types.
55
69
  */
56
- export type SocialControllerMethodActions = SocialControllerUpdateLeaderboardAction | SocialControllerFollowTraderAction | SocialControllerUnfollowTraderAction | SocialControllerUpdateFollowingAction;
70
+ export type SocialControllerMethodActions = SocialControllerUpdateLeaderboardAction | SocialControllerFollowTraderAction | SocialControllerUnfollowTraderAction | SocialControllerUpdateFollowingAction | SocialControllerOptOutOfLeaderboardAction | SocialControllerOptInToLeaderboardAction;
57
71
  //# sourceMappingURL=SocialController-method-action-types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SocialController-method-action-types.d.mts","sourceRoot":"","sources":["../src/SocialController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,+BAA2B;AAE3D;;;;;GAKG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;CAChD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,uCAAuC,GACvC,kCAAkC,GAClC,oCAAoC,GACpC,qCAAqC,CAAC"}
1
+ {"version":3,"file":"SocialController-method-action-types.d.mts","sourceRoot":"","sources":["../src/SocialController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,+BAA2B;AAE3D;;;;;GAKG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;CAChD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;CAClD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;CACjD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GACrC,uCAAuC,GACvC,kCAAkC,GAClC,oCAAoC,GACpC,qCAAqC,GACrC,yCAAyC,GACzC,wCAAwC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SocialController-method-action-types.mjs","sourceRoot":"","sources":["../src/SocialController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SocialController } from './SocialController';\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 */\nexport type SocialControllerUpdateLeaderboardAction = {\n type: `SocialController:updateLeaderboard`;\n handler: SocialController['updateLeaderboard'];\n};\n\n/**\n * Follows one or more traders on behalf of the current user and updates\n * the following list in state. The caller is identified server-side from\n * the JWT attached by the SocialService.\n *\n * @param options - Options bag.\n * @param options.targets - Addresses or profile IDs to follow.\n * @returns The follow response with confirmed follows.\n */\nexport type SocialControllerFollowTraderAction = {\n type: `SocialController:followTrader`;\n handler: SocialController['followTrader'];\n};\n\n/**\n * Unfollows one or more traders on behalf of the current user and updates\n * the following list in state. The caller is identified server-side from\n * the JWT attached by the SocialService.\n *\n * @param options - Options bag.\n * @param options.targets - Addresses or profile IDs to unfollow.\n * @returns The unfollow response with confirmed unfollows.\n */\nexport type SocialControllerUnfollowTraderAction = {\n type: `SocialController:unfollowTrader`;\n handler: SocialController['unfollowTrader'];\n};\n\n/**\n * Fetches the list of traders the current user follows and replaces\n * the following addresses in state. The caller is identified server-side\n * from the JWT attached by the SocialService.\n *\n * @returns The following response.\n */\nexport type SocialControllerUpdateFollowingAction = {\n type: `SocialController:updateFollowing`;\n handler: SocialController['updateFollowing'];\n};\n\n/**\n * Union of all SocialController action types.\n */\nexport type SocialControllerMethodActions =\n | SocialControllerUpdateLeaderboardAction\n | SocialControllerFollowTraderAction\n | SocialControllerUnfollowTraderAction\n | SocialControllerUpdateFollowingAction;\n"]}
1
+ {"version":3,"file":"SocialController-method-action-types.mjs","sourceRoot":"","sources":["../src/SocialController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { SocialController } from './SocialController';\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 */\nexport type SocialControllerUpdateLeaderboardAction = {\n type: `SocialController:updateLeaderboard`;\n handler: SocialController['updateLeaderboard'];\n};\n\n/**\n * Follows one or more traders on behalf of the current user and updates\n * the following list in state. The caller is identified server-side from\n * the JWT attached by the SocialService.\n *\n * @param options - Options bag.\n * @param options.targets - Addresses or profile IDs to follow.\n * @returns The follow response with confirmed follows.\n */\nexport type SocialControllerFollowTraderAction = {\n type: `SocialController:followTrader`;\n handler: SocialController['followTrader'];\n};\n\n/**\n * Unfollows one or more traders on behalf of the current user and updates\n * the following list in state. The caller is identified server-side from\n * the JWT attached by the SocialService.\n *\n * @param options - Options bag.\n * @param options.targets - Addresses or profile IDs to unfollow.\n * @returns The unfollow response with confirmed unfollows.\n */\nexport type SocialControllerUnfollowTraderAction = {\n type: `SocialController:unfollowTrader`;\n handler: SocialController['unfollowTrader'];\n};\n\n/**\n * Fetches the list of traders the current user follows and replaces\n * the following addresses in state. The caller is identified server-side\n * from the JWT attached by the SocialService.\n *\n * @returns The following response.\n */\nexport type SocialControllerUpdateFollowingAction = {\n type: `SocialController:updateFollowing`;\n handler: SocialController['updateFollowing'];\n};\n\n/**\n * Opts the current user out of the PnL leaderboard.\n */\nexport type SocialControllerOptOutOfLeaderboardAction = {\n type: `SocialController:optOutOfLeaderboard`;\n handler: SocialController['optOutOfLeaderboard'];\n};\n\n/**\n * Opts the current user back into the PnL leaderboard.\n */\nexport type SocialControllerOptInToLeaderboardAction = {\n type: `SocialController:optInToLeaderboard`;\n handler: SocialController['optInToLeaderboard'];\n};\n\n/**\n * Union of all SocialController action types.\n */\nexport type SocialControllerMethodActions =\n | SocialControllerUpdateLeaderboardAction\n | SocialControllerFollowTraderAction\n | SocialControllerUnfollowTraderAction\n | SocialControllerUpdateFollowingAction\n | SocialControllerOptOutOfLeaderboardAction\n | SocialControllerOptInToLeaderboardAction;\n"]}
@@ -9,6 +9,8 @@ const MESSENGER_EXPOSED_METHODS = [
9
9
  'followTrader',
10
10
  'unfollowTrader',
11
11
  'updateFollowing',
12
+ 'optOutOfLeaderboard',
13
+ 'optInToLeaderboard',
12
14
  ];
13
15
  // === DEFAULT STATE ===
14
16
  /**
@@ -141,6 +143,18 @@ class SocialController extends base_controller_1.BaseController {
141
143
  });
142
144
  return followingResponse;
143
145
  }
146
+ /**
147
+ * Opts the current user out of the PnL leaderboard.
148
+ */
149
+ async optOutOfLeaderboard() {
150
+ await this.messenger.call('SocialService:optOutOfLeaderboard');
151
+ }
152
+ /**
153
+ * Opts the current user back into the PnL leaderboard.
154
+ */
155
+ async optInToLeaderboard() {
156
+ await this.messenger.call('SocialService:optInToLeaderboard');
157
+ }
144
158
  }
145
159
  exports.SocialController = SocialController;
146
160
  //# sourceMappingURL=SocialController.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"SocialController.cjs","sourceRoot":"","sources":["../src/SocialController.ts"],"names":[],"mappings":";;;AAKA,+DAA2D;AAG3D,6DAAoD;AAmBpD,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG;IAChC,mBAAmB;IACnB,cAAc;IACd,gBAAgB;IAChB,iBAAiB;CACT,CAAC;AA+CX,wBAAwB;AAExB;;;;GAIG;AACH,SAAgB,+BAA+B;IAC7C,OAAO;QACL,kBAAkB,EAAE,EAAE;QACtB,kBAAkB,EAAE,EAAE;QACtB,mBAAmB,EAAE,EAAE;KACxB,CAAC;AACJ,CAAC;AAND,0EAMC;AAED,yBAAyB;AAEzB,MAAM,wBAAwB,GAAyC;IACrE,kBAAkB,EAAE;QAClB,OAAO,EAAE,IAAI;QACb,sBAAsB,E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AC,OAAO,CAAC,CAC9D,CAAC;QACF,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAC/B,gBAAgB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAChE,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,kBAAkB,GAAG,KAAK,CAAC,kBAAkB,CAAC,MAAM,CACxD,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAC5C,CAAC;YACF,KAAK,CAAC,mBAAmB,GAAG,KAAK,CAAC,mBAAmB,CAAC,MAAM,CAC1D,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,CACnC,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,eAAe;QACnB,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CACjD,8BAA8B,CAC/B,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,kBAAkB,GAAG,iBAAiB,CAAC,SAAS,CAAC,GAAG,CACxD,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAC7B,CAAC;YACF,KAAK,CAAC,mBAAmB,GAAG,iBAAiB,CAAC,SAAS,CAAC,GAAG,CACzD,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAC/B,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF;AAzID,4CAyIC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport { controllerName } from './social-constants';\nimport type {\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 followingProfileIds: [],\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 followingProfileIds: {\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 on behalf of the current user and updates\n * the following list in state. The caller is identified server-side from\n * the JWT attached by the SocialService.\n *\n * @param options - Options bag.\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 const newProfileIds = [\n ...new Set(followResponse.followed.map((profile) => profile.profileId)),\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 const existingIds = new Set(state.followingProfileIds);\n const uniqueNewIds = newProfileIds.filter((id) => !existingIds.has(id));\n state.followingProfileIds.push(...uniqueNewIds);\n });\n\n return followResponse;\n }\n\n /**\n * Unfollows one or more traders on behalf of the current user and updates\n * the following list in state. The caller is identified server-side from\n * the JWT attached by the SocialService.\n *\n * @param options - Options bag.\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 const removedProfileIds = new Set(\n unfollowResponse.unfollowed.map((profile) => profile.profileId),\n );\n\n this.update((state) => {\n state.followingAddresses = state.followingAddresses.filter(\n (address) => !removedAddresses.has(address),\n );\n state.followingProfileIds = state.followingProfileIds.filter(\n (id) => !removedProfileIds.has(id),\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. The caller is identified server-side\n * from the JWT attached by the SocialService.\n *\n * @returns The following response.\n */\n async updateFollowing(): Promise<FollowingResponse> {\n const followingResponse = await this.messenger.call(\n 'SocialService:fetchFollowing',\n );\n\n this.update((state) => {\n state.followingAddresses = followingResponse.following.map(\n (profile) => profile.address,\n );\n state.followingProfileIds = followingResponse.following.map(\n (profile) => profile.profileId,\n );\n });\n\n return followingResponse;\n }\n}\n"]}
1
+ {"version":3,"file":"SocialController.cjs","sourceRoot":"","sources":["../src/SocialController.ts"],"names":[],"mappings":";;;AAKA,+DAA2D;AAG3D,6DAAoD;AAqBpD,oBAAoB;AAEpB,MAAM,y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SAAS,CAAC,GAAG,CACxD,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAC7B,CAAC;YACF,KAAK,CAAC,mBAAmB,GAAG,iBAAiB,CAAC,SAAS,CAAC,GAAG,CACzD,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAC/B,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,mBAAmB;QACvB,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;IACjE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,kBAAkB;QACtB,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IAChE,CAAC;CACF;AAvJD,4CAuJC","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport { controllerName } from './social-constants';\nimport type {\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 SocialServiceOptInToLeaderboardAction,\n SocialServiceOptOutOfLeaderboardAction,\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 'optOutOfLeaderboard',\n 'optInToLeaderboard',\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 | SocialServiceOptOutOfLeaderboardAction\n | SocialServiceOptInToLeaderboardAction;\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 followingProfileIds: [],\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 followingProfileIds: {\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 on behalf of the current user and updates\n * the following list in state. The caller is identified server-side from\n * the JWT attached by the SocialService.\n *\n * @param options - Options bag.\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 const newProfileIds = [\n ...new Set(followResponse.followed.map((profile) => profile.profileId)),\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 const existingIds = new Set(state.followingProfileIds);\n const uniqueNewIds = newProfileIds.filter((id) => !existingIds.has(id));\n state.followingProfileIds.push(...uniqueNewIds);\n });\n\n return followResponse;\n }\n\n /**\n * Unfollows one or more traders on behalf of the current user and updates\n * the following list in state. The caller is identified server-side from\n * the JWT attached by the SocialService.\n *\n * @param options - Options bag.\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 const removedProfileIds = new Set(\n unfollowResponse.unfollowed.map((profile) => profile.profileId),\n );\n\n this.update((state) => {\n state.followingAddresses = state.followingAddresses.filter(\n (address) => !removedAddresses.has(address),\n );\n state.followingProfileIds = state.followingProfileIds.filter(\n (id) => !removedProfileIds.has(id),\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. The caller is identified server-side\n * from the JWT attached by the SocialService.\n *\n * @returns The following response.\n */\n async updateFollowing(): Promise<FollowingResponse> {\n const followingResponse = await this.messenger.call(\n 'SocialService:fetchFollowing',\n );\n\n this.update((state) => {\n state.followingAddresses = followingResponse.following.map(\n (profile) => profile.address,\n );\n state.followingProfileIds = followingResponse.following.map(\n (profile) => profile.profileId,\n );\n });\n\n return followingResponse;\n }\n\n /**\n * Opts the current user out of the PnL leaderboard.\n */\n async optOutOfLeaderboard(): Promise<void> {\n await this.messenger.call('SocialService:optOutOfLeaderboard');\n }\n\n /**\n * Opts the current user back into the PnL leaderboard.\n */\n async optInToLeaderboard(): Promise<void> {\n await this.messenger.call('SocialService:optInToLeaderboard');\n }\n}\n"]}
@@ -4,12 +4,12 @@ import type { Messenger } from "@metamask/messenger";
4
4
  import { controllerName } from "./social-constants.cjs";
5
5
  import type { FetchLeaderboardOptions, FollowOptions, FollowResponse, FollowingResponse, LeaderboardResponse, SocialControllerState, UnfollowOptions, UnfollowResponse } from "./social-types.cjs";
6
6
  import type { SocialControllerMethodActions } from "./SocialController-method-action-types.cjs";
7
- import type { SocialServiceFetchFollowingAction, SocialServiceFetchLeaderboardAction, SocialServiceFollowAction, SocialServiceUnfollowAction } from "./SocialService-method-action-types.cjs";
7
+ import type { SocialServiceFetchFollowingAction, SocialServiceFetchLeaderboardAction, SocialServiceFollowAction, SocialServiceOptInToLeaderboardAction, SocialServiceOptOutOfLeaderboardAction, SocialServiceUnfollowAction } from "./SocialService-method-action-types.cjs";
8
8
  export type SocialControllerGetStateAction = ControllerGetStateAction<typeof controllerName, SocialControllerState>;
9
9
  export type SocialControllerActions = SocialControllerGetStateAction | SocialControllerMethodActions;
10
10
  export type SocialControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, SocialControllerState>;
11
11
  export type SocialControllerEvents = SocialControllerStateChangeEvent;
12
- type AllowedActions = SocialServiceFetchLeaderboardAction | SocialServiceFollowAction | SocialServiceUnfollowAction | SocialServiceFetchFollowingAction;
12
+ type AllowedActions = SocialServiceFetchLeaderboardAction | SocialServiceFollowAction | SocialServiceUnfollowAction | SocialServiceFetchFollowingAction | SocialServiceOptOutOfLeaderboardAction | SocialServiceOptInToLeaderboardAction;
13
13
  type AllowedEvents = never;
14
14
  export type SocialControllerMessenger = Messenger<typeof controllerName, SocialControllerActions | AllowedActions, SocialControllerEvents | AllowedEvents>;
15
15
  export type SocialControllerOptions = {
@@ -67,6 +67,14 @@ export declare class SocialController extends BaseController<typeof controllerNa
67
67
  * @returns The following response.
68
68
  */
69
69
  updateFollowing(): Promise<FollowingResponse>;
70
+ /**
71
+ * Opts the current user out of the PnL leaderboard.
72
+ */
73
+ optOutOfLeaderboard(): Promise<void>;
74
+ /**
75
+ * Opts the current user back into the PnL leaderboard.
76
+ */
77
+ optInToLeaderboard(): Promise<void>;
70
78
  }
71
79
  export {};
72
80
  //# sourceMappingURL=SocialController.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SocialController.d.cts","sourceRoot":"","sources":["../src/SocialController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,EAAE,cAAc,EAAE,+BAA2B;AACpD,OAAO,KAA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C;IAa/B;;;;;;;;OAQG;IACG,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IA4BnE;;;;;;;;OAQG;IACG,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAyBzE;;;;;;OAMG;IACG,eAAe,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAgBpD"}
1
+ {"version":3,"file":"SocialController.d.cts","sourceRoot":"","sources":["../src/SocialController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,EAAE,cAAc,EAAE,+BAA2B;AACpD,OAAO,KAAK,EACV,uBAAuB,EACvB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EACjB,2BAAuB;AACxB,OAAO,KAAK,EAAE,6BAA6B,EAAE,mDAA+C;AAC5F,OAAO,KAAK,EACV,iCAAiC,EACjC,mCAAmC,EACnC,yBAAyB,EACzB,qCAAqC,EACrC,sCAAsC,EACtC,2BAA2B,EAC5B,gDAA4C;AAe7C,MAAM,MAAM,8BAA8B,GAAG,wBAAwB,CACnE,OAAO,cAAc,EACrB,qBAAqB,CACtB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAC/B,8BAA8B,GAC9B,6BAA6B,CAAC;AAIlC,MAAM,MAAM,gCAAgC,GAAG,0BAA0B,CACvE,OAAO,cAAc,EACrB,qBAAqB,CACtB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,gCAAgC,CAAC;AAItE,KAAK,cAAc,GACf,mCAAmC,GACnC,yBAAyB,GACzB,2BAA2B,GAC3B,iCAAiC,GACjC,sCAAsC,GACtC,qCAAqC,CAAC;AAE1C,KAAK,aAAa,GAAG,KAAK,CAAC;AAI3B,MAAM,MAAM,yBAAyB,GAAG,SAAS,CAC/C,OAAO,cAAc,EACrB,uBAAuB,GAAG,cAAc,EACxC,sBAAsB,GAAG,aAAa,CACvC,CAAC;AAIF,MAAM,MAAM,uBAAuB,GAAG;IACpC,SAAS,EAAE,yBAAyB,CAAC;IACrC,KAAK,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACxC,CAAC;AAIF;;;;GAIG;AACH,wBAAgB,+BAA+B,IAAI,qBAAqB,CAMvE;AA2BD;;;;;;;GAOG;AACH,qBAAa,gBAAiB,SAAQ,cAAc,CAClD,OAAO,cAAc,EACrB,qBAAqB,EACrB,yBAAyB,CAC1B;gBACa,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,uBAAuB;IAiBzD;;;;;OAKG;IACG,iBAAiB,CACrB,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,mBAAmB,CAAC;IAa/B;;;;;;;;OAQG;IACG,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IA4BnE;;;;;;;;OAQG;IACG,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAyBzE;;;;;;OAMG;IACG,eAAe,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAiBnD;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI1C;;OAEG;IACG,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;CAG1C"}
@@ -4,12 +4,12 @@ import type { Messenger } from "@metamask/messenger";
4
4
  import { controllerName } from "./social-constants.mjs";
5
5
  import type { FetchLeaderboardOptions, FollowOptions, FollowResponse, FollowingResponse, LeaderboardResponse, SocialControllerState, UnfollowOptions, UnfollowResponse } from "./social-types.mjs";
6
6
  import type { SocialControllerMethodActions } from "./SocialController-method-action-types.mjs";
7
- import type { SocialServiceFetchFollowingAction, SocialServiceFetchLeaderboardAction, SocialServiceFollowAction, SocialServiceUnfollowAction } from "./SocialService-method-action-types.mjs";
7
+ import type { SocialServiceFetchFollowingAction, SocialServiceFetchLeaderboardAction, SocialServiceFollowAction, SocialServiceOptInToLeaderboardAction, SocialServiceOptOutOfLeaderboardAction, SocialServiceUnfollowAction } from "./SocialService-method-action-types.mjs";
8
8
  export type SocialControllerGetStateAction = ControllerGetStateAction<typeof controllerName, SocialControllerState>;
9
9
  export type SocialControllerActions = SocialControllerGetStateAction | SocialControllerMethodActions;
10
10
  export type SocialControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, SocialControllerState>;
11
11
  export type SocialControllerEvents = SocialControllerStateChangeEvent;
12
- type AllowedActions = SocialServiceFetchLeaderboardAction | SocialServiceFollowAction | SocialServiceUnfollowAction | SocialServiceFetchFollowingAction;
12
+ type AllowedActions = SocialServiceFetchLeaderboardAction | SocialServiceFollowAction | SocialServiceUnfollowAction | SocialServiceFetchFollowingAction | SocialServiceOptOutOfLeaderboardAction | SocialServiceOptInToLeaderboardAction;
13
13
  type AllowedEvents = never;
14
14
  export type SocialControllerMessenger = Messenger<typeof controllerName, SocialControllerActions | AllowedActions, SocialControllerEvents | AllowedEvents>;
15
15
  export type SocialControllerOptions = {
@@ -67,6 +67,14 @@ export declare class SocialController extends BaseController<typeof controllerNa
67
67
  * @returns The following response.
68
68
  */
69
69
  updateFollowing(): Promise<FollowingResponse>;
70
+ /**
71
+ * Opts the current user out of the PnL leaderboard.
72
+ */
73
+ optOutOfLeaderboard(): Promise<void>;
74
+ /**
75
+ * Opts the current user back into the PnL leaderboard.
76
+ */
77
+ optInToLeaderboard(): Promise<void>;
70
78
  }
71
79
  export {};
72
80
  //# sourceMappingURL=SocialController.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SocialController.d.mts","sourceRoot":"","sources":["../src/SocialController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAA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,KAAK,EAAE,EAAE,uBAAuB;IAiBzD;;;;;OAKG;IACG,iBAAiB,CACrB,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,mBAAmB,CAAC;IAa/B;;;;;;;;OAQG;IACG,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IA4BnE;;;;;;;;OAQG;IACG,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAyBzE;;;;;;OAMG;IACG,eAAe,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAgBpD"}
1
+ {"version":3,"file":"SocialController.d.mts","sourceRoot":"","sources":["../src/SocialController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAErD,OAAO,EAAE,cAAc,EAAE,+BAA2B;AACpD,OAAO,KAAK,EACV,uBAAuB,EACvB,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EACjB,2BAAuB;AACxB,OAAO,KAAK,EAAE,6BAA6B,EAAE,mDAA+C;AAC5F,OAAO,KAAK,EACV,iCAAiC,EACjC,mCAAmC,EACnC,yBAAyB,EACzB,qCAAqC,EACrC,sCAAsC,EACtC,2BAA2B,EAC5B,gDAA4C;AAe7C,MAAM,MAAM,8BAA8B,GAAG,wBAAwB,CACnE,OAAO,cAAc,EACrB,qBAAqB,CACtB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAC/B,8BAA8B,GAC9B,6BAA6B,CAAC;AAIlC,MAAM,MAAM,gCAAgC,GAAG,0BAA0B,CACvE,OAAO,cAAc,EACrB,qBAAqB,CACtB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,gCAAgC,CAAC;AAItE,KAAK,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DEFAULT STATE ===
11
13
  /**
@@ -137,5 +139,17 @@ export class SocialController extends BaseController {
137
139
  });
138
140
  return followingResponse;
139
141
  }
142
+ /**
143
+ * Opts the current user out of the PnL leaderboard.
144
+ */
145
+ async optOutOfLeaderboard() {
146
+ await this.messenger.call('SocialService:optOutOfLeaderboard');
147
+ }
148
+ /**
149
+ * Opts the current user back into the PnL leaderboard.
150
+ */
151
+ async optInToLeaderboard() {
152
+ await this.messenger.call('SocialService:optInToLeaderboard');
153
+ }
140
154
  }
141
155
  //# sourceMappingURL=SocialController.mjs.map
@@ -1 +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;AAmBpD,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;QACtB,mBAAmB,EAAE,EAAE;KACxB,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;IACD,mBAAmB,EAAE;QACnB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,KAAK;QACzB,QAAQ,EAAE,IAAI;KACf;CACF,CAAC;AA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C,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAC5C,CAAC;YACF,KAAK,CAAC,mBAAmB,GAAG,KAAK,CAAC,mBAAmB,CAAC,MAAM,CAC1D,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC,CACnC,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,eAAe;QACnB,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CACjD,8BAA8B,CAC/B,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;YACpB,KAAK,CAAC,kBAAkB,GAAG,iBAAiB,CAAC,SAAS,CAAC,GAAG,CACxD,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAC7B,CAAC;YACF,KAAK,CAAC,mBAAmB,GAAG,iBAAiB,CAAC,SAAS,CAAC,GAAG,CACzD,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAC/B,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport { controllerName } from './social-constants';\nimport type {\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 followingProfileIds: [],\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 followingProfileIds: {\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 on behalf of the current user and updates\n * the following list in state. The caller is identified server-side from\n * the JWT attached by the SocialService.\n *\n * @param options - Options bag.\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 const newProfileIds = [\n ...new Set(followResponse.followed.map((profile) => profile.profileId)),\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 const existingIds = new Set(state.followingProfileIds);\n const uniqueNewIds = newProfileIds.filter((id) => !existingIds.has(id));\n state.followingProfileIds.push(...uniqueNewIds);\n });\n\n return followResponse;\n }\n\n /**\n * Unfollows one or more traders on behalf of the current user and updates\n * the following list in state. The caller is identified server-side from\n * the JWT attached by the SocialService.\n *\n * @param options - Options bag.\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 const removedProfileIds = new Set(\n unfollowResponse.unfollowed.map((profile) => profile.profileId),\n );\n\n this.update((state) => {\n state.followingAddresses = state.followingAddresses.filter(\n (address) => !removedAddresses.has(address),\n );\n state.followingProfileIds = state.followingProfileIds.filter(\n (id) => !removedProfileIds.has(id),\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. The caller is identified server-side\n * from the JWT attached by the SocialService.\n *\n * @returns The following response.\n */\n async updateFollowing(): Promise<FollowingResponse> {\n const followingResponse = await this.messenger.call(\n 'SocialService:fetchFollowing',\n );\n\n this.update((state) => {\n state.followingAddresses = followingResponse.following.map(\n (profile) => profile.address,\n );\n state.followingProfileIds = followingResponse.following.map(\n (profile) => profile.profileId,\n );\n });\n\n return followingResponse;\n }\n}\n"]}
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;AAqBpD,oBAAoB;AAEpB,MAAM,yBAAyB,GAAG;IAChC,mBAAmB;IACnB,cAAc;IACd,gBAAgB;IAChB,iBAAiB;IACjB,qBAAqB;IACrB,oBAAoB;CACZ,CAAC;AAiDX,wBAAwB;AAExB;;;;GAIG;AACH,MAAM,UAAU,+BAA+B;IAC7C,OAAO;QACL,kBAAkB,EAAE,EAAE;QACtB,kBAAkB,EAAE,EAAE;QACtB,mBAAmB,EAAE,EAAE;KACxB,CAAC;AACJ,CAAC;AAED,yBAAyB;AAEzB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CAAC,mBAAmB;QACvB,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;IACjE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,kBAAkB;QACtB,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["import type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n StateMetadata,\n} from '@metamask/base-controller';\nimport { BaseController } from '@metamask/base-controller';\nimport type { Messenger } from '@metamask/messenger';\n\nimport { controllerName } from './social-constants';\nimport type {\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 SocialServiceOptInToLeaderboardAction,\n SocialServiceOptOutOfLeaderboardAction,\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 'optOutOfLeaderboard',\n 'optInToLeaderboard',\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 | SocialServiceOptOutOfLeaderboardAction\n | SocialServiceOptInToLeaderboardAction;\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 followingProfileIds: [],\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 followingProfileIds: {\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 on behalf of the current user and updates\n * the following list in state. The caller is identified server-side from\n * the JWT attached by the SocialService.\n *\n * @param options - Options bag.\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 const newProfileIds = [\n ...new Set(followResponse.followed.map((profile) => profile.profileId)),\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 const existingIds = new Set(state.followingProfileIds);\n const uniqueNewIds = newProfileIds.filter((id) => !existingIds.has(id));\n state.followingProfileIds.push(...uniqueNewIds);\n });\n\n return followResponse;\n }\n\n /**\n * Unfollows one or more traders on behalf of the current user and updates\n * the following list in state. The caller is identified server-side from\n * the JWT attached by the SocialService.\n *\n * @param options - Options bag.\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 const removedProfileIds = new Set(\n unfollowResponse.unfollowed.map((profile) => profile.profileId),\n );\n\n this.update((state) => {\n state.followingAddresses = state.followingAddresses.filter(\n (address) => !removedAddresses.has(address),\n );\n state.followingProfileIds = state.followingProfileIds.filter(\n (id) => !removedProfileIds.has(id),\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. The caller is identified server-side\n * from the JWT attached by the SocialService.\n *\n * @returns The following response.\n */\n async updateFollowing(): Promise<FollowingResponse> {\n const followingResponse = await this.messenger.call(\n 'SocialService:fetchFollowing',\n );\n\n this.update((state) => {\n state.followingAddresses = followingResponse.following.map(\n (profile) => profile.address,\n );\n state.followingProfileIds = followingResponse.following.map(\n (profile) => profile.profileId,\n );\n });\n\n return followingResponse;\n }\n\n /**\n * Opts the current user out of the PnL leaderboard.\n */\n async optOutOfLeaderboard(): Promise<void> {\n await this.messenger.call('SocialService:optOutOfLeaderboard');\n }\n\n /**\n * Opts the current user back into the PnL leaderboard.\n */\n async optInToLeaderboard(): Promise<void> {\n await this.messenger.call('SocialService:optInToLeaderboard');\n }\n}\n"]}
@@ -1 +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 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 */\nexport type SocialServiceFetchPositionByIdAction = {\n type: `SocialService:fetchPositionById`;\n handler: SocialService['fetchPositionById'];\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 */\nexport type SocialServiceFetchFollowingAction = {\n type: `SocialService:fetchFollowing`;\n handler: SocialService['fetchFollowing'];\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 */\nexport type SocialServiceFollowAction = {\n type: `SocialService:follow`;\n handler: SocialService['follow'];\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 */\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 | SocialServiceFetchPositionByIdAction\n | SocialServiceFetchFollowingAction\n | SocialServiceFollowAction\n | SocialServiceUnfollowAction;\n"]}
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 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 */\nexport type SocialServiceFetchPositionByIdAction = {\n type: `SocialService:fetchPositionById`;\n handler: SocialService['fetchPositionById'];\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 */\nexport type SocialServiceFetchFollowingAction = {\n type: `SocialService:fetchFollowing`;\n handler: SocialService['fetchFollowing'];\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 */\nexport type SocialServiceFollowAction = {\n type: `SocialService:follow`;\n handler: SocialService['follow'];\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 */\nexport type SocialServiceUnfollowAction = {\n type: `SocialService:unfollow`;\n handler: SocialService['unfollow'];\n};\n\n/**\n * Opts the current user out of the PnL leaderboard.\n */\nexport type SocialServiceOptOutOfLeaderboardAction = {\n type: `SocialService:optOutOfLeaderboard`;\n handler: SocialService['optOutOfLeaderboard'];\n};\n\n/**\n * Opts the current user back into the PnL leaderboard.\n */\nexport type SocialServiceOptInToLeaderboardAction = {\n type: `SocialService:optInToLeaderboard`;\n handler: SocialService['optInToLeaderboard'];\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 | SocialServiceFetchPositionByIdAction\n | SocialServiceFetchFollowingAction\n | SocialServiceFollowAction\n | SocialServiceUnfollowAction\n | SocialServiceOptOutOfLeaderboardAction\n | SocialServiceOptInToLeaderboardAction;\n"]}
@@ -130,8 +130,22 @@ export type SocialServiceUnfollowAction = {
130
130
  type: `SocialService:unfollow`;
131
131
  handler: SocialService['unfollow'];
132
132
  };
133
+ /**
134
+ * Opts the current user out of the PnL leaderboard.
135
+ */
136
+ export type SocialServiceOptOutOfLeaderboardAction = {
137
+ type: `SocialService:optOutOfLeaderboard`;
138
+ handler: SocialService['optOutOfLeaderboard'];
139
+ };
140
+ /**
141
+ * Opts the current user back into the PnL leaderboard.
142
+ */
143
+ export type SocialServiceOptInToLeaderboardAction = {
144
+ type: `SocialService:optInToLeaderboard`;
145
+ handler: SocialService['optInToLeaderboard'];
146
+ };
133
147
  /**
134
148
  * Union of all SocialService action types.
135
149
  */
136
- export type SocialServiceMethodActions = SocialServiceFetchLeaderboardAction | SocialServiceFetchTraderProfileAction | SocialServiceFetchOpenPositionsAction | SocialServiceFetchClosedPositionsAction | SocialServiceFetchFollowersAction | SocialServiceFetchPositionByIdAction | SocialServiceFetchFollowingAction | SocialServiceFollowAction | SocialServiceUnfollowAction;
150
+ export type SocialServiceMethodActions = SocialServiceFetchLeaderboardAction | SocialServiceFetchTraderProfileAction | SocialServiceFetchOpenPositionsAction | SocialServiceFetchClosedPositionsAction | SocialServiceFetchFollowersAction | SocialServiceFetchPositionByIdAction | SocialServiceFetchFollowingAction | SocialServiceFollowAction | SocialServiceUnfollowAction | SocialServiceOptOutOfLeaderboardAction | SocialServiceOptInToLeaderboardAction;
137
151
  //# sourceMappingURL=SocialService-method-action-types.d.cts.map
@@ -1 +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;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MAAM,0BAA0B,GAClC,mCAAmC,GACnC,qCAAqC,GACrC,qCAAqC,GACrC,uCAAuC,GACvC,iCAAiC,GACjC,oCAAoC,GACpC,iCAAiC,GACjC,yBAAyB,GACzB,2BAA2B,CAAC"}
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,CAAC;IACzC,OAAO,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAC;CAChD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,sBAAsB,CAAC;IAC7B,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG;IACnD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAClC,mCAAmC,GACnC,qCAAqC,GACrC,qCAAqC,GACrC,uCAAuC,GACvC,iCAAiC,GACjC,oCAAoC,GACpC,iCAAiC,GACjC,yBAAyB,GACzB,2BAA2B,GAC3B,sCAAsC,GACtC,qCAAqC,CAAC"}
@@ -130,8 +130,22 @@ export type SocialServiceUnfollowAction = {
130
130
  type: `SocialService:unfollow`;
131
131
  handler: SocialService['unfollow'];
132
132
  };
133
+ /**
134
+ * Opts the current user out of the PnL leaderboard.
135
+ */
136
+ export type SocialServiceOptOutOfLeaderboardAction = {
137
+ type: `SocialService:optOutOfLeaderboard`;
138
+ handler: SocialService['optOutOfLeaderboard'];
139
+ };
140
+ /**
141
+ * Opts the current user back into the PnL leaderboard.
142
+ */
143
+ export type SocialServiceOptInToLeaderboardAction = {
144
+ type: `SocialService:optInToLeaderboard`;
145
+ handler: SocialService['optInToLeaderboard'];
146
+ };
133
147
  /**
134
148
  * Union of all SocialService action types.
135
149
  */
136
- export type SocialServiceMethodActions = SocialServiceFetchLeaderboardAction | SocialServiceFetchTraderProfileAction | SocialServiceFetchOpenPositionsAction | SocialServiceFetchClosedPositionsAction | SocialServiceFetchFollowersAction | SocialServiceFetchPositionByIdAction | SocialServiceFetchFollowingAction | SocialServiceFollowAction | SocialServiceUnfollowAction;
150
+ export type SocialServiceMethodActions = SocialServiceFetchLeaderboardAction | SocialServiceFetchTraderProfileAction | SocialServiceFetchOpenPositionsAction | SocialServiceFetchClosedPositionsAction | SocialServiceFetchFollowersAction | SocialServiceFetchPositionByIdAction | SocialServiceFetchFollowingAction | SocialServiceFollowAction | SocialServiceUnfollowAction | SocialServiceOptOutOfLeaderboardAction | SocialServiceOptInToLeaderboardAction;
137
151
  //# sourceMappingURL=SocialService-method-action-types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SocialService-method-action-types.d.mts","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,CAAC;IACzC,OAAO,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,aAAa,CAAC,sBAAsB,CAAC,CAAC;CAChD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;CAC7C,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C,IAAI,EAAE,8BAA8B,CAAC;IACrC,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,sBAAsB,CAAC;IAC7B,OAAO,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,EAAE,wBAAwB,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,oCAAoC,GACpC,iCAAiC,GACjC,yBAAyB,GACzB,2BAA2B,CAAC"}
1
+ {"version":3,"file":"SocialService-method-action-types.d.mts","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;IA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B,OAAO,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;CACpC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sCAAsC,GAAG;IACnD,IAAI,EAAE,mCAAmC,CAAC;IAC1C,OAAO,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAClC,mCAAmC,GACnC,qCAAqC,GACrC,qCAAqC,GACrC,uCAAuC,GACvC,iCAAiC,GACjC,oCAAoC,GACpC,iCAAiC,GACjC,yBAAyB,GACzB,2BAA2B,GAC3B,sCAAsC,GACtC,qCAAqC,CAAC"}
@@ -1 +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 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 */\nexport type SocialServiceFetchPositionByIdAction = {\n type: `SocialService:fetchPositionById`;\n handler: SocialService['fetchPositionById'];\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 */\nexport type SocialServiceFetchFollowingAction = {\n type: `SocialService:fetchFollowing`;\n handler: SocialService['fetchFollowing'];\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 */\nexport type SocialServiceFollowAction = {\n type: `SocialService:follow`;\n handler: SocialService['follow'];\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 */\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 | SocialServiceFetchPositionByIdAction\n | SocialServiceFetchFollowingAction\n | SocialServiceFollowAction\n | SocialServiceUnfollowAction;\n"]}
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 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 */\nexport type SocialServiceFetchPositionByIdAction = {\n type: `SocialService:fetchPositionById`;\n handler: SocialService['fetchPositionById'];\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 */\nexport type SocialServiceFetchFollowingAction = {\n type: `SocialService:fetchFollowing`;\n handler: SocialService['fetchFollowing'];\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 */\nexport type SocialServiceFollowAction = {\n type: `SocialService:follow`;\n handler: SocialService['follow'];\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 */\nexport type SocialServiceUnfollowAction = {\n type: `SocialService:unfollow`;\n handler: SocialService['unfollow'];\n};\n\n/**\n * Opts the current user out of the PnL leaderboard.\n */\nexport type SocialServiceOptOutOfLeaderboardAction = {\n type: `SocialService:optOutOfLeaderboard`;\n handler: SocialService['optOutOfLeaderboard'];\n};\n\n/**\n * Opts the current user back into the PnL leaderboard.\n */\nexport type SocialServiceOptInToLeaderboardAction = {\n type: `SocialService:optInToLeaderboard`;\n handler: SocialService['optInToLeaderboard'];\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 | SocialServiceFetchPositionByIdAction\n | SocialServiceFetchFollowingAction\n | SocialServiceFollowAction\n | SocialServiceUnfollowAction\n | SocialServiceOptOutOfLeaderboardAction\n | SocialServiceOptInToLeaderboardAction;\n"]}
@@ -145,6 +145,8 @@ const MESSENGER_EXPOSED_METHODS = [
145
145
  'fetchPositionById',
146
146
  'follow',
147
147
  'unfollow',
148
+ 'optOutOfLeaderboard',
149
+ 'optInToLeaderboard',
148
150
  ];
149
151
  // ---------------------------------------------------------------------------
150
152
  // Service
@@ -408,6 +410,44 @@ class SocialService extends base_data_service_1.BaseDataService {
408
410
  });
409
411
  return unfollowResponse;
410
412
  }
413
+ /**
414
+ * Opts the current user out of the PnL leaderboard.
415
+ */
416
+ async optOutOfLeaderboard() {
417
+ await this.fetchQuery({
418
+ queryKey: [`${this.name}:optOutOfLeaderboard`],
419
+ staleTime: 0,
420
+ queryFn: async () => {
421
+ const url = `${__classPrivateFieldGet(this, _SocialService_instances, "a", _SocialService_v1Url_get)}/leaderboard/opt-out`;
422
+ const authHeaders = await __classPrivateFieldGet(this, _SocialService_instances, "m", _SocialService_getAuthHeaders).call(this);
423
+ const response = await fetch(url, {
424
+ method: 'POST',
425
+ headers: authHeaders,
426
+ });
427
+ __classPrivateFieldGet(_a, _a, "m", _SocialService_throwIfNotOk).call(_a, response, social_constants_1.SocialServiceErrorMessage.LEADERBOARD_OPT_OUT_FAILED);
428
+ return null;
429
+ },
430
+ });
431
+ }
432
+ /**
433
+ * Opts the current user back into the PnL leaderboard.
434
+ */
435
+ async optInToLeaderboard() {
436
+ await this.fetchQuery({
437
+ queryKey: [`${this.name}:optInToLeaderboard`],
438
+ staleTime: 0,
439
+ queryFn: async () => {
440
+ const url = `${__classPrivateFieldGet(this, _SocialService_instances, "a", _SocialService_v1Url_get)}/leaderboard/opt-in`;
441
+ const authHeaders = await __classPrivateFieldGet(this, _SocialService_instances, "m", _SocialService_getAuthHeaders).call(this);
442
+ const response = await fetch(url, {
443
+ method: 'POST',
444
+ headers: authHeaders,
445
+ });
446
+ __classPrivateFieldGet(_a, _a, "m", _SocialService_throwIfNotOk).call(_a, response, social_constants_1.SocialServiceErrorMessage.LEADERBOARD_OPT_IN_FAILED);
447
+ return null;
448
+ },
449
+ });
450
+ }
411
451
  }
412
452
  exports.SocialService = SocialService;
413
453
  _a = SocialService, _SocialService_baseUrl = new WeakMap(), _SocialService_instances = new WeakSet(), _SocialService_v1Url_get = function _SocialService_v1Url_get() {