@nadohq/mobile-client 0.29.0 → 0.31.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 (208) hide show
  1. package/README.md +15 -8
  2. package/dist/{MobileClient-9JSAzblH.cjs → MobileClient-_i0ZV6Dq.cjs} +104 -44
  3. package/dist/MobileClient-_i0ZV6Dq.cjs.map +1 -0
  4. package/dist/MobileClient.cjs +1 -1
  5. package/dist/MobileClient.d.cts +77 -36
  6. package/dist/MobileClient.d.cts.map +1 -1
  7. package/dist/MobileClient.d.ts +77 -36
  8. package/dist/MobileClient.d.ts.map +1 -1
  9. package/dist/MobileClient.js +105 -45
  10. package/dist/MobileClient.js.map +1 -1
  11. package/dist/{MobileServerFailureError-ZggEcEda.d.cts → MobileServerFailureError-BoyAfEZA.d.cts} +3 -2
  12. package/dist/MobileServerFailureError-BoyAfEZA.d.cts.map +1 -0
  13. package/dist/{MobileServerFailureError-f9KhKnJj.d.ts → MobileServerFailureError-MgYVBh5p.d.ts} +3 -2
  14. package/dist/MobileServerFailureError-MgYVBh5p.d.ts.map +1 -0
  15. package/dist/{buildSignedMobileRequest-BsbBkU0K.d.cts → buildSignedMobileRequest-CBMt97aY.d.cts} +2 -2
  16. package/dist/{buildSignedMobileRequest-BsbBkU0K.d.cts.map → buildSignedMobileRequest-CBMt97aY.d.cts.map} +1 -1
  17. package/dist/{buildSignedMobileRequest-CDRsRNHm.d.ts → buildSignedMobileRequest-qEC4gWaI.d.ts} +2 -2
  18. package/dist/{buildSignedMobileRequest-CDRsRNHm.d.ts.map → buildSignedMobileRequest-qEC4gWaI.d.ts.map} +1 -1
  19. package/dist/{canonicalize-PX6dTIdF.d.ts → canonicalize-QNARV_Xc.d.cts} +4 -4
  20. package/dist/canonicalize-QNARV_Xc.d.cts.map +1 -0
  21. package/dist/{canonicalize-Dm7sXwPg.d.cts → canonicalize-wVdGejB1.d.ts} +4 -4
  22. package/dist/canonicalize-wVdGejB1.d.ts.map +1 -0
  23. package/dist/clientTypes-6utzUU-b.d.ts +240 -0
  24. package/dist/clientTypes-6utzUU-b.d.ts.map +1 -0
  25. package/dist/clientTypes-D9qgtNlE.d.cts +240 -0
  26. package/dist/clientTypes-D9qgtNlE.d.cts.map +1 -0
  27. package/dist/dataMappers.cjs +35 -1
  28. package/dist/dataMappers.cjs.map +1 -1
  29. package/dist/dataMappers.d.cts +8 -3
  30. package/dist/dataMappers.d.cts.map +1 -1
  31. package/dist/dataMappers.d.ts +8 -3
  32. package/dist/dataMappers.d.ts.map +1 -1
  33. package/dist/dataMappers.js +35 -2
  34. package/dist/dataMappers.js.map +1 -1
  35. package/dist/{eip712MethodByType-DLh9MRsD.d.cts → eip712MethodByType-CroIPqsJ.d.cts} +2 -2
  36. package/dist/eip712MethodByType-CroIPqsJ.d.cts.map +1 -0
  37. package/dist/{eip712MethodByType-DJgXal9r.d.ts → eip712MethodByType-DBUy4AdI.d.ts} +2 -2
  38. package/dist/eip712MethodByType-DBUy4AdI.d.ts.map +1 -0
  39. package/dist/feed-BF5k6Ryu.d.ts +14 -0
  40. package/dist/feed-BF5k6Ryu.d.ts.map +1 -0
  41. package/dist/feed-CBIwOhTO.d.cts +14 -0
  42. package/dist/feed-CBIwOhTO.d.cts.map +1 -0
  43. package/dist/index.cjs +8 -1
  44. package/dist/index.d.cts +17 -15
  45. package/dist/index.d.ts +17 -15
  46. package/dist/index.js +3 -1
  47. package/dist/{mobileErrorCodes-BeyBKmwh.d.cts → mobileErrorCodes-CuQ5lyBV.d.ts} +8 -8
  48. package/dist/mobileErrorCodes-CuQ5lyBV.d.ts.map +1 -0
  49. package/dist/{mobileErrorCodes-QG5XbEY6.d.ts → mobileErrorCodes-D_SyBm0k.d.cts} +8 -8
  50. package/dist/mobileErrorCodes-D_SyBm0k.d.cts.map +1 -0
  51. package/dist/{patterns-BbxH3_VA.d.ts → patterns-B5gi7OfV.d.ts} +1 -1
  52. package/dist/patterns-B5gi7OfV.d.ts.map +1 -0
  53. package/dist/{patterns-B9J2ldpx.d.cts → patterns-Db6fgz8i.d.cts} +1 -1
  54. package/dist/patterns-Db6fgz8i.d.cts.map +1 -0
  55. package/dist/{payloadHash-nj8WuLUP.d.cts → payloadHash-B0tlFOK8.d.cts} +2 -2
  56. package/dist/payloadHash-B0tlFOK8.d.cts.map +1 -0
  57. package/dist/{payloadHash-Bmhzs78N.d.ts → payloadHash-D1yTQSF4.d.ts} +2 -2
  58. package/dist/payloadHash-D1yTQSF4.d.ts.map +1 -0
  59. package/dist/serverBaseTypes-CzRgwUvA.d.ts +25 -0
  60. package/dist/serverBaseTypes-CzRgwUvA.d.ts.map +1 -0
  61. package/dist/serverBaseTypes-DSRgU2Fb.d.cts +25 -0
  62. package/dist/serverBaseTypes-DSRgU2Fb.d.cts.map +1 -0
  63. package/dist/serverExecuteTypes-BCb6bUMP.d.cts +19 -0
  64. package/dist/serverExecuteTypes-BCb6bUMP.d.cts.map +1 -0
  65. package/dist/serverExecuteTypes-CI3NBW2Z.d.ts +19 -0
  66. package/dist/serverExecuteTypes-CI3NBW2Z.d.ts.map +1 -0
  67. package/dist/serverModelTypes-BYQcsRrx.d.cts +146 -0
  68. package/dist/serverModelTypes-BYQcsRrx.d.cts.map +1 -0
  69. package/dist/serverModelTypes-DvPs5qs3.d.ts +146 -0
  70. package/dist/serverModelTypes-DvPs5qs3.d.ts.map +1 -0
  71. package/dist/serverQueryTypes-9H6P1vJ5.d.cts +92 -0
  72. package/dist/serverQueryTypes-9H6P1vJ5.d.cts.map +1 -0
  73. package/dist/serverQueryTypes-Cbjx0bIj.d.ts +92 -0
  74. package/dist/serverQueryTypes-Cbjx0bIj.d.ts.map +1 -0
  75. package/dist/serverRequestTypes-CHDk6JwE.d.cts +85 -0
  76. package/dist/serverRequestTypes-CHDk6JwE.d.cts.map +1 -0
  77. package/dist/serverRequestTypes-DYTLrCpz.d.ts +85 -0
  78. package/dist/serverRequestTypes-DYTLrCpz.d.ts.map +1 -0
  79. package/dist/{serverResponseGuards-DjCNL3CR.d.cts → serverResponseGuards-DRMHmfXh.d.cts} +2 -2
  80. package/dist/{serverResponseGuards-DjCNL3CR.d.cts.map → serverResponseGuards-DRMHmfXh.d.cts.map} +1 -1
  81. package/dist/{serverResponseGuards-C_vZIgGl.d.ts → serverResponseGuards-DpbZvJfL.d.ts} +2 -2
  82. package/dist/{serverResponseGuards-C_vZIgGl.d.ts.map → serverResponseGuards-DpbZvJfL.d.ts.map} +1 -1
  83. package/dist/signing/buildSignedMobileRequest.cjs +1 -1
  84. package/dist/signing/buildSignedMobileRequest.d.cts +1 -1
  85. package/dist/signing/buildSignedMobileRequest.d.ts +1 -1
  86. package/dist/signing/canonicalize.cjs +4 -37
  87. package/dist/signing/canonicalize.cjs.map +1 -1
  88. package/dist/signing/canonicalize.d.cts +1 -1
  89. package/dist/signing/canonicalize.d.ts +1 -1
  90. package/dist/signing/canonicalize.js +4 -37
  91. package/dist/signing/canonicalize.js.map +1 -1
  92. package/dist/signing/eip712MethodByType.cjs +1 -5
  93. package/dist/signing/eip712MethodByType.cjs.map +1 -1
  94. package/dist/signing/eip712MethodByType.d.cts +1 -1
  95. package/dist/signing/eip712MethodByType.d.ts +1 -1
  96. package/dist/signing/eip712MethodByType.js +1 -5
  97. package/dist/signing/eip712MethodByType.js.map +1 -1
  98. package/dist/signing/index.d.cts +5 -5
  99. package/dist/signing/index.d.ts +5 -5
  100. package/dist/signing/payloadHash.cjs +1 -1
  101. package/dist/signing/payloadHash.d.cts +1 -1
  102. package/dist/signing/payloadHash.d.ts +1 -1
  103. package/dist/signing/types.d.cts +1 -1
  104. package/dist/signing/types.d.ts +1 -1
  105. package/dist/types/MobileServerFailureError.cjs +1 -1
  106. package/dist/types/MobileServerFailureError.cjs.map +1 -1
  107. package/dist/types/MobileServerFailureError.d.cts +1 -1
  108. package/dist/types/MobileServerFailureError.d.ts +1 -1
  109. package/dist/types/MobileServerFailureError.js.map +1 -1
  110. package/dist/types/clientTypes.d.cts +2 -2
  111. package/dist/types/clientTypes.d.ts +2 -2
  112. package/dist/types/index.cjs +4 -0
  113. package/dist/types/index.d.cts +9 -8
  114. package/dist/types/index.d.ts +9 -8
  115. package/dist/types/index.js +2 -1
  116. package/dist/types/mobileErrorCodes.cjs +10 -7
  117. package/dist/types/mobileErrorCodes.cjs.map +1 -1
  118. package/dist/types/mobileErrorCodes.d.cts +1 -1
  119. package/dist/types/mobileErrorCodes.d.ts +1 -1
  120. package/dist/types/mobileErrorCodes.js +9 -6
  121. package/dist/types/mobileErrorCodes.js.map +1 -1
  122. package/dist/types/serverBaseTypes.d.cts +2 -2
  123. package/dist/types/serverBaseTypes.d.ts +2 -2
  124. package/dist/types/serverExecuteTypes.d.cts +2 -2
  125. package/dist/types/serverExecuteTypes.d.ts +2 -2
  126. package/dist/types/serverModelTypes.cjs +29 -0
  127. package/dist/types/serverModelTypes.cjs.map +1 -0
  128. package/dist/types/serverModelTypes.d.cts +2 -2
  129. package/dist/types/serverModelTypes.d.ts +2 -2
  130. package/dist/types/serverModelTypes.js +26 -1
  131. package/dist/types/serverModelTypes.js.map +1 -0
  132. package/dist/types/serverQueryTypes.d.cts +2 -2
  133. package/dist/types/serverQueryTypes.d.ts +2 -2
  134. package/dist/types/serverRequestTypes.cjs +0 -0
  135. package/dist/types/serverRequestTypes.d.cts +2 -0
  136. package/dist/types/serverRequestTypes.d.ts +2 -0
  137. package/dist/types/serverRequestTypes.js +1 -0
  138. package/dist/{types-B76Pn7Sy.d.ts → types-CQE3HD2V.d.ts} +4 -15
  139. package/dist/types-CQE3HD2V.d.ts.map +1 -0
  140. package/dist/{types-uCD4BNZR.d.cts → types-bNB98pYk.d.cts} +4 -15
  141. package/dist/types-bNB98pYk.d.cts.map +1 -0
  142. package/dist/utils/feed.cjs +17 -0
  143. package/dist/utils/feed.cjs.map +1 -0
  144. package/dist/utils/feed.d.cts +2 -0
  145. package/dist/utils/feed.d.ts +2 -0
  146. package/dist/utils/feed.js +15 -0
  147. package/dist/utils/feed.js.map +1 -0
  148. package/dist/utils/index.cjs +3 -0
  149. package/dist/utils/index.d.cts +4 -3
  150. package/dist/utils/index.d.ts +4 -3
  151. package/dist/utils/index.js +2 -1
  152. package/dist/utils/patterns.d.cts +1 -1
  153. package/dist/utils/patterns.d.ts +1 -1
  154. package/dist/utils/serverResponseGuards.d.cts +1 -1
  155. package/dist/utils/serverResponseGuards.d.ts +1 -1
  156. package/package.json +3 -3
  157. package/src/MobileClient.ts +163 -112
  158. package/src/dataMappers.ts +41 -0
  159. package/src/signing/canonicalize.ts +4 -37
  160. package/src/signing/eip712MethodByType.ts +1 -5
  161. package/src/signing/signing.test.ts +17 -60
  162. package/src/signing/types.ts +2 -12
  163. package/src/types/MobileServerFailureError.ts +2 -4
  164. package/src/types/clientTypes.ts +105 -27
  165. package/src/types/index.ts +1 -0
  166. package/src/types/mobileErrorCodes.ts +8 -5
  167. package/src/types/serverBaseTypes.ts +7 -28
  168. package/src/types/serverExecuteTypes.ts +17 -0
  169. package/src/types/serverModelTypes.ts +104 -8
  170. package/src/types/serverQueryTypes.ts +84 -39
  171. package/src/types/serverRequestTypes.ts +91 -0
  172. package/src/utils/feed.ts +11 -0
  173. package/src/utils/index.ts +1 -0
  174. package/dist/MobileClient-9JSAzblH.cjs.map +0 -1
  175. package/dist/MobileServerFailureError-ZggEcEda.d.cts.map +0 -1
  176. package/dist/MobileServerFailureError-f9KhKnJj.d.ts.map +0 -1
  177. package/dist/canonicalize-Dm7sXwPg.d.cts.map +0 -1
  178. package/dist/canonicalize-PX6dTIdF.d.ts.map +0 -1
  179. package/dist/clientTypes-DWW2N66c.d.ts +0 -168
  180. package/dist/clientTypes-DWW2N66c.d.ts.map +0 -1
  181. package/dist/clientTypes-Et0PUa2d.d.cts +0 -168
  182. package/dist/clientTypes-Et0PUa2d.d.cts.map +0 -1
  183. package/dist/eip712MethodByType-DJgXal9r.d.ts.map +0 -1
  184. package/dist/eip712MethodByType-DLh9MRsD.d.cts.map +0 -1
  185. package/dist/mobileErrorCodes-BeyBKmwh.d.cts.map +0 -1
  186. package/dist/mobileErrorCodes-QG5XbEY6.d.ts.map +0 -1
  187. package/dist/patterns-B9J2ldpx.d.cts.map +0 -1
  188. package/dist/patterns-BbxH3_VA.d.ts.map +0 -1
  189. package/dist/payloadHash-Bmhzs78N.d.ts.map +0 -1
  190. package/dist/payloadHash-nj8WuLUP.d.cts.map +0 -1
  191. package/dist/serverBaseTypes-BicXMrZV.d.cts +0 -43
  192. package/dist/serverBaseTypes-BicXMrZV.d.cts.map +0 -1
  193. package/dist/serverBaseTypes-ewbo8l4R.d.ts +0 -43
  194. package/dist/serverBaseTypes-ewbo8l4R.d.ts.map +0 -1
  195. package/dist/serverExecuteTypes-CXnMjKnt.d.ts +0 -11
  196. package/dist/serverExecuteTypes-CXnMjKnt.d.ts.map +0 -1
  197. package/dist/serverExecuteTypes-DKYK1V7C.d.cts +0 -11
  198. package/dist/serverExecuteTypes-DKYK1V7C.d.cts.map +0 -1
  199. package/dist/serverModelTypes-CQgfqgW3.d.cts +0 -69
  200. package/dist/serverModelTypes-CQgfqgW3.d.cts.map +0 -1
  201. package/dist/serverModelTypes-vEPhHIit.d.ts +0 -69
  202. package/dist/serverModelTypes-vEPhHIit.d.ts.map +0 -1
  203. package/dist/serverQueryTypes-BI-2TD8F.d.ts +0 -53
  204. package/dist/serverQueryTypes-BI-2TD8F.d.ts.map +0 -1
  205. package/dist/serverQueryTypes-D7Yharse.d.cts +0 -53
  206. package/dist/serverQueryTypes-D7Yharse.d.cts.map +0 -1
  207. package/dist/types-B76Pn7Sy.d.ts.map +0 -1
  208. package/dist/types-uCD4BNZR.d.cts.map +0 -1
