@metamask/social-controllers 0.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +23 -1
  2. package/dist/SocialController-method-action-types.cjs.map +1 -1
  3. package/dist/SocialController-method-action-types.d.cts +8 -7
  4. package/dist/SocialController-method-action-types.d.cts.map +1 -1
  5. package/dist/SocialController-method-action-types.d.mts +8 -7
  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 +10 -9
  9. package/dist/SocialController.cjs.map +1 -1
  10. package/dist/SocialController.d.cts +10 -9
  11. package/dist/SocialController.d.cts.map +1 -1
  12. package/dist/SocialController.d.mts +10 -9
  13. package/dist/SocialController.d.mts.map +1 -1
  14. package/dist/SocialController.mjs +10 -9
  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 +11 -12
  18. package/dist/SocialService-method-action-types.d.cts.map +1 -1
  19. package/dist/SocialService-method-action-types.d.mts +11 -12
  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 +52 -30
  23. package/dist/SocialService.cjs.map +1 -1
  24. package/dist/SocialService.d.cts +18 -15
  25. package/dist/SocialService.d.cts.map +1 -1
  26. package/dist/SocialService.d.mts +18 -15
  27. package/dist/SocialService.d.mts.map +1 -1
  28. package/dist/SocialService.mjs +52 -30
  29. package/dist/SocialService.mjs.map +1 -1
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +1 -1
  32. package/dist/index.d.cts.map +1 -1
  33. package/dist/index.d.mts +1 -1
  34. package/dist/index.d.mts.map +1 -1
  35. package/dist/index.mjs.map +1 -1
  36. package/dist/social-types.cjs.map +1 -1
  37. package/dist/social-types.d.cts +3 -11
  38. package/dist/social-types.d.cts.map +1 -1
  39. package/dist/social-types.d.mts +3 -11
  40. package/dist/social-types.d.mts.map +1 -1
  41. package/dist/social-types.mjs.map +1 -1
  42. package/package.json +5 -4
@@ -1 +1 @@
1
- {"version":3,"file":"social-types.mjs","sourceRoot":"","sources":["../src/social-types.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,MAAM,EACN,QAAQ,EACR,MAAM,EACN,IAAI,IAAI,UAAU,EACnB,8BAA8B;AA8B/B,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC;IACpC,SAAS,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAChC,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC5B,WAAW,EAAE,MAAM,EAAE;IACrB,OAAO,EAAE,MAAM,EAAE;IACjB,SAAS,EAAE,MAAM,EAAE;IACnB,eAAe,EAAE,MAAM,EAAE;CAC1B,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport {\n enums,\n number,\n optional,\n string,\n type as structType,\n} from '@metamask/superstruct';\n\n// ---------------------------------------------------------------------------\n// Shared sub-types\n// ---------------------------------------------------------------------------\n\n/**\n * Minimal profile summary used across follow/follower responses.\n */\nexport type ProfileSummary = {\n /** Clicker profile ID (UUID). */\n profileId: string;\n /** Primary wallet address. */\n address: string;\n /** Display name or truncated address. */\n name: string;\n /** Profile avatar URL. */\n imageUrl?: string | null;\n};\n\n/**\n * Social media handles attached to a trader profile.\n */\nexport type SocialHandles = {\n twitter?: string | null;\n farcaster?: string | null;\n ens?: string | null;\n lens?: string | null;\n};\n\nexport const TradeStruct = structType({\n direction: enums(['buy', 'sell']),\n intent: enums(['enter', 'exit']),\n category: optional(string()),\n tokenAmount: number(),\n usdCost: number(),\n timestamp: number(),\n transactionHash: string(),\n});\n\nexport type Trade = Infer<typeof TradeStruct>;\n\n// ---------------------------------------------------------------------------\n// Leaderboard\n// ---------------------------------------------------------------------------\n\n/**\n * A single entry in the leaderboard response.\n */\nexport type LeaderboardEntry = {\n rank: number;\n addresses: string[];\n profileId: string;\n name: string;\n imageUrl?: string | null;\n pnl30d: number;\n winRate30d?: number | null;\n /** Renamed from roi30d. */\n roiPercent30d?: number | null;\n /** Renamed from tradeCount. */\n tradeCount30d?: number | null;\n pnl7d?: number | null;\n winRate7d?: number | null;\n roiPercent7d?: number | null;\n tradeCount7d?: number | null;\n pnlPerChain: Record<string, number>;\n followerCount: number;\n socialHandles: SocialHandles;\n};\n\n/**\n * Response from `GET /v1/leaderboard`.\n */\nexport type LeaderboardResponse = {\n traders: LeaderboardEntry[];\n};\n\n// ---------------------------------------------------------------------------\n// Trader profile\n// ---------------------------------------------------------------------------\n\nexport type TraderProfile = {\n profileId: string;\n address: string;\n allAddresses: string[];\n name: string;\n imageUrl?: string | null;\n};\n\nexport type TraderStats = {\n pnl30d?: number | null;\n winRate30d?: number | null;\n /** Renamed from roi30d. */\n roiPercent30d?: number | null;\n /** Renamed from tradeCount. */\n tradeCount30d?: number | null;\n pnl7d?: number | null;\n winRate7d?: number | null;\n roiPercent7d?: number | null;\n tradeCount7d?: number | null;\n /** Median holding time in minutes. */\n medianHoldMinutes?: number | null;\n};\n\nexport type PerChainBreakdown = {\n perChainPnl: Record<string, number>;\n /** ROI can be null for chains with no trading activity (zero cost-basis). */\n perChainRoi: Record<string, number | null>;\n perChainVolume: Record<string, number>;\n};\n\n/**\n * Response from `GET /v1/traders/:addressOrId/profile`.\n */\nexport type TraderProfileResponse = {\n profile: TraderProfile;\n stats: TraderStats;\n perChainBreakdown: PerChainBreakdown;\n socialHandles: SocialHandles;\n followerCount: number;\n followingCount: number;\n};\n\n// ---------------------------------------------------------------------------\n// Positions\n// ---------------------------------------------------------------------------\n\nexport type Position = {\n tokenSymbol: string;\n tokenName: string;\n tokenAddress: string;\n chain: string;\n positionAmount: number;\n boughtUsd: number;\n soldUsd: number;\n realizedPnl: number;\n costBasis: number;\n trades: Trade[];\n lastTradeAt: number;\n /** Daylight-hosted token image URL. */\n tokenImageUrl?: string | null;\n /** Current USD value of the remaining position (open positions only). */\n currentValueUSD?: number | null;\n /** Unrealized + realized PnL in USD. */\n pnlValueUsd?: number | null;\n /** PnL as a percentage of cost basis. */\n pnlPercent?: number | null;\n};\n\nexport type Pagination = {\n hasMore: boolean;\n nextPage?: number;\n};\n\n/**\n * Response from `GET /v1/traders/:addressOrId/positions/open`\n * and `GET /v1/traders/:addressOrId/positions/closed`.\n */\nexport type PositionsResponse = {\n positions: Position[];\n pagination: Pagination;\n /** ISO 8601 timestamp indicating when the response was computed server-side. */\n computedAt?: string | null;\n};\n\n// ---------------------------------------------------------------------------\n// Followers\n// ---------------------------------------------------------------------------\n\n/**\n * Response from `GET /v1/traders/:addressOrId/followers`.\n */\nexport type FollowersResponse = {\n followers: ProfileSummary[];\n count: number;\n};\n\n// ---------------------------------------------------------------------------\n// Following\n// ---------------------------------------------------------------------------\n\n/**\n * Response from `GET /v1/users/:addressOrUid/following`.\n */\nexport type FollowingResponse = {\n following: ProfileSummary[];\n count: number;\n};\n\n// ---------------------------------------------------------------------------\n// Follow / Unfollow\n// ---------------------------------------------------------------------------\n\n/**\n * Response from `PUT /v1/users/:addressOrUid/follows`.\n */\nexport type FollowResponse = {\n followed: ProfileSummary[];\n};\n\n/**\n * Response from `DELETE /v1/users/:addressOrUid/follows`.\n */\nexport type UnfollowResponse = {\n unfollowed: ProfileSummary[];\n};\n\n// ---------------------------------------------------------------------------\n// Fetch options\n// ---------------------------------------------------------------------------\n\nexport type FetchLeaderboardOptions = {\n sort?: 'pnl' | 'winRate' | 'roi';\n chains?: string[];\n limit?: number;\n};\n\nexport type FetchTraderProfileOptions = {\n /** Wallet address or Clicker profile ID. */\n addressOrId: string;\n};\n\nexport type FetchPositionsOptions = {\n /** Wallet address or Clicker profile ID. */\n addressOrId: string;\n chain?: string;\n sort?: 'value' | 'latest';\n limit?: number;\n page?: number;\n};\n\nexport type FetchFollowersOptions = {\n /** Wallet address or Clicker profile ID. */\n addressOrId: string;\n};\n\nexport type FetchFollowingOptions = {\n /** Wallet address or Clicker profile ID. */\n addressOrUid: string;\n};\n\nexport type FollowOptions = {\n /** Wallet address or Clicker profile ID of the user. */\n addressOrUid: string;\n /** Array of wallet addresses or profile IDs to follow. */\n targets: string[];\n};\n\nexport type UnfollowOptions = {\n /** Wallet address or Clicker profile ID of the user. */\n addressOrUid: string;\n /** Array of wallet addresses or profile IDs to unfollow. */\n targets: string[];\n};\n\n// ---------------------------------------------------------------------------\n// Controller state\n// ---------------------------------------------------------------------------\n\n/**\n * State managed by the SocialController.\n *\n * The controller acts as a simple store — no TTL or eviction logic.\n * The UI decides when to re-fetch; the social-api's own cache layer\n * handles upstream rate-limiting.\n */\nexport type SocialControllerState = {\n /** Cached ranked trader list from the last `updateLeaderboard` call. */\n leaderboardEntries: LeaderboardEntry[];\n /** Wallet addresses the current user follows. */\n followingAddresses: string[];\n /** Clicker profile IDs the current user follows — used by mobile UI. */\n followingProfileIds: string[];\n};\n"]}
1
+ {"version":3,"file":"social-types.mjs","sourceRoot":"","sources":["../src/social-types.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,MAAM,EACN,QAAQ,EACR,MAAM,EACN,IAAI,IAAI,UAAU,EACnB,8BAA8B;AA8B/B,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC;IACpC,SAAS,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAChC,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC5B,WAAW,EAAE,MAAM,EAAE;IACrB,OAAO,EAAE,MAAM,EAAE;IACjB,SAAS,EAAE,MAAM,EAAE;IACnB,eAAe,EAAE,MAAM,EAAE;CAC1B,CAAC,CAAC","sourcesContent":["import type { Infer } from '@metamask/superstruct';\nimport {\n enums,\n number,\n optional,\n string,\n type as structType,\n} from '@metamask/superstruct';\n\n// ---------------------------------------------------------------------------\n// Shared sub-types\n// ---------------------------------------------------------------------------\n\n/**\n * Minimal profile summary used across follow/follower responses.\n */\nexport type ProfileSummary = {\n /** Clicker profile ID (UUID). */\n profileId: string;\n /** Primary wallet address. */\n address: string;\n /** Display name or truncated address. */\n name: string;\n /** Profile avatar URL. */\n imageUrl?: string | null;\n};\n\n/**\n * Social media handles attached to a trader profile.\n */\nexport type SocialHandles = {\n twitter?: string | null;\n farcaster?: string | null;\n ens?: string | null;\n lens?: string | null;\n};\n\nexport const TradeStruct = structType({\n direction: enums(['buy', 'sell']),\n intent: enums(['enter', 'exit']),\n category: optional(string()),\n tokenAmount: number(),\n usdCost: number(),\n timestamp: number(),\n transactionHash: string(),\n});\n\nexport type Trade = Infer<typeof TradeStruct>;\n\n// ---------------------------------------------------------------------------\n// Leaderboard\n// ---------------------------------------------------------------------------\n\n/**\n * A single entry in the leaderboard response.\n */\nexport type LeaderboardEntry = {\n rank: number;\n addresses: string[];\n profileId: string;\n name: string;\n imageUrl?: string | null;\n pnl30d: number;\n winRate30d?: number | null;\n /** Renamed from roi30d. */\n roiPercent30d?: number | null;\n /** Renamed from tradeCount. */\n tradeCount30d?: number | null;\n pnl7d?: number | null;\n winRate7d?: number | null;\n roiPercent7d?: number | null;\n tradeCount7d?: number | null;\n pnlPerChain: Record<string, number>;\n followerCount: number;\n socialHandles: SocialHandles;\n};\n\n/**\n * Response from `GET /v1/leaderboard`.\n */\nexport type LeaderboardResponse = {\n traders: LeaderboardEntry[];\n};\n\n// ---------------------------------------------------------------------------\n// Trader profile\n// ---------------------------------------------------------------------------\n\nexport type TraderProfile = {\n profileId: string;\n address: string;\n allAddresses: string[];\n name: string;\n imageUrl?: string | null;\n};\n\nexport type TraderStats = {\n pnl30d?: number | null;\n winRate30d?: number | null;\n /** Renamed from roi30d. */\n roiPercent30d?: number | null;\n /** Renamed from tradeCount. */\n tradeCount30d?: number | null;\n pnl7d?: number | null;\n winRate7d?: number | null;\n roiPercent7d?: number | null;\n tradeCount7d?: number | null;\n /** Median holding time in minutes. */\n medianHoldMinutes?: number | null;\n};\n\nexport type PerChainBreakdown = {\n perChainPnl: Record<string, number>;\n /** ROI can be null for chains with no trading activity (zero cost-basis). */\n perChainRoi: Record<string, number | null>;\n perChainVolume: Record<string, number>;\n};\n\n/**\n * Response from `GET /v1/traders/:addressOrId/profile`.\n */\nexport type TraderProfileResponse = {\n profile: TraderProfile;\n stats: TraderStats;\n perChainBreakdown: PerChainBreakdown;\n socialHandles: SocialHandles;\n followerCount: number;\n followingCount: number;\n};\n\n// ---------------------------------------------------------------------------\n// Positions\n// ---------------------------------------------------------------------------\n\nexport type Position = {\n tokenSymbol: string;\n tokenName: string;\n tokenAddress: string;\n chain: string;\n positionAmount: number;\n boughtUsd: number;\n soldUsd: number;\n realizedPnl: number;\n costBasis: number;\n trades: Trade[];\n lastTradeAt: number;\n /** Daylight-hosted token image URL. */\n tokenImageUrl?: string | null;\n /** Current USD value of the remaining position (open positions only). */\n currentValueUSD?: number | null;\n /** Unrealized + realized PnL in USD. */\n pnlValueUsd?: number | null;\n /** PnL as a percentage of cost basis. */\n pnlPercent?: number | null;\n};\n\nexport type Pagination = {\n hasMore: boolean;\n nextPage?: number;\n};\n\n/**\n * Response from `GET /v1/traders/:addressOrId/positions/open`\n * and `GET /v1/traders/:addressOrId/positions/closed`.\n */\nexport type PositionsResponse = {\n positions: Position[];\n pagination: Pagination;\n /** ISO 8601 timestamp indicating when the response was computed server-side. */\n computedAt?: string | null;\n};\n\n// ---------------------------------------------------------------------------\n// Followers\n// ---------------------------------------------------------------------------\n\n/**\n * Response from `GET /v1/traders/:addressOrId/followers`.\n */\nexport type FollowersResponse = {\n followers: ProfileSummary[];\n count: number;\n};\n\n// ---------------------------------------------------------------------------\n// Following\n// ---------------------------------------------------------------------------\n\n/**\n * Response from `GET /v1/users/me/following`.\n */\nexport type FollowingResponse = {\n following: ProfileSummary[];\n count: number;\n};\n\n// ---------------------------------------------------------------------------\n// Follow / Unfollow\n// ---------------------------------------------------------------------------\n\n/**\n * Response from `PUT /v1/users/me/follows`.\n */\nexport type FollowResponse = {\n followed: ProfileSummary[];\n};\n\n/**\n * Response from `DELETE /v1/users/me/follows`.\n */\nexport type UnfollowResponse = {\n unfollowed: ProfileSummary[];\n};\n\n// ---------------------------------------------------------------------------\n// Fetch options\n// ---------------------------------------------------------------------------\n\nexport type FetchLeaderboardOptions = {\n sort?: 'pnl' | 'winRate' | 'roi';\n chains?: string[];\n limit?: number;\n};\n\nexport type FetchTraderProfileOptions = {\n /** Wallet address or Clicker profile ID. */\n addressOrId: string;\n};\n\nexport type FetchPositionsOptions = {\n /** Wallet address or Clicker profile ID. */\n addressOrId: string;\n chain?: string;\n sort?: 'value' | 'latest';\n limit?: number;\n page?: number;\n};\n\nexport type FetchFollowersOptions = {\n /** Wallet address or Clicker profile ID. */\n addressOrId: string;\n};\n\nexport type FollowOptions = {\n /** Array of wallet addresses or profile IDs to follow. */\n targets: string[];\n};\n\nexport type UnfollowOptions = {\n /** Array of wallet addresses or profile IDs to unfollow. */\n targets: string[];\n};\n\n// ---------------------------------------------------------------------------\n// Controller state\n// ---------------------------------------------------------------------------\n\n/**\n * State managed by the SocialController.\n *\n * The controller acts as a simple store — no TTL or eviction logic.\n * The UI decides when to re-fetch; the social-api's own cache layer\n * handles upstream rate-limiting.\n */\nexport type SocialControllerState = {\n /** Cached ranked trader list from the last `updateLeaderboard` call. */\n leaderboardEntries: LeaderboardEntry[];\n /** Wallet addresses the current user follows. */\n followingAddresses: string[];\n /** Clicker profile IDs the current user follows — used by mobile UI. */\n followingProfileIds: string[];\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask/social-controllers",
3
- "version": "0.2.0",
3
+ "version": "2.0.0",
4
4
  "description": "A collection of social related controllers",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -44,8 +44,8 @@
44
44
  "build:docs": "typedoc",
45
45
  "changelog:update": "../../scripts/update-changelog.sh @metamask/social-controllers",
46
46
  "changelog:validate": "../../scripts/validate-changelog.sh @metamask/social-controllers",
47
- "messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --check",
48
- "messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --generate",
47
+ "messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --check",
48
+ "messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --generate",
49
49
  "since-latest-release": "../../scripts/since-latest-release.sh",
50
50
  "test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter",
51
51
  "test:clean": "NODE_OPTIONS=--experimental-vm-modules jest --clearCache",
@@ -57,10 +57,11 @@
57
57
  "@metamask/base-data-service": "^0.1.1",
58
58
  "@metamask/controller-utils": "^11.20.0",
59
59
  "@metamask/messenger": "^1.1.1",
60
+ "@metamask/profile-sync-controller": "^28.0.2",
60
61
  "@metamask/superstruct": "^3.1.0"
61
62
  },
62
63
  "devDependencies": {
63
- "@metamask/auto-changelog": "^6.0.0",
64
+ "@metamask/auto-changelog": "^6.1.0",
64
65
  "@ts-bridge/cli": "^0.6.4",
65
66
  "@types/jest": "^29.5.14",
66
67
  "deepmerge": "^4.2.2",