@metamask-previews/social-controllers 0.0.0-preview-26038d8d3 → 0.0.0-preview-3f3a92d7b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -8
- package/dist/index.cjs +10 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -8
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +7 -8
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +9 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -9
- package/dist/SocialController-method-action-types.cjs +0 -7
- package/dist/SocialController-method-action-types.cjs.map +0 -1
- package/dist/SocialController-method-action-types.d.cts +0 -38
- package/dist/SocialController-method-action-types.d.cts.map +0 -1
- package/dist/SocialController-method-action-types.d.mts +0 -38
- package/dist/SocialController-method-action-types.d.mts.map +0 -1
- package/dist/SocialController-method-action-types.mjs +0 -6
- package/dist/SocialController-method-action-types.mjs.map +0 -1
- package/dist/SocialController.cjs +0 -127
- package/dist/SocialController.cjs.map +0 -1
- package/dist/SocialController.d.cts +0 -71
- package/dist/SocialController.d.cts.map +0 -1
- package/dist/SocialController.d.mts +0 -71
- package/dist/SocialController.d.mts.map +0 -1
- package/dist/SocialController.mjs +0 -122
- package/dist/SocialController.mjs.map +0 -1
- package/dist/SocialService-method-action-types.cjs +0 -7
- package/dist/SocialService-method-action-types.cjs.map +0 -1
- package/dist/SocialService-method-action-types.d.cts +0 -66
- package/dist/SocialService-method-action-types.d.cts.map +0 -1
- package/dist/SocialService-method-action-types.d.mts +0 -66
- package/dist/SocialService-method-action-types.d.mts.map +0 -1
- package/dist/SocialService-method-action-types.mjs +0 -6
- package/dist/SocialService-method-action-types.mjs.map +0 -1
- package/dist/SocialService.cjs +0 -414
- package/dist/SocialService.cjs.map +0 -1
- package/dist/SocialService.d.cts +0 -113
- package/dist/SocialService.d.cts.map +0 -1
- package/dist/SocialService.d.mts +0 -113
- package/dist/SocialService.d.mts.map +0 -1
- package/dist/SocialService.mjs +0 -410
- package/dist/SocialService.mjs.map +0 -1
- package/dist/social-constants.cjs +0 -24
- package/dist/social-constants.cjs.map +0 -1
- package/dist/social-constants.d.cts +0 -21
- package/dist/social-constants.d.cts.map +0 -1
- package/dist/social-constants.d.mts +0 -21
- package/dist/social-constants.d.mts.map +0 -1
- package/dist/social-constants.mjs +0 -21
- package/dist/social-constants.mjs.map +0 -1
- package/dist/social-types.cjs +0 -6
- package/dist/social-types.cjs.map +0 -1
- package/dist/social-types.d.cts +0 -191
- package/dist/social-types.d.cts.map +0 -1
- package/dist/social-types.d.mts +0 -191
- package/dist/social-types.d.mts.map +0 -1
- package/dist/social-types.mjs +0 -5
- package/dist/social-types.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,13 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
-
- Initial release ([#8321](https://github.com/MetaMask/core/pull/8321)
|
|
13
|
-
- Add `SocialService` data service wrapping social-api endpoints with superstruct response validation
|
|
14
|
-
- Add methods `fetchLeaderboard`, `fetchTraderProfile`, `fetchOpenPositions`, `fetchClosedPositions`, `fetchFollowers`, `fetchFollowing`, `follow`, `unfollow`
|
|
15
|
-
- Add `SocialController` extending `BaseController` with messenger actions for state management
|
|
16
|
-
- `updateLeaderboard` — fetches leaderboard and persists entries to state
|
|
17
|
-
- `followTrader` — follows traders and updates following addresses in state
|
|
18
|
-
- `unfollowTrader` — unfollows traders and removes addresses from state
|
|
19
|
-
- `updateFollowing` — fetches following list and replaces addresses in state
|
|
12
|
+
- Initial release ([#8321](https://github.com/MetaMask/core/pull/8321))
|
|
20
13
|
|
|
21
14
|
[Unreleased]: https://github.com/MetaMask/core/
|
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Example function that returns a greeting for the given name.
|
|
5
|
+
*
|
|
6
|
+
* @param name - The name to greet.
|
|
7
|
+
* @returns The greeting.
|
|
8
|
+
*/
|
|
9
|
+
function greeter(name) {
|
|
10
|
+
return `Hello, ${name}!`;
|
|
11
|
+
}
|
|
12
|
+
exports.default = greeter;
|
|
12
13
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,SAAwB,OAAO,CAAC,IAAY;IAC1C,OAAO,UAAU,IAAI,GAAG,CAAC;AAC3B,CAAC;AAFD,0BAEC","sourcesContent":["/**\n * Example function that returns a greeting for the given name.\n *\n * @param name - The name to greet.\n * @returns The greeting.\n */\nexport default function greeter(name: string): string {\n return `Hello, ${name}!`;\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export { serviceName as socialServiceName, SocialServiceErrorMessage, } from "./social-constants.cjs";
|
|
1
|
+
/**
|
|
2
|
+
* Example function that returns a greeting for the given name.
|
|
3
|
+
*
|
|
4
|
+
* @param name - The name to greet.
|
|
5
|
+
* @returns The greeting.
|
|
6
|
+
*/
|
|
7
|
+
export default function greeter(name: string): string;
|
|
9
8
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export { serviceName as socialServiceName, SocialServiceErrorMessage, } from "./social-constants.mjs";
|
|
1
|
+
/**
|
|
2
|
+
* Example function that returns a greeting for the given name.
|
|
3
|
+
*
|
|
4
|
+
* @param name - The name to greet.
|
|
5
|
+
* @returns The greeting.
|
|
6
|
+
*/
|
|
7
|
+
export default function greeter(name: string): string;
|
|
9
8
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Example function that returns a greeting for the given name.
|
|
3
|
+
*
|
|
4
|
+
* @param name - The name to greet.
|
|
5
|
+
* @returns The greeting.
|
|
6
|
+
*/
|
|
7
|
+
export default function greeter(name) {
|
|
8
|
+
return `Hello, ${name}!`;
|
|
9
|
+
}
|
|
4
10
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,IAAY;IAC1C,OAAO,UAAU,IAAI,GAAG,CAAC;AAC3B,CAAC","sourcesContent":["/**\n * Example function that returns a greeting for the given name.\n *\n * @param name - The name to greet.\n * @returns The greeting.\n */\nexport default function greeter(name: string): string {\n return `Hello, ${name}!`;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/social-controllers",
|
|
3
|
-
"version": "0.0.0-preview-
|
|
3
|
+
"version": "0.0.0-preview-3f3a92d7b",
|
|
4
4
|
"description": "A collection of social related controllers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"MetaMask",
|
|
@@ -46,14 +46,6 @@
|
|
|
46
46
|
"test:verbose": "NODE_OPTIONS=--experimental-vm-modules jest --verbose",
|
|
47
47
|
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
48
48
|
},
|
|
49
|
-
"dependencies": {
|
|
50
|
-
"@metamask/base-controller": "^9.0.1",
|
|
51
|
-
"@metamask/base-data-service": "^0.1.1",
|
|
52
|
-
"@metamask/controller-utils": "^11.20.0",
|
|
53
|
-
"@metamask/messenger": "^1.0.0",
|
|
54
|
-
"@metamask/superstruct": "^3.1.0",
|
|
55
|
-
"@metamask/utils": "^11.9.0"
|
|
56
|
-
},
|
|
57
49
|
"devDependencies": {
|
|
58
50
|
"@metamask/auto-changelog": "^3.4.4",
|
|
59
51
|
"@ts-bridge/cli": "^0.6.4",
|
|
@@ -1 +0,0 @@
|
|
|
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 */\nexport type SocialControllerUpdateLeaderboardAction = {\n type: `SocialController:updateLeaderboard`;\n handler: SocialController['updateLeaderboard'];\n};\n\n/**\n * Follows one or more traders and updates the following list in state.\n */\nexport type SocialControllerFollowTraderAction = {\n type: `SocialController:followTrader`;\n handler: SocialController['followTrader'];\n};\n\n/**\n * Unfollows one or more traders and updates the following list in state.\n */\nexport type SocialControllerUnfollowTraderAction = {\n type: `SocialController:unfollowTrader`;\n handler: SocialController['unfollowTrader'];\n};\n\n/**\n * Fetches the following list and replaces addresses in state.\n */\nexport type SocialControllerUpdateFollowingAction = {\n type: `SocialController:updateFollowing`;\n handler: SocialController['updateFollowing'];\n};\n\n/**\n * Union of all SocialController method action types.\n */\nexport type SocialControllerMethodActions =\n | SocialControllerUpdateLeaderboardAction\n | SocialControllerFollowTraderAction\n | SocialControllerUnfollowTraderAction\n | SocialControllerUpdateFollowingAction;\n"]}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is auto generated.
|
|
3
|
-
* Do not edit manually.
|
|
4
|
-
*/
|
|
5
|
-
import type { SocialController } from "./SocialController.cjs";
|
|
6
|
-
/**
|
|
7
|
-
* Fetches the leaderboard and persists the entries to state.
|
|
8
|
-
*/
|
|
9
|
-
export type SocialControllerUpdateLeaderboardAction = {
|
|
10
|
-
type: `SocialController:updateLeaderboard`;
|
|
11
|
-
handler: SocialController['updateLeaderboard'];
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Follows one or more traders and updates the following list in state.
|
|
15
|
-
*/
|
|
16
|
-
export type SocialControllerFollowTraderAction = {
|
|
17
|
-
type: `SocialController:followTrader`;
|
|
18
|
-
handler: SocialController['followTrader'];
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Unfollows one or more traders and updates the following list in state.
|
|
22
|
-
*/
|
|
23
|
-
export type SocialControllerUnfollowTraderAction = {
|
|
24
|
-
type: `SocialController:unfollowTrader`;
|
|
25
|
-
handler: SocialController['unfollowTrader'];
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Fetches the following list and replaces addresses in state.
|
|
29
|
-
*/
|
|
30
|
-
export type SocialControllerUpdateFollowingAction = {
|
|
31
|
-
type: `SocialController:updateFollowing`;
|
|
32
|
-
handler: SocialController['updateFollowing'];
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Union of all SocialController method action types.
|
|
36
|
-
*/
|
|
37
|
-
export type SocialControllerMethodActions = SocialControllerUpdateLeaderboardAction | SocialControllerFollowTraderAction | SocialControllerUnfollowTraderAction | SocialControllerUpdateFollowingAction;
|
|
38
|
-
//# sourceMappingURL=SocialController-method-action-types.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;;GAEG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CAC7C,CAAC;AAEF;;GAEG;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,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is auto generated.
|
|
3
|
-
* Do not edit manually.
|
|
4
|
-
*/
|
|
5
|
-
import type { SocialController } from "./SocialController.mjs";
|
|
6
|
-
/**
|
|
7
|
-
* Fetches the leaderboard and persists the entries to state.
|
|
8
|
-
*/
|
|
9
|
-
export type SocialControllerUpdateLeaderboardAction = {
|
|
10
|
-
type: `SocialController:updateLeaderboard`;
|
|
11
|
-
handler: SocialController['updateLeaderboard'];
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Follows one or more traders and updates the following list in state.
|
|
15
|
-
*/
|
|
16
|
-
export type SocialControllerFollowTraderAction = {
|
|
17
|
-
type: `SocialController:followTrader`;
|
|
18
|
-
handler: SocialController['followTrader'];
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Unfollows one or more traders and updates the following list in state.
|
|
22
|
-
*/
|
|
23
|
-
export type SocialControllerUnfollowTraderAction = {
|
|
24
|
-
type: `SocialController:unfollowTrader`;
|
|
25
|
-
handler: SocialController['unfollowTrader'];
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Fetches the following list and replaces addresses in state.
|
|
29
|
-
*/
|
|
30
|
-
export type SocialControllerUpdateFollowingAction = {
|
|
31
|
-
type: `SocialController:updateFollowing`;
|
|
32
|
-
handler: SocialController['updateFollowing'];
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Union of all SocialController method action types.
|
|
36
|
-
*/
|
|
37
|
-
export type SocialControllerMethodActions = SocialControllerUpdateLeaderboardAction | SocialControllerFollowTraderAction | SocialControllerUnfollowTraderAction | SocialControllerUpdateFollowingAction;
|
|
38
|
-
//# sourceMappingURL=SocialController-method-action-types.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;;GAEG;AACH,MAAM,MAAM,uCAAuC,GAAG;IACpD,IAAI,EAAE,oCAAoC,CAAC;IAC3C,OAAO,EAAE,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;CAChD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,IAAI,EAAE,iCAAiC,CAAC;IACxC,OAAO,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;CAC7C,CAAC;AAEF;;GAEG;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 +0,0 @@
|
|
|
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 */\nexport type SocialControllerUpdateLeaderboardAction = {\n type: `SocialController:updateLeaderboard`;\n handler: SocialController['updateLeaderboard'];\n};\n\n/**\n * Follows one or more traders and updates the following list in state.\n */\nexport type SocialControllerFollowTraderAction = {\n type: `SocialController:followTrader`;\n handler: SocialController['followTrader'];\n};\n\n/**\n * Unfollows one or more traders and updates the following list in state.\n */\nexport type SocialControllerUnfollowTraderAction = {\n type: `SocialController:unfollowTrader`;\n handler: SocialController['unfollowTrader'];\n};\n\n/**\n * Fetches the following list and replaces addresses in state.\n */\nexport type SocialControllerUpdateFollowingAction = {\n type: `SocialController:updateFollowing`;\n handler: SocialController['updateFollowing'];\n};\n\n/**\n * Union of all SocialController method action types.\n */\nexport type SocialControllerMethodActions =\n | SocialControllerUpdateLeaderboardAction\n | SocialControllerFollowTraderAction\n | SocialControllerUnfollowTraderAction\n | SocialControllerUpdateFollowingAction;\n"]}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SocialController = exports.getDefaultSocialControllerState = void 0;
|
|
4
|
-
const base_controller_1 = require("@metamask/base-controller");
|
|
5
|
-
const social_constants_1 = require("./social-constants.cjs");
|
|
6
|
-
// === MESSENGER ===
|
|
7
|
-
const MESSENGER_EXPOSED_METHODS = [
|
|
8
|
-
'updateLeaderboard',
|
|
9
|
-
'followTrader',
|
|
10
|
-
'unfollowTrader',
|
|
11
|
-
'updateFollowing',
|
|
12
|
-
];
|
|
13
|
-
// === DEFAULT STATE ===
|
|
14
|
-
/**
|
|
15
|
-
* Returns the default state for the SocialController.
|
|
16
|
-
*
|
|
17
|
-
* @returns A fresh default state object.
|
|
18
|
-
*/
|
|
19
|
-
function getDefaultSocialControllerState() {
|
|
20
|
-
return {
|
|
21
|
-
leaderboardEntries: [],
|
|
22
|
-
followingAddresses: [],
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
exports.getDefaultSocialControllerState = getDefaultSocialControllerState;
|
|
26
|
-
// === STATE METADATA ===
|
|
27
|
-
const socialControllerMetadata = {
|
|
28
|
-
leaderboardEntries: {
|
|
29
|
-
persist: true,
|
|
30
|
-
includeInDebugSnapshot: false,
|
|
31
|
-
includeInStateLogs: false,
|
|
32
|
-
usedInUi: true,
|
|
33
|
-
},
|
|
34
|
-
followingAddresses: {
|
|
35
|
-
persist: true,
|
|
36
|
-
includeInDebugSnapshot: false,
|
|
37
|
-
includeInStateLogs: false,
|
|
38
|
-
usedInUi: true,
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
// === CONTROLLER ===
|
|
42
|
-
/**
|
|
43
|
-
* Controller that manages social trading state for the extension UI.
|
|
44
|
-
*
|
|
45
|
-
* Acts as a simple store with no TTL or eviction — the UI decides when
|
|
46
|
-
* to re-fetch, and the social-api's own cache layer handles upstream
|
|
47
|
-
* rate-limiting. State is persisted across sessions so the UI can render
|
|
48
|
-
* immediately on startup while a fresh fetch is in flight.
|
|
49
|
-
*/
|
|
50
|
-
class SocialController extends base_controller_1.BaseController {
|
|
51
|
-
constructor({ messenger, state }) {
|
|
52
|
-
super({
|
|
53
|
-
name: social_constants_1.controllerName,
|
|
54
|
-
metadata: socialControllerMetadata,
|
|
55
|
-
state: {
|
|
56
|
-
...getDefaultSocialControllerState(),
|
|
57
|
-
...state,
|
|
58
|
-
},
|
|
59
|
-
messenger,
|
|
60
|
-
});
|
|
61
|
-
this.messenger.registerMethodActionHandlers(this, MESSENGER_EXPOSED_METHODS);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Fetches the leaderboard and persists the entries to state.
|
|
65
|
-
*
|
|
66
|
-
* @param options - Optional leaderboard query parameters.
|
|
67
|
-
* @returns The leaderboard response from the social-api.
|
|
68
|
-
*/
|
|
69
|
-
async updateLeaderboard(options) {
|
|
70
|
-
const leaderboardResponse = await this.messenger.call('SocialService:fetchLeaderboard', options);
|
|
71
|
-
this.update((state) => {
|
|
72
|
-
state.leaderboardEntries = leaderboardResponse.traders;
|
|
73
|
-
});
|
|
74
|
-
return leaderboardResponse;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Follows one or more traders and updates the following list in state.
|
|
78
|
-
*
|
|
79
|
-
* @param options - Options bag.
|
|
80
|
-
* @param options.addressOrUid - Wallet address or Clicker profile ID of the current user.
|
|
81
|
-
* @param options.targets - Addresses or profile IDs to follow.
|
|
82
|
-
* @returns The follow response with confirmed follows.
|
|
83
|
-
*/
|
|
84
|
-
async followTrader(options) {
|
|
85
|
-
const followResponse = await this.messenger.call('SocialService:follow', options);
|
|
86
|
-
const newAddresses = followResponse.followed.map((profile) => profile.address);
|
|
87
|
-
this.update((state) => {
|
|
88
|
-
const existing = new Set(state.followingAddresses);
|
|
89
|
-
const uniqueNewAddresses = newAddresses.filter((address) => !existing.has(address));
|
|
90
|
-
state.followingAddresses.push(...uniqueNewAddresses);
|
|
91
|
-
});
|
|
92
|
-
return followResponse;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Unfollows one or more traders and updates the following list in state.
|
|
96
|
-
*
|
|
97
|
-
* @param options - Options bag.
|
|
98
|
-
* @param options.addressOrUid - Wallet address or Clicker profile ID of the current user.
|
|
99
|
-
* @param options.targets - Addresses or profile IDs to unfollow.
|
|
100
|
-
* @returns The unfollow response with confirmed unfollows.
|
|
101
|
-
*/
|
|
102
|
-
async unfollowTrader(options) {
|
|
103
|
-
const unfollowResponse = await this.messenger.call('SocialService:unfollow', options);
|
|
104
|
-
const removedAddresses = new Set(unfollowResponse.unfollowed.map((profile) => profile.address));
|
|
105
|
-
this.update((state) => {
|
|
106
|
-
state.followingAddresses = state.followingAddresses.filter((address) => !removedAddresses.has(address));
|
|
107
|
-
});
|
|
108
|
-
return unfollowResponse;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Fetches the list of traders the current user follows and replaces
|
|
112
|
-
* the following addresses in state.
|
|
113
|
-
*
|
|
114
|
-
* @param options - Options bag.
|
|
115
|
-
* @param options.addressOrUid - Wallet address or Clicker profile ID of the current user.
|
|
116
|
-
* @returns The following response.
|
|
117
|
-
*/
|
|
118
|
-
async updateFollowing(options) {
|
|
119
|
-
const followingResponse = await this.messenger.call('SocialService:fetchFollowing', options);
|
|
120
|
-
this.update((state) => {
|
|
121
|
-
state.followingAddresses = followingResponse.following.map((profile) => profile.address);
|
|
122
|
-
});
|
|
123
|
-
return followingResponse;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
exports.SocialController = SocialController;
|
|
127
|
-
//# sourceMappingURL=SocialController.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SocialController.cjs","sourceRoot":"","sources":["../src/SocialController.ts"],"names":[],"mappings":";;;AAKA,+DAA2D;AAG3D,6DAAoD;AAoBpD,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;KACvB,CAAC;AACJ,CAAC;AALD,0EAKC;AAED,yBAAyB;AAEzB,MAAM,wBAAwB,GAAyC;IACrE,kBAAkB,EAAE;QAClB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,KAAK;QACzB,QAAQ,EAAE,IAAI;KACf;IACD,kBAAkB,EAAE;QAClB,OAAO,EAAE,IAAI;QACb,sBAAsB,EAAE,KAAK;QAC7B,kBAAkB,EAAE,KAAK;QACzB,QAAQ,EAAE,IAAI;KACf;CACF,CAAC;AAEF,qBAAqB;AAErB;;;;;;;GAOG;AACH,MAAa,gBAAiB,SAAQ,gCAIrC;IACC,YAAY,EAAE,SAAS,EAAE,KAAK,EAA2B;QACvD,KAAK,CAAC;YACJ,IAAI,EAAE,iCAAc;YACpB,QAAQ,EAAE,wBAAwB;YAClC,KAAK,EAAE;gBACL,GAAG,+BAA+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GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAChD,wBAAwB,EACxB,OAAO,CACR,CAAC;QAEF,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAC9B,gBAAgB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAC9D,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;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,eAAe,CACnB,OAA8B;QAE9B,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CACjD,8BAA8B,EAC9B,OAAO,CACR,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;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF;AA3HD,4CA2HC","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 FetchFollowingOptions,\n FetchLeaderboardOptions,\n FollowOptions,\n FollowResponse,\n FollowingResponse,\n LeaderboardResponse,\n SocialControllerState,\n UnfollowOptions,\n UnfollowResponse,\n} from './social-types';\nimport type { SocialControllerMethodActions } from './SocialController-method-action-types';\nimport type {\n SocialServiceFetchFollowingAction,\n SocialServiceFetchLeaderboardAction,\n SocialServiceFollowAction,\n SocialServiceUnfollowAction,\n} from './SocialService-method-action-types';\n\n// === MESSENGER ===\n\nconst MESSENGER_EXPOSED_METHODS = [\n 'updateLeaderboard',\n 'followTrader',\n 'unfollowTrader',\n 'updateFollowing',\n] as const;\n\n// === ACTION TYPES ===\n\nexport type SocialControllerGetStateAction = ControllerGetStateAction<\n typeof controllerName,\n SocialControllerState\n>;\n\nexport type SocialControllerActions =\n | SocialControllerGetStateAction\n | SocialControllerMethodActions;\n\n// === EVENT TYPES ===\n\nexport type SocialControllerStateChangeEvent = ControllerStateChangeEvent<\n typeof controllerName,\n SocialControllerState\n>;\n\nexport type SocialControllerEvents = SocialControllerStateChangeEvent;\n\n// === ALLOWED ACTIONS/EVENTS ===\n\ntype AllowedActions =\n | SocialServiceFetchLeaderboardAction\n | SocialServiceFollowAction\n | SocialServiceUnfollowAction\n | SocialServiceFetchFollowingAction;\n\ntype AllowedEvents = never;\n\n// === MESSENGER TYPE ===\n\nexport type SocialControllerMessenger = Messenger<\n typeof controllerName,\n SocialControllerActions | AllowedActions,\n SocialControllerEvents | AllowedEvents\n>;\n\n// === OPTIONS ===\n\nexport type SocialControllerOptions = {\n messenger: SocialControllerMessenger;\n state?: Partial<SocialControllerState>;\n};\n\n// === DEFAULT STATE ===\n\n/**\n * Returns the default state for the SocialController.\n *\n * @returns A fresh default state object.\n */\nexport function getDefaultSocialControllerState(): SocialControllerState {\n return {\n leaderboardEntries: [],\n followingAddresses: [],\n };\n}\n\n// === STATE METADATA ===\n\nconst socialControllerMetadata: StateMetadata<SocialControllerState> = {\n leaderboardEntries: {\n persist: true,\n includeInDebugSnapshot: false,\n includeInStateLogs: false,\n usedInUi: true,\n },\n followingAddresses: {\n persist: true,\n includeInDebugSnapshot: false,\n includeInStateLogs: false,\n usedInUi: true,\n },\n};\n\n// === CONTROLLER ===\n\n/**\n * Controller that manages social trading state for the extension UI.\n *\n * Acts as a simple store with no TTL or eviction — the UI decides when\n * to re-fetch, and the social-api's own cache layer handles upstream\n * rate-limiting. State is persisted across sessions so the UI can render\n * immediately on startup while a fresh fetch is in flight.\n */\nexport class SocialController extends BaseController<\n typeof controllerName,\n SocialControllerState,\n SocialControllerMessenger\n> {\n constructor({ messenger, state }: SocialControllerOptions) {\n super({\n name: controllerName,\n metadata: socialControllerMetadata,\n state: {\n ...getDefaultSocialControllerState(),\n ...state,\n },\n messenger,\n });\n\n this.messenger.registerMethodActionHandlers(\n this,\n MESSENGER_EXPOSED_METHODS,\n );\n }\n\n /**\n * Fetches the leaderboard and persists the entries to state.\n *\n * @param options - Optional leaderboard query parameters.\n * @returns The leaderboard response from the social-api.\n */\n async updateLeaderboard(\n options?: FetchLeaderboardOptions,\n ): Promise<LeaderboardResponse> {\n const leaderboardResponse = await this.messenger.call(\n 'SocialService:fetchLeaderboard',\n options,\n );\n\n this.update((state) => {\n state.leaderboardEntries = leaderboardResponse.traders;\n });\n\n return leaderboardResponse;\n }\n\n /**\n * Follows one or more traders and updates the following list in state.\n *\n * @param options - Options bag.\n * @param options.addressOrUid - Wallet address or Clicker profile ID of the current user.\n * @param options.targets - Addresses or profile IDs to follow.\n * @returns The follow response with confirmed follows.\n */\n async followTrader(options: FollowOptions): Promise<FollowResponse> {\n const followResponse = await this.messenger.call(\n 'SocialService:follow',\n options,\n );\n\n const newAddresses = followResponse.followed.map(\n (profile) => profile.address,\n );\n\n this.update((state) => {\n const existing = new Set(state.followingAddresses);\n const uniqueNewAddresses = newAddresses.filter(\n (address) => !existing.has(address),\n );\n state.followingAddresses.push(...uniqueNewAddresses);\n });\n\n return followResponse;\n }\n\n /**\n * Unfollows one or more traders and updates the following list in state.\n *\n * @param options - Options bag.\n * @param options.addressOrUid - Wallet address or Clicker profile ID of the current user.\n * @param options.targets - Addresses or profile IDs to unfollow.\n * @returns The unfollow response with confirmed unfollows.\n */\n async unfollowTrader(options: UnfollowOptions): Promise<UnfollowResponse> {\n const unfollowResponse = await this.messenger.call(\n 'SocialService:unfollow',\n options,\n );\n\n const removedAddresses = new Set(\n unfollowResponse.unfollowed.map((profile) => profile.address),\n );\n\n this.update((state) => {\n state.followingAddresses = state.followingAddresses.filter(\n (address) => !removedAddresses.has(address),\n );\n });\n\n return unfollowResponse;\n }\n\n /**\n * Fetches the list of traders the current user follows and replaces\n * the following addresses in state.\n *\n * @param options - Options bag.\n * @param options.addressOrUid - Wallet address or Clicker profile ID of the current user.\n * @returns The following response.\n */\n async updateFollowing(\n options: FetchFollowingOptions,\n ): Promise<FollowingResponse> {\n const followingResponse = await this.messenger.call(\n 'SocialService:fetchFollowing',\n options,\n );\n\n this.update((state) => {\n state.followingAddresses = followingResponse.following.map(\n (profile) => profile.address,\n );\n });\n\n return followingResponse;\n }\n}\n"]}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
|
|
2
|
-
import { BaseController } from "@metamask/base-controller";
|
|
3
|
-
import type { Messenger } from "@metamask/messenger";
|
|
4
|
-
import { controllerName } from "./social-constants.cjs";
|
|
5
|
-
import type { FetchFollowingOptions, FetchLeaderboardOptions, FollowOptions, FollowResponse, FollowingResponse, LeaderboardResponse, SocialControllerState, UnfollowOptions, UnfollowResponse } from "./social-types.cjs";
|
|
6
|
-
import type { SocialControllerMethodActions } from "./SocialController-method-action-types.cjs";
|
|
7
|
-
import type { SocialServiceFetchFollowingAction, SocialServiceFetchLeaderboardAction, SocialServiceFollowAction, SocialServiceUnfollowAction } from "./SocialService-method-action-types.cjs";
|
|
8
|
-
export type SocialControllerGetStateAction = ControllerGetStateAction<typeof controllerName, SocialControllerState>;
|
|
9
|
-
export type SocialControllerActions = SocialControllerGetStateAction | SocialControllerMethodActions;
|
|
10
|
-
export type SocialControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, SocialControllerState>;
|
|
11
|
-
export type SocialControllerEvents = SocialControllerStateChangeEvent;
|
|
12
|
-
type AllowedActions = SocialServiceFetchLeaderboardAction | SocialServiceFollowAction | SocialServiceUnfollowAction | SocialServiceFetchFollowingAction;
|
|
13
|
-
type AllowedEvents = never;
|
|
14
|
-
export type SocialControllerMessenger = Messenger<typeof controllerName, SocialControllerActions | AllowedActions, SocialControllerEvents | AllowedEvents>;
|
|
15
|
-
export type SocialControllerOptions = {
|
|
16
|
-
messenger: SocialControllerMessenger;
|
|
17
|
-
state?: Partial<SocialControllerState>;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Returns the default state for the SocialController.
|
|
21
|
-
*
|
|
22
|
-
* @returns A fresh default state object.
|
|
23
|
-
*/
|
|
24
|
-
export declare function getDefaultSocialControllerState(): SocialControllerState;
|
|
25
|
-
/**
|
|
26
|
-
* Controller that manages social trading state for the extension UI.
|
|
27
|
-
*
|
|
28
|
-
* Acts as a simple store with no TTL or eviction — the UI decides when
|
|
29
|
-
* to re-fetch, and the social-api's own cache layer handles upstream
|
|
30
|
-
* rate-limiting. State is persisted across sessions so the UI can render
|
|
31
|
-
* immediately on startup while a fresh fetch is in flight.
|
|
32
|
-
*/
|
|
33
|
-
export declare class SocialController extends BaseController<typeof controllerName, SocialControllerState, SocialControllerMessenger> {
|
|
34
|
-
constructor({ messenger, state }: SocialControllerOptions);
|
|
35
|
-
/**
|
|
36
|
-
* Fetches the leaderboard and persists the entries to state.
|
|
37
|
-
*
|
|
38
|
-
* @param options - Optional leaderboard query parameters.
|
|
39
|
-
* @returns The leaderboard response from the social-api.
|
|
40
|
-
*/
|
|
41
|
-
updateLeaderboard(options?: FetchLeaderboardOptions): Promise<LeaderboardResponse>;
|
|
42
|
-
/**
|
|
43
|
-
* Follows one or more traders and updates the following list in state.
|
|
44
|
-
*
|
|
45
|
-
* @param options - Options bag.
|
|
46
|
-
* @param options.addressOrUid - Wallet address or Clicker profile ID of the current user.
|
|
47
|
-
* @param options.targets - Addresses or profile IDs to follow.
|
|
48
|
-
* @returns The follow response with confirmed follows.
|
|
49
|
-
*/
|
|
50
|
-
followTrader(options: FollowOptions): Promise<FollowResponse>;
|
|
51
|
-
/**
|
|
52
|
-
* Unfollows one or more traders and updates the following list in state.
|
|
53
|
-
*
|
|
54
|
-
* @param options - Options bag.
|
|
55
|
-
* @param options.addressOrUid - Wallet address or Clicker profile ID of the current user.
|
|
56
|
-
* @param options.targets - Addresses or profile IDs to unfollow.
|
|
57
|
-
* @returns The unfollow response with confirmed unfollows.
|
|
58
|
-
*/
|
|
59
|
-
unfollowTrader(options: UnfollowOptions): Promise<UnfollowResponse>;
|
|
60
|
-
/**
|
|
61
|
-
* Fetches the list of traders the current user follows and replaces
|
|
62
|
-
* the following addresses in state.
|
|
63
|
-
*
|
|
64
|
-
* @param options - Options bag.
|
|
65
|
-
* @param options.addressOrUid - Wallet address or Clicker profile ID of the current user.
|
|
66
|
-
* @returns The following response.
|
|
67
|
-
*/
|
|
68
|
-
updateFollowing(options: FetchFollowingOptions): Promise<FollowingResponse>;
|
|
69
|
-
}
|
|
70
|
-
export {};
|
|
71
|
-
//# sourceMappingURL=SocialController.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,qBAAqB,EACrB,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,EAC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,eAAe,CACnB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;CAc9B"}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller";
|
|
2
|
-
import { BaseController } from "@metamask/base-controller";
|
|
3
|
-
import type { Messenger } from "@metamask/messenger";
|
|
4
|
-
import { controllerName } from "./social-constants.mjs";
|
|
5
|
-
import type { FetchFollowingOptions, FetchLeaderboardOptions, FollowOptions, FollowResponse, FollowingResponse, LeaderboardResponse, SocialControllerState, UnfollowOptions, UnfollowResponse } from "./social-types.mjs";
|
|
6
|
-
import type { SocialControllerMethodActions } from "./SocialController-method-action-types.mjs";
|
|
7
|
-
import type { SocialServiceFetchFollowingAction, SocialServiceFetchLeaderboardAction, SocialServiceFollowAction, SocialServiceUnfollowAction } from "./SocialService-method-action-types.mjs";
|
|
8
|
-
export type SocialControllerGetStateAction = ControllerGetStateAction<typeof controllerName, SocialControllerState>;
|
|
9
|
-
export type SocialControllerActions = SocialControllerGetStateAction | SocialControllerMethodActions;
|
|
10
|
-
export type SocialControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, SocialControllerState>;
|
|
11
|
-
export type SocialControllerEvents = SocialControllerStateChangeEvent;
|
|
12
|
-
type AllowedActions = SocialServiceFetchLeaderboardAction | SocialServiceFollowAction | SocialServiceUnfollowAction | SocialServiceFetchFollowingAction;
|
|
13
|
-
type AllowedEvents = never;
|
|
14
|
-
export type SocialControllerMessenger = Messenger<typeof controllerName, SocialControllerActions | AllowedActions, SocialControllerEvents | AllowedEvents>;
|
|
15
|
-
export type SocialControllerOptions = {
|
|
16
|
-
messenger: SocialControllerMessenger;
|
|
17
|
-
state?: Partial<SocialControllerState>;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Returns the default state for the SocialController.
|
|
21
|
-
*
|
|
22
|
-
* @returns A fresh default state object.
|
|
23
|
-
*/
|
|
24
|
-
export declare function getDefaultSocialControllerState(): SocialControllerState;
|
|
25
|
-
/**
|
|
26
|
-
* Controller that manages social trading state for the extension UI.
|
|
27
|
-
*
|
|
28
|
-
* Acts as a simple store with no TTL or eviction — the UI decides when
|
|
29
|
-
* to re-fetch, and the social-api's own cache layer handles upstream
|
|
30
|
-
* rate-limiting. State is persisted across sessions so the UI can render
|
|
31
|
-
* immediately on startup while a fresh fetch is in flight.
|
|
32
|
-
*/
|
|
33
|
-
export declare class SocialController extends BaseController<typeof controllerName, SocialControllerState, SocialControllerMessenger> {
|
|
34
|
-
constructor({ messenger, state }: SocialControllerOptions);
|
|
35
|
-
/**
|
|
36
|
-
* Fetches the leaderboard and persists the entries to state.
|
|
37
|
-
*
|
|
38
|
-
* @param options - Optional leaderboard query parameters.
|
|
39
|
-
* @returns The leaderboard response from the social-api.
|
|
40
|
-
*/
|
|
41
|
-
updateLeaderboard(options?: FetchLeaderboardOptions): Promise<LeaderboardResponse>;
|
|
42
|
-
/**
|
|
43
|
-
* Follows one or more traders and updates the following list in state.
|
|
44
|
-
*
|
|
45
|
-
* @param options - Options bag.
|
|
46
|
-
* @param options.addressOrUid - Wallet address or Clicker profile ID of the current user.
|
|
47
|
-
* @param options.targets - Addresses or profile IDs to follow.
|
|
48
|
-
* @returns The follow response with confirmed follows.
|
|
49
|
-
*/
|
|
50
|
-
followTrader(options: FollowOptions): Promise<FollowResponse>;
|
|
51
|
-
/**
|
|
52
|
-
* Unfollows one or more traders and updates the following list in state.
|
|
53
|
-
*
|
|
54
|
-
* @param options - Options bag.
|
|
55
|
-
* @param options.addressOrUid - Wallet address or Clicker profile ID of the current user.
|
|
56
|
-
* @param options.targets - Addresses or profile IDs to unfollow.
|
|
57
|
-
* @returns The unfollow response with confirmed unfollows.
|
|
58
|
-
*/
|
|
59
|
-
unfollowTrader(options: UnfollowOptions): Promise<UnfollowResponse>;
|
|
60
|
-
/**
|
|
61
|
-
* Fetches the list of traders the current user follows and replaces
|
|
62
|
-
* the following addresses in state.
|
|
63
|
-
*
|
|
64
|
-
* @param options - Options bag.
|
|
65
|
-
* @param options.addressOrUid - Wallet address or Clicker profile ID of the current user.
|
|
66
|
-
* @returns The following response.
|
|
67
|
-
*/
|
|
68
|
-
updateFollowing(options: FetchFollowingOptions): Promise<FollowingResponse>;
|
|
69
|
-
}
|
|
70
|
-
export {};
|
|
71
|
-
//# sourceMappingURL=SocialController.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,qBAAqB,EACrB,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,2BAA2B,EAC5B,gDAA4C;AAa7C,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,CAAC;AAEtC,KAAK,aAAa,GAAG,KAAK,CAA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