@@ -1,10 +1,7 @@
1
1
  import { WalletClientWithAccount } from '@nadohq/shared';
2
2
  import { Hex } from 'viem';
3
3
  import { MobileSignedRequestParams } from '../types/clientTypes';
4
- import {
5
- MobileNotificationPlatform,
6
- MobileServerNotificationPreferences,
7
- } from '../types/serverModelTypes';
4
+ import { MobileNotificationPlatform } from '../types/serverModelTypes';
8
5
 
9
6
  /**
10
7
  * Unsigned inner payloads that can be authenticated against the mobile service API.
@@ -16,8 +13,7 @@ import {
16
13
  * {@link canonicalizeMobileInner}, which is the source of truth. Keep the field order here in sync with it.
17
14
  */
18
15
  export type MobileSignedInner =
19
- | { type: 'claim_username'; display_name: string }
20
- | { type: 'update_username'; display_name: string }
16
+ | { type: 'set_username'; display_name: string }
21
17
  | { type: 'set_private_mode'; private_mode: boolean }
22
18
  | { type: 'self_identity' }
23
19
  | {
@@ -29,12 +25,6 @@ export type MobileSignedInner =
29
25
  locale: string | null;
30
26
  app_version: string | null;
31
27
  }
32
- | { type: 'unregister_expo_token'; expo_token: string }
33
- | {
34
- type: 'update_preferences';
35
- preferences: MobileServerNotificationPreferences;
36
- }
37
- | { type: 'notification_preferences' }
38
28
  | { type: 'registered_devices' };
39
29
 
40
30
  /**
@@ -1,8 +1,6 @@
1
1
  import { BaseServerFailureError } from '@nadohq/shared';
2
- import {
3
- MobileServerFailureResponse,
4
- MobileServerRequestType,
5
- } from './serverBaseTypes';
2
+ import { MobileServerFailureResponse } from './serverBaseTypes';
3
+ import { MobileServerRequestType } from './serverRequestTypes';
6
4
 
7
5
  /**
8
6
  * Error thrown when the mobile service API returns a failure envelope, either as a non-2xx HTTP response
@@ -1,39 +1,47 @@
1
1
  import { SignatureParams, Subaccount } from '@nadohq/shared';
2
2
  import { Hex } from 'viem';
3
3
  import {
4
+ MobileFeedMarginMode,
5
+ MobileFeedTradePosition,
4
6
  MobileNotificationCategory,
5
7
  MobileNotificationPlatform,
6
8
  } from './serverModelTypes';
7
9
 
8
10
  /**
9
- * A subaccount's claimed identity on the mobile service API.
11
+ * A subaccount's identity on the mobile service API. Every non-isolated subaccount has one implicitly, so
12
+ * both name fields are `null` until a username is claimed — render a local fallback label in that case and
13
+ * key lookups, links, and caches off `subaccount`.
10
14
  *
11
15
  * `username` and `displayName` are two representations of the same claimed name: `displayName` is what the
12
16
  * user entered (preserving casing, e.g. `Alice.One`), while `username` is the canonical, lowercased handle
13
- * derived from it (e.g. `alice.one`). `username` is the unique key used for profile lookups
14
- * ({@link MobilePublicProfile}); `displayName` is only for presentation.
17
+ * derived from it (e.g. `alice.one`), unique across identities.
15
18
  */
16
19
  export interface MobileIdentity {
17
20
  subaccount: Hex;
18
21
  /**
19
- * Canonical, lowercased handle derived from {@link MobileIdentity.displayName}, unique per identity and
20
- * used for profile lookups.
22
+ * Canonical, lowercased handle derived from {@link MobileIdentity.displayName}, unique across identities,
23
+ * or `null` if no username has been claimed.
21
24
  */
22
- username: string;
25
+ username: string | null;
23
26
  /**
24
- * User-facing name as claimed, preserving original casing. Validated against `MOBILE_DISPLAY_NAME_PATTERN`.
27
+ * User-facing name as claimed, preserving original casing, or `null` if no username has been claimed.
28
+ * Validated against `MOBILE_DISPLAY_NAME_PATTERN`.
25
29
  */
26
- displayName: string;
30
+ displayName: string | null;
27
31
  privateMode: boolean;
28
32
  }
29
33
 
30
34
  /**
31
- * A subaccount's public profile, as returned by an unsigned profile lookup.
35
+ * A subaccount's public profile, as returned by an unsigned profile lookup. Private Mode hides the account's
36
+ * activity, not its profile, so `privateMode` is exposed here too.
32
37
  */
33
38
  export interface MobilePublicProfile {
34
39
  subaccount: Hex;
35
- username: string;
36
- displayName: string;
40
+ /** Canonical, lowercased handle, or `null` if no username has been claimed. */
41
+ username: string | null;
42
+ /** User-facing name as claimed, or `null` if no username has been claimed. */
43
+ displayName: string | null;
44
+ privateMode: boolean;
37
45
  }
38
46
 
39
47
  /**
@@ -44,6 +52,58 @@ export interface MobileUsernameAvailability {
44
52
  available: boolean;
45
53
  }
46
54
 
55
+ /**
56
+ * Margin of a feed trade. Branch on `mode` — do not infer isolated state from leverage presence:
57
+ * `estimatedLeverage` (a rounded whole-number estimate, not exact submitted leverage) is `undefined` on
58
+ * `cross`, and also `undefined` inside `isolated` when no estimate is available.
59
+ */
60
+ export interface MobileFeedMargin {
61
+ mode: MobileFeedMarginMode;
62
+ estimatedLeverage?: number;
63
+ }
64
+
65
+ /**
66
+ * A single feed trade: one row per order digest, enriched with the trader's current identity at read time
67
+ * (a rename can change an already-fetched trade on the next read). Amounts are display-oriented human-unit
68
+ * numbers — do not use them for accounting, order construction, or exact threshold decisions.
69
+ */
70
+ export interface MobileFeedTrade {
71
+ /** Order digest this trade is keyed by; the stable id for reconciling live pagination. */
72
+ orderDigest: Hex;
73
+ subaccount: Hex;
74
+ /** `null` when the trader has not claimed a username; render a local fallback label from `subaccount`. */
75
+ username: string | null;
76
+ /** `null` when the trader has not claimed a username; render a local fallback label from `subaccount`. */
77
+ displayName: string | null;
78
+ /** Reserved for a future avatar source; `null` until one is implemented. */
79
+ avatarUrl: string | null;
80
+ productId: number;
81
+ /** Executed quantity in human units. */
82
+ quantity: number;
83
+ /** Trade notional in whole-dollar human units. */
84
+ notional: number;
85
+ /** Average execution price in human units. */
86
+ averagePrice: number;
87
+ margin: MobileFeedMargin;
88
+ /** Resulting position change. `position.direction` is NOT the execution buy/sell side. */
89
+ position: MobileFeedTradePosition;
90
+ /** Realized PnL of the trade in human units; can be negative. */
91
+ realizedPnl: number;
92
+ /** Fill time as a Unix timestamp (milliseconds). */
93
+ filledAt: number;
94
+ }
95
+
96
+ /**
97
+ * A page of feed trades. `nextCursor` is `null` when there was no additional candidate at query time.
98
+ * Pagination is live, not snapshot, so a later fill can move a trade between pages — deduplicate by
99
+ * {@link MobileFeedTrade.orderDigest} and treat the merged list as a short-lived view, not an authoritative
100
+ * cache (removals from Private Mode or blacklists are not signaled).
101
+ */
102
+ export interface MobileFeedPage {
103
+ trades: MobileFeedTrade[];
104
+ nextCursor: string | null;
105
+ }
106
+
47
107
  /**
48
108
  * Scope limiting a notification category preference. Scopes are part of the wire format but rejected by the
49
109
  * backend for the MVP — `scopes` must be empty.
@@ -98,6 +158,16 @@ export interface MobileRegisteredDevice {
98
158
  export interface MobileSignedRequestParams
99
159
  extends Subaccount, SignatureParams {}
100
160
 
161
+ /**
162
+ * Common params for the unsigned notification requests, which name their target with an Expo push token
163
+ * instead of a subaccount and signature — the counterpart to {@link MobileSignedRequestParams}. The backend
164
+ * resolves the token's owning wallet and reads or mutates that wallet's state.
165
+ */
166
+ export interface MobileWithExpoTokenParams {
167
+ /** Expo push token, e.g. `ExponentPushToken[...]`. */
168
+ expoToken: string;
169
+ }
170
+
101
171
  /**
102
172
  * Params for {@link MobileClient.getUsernameAvailability}.
103
173
  */
@@ -108,26 +178,36 @@ export interface GetMobileUsernameAvailabilityParams {
108
178
  /**
109
179
  * Params for {@link MobileClient.getPublicProfile}.
110
180
  */
111
- export interface GetMobilePublicProfileParams {
112
- username: string;
113
- }
181
+ export type GetMobilePublicProfileParams = Subaccount;
114
182
 
115
183
  /**
116
- * Params for {@link MobileClient.getSelfIdentity}.
184
+ * Params for {@link MobileClient.getFeed}.
117
185
  */
118
- export type GetMobileSelfIdentityParams = MobileSignedRequestParams;
186
+ export interface GetMobileFeedParams {
187
+ /**
188
+ * Minimum notional filter as a whole-dollar safe integer, at least `MOBILE_FEED_MIN_NOTIONAL_FLOOR`
189
+ * ($1,000). Omit for the unfiltered feed.
190
+ */
191
+ minimumNotional?: number;
192
+ /** Page size, 1–`MOBILE_FEED_MAX_PAGE_SIZE` (50); the backend defaults to 50 when omitted. */
193
+ limit?: number;
194
+ /**
195
+ * Opaque keyset cursor from a prior page's {@link MobileFeedPage.nextCursor}. Send it back unchanged with
196
+ * the exact same `minimumNotional` it was issued for.
197
+ */
198
+ cursor?: string;
199
+ }
119
200
 
120
201
  /**
121
- * Params for {@link MobileClient.claimUsername}.
202
+ * Params for {@link MobileClient.getSelfIdentity}.
122
203
  */
123
- export interface MobileClaimUsernameParams extends MobileSignedRequestParams {
124
- displayName: string;
125
- }
204
+ export type GetMobileSelfIdentityParams = MobileSignedRequestParams;
126
205
 
127
206
  /**
128
- * Params for {@link MobileClient.updateUsername}.
207
+ * Params for {@link MobileClient.setUsername}.
129
208
  */
130
- export interface MobileUpdateUsernameParams extends MobileSignedRequestParams {
209
+ export interface MobileSetUsernameParams extends MobileSignedRequestParams {
210
+ /** User-facing name to claim, preserving casing. Must match `MOBILE_DISPLAY_NAME_PATTERN`. */
131
211
  displayName: string;
132
212
  }
133
213
 
@@ -160,21 +240,19 @@ export interface MobileRegisterExpoTokenParams extends MobileSignedRequestParams
160
240
  /**
161
241
  * Params for {@link MobileClient.unregisterExpoToken}.
162
242
  */
163
- export interface MobileUnregisterExpoTokenParams extends MobileSignedRequestParams {
164
- expoToken: string;
165
- }
243
+ export type MobileUnregisterExpoTokenParams = MobileWithExpoTokenParams;
166
244
 
167
245
  /**
168
246
  * Params for {@link MobileClient.updateNotificationPreferences}.
169
247
  */
170
- export interface MobileUpdateNotificationPreferencesParams extends MobileSignedRequestParams {
248
+ export interface MobileUpdateNotificationPreferencesParams extends MobileWithExpoTokenParams {
171
249
  preferences: MobileNotificationPreferences;
172
250
  }
173
251
 
174
252
  /**
175
253
  * Params for {@link MobileClient.getNotificationPreferences}.
176
254
  */
177
- export type GetMobileNotificationPreferencesParams = MobileSignedRequestParams;
255
+ export type GetMobileNotificationPreferencesParams = MobileWithExpoTokenParams;
178
256
 
179
257
  /**
180
258
  * Params for {@link MobileClient.getRegisteredDevices}.
@@ -5,3 +5,4 @@ export * from './serverBaseTypes';
5
5
  export * from './serverExecuteTypes';
6
6
  export * from './serverModelTypes';
7
7
  export * from './serverQueryTypes';
8
+ export * from './serverRequestTypes';
@@ -1,22 +1,25 @@
1
1
  import { NADO_ERROR_CODES } from '@nadohq/shared';
2
2
 
3
3
  /**
4
- * Numeric error codes returned by the mobile service API. Identity codes (61xx) and notification codes
5
- * (62xx) are mobile-specific; the remaining codes are shared cross-service codes from the backend's common
6
- * error enum, inlined via spread from {@link NADO_ERROR_CODES}.
4
+ * Numeric error codes returned by the mobile service API. Identity codes (61xx), notification codes (62xx),
5
+ * and feed codes (63xx) are mobile-specific; the remaining codes are shared cross-service codes from the
6
+ * backend's common error enum, inlined via spread from {@link NADO_ERROR_CODES}.
7
7
  */
8
8
  export const MOBILE_ERROR_CODES = {
9
9
  ...NADO_ERROR_CODES,
10
10
  INVALID_DISPLAY_NAME: 6100,
11
11
  USERNAME_UNAVAILABLE: 6101,
12
- IDENTITY_ALREADY_CLAIMED: 6102,
13
- IDENTITY_REQUIRED: 6103,
14
12
  INVALID_IDENTITY_TARGET: 6104,
13
+ /** Another identity write for the subaccount committed with a later nonce. Re-read before retrying. */
15
14
  STALE_IDENTITY_UPDATE: 6105,
16
15
  PROFILE_NOT_FOUND: 6106,
17
16
  INVALID_EXPO_TOKEN: 6200,
18
17
  INVALID_DEVICE_METADATA: 6201,
19
18
  INVALID_PREFERENCES: 6202,
19
+ /** Feed `minimumNotional` or `limit` is outside its allowed domain. Fix the request; do not retry unchanged. */
20
+ INVALID_FEED_FILTER: 6300,
21
+ /** Feed cursor is malformed or bound to a different filter. Discard it and restart from the first page. */
22
+ INVALID_FEED_CURSOR: 6301,
20
23
  } as const;
21
24
 
22
25
  /**
@@ -1,35 +1,14 @@
1
- /**
2
- * Params for each unsigned `public_query`, keyed by request `type`.
3
- */
4
- export interface MobileServerPublicQueryParamsByType {
5
- username_availability: { display_name: string };
6
- profile: { username: string };
7
- }
8
-
9
- /**
10
- * Discriminant `type` values for unsigned `public_query` requests.
11
- */
12
- export type MobileServerPublicQueryType =
13
- keyof MobileServerPublicQueryParamsByType;
1
+ import { MobileServerRequestType } from './serverRequestTypes';
14
2
 
15
3
  /**
16
- * Wire `request_type` the backend echoes on failure envelopes, prefixed by route (`public_query_*`,
17
- * `query_*`, `execute_*`, e.g. `execute_claim_username`). Public-query types are enumerated; signed
18
- * query/execute names are kept as a `${prefix}_${string}` template to avoid duplicating the signed-type
19
- * tags declared in `signing.ts`.
4
+ * Base success envelope shared by every mobile service API route: just the `status` discriminant. Query
5
+ * routes intersect this with their payload (see {@link MobileServerPublicQuerySuccessResponse}), inlining the
6
+ * payload fields alongside `status` rather than nesting them under a `data` key like the engine does; execute
7
+ * routes return it as-is because they carry no payload.
20
8
  */
21
- export type MobileServerRequestType =
22
- | `public_query_${MobileServerPublicQueryType}`
23
- | `query_${string}`
24
- | `execute_${string}`;
25
-
26
- /**
27
- * Successful mobile service API envelope, discriminated on `status`. Payload fields are inlined alongside
28
- * `status` rather than nested under a `data` key, matching the mobile backend's wire format.
29
- */
30
- export type MobileServerSuccessResponse<TData extends object = object> = {
9
+ export interface MobileServerSuccessResponse {
31
10
  status: 'success';
32
- } & TData;
11
+ }
33
12
 
34
13
  /**
35
14
  * Failure envelope returned by any mobile service API route. A response missing this envelope shape
@@ -2,6 +2,23 @@ import {
2
2
  MobileServerFailureResponse,
3
3
  MobileServerSuccessResponse,
4
4
  } from './serverBaseTypes';
5
+ import {
6
+ MobileServerPublicExecuteRequestByType,
7
+ MobileServerPublicExecuteRequestType,
8
+ } from './serverRequestTypes';
9
+
10
+ /**
11
+ * Unsigned `public_execute` request body: a `type` discriminant flattened with its params, mirroring
12
+ * {@link MobileServerPublicQueryRequest}.
13
+ */
14
+ export type MobileServerPublicExecuteRequest<
15
+ T extends MobileServerPublicExecuteRequestType =
16
+ MobileServerPublicExecuteRequestType,
17
+ > = {
18
+ [K in MobileServerPublicExecuteRequestType]: {
19
+ type: K;
20
+ } & MobileServerPublicExecuteRequestByType[K];
21
+ }[T];
5
22
 
6
23
  /**
7
24
  * Discriminated `execute` result union. Mobile execute routes return no payload beyond the success
@@ -1,3 +1,4 @@
1
+ import { BalanceSide } from '@nadohq/shared';
1
2
  import { Hex } from 'viem';
2
3
 
3
4
  /**
@@ -17,24 +18,119 @@ export type MobileNotificationCategory =
17
18
  | 'announcement';
18
19
 
19
20
  /**
20
- * Server-side public profile shape (snake_case).
21
+ * Server-side public profile shape (snake_case). Name fields are `null` until the subaccount claims a
22
+ * username.
21
23
  */
22
24
  export interface MobileServerProfile {
23
25
  subaccount: Hex;
24
- username: string;
25
- display_name: string;
26
+ username: string | null;
27
+ display_name: string | null;
28
+ private_mode: boolean;
26
29
  }
27
30
 
28
31
  /**
29
- * Server-side identity shape (snake_case) returned by the signed `self_identity` query.
32
+ * Server-side identity shape (snake_case) returned by the signed `self_identity` query. Name fields are
33
+ * `null` until the subaccount claims a username.
30
34
  */
31
35
  export interface MobileServerIdentity {
32
36
  subaccount: Hex;
33
- username: string;
34
- display_name: string;
37
+ username: string | null;
38
+ display_name: string | null;
35
39
  private_mode: boolean;
36
40
  }
37
41
 
42
+ /**
43
+ * Direction of the position a feed trade resulted in — for `closed`, the direction that was closed. This is
44
+ * NOT the execution buy/sell side, which the feed does not expose. Aliases {@link BalanceSide} so the feed's
45
+ * direction values stay in lockstep with the rest of the SDK.
46
+ */
47
+ export type MobileFeedTradePositionDirection = BalanceSide;
48
+
49
+ /**
50
+ * Every {@link MobileFeedTradePositionDirection} the feed can report, for callers that need the values at
51
+ * runtime (validation, filters, UI enumeration).
52
+ */
53
+ export const MOBILE_FEED_TRADE_POSITION_DIRECTIONS = [
54
+ 'long',
55
+ 'short',
56
+ ] as const satisfies readonly MobileFeedTradePositionDirection[];
57
+
58
+ /**
59
+ * Every {@link MobileFeedTradePositionEffect} the feed can report, for callers that need the values at
60
+ * runtime (validation, filters, UI enumeration).
61
+ */
62
+ export const MOBILE_FEED_TRADE_POSITION_EFFECTS = [
63
+ 'opened',
64
+ 'increased',
65
+ 'reduced',
66
+ 'closed',
67
+ 'flipped',
68
+ ] as const;
69
+
70
+ /**
71
+ * How a feed trade changed the trader's position in the product.
72
+ */
73
+ export type MobileFeedTradePositionEffect =
74
+ (typeof MOBILE_FEED_TRADE_POSITION_EFFECTS)[number];
75
+
76
+ /**
77
+ * Position change of a feed trade. Both keys are single words, so the wire and client shapes are identical
78
+ * and this type is shared by {@link MobileServerFeedTrade} and the client-side `MobileFeedTrade`.
79
+ */
80
+ export interface MobileFeedTradePosition {
81
+ direction: MobileFeedTradePositionDirection;
82
+ effect: MobileFeedTradePositionEffect;
83
+ }
84
+
85
+ /**
86
+ * Every {@link MobileFeedMarginMode} the feed can report, for callers that need the values at runtime
87
+ * (validation, filters, UI enumeration).
88
+ */
89
+ export const MOBILE_FEED_MARGIN_MODES = ['cross', 'isolated'] as const;
90
+
91
+ /**
92
+ * Margin mode a feed trade was executed under. Shared by the wire and client margin shapes.
93
+ */
94
+ export type MobileFeedMarginMode = (typeof MOBILE_FEED_MARGIN_MODES)[number];
95
+
96
+ /**
97
+ * Server-side margin of a feed trade. Branch on `mode` — do not infer isolated state from leverage presence:
98
+ * `estimated_leverage` (a rounded whole-number estimate, not exact submitted leverage) is omitted on `cross`,
99
+ * and also omitted inside `isolated` when no estimate is available.
100
+ */
101
+ export interface MobileServerFeedMargin {
102
+ mode: MobileFeedMarginMode;
103
+ estimated_leverage?: number;
104
+ }
105
+
106
+ /**
107
+ * Server-side feed trade shape (snake_case): one row per order digest, enriched at read time with the
108
+ * trader's current identity. Amounts are display-oriented human-unit JSON numbers — do not use them for
109
+ * accounting, order construction, or exact threshold decisions.
110
+ */
111
+ export interface MobileServerFeedTrade {
112
+ /** Order digest this row is keyed by; the stable id clients use to reconcile live pagination. */
113
+ order_digest: Hex;
114
+ subaccount: Hex;
115
+ username: string | null;
116
+ display_name: string | null;
117
+ /** Reserved for a future avatar source; `null` until one is implemented. */
118
+ avatar_url: string | null;
119
+ product_id: number;
120
+ /** Executed quantity in human units. */
121
+ quantity: number;
122
+ /** Trade notional in whole-dollar human units. */
123
+ notional: number;
124
+ /** Average execution price in human units. */
125
+ average_price: number;
126
+ margin: MobileServerFeedMargin;
127
+ position: MobileFeedTradePosition;
128
+ /** Realized PnL of the trade in human units; can be negative. */
129
+ realized_pnl: number;
130
+ /** Fill time as JavaScript-safe integer Unix milliseconds. */
131
+ filled_at_ms: number;
132
+ }
133
+
38
134
  /**
39
135
  * Server-side scope limiting a notification category preference. Scopes are rejected by the backend for the
40
136
  * MVP (`scopes` must be empty) but are part of the wire format.
@@ -53,8 +149,8 @@ export interface MobileServerNotificationCategoryPreference {
53
149
  }
54
150
 
55
151
  /**
56
- * Server-side notification preferences shape (snake_case), used in both the `update_preferences` execute and
57
- * the `notification_preferences` query response.
152
+ * Server-side notification preferences shape (snake_case), used in both the `update_preferences` public
153
+ * execute and the `notification_preferences` public query response.
58
154
  */
59
155
  export interface MobileServerNotificationPreferences {
60
156
  /** Only `1` is accepted by the backend for the MVP. */
@@ -1,74 +1,119 @@
1
+ import { MobileServerSuccessResponse } from './serverBaseTypes';
1
2
  import {
2
- MobileServerPublicQueryParamsByType,
3
- MobileServerPublicQueryType,
4
- MobileServerSuccessResponse,
5
- } from './serverBaseTypes';
6
- import {
3
+ MobileServerFeedTrade,
7
4
  MobileServerIdentity,
8
5
  MobileServerNotificationPreferences,
9
6
  MobileServerProfile,
10
7
  MobileServerRegisteredDevice,
11
8
  } from './serverModelTypes';
9
+ import {
10
+ MobileServerPublicQueryRequestByType,
11
+ MobileServerPublicQueryRequestType,
12
+ MobileServerSignedQueryRequestType,
13
+ } from './serverRequestTypes';
12
14
 
13
15
  /**
14
16
  * Unsigned `public_query` request body: a `type` discriminant flattened with its params.
15
17
  */
16
18
  export type MobileServerPublicQueryRequest<
17
- T extends MobileServerPublicQueryType = MobileServerPublicQueryType,
19
+ T extends MobileServerPublicQueryRequestType =
20
+ MobileServerPublicQueryRequestType,
18
21
  > = {
19
- [K in MobileServerPublicQueryType]: {
22
+ [K in MobileServerPublicQueryRequestType]: {
20
23
  type: K;
21
- } & MobileServerPublicQueryParamsByType[K];
24
+ } & MobileServerPublicQueryRequestByType[K];
22
25
  }[T];
23
26
 
24
27
  /**
25
- * Request body for the `username_availability` public query.
28
+ * Payload of the `username_availability` public query success response.
26
29
  */
27
- export type MobileServerUsernameAvailabilityRequest =
28
- MobileServerPublicQueryRequest<'username_availability'>;
30
+ export interface MobileServerUsernameAvailabilityResponse {
31
+ username: string;
32
+ available: boolean;
33
+ }
29
34
 
30
35
  /**
31
- * Request body for the `profile` public query.
36
+ * Payload of the `profile` public query success response.
32
37
  */
33
- export type MobileServerProfileRequest =
34
- MobileServerPublicQueryRequest<'profile'>;
38
+ export interface MobileServerProfileResponse {
39
+ profile: MobileServerProfile;
40
+ }
35
41
 
36
42
  /**
37
- * Successful response for the `username_availability` public query.
43
+ * Payload of the `feed` public query success response.
38
44
  */
39
- export type MobileServerUsernameAvailabilityResponse =
40
- MobileServerSuccessResponse<{
41
- username: string;
42
- available: boolean;
43
- }>;
45
+ export interface MobileServerFeedResponse {
46
+ trades: MobileServerFeedTrade[];
47
+ /**
48
+ * `null` when there was no additional candidate at query time; a page may contain fewer than `limit` trades
49
+ * (or none) with a non-null cursor because invalid enrichment rows are omitted and pagination is live
50
+ * rather than snapshot.
51
+ */
52
+ next_cursor: string | null;
53
+ }
44
54
 
45
55
  /**
46
- * Successful response for the `profile` public query.
56
+ * Payload of the signed `self_identity` query success response. Every non-isolated subaccount has an implicit
57
+ * identity, so the backend returns one for any valid sender, with `null` name fields when no username has
58
+ * been claimed; `identity` stays nullable to match the backend's `Option`.
47
59
  */
48
- export type MobileServerProfileResponse = MobileServerSuccessResponse<{
49
- profile: MobileServerProfile;
50
- }>;
60
+ export interface MobileServerSelfIdentityResponse {
61
+ identity: MobileServerIdentity | null;
62
+ }
51
63
 
52
64
  /**
53
- * Successful response for the signed `self_identity` query. A `null` identity means the subaccount has not
54
- * claimed a username yet — this is normal data, not an error.
65
+ * Payload of the `notification_preferences` public query success response.
55
66
  */
56
- export type MobileServerSelfIdentityResponse = MobileServerSuccessResponse<{
57
- identity: MobileServerIdentity | null;
58
- }>;
67
+ export interface MobileServerNotificationPreferencesResponse {
68
+ preferences: MobileServerNotificationPreferences;
69
+ }
70
+
71
+ /**
72
+ * Payload of the signed `registered_devices` query success response.
73
+ */
74
+ export interface MobileServerRegisteredDevicesResponse {
75
+ devices: MobileServerRegisteredDevice[];
76
+ }
77
+
78
+ /**
79
+ * Success payloads for each unsigned `public_query`, keyed by request `type`. Counterpart to
80
+ * {@link MobileServerPublicQueryRequestByType} so a query's request params and response share one lookup,
81
+ * matching engine's `EngineServerQueryResponseByType`. Holds the unwrapped payload; the envelope is applied
82
+ * by {@link MobileServerPublicQuerySuccessResponse}.
83
+ */
84
+ export interface MobileServerPublicQueryResponseByType {
85
+ username_availability: MobileServerUsernameAvailabilityResponse;
86
+ profile: MobileServerProfileResponse;
87
+ feed: MobileServerFeedResponse;
88
+ notification_preferences: MobileServerNotificationPreferencesResponse;
89
+ }
90
+
91
+ /**
92
+ * Success payloads for each signed `query`, keyed by request `type`. Counterpart to
93
+ * {@link MobileServerSignedQueryRequestByType} so a signed query's request params and response share one
94
+ * lookup, matching the public route. Holds the unwrapped payload; the envelope is applied by
95
+ * {@link MobileServerSignedQuerySuccessResponse}.
96
+ */
97
+ export interface MobileServerSignedQueryResponseByType {
98
+ self_identity: MobileServerSelfIdentityResponse;
99
+ registered_devices: MobileServerRegisteredDevicesResponse;
100
+ }
59
101
 
60
102
  /**
61
- * Successful response for the signed `notification_preferences` query.
103
+ * Full success response for an unsigned `public_query`: the {@link MobileServerSuccessResponse} envelope with
104
+ * the query's payload inlined alongside `status`. Derived from {@link MobileServerPublicQueryResponseByType},
105
+ * mirroring engine's `EngineServerQuerySuccessResponse` (inlined here instead of nested under `data`).
62
106
  */
63
- export type MobileServerNotificationPreferencesResponse =
64
- MobileServerSuccessResponse<{
65
- preferences: MobileServerNotificationPreferences;
66
- }>;
107
+ export type MobileServerPublicQuerySuccessResponse<
108
+ T extends MobileServerPublicQueryRequestType =
109
+ MobileServerPublicQueryRequestType,
110
+ > = MobileServerSuccessResponse & MobileServerPublicQueryResponseByType[T];
67
111
 
68
112
  /**
69
- * Successful response for the signed `registered_devices` query.
113
+ * Full success response for a signed `query`: the {@link MobileServerSuccessResponse} envelope with the
114
+ * query's payload inlined alongside `status`. Derived from {@link MobileServerSignedQueryResponseByType}.
70
115
  */
71
- export type MobileServerRegisteredDevicesResponse =
72
- MobileServerSuccessResponse<{
73
- devices: MobileServerRegisteredDevice[];
74
- }>;
116
+ export type MobileServerSignedQuerySuccessResponse<
117
+ T extends MobileServerSignedQueryRequestType =
118
+ MobileServerSignedQueryRequestType,
119
+ > = MobileServerSuccessResponse & MobileServerSignedQueryResponseByType[T];