@nadohq/mobile-client 0.33.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -11
- package/dist/{MobileClient-SQ7byUxo.cjs → MobileClient-D5TNTnLx.cjs} +3 -21
- package/dist/MobileClient-D5TNTnLx.cjs.map +1 -0
- package/dist/MobileClient.cjs +1 -1
- package/dist/MobileClient.d.cts +10 -16
- package/dist/MobileClient.d.cts.map +1 -1
- package/dist/MobileClient.d.ts +10 -16
- package/dist/MobileClient.d.ts.map +1 -1
- package/dist/MobileClient.js +4 -22
- package/dist/MobileClient.js.map +1 -1
- package/dist/{MobileServerFailureError-N3nGgdmg.d.cts → MobileServerFailureError-CPFjwUBx.d.cts} +3 -3
- package/dist/{MobileServerFailureError-N3nGgdmg.d.cts.map → MobileServerFailureError-CPFjwUBx.d.cts.map} +1 -1
- package/dist/{MobileServerFailureError-A2EcYe6Y.d.ts → MobileServerFailureError-Terv2Wzy.d.ts} +3 -3
- package/dist/{MobileServerFailureError-A2EcYe6Y.d.ts.map → MobileServerFailureError-Terv2Wzy.d.ts.map} +1 -1
- package/dist/{buildSignedMobileRequest-B8iVGxQc.d.ts → buildSignedMobileRequest-BScnCGPF.d.ts} +2 -2
- package/dist/{buildSignedMobileRequest-B8iVGxQc.d.ts.map → buildSignedMobileRequest-BScnCGPF.d.ts.map} +1 -1
- package/dist/{buildSignedMobileRequest-CtRX4zl4.d.cts → buildSignedMobileRequest-CXfnhc-4.d.cts} +2 -2
- package/dist/{buildSignedMobileRequest-CtRX4zl4.d.cts.map → buildSignedMobileRequest-CXfnhc-4.d.cts.map} +1 -1
- package/dist/{canonicalize-Cz1rz_ER.d.ts → canonicalize-CQ-pMYIt.d.ts} +2 -2
- package/dist/canonicalize-CQ-pMYIt.d.ts.map +1 -0
- package/dist/{canonicalize-afPLlUjE.d.cts → canonicalize-hzhboB-C.d.cts} +2 -2
- package/dist/canonicalize-hzhboB-C.d.cts.map +1 -0
- package/dist/{clientTypes-DqDZEcBu.d.ts → clientTypes-BwakovWk.d.cts} +3 -30
- package/dist/clientTypes-BwakovWk.d.cts.map +1 -0
- package/dist/{clientTypes-DIipTg9D.d.cts → clientTypes-D-o1_2Yc.d.ts} +3 -30
- package/dist/clientTypes-D-o1_2Yc.d.ts.map +1 -0
- package/dist/dataMappers.cjs +0 -12
- package/dist/dataMappers.cjs.map +1 -1
- package/dist/dataMappers.d.cts +4 -8
- package/dist/dataMappers.d.cts.map +1 -1
- package/dist/dataMappers.d.ts +4 -8
- package/dist/dataMappers.d.ts.map +1 -1
- package/dist/dataMappers.js +1 -12
- package/dist/dataMappers.js.map +1 -1
- package/dist/{eip712MethodByType-CUAcWwX0.d.cts → eip712MethodByType-3aiJkrHj.d.cts} +2 -2
- package/dist/eip712MethodByType-3aiJkrHj.d.cts.map +1 -0
- package/dist/{eip712MethodByType-BzfeoDTF.d.ts → eip712MethodByType-zNvZukU7.d.ts} +2 -2
- package/dist/eip712MethodByType-zNvZukU7.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +14 -14
- package/dist/index.d.ts +14 -14
- package/dist/{payloadHash-yIWBW4Iq.d.ts → payloadHash-BxL26uwq.d.ts} +2 -2
- package/dist/payloadHash-BxL26uwq.d.ts.map +1 -0
- package/dist/{payloadHash-CgKXMvZU.d.cts → payloadHash-DVkEt-Rg.d.cts} +2 -2
- package/dist/payloadHash-DVkEt-Rg.d.cts.map +1 -0
- package/dist/{serverBaseTypes-ClQZqTAK.d.ts → serverBaseTypes-B_KHFDab.d.ts} +2 -2
- package/dist/{serverBaseTypes-ClQZqTAK.d.ts.map → serverBaseTypes-B_KHFDab.d.ts.map} +1 -1
- package/dist/{serverBaseTypes-_a1pE464.d.cts → serverBaseTypes-C8KjE9Fm.d.cts} +2 -2
- package/dist/{serverBaseTypes-_a1pE464.d.cts.map → serverBaseTypes-C8KjE9Fm.d.cts.map} +1 -1
- package/dist/{serverExecuteTypes-CUla9jFj.d.cts → serverExecuteTypes-Cb5v7y0A.d.cts} +3 -3
- package/dist/{serverExecuteTypes-CUla9jFj.d.cts.map → serverExecuteTypes-Cb5v7y0A.d.cts.map} +1 -1
- package/dist/{serverExecuteTypes-BD8Awy8Q.d.ts → serverExecuteTypes-GFjZj_DC.d.ts} +3 -3
- package/dist/{serverExecuteTypes-BD8Awy8Q.d.ts.map → serverExecuteTypes-GFjZj_DC.d.ts.map} +1 -1
- package/dist/{serverModelTypes-BIGPd52y.d.ts → serverModelTypes-CwgibK-l.d.cts} +2 -12
- package/dist/serverModelTypes-CwgibK-l.d.cts.map +1 -0
- package/dist/{serverModelTypes-DGYc_3XP.d.cts → serverModelTypes-_cX99seo.d.ts} +2 -12
- package/dist/serverModelTypes-_cX99seo.d.ts.map +1 -0
- package/dist/{serverQueryTypes-4J8qNQld.d.ts → serverQueryTypes-DwE1iJ9f.d.cts} +5 -27
- package/dist/serverQueryTypes-DwE1iJ9f.d.cts.map +1 -0
- package/dist/{serverQueryTypes-C_rvZnol.d.cts → serverQueryTypes-NIrPm2Sl.d.ts} +5 -27
- package/dist/serverQueryTypes-NIrPm2Sl.d.ts.map +1 -0
- package/dist/{serverRequestTypes-w1r41ff7.d.ts → serverRequestTypes-516zXnQ6.d.ts} +9 -24
- package/dist/{serverRequestTypes-w1r41ff7.d.ts.map → serverRequestTypes-516zXnQ6.d.ts.map} +1 -1
- package/dist/{serverRequestTypes-Cw661qjM.d.cts → serverRequestTypes-GAtVYIda.d.cts} +9 -24
- package/dist/{serverRequestTypes-Cw661qjM.d.cts.map → serverRequestTypes-GAtVYIda.d.cts.map} +1 -1
- package/dist/{serverResponseGuards-DNJZw8yq.d.ts → serverResponseGuards-Cep5s7j5.d.ts} +2 -2
- package/dist/{serverResponseGuards-DNJZw8yq.d.ts.map → serverResponseGuards-Cep5s7j5.d.ts.map} +1 -1
- package/dist/{serverResponseGuards-DEyNjgwq.d.cts → serverResponseGuards-Dxt9_aGh.d.cts} +2 -2
- package/dist/{serverResponseGuards-DEyNjgwq.d.cts.map → serverResponseGuards-Dxt9_aGh.d.cts.map} +1 -1
- package/dist/signing/buildSignedMobileRequest.cjs +1 -1
- package/dist/signing/buildSignedMobileRequest.d.cts +1 -1
- package/dist/signing/buildSignedMobileRequest.d.ts +1 -1
- package/dist/signing/canonicalize.cjs +0 -1
- package/dist/signing/canonicalize.cjs.map +1 -1
- package/dist/signing/canonicalize.d.cts +1 -1
- package/dist/signing/canonicalize.d.ts +1 -1
- package/dist/signing/canonicalize.js +0 -1
- package/dist/signing/canonicalize.js.map +1 -1
- package/dist/signing/eip712MethodByType.cjs +0 -1
- package/dist/signing/eip712MethodByType.cjs.map +1 -1
- package/dist/signing/eip712MethodByType.d.cts +1 -1
- package/dist/signing/eip712MethodByType.d.ts +1 -1
- package/dist/signing/eip712MethodByType.js +0 -1
- package/dist/signing/eip712MethodByType.js.map +1 -1
- package/dist/signing/index.d.cts +5 -5
- package/dist/signing/index.d.ts +5 -5
- package/dist/signing/payloadHash.cjs +1 -1
- package/dist/signing/payloadHash.d.cts +1 -1
- package/dist/signing/payloadHash.d.ts +1 -1
- package/dist/signing/types.d.cts +1 -1
- package/dist/signing/types.d.ts +1 -1
- package/dist/types/MobileServerFailureError.cjs +1 -1
- package/dist/types/MobileServerFailureError.d.cts +1 -1
- package/dist/types/MobileServerFailureError.d.ts +1 -1
- package/dist/types/clientTypes.d.cts +2 -2
- package/dist/types/clientTypes.d.ts +2 -2
- package/dist/types/index.d.cts +8 -8
- package/dist/types/index.d.ts +8 -8
- package/dist/types/mobileErrorCodes.cjs +1 -1
- package/dist/types/serverBaseTypes.d.cts +1 -1
- package/dist/types/serverBaseTypes.d.ts +1 -1
- package/dist/types/serverExecuteTypes.d.cts +1 -1
- package/dist/types/serverExecuteTypes.d.ts +1 -1
- package/dist/types/serverModelTypes.cjs.map +1 -1
- package/dist/types/serverModelTypes.d.cts +2 -2
- package/dist/types/serverModelTypes.d.ts +2 -2
- package/dist/types/serverModelTypes.js.map +1 -1
- package/dist/types/serverQueryTypes.d.cts +2 -2
- package/dist/types/serverQueryTypes.d.ts +2 -2
- package/dist/types/serverRequestTypes.d.cts +2 -2
- package/dist/types/serverRequestTypes.d.ts +2 -2
- package/dist/{types-DNd9S0Rz.d.ts → types-47IPsDyA.d.cts} +3 -5
- package/dist/types-47IPsDyA.d.cts.map +1 -0
- package/dist/{types-BycRkqAj.d.cts → types-D5kFJzEX.d.ts} +3 -5
- package/dist/types-D5kFJzEX.d.ts.map +1 -0
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/serverResponseGuards.d.cts +1 -1
- package/dist/utils/serverResponseGuards.d.ts +1 -1
- package/package.json +3 -3
- package/src/MobileClient.ts +7 -45
- package/src/dataMappers.ts +0 -16
- package/src/signing/canonicalize.ts +0 -2
- package/src/signing/eip712MethodByType.ts +0 -1
- package/src/signing/signing.test.ts +0 -8
- package/src/signing/types.ts +0 -1
- package/src/types/clientTypes.ts +0 -29
- package/src/types/serverModelTypes.ts +0 -11
- package/src/types/serverQueryTypes.ts +0 -30
- package/src/types/serverRequestTypes.ts +4 -26
- package/dist/MobileClient-SQ7byUxo.cjs.map +0 -1
- package/dist/canonicalize-Cz1rz_ER.d.ts.map +0 -1
- package/dist/canonicalize-afPLlUjE.d.cts.map +0 -1
- package/dist/clientTypes-DIipTg9D.d.cts.map +0 -1
- package/dist/clientTypes-DqDZEcBu.d.ts.map +0 -1
- package/dist/eip712MethodByType-BzfeoDTF.d.ts.map +0 -1
- package/dist/eip712MethodByType-CUAcWwX0.d.cts.map +0 -1
- package/dist/payloadHash-CgKXMvZU.d.cts.map +0 -1
- package/dist/payloadHash-yIWBW4Iq.d.ts.map +0 -1
- package/dist/serverModelTypes-BIGPd52y.d.ts.map +0 -1
- package/dist/serverModelTypes-DGYc_3XP.d.cts.map +0 -1
- package/dist/serverQueryTypes-4J8qNQld.d.ts.map +0 -1
- package/dist/serverQueryTypes-C_rvZnol.d.cts.map +0 -1
- package/dist/types-BycRkqAj.d.cts.map +0 -1
- package/dist/types-DNd9S0Rz.d.ts.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as MobileServerPublicExecuteRequest, t as MobileServerExecuteResult } from "../serverExecuteTypes-
|
|
1
|
+
import { n as MobileServerPublicExecuteRequest, t as MobileServerExecuteResult } from "../serverExecuteTypes-GFjZj_DC.js";
|
|
2
2
|
export { MobileServerExecuteResult, MobileServerPublicExecuteRequest };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverModelTypes.cjs","names":[],"sources":["../../src/types/serverModelTypes.ts"],"sourcesContent":["import { BalanceSide } from '@nadohq/shared';\nimport { Hex } from 'viem';\n\n/**\n * Platform of a device registered for push notifications.\n */\nexport type MobileNotificationPlatform = 'ios' | 'android';\n\n/**\n * Category of push notification.\n */\nexport type MobileNotificationCategory =\n | 'order_fill'\n | 'order_update'\n | 'liquidation'\n | 'funding'\n | 'product_listing'\n | 'announcement';\n\n/**\n * Server-side public profile shape (snake_case). Name fields are `null` until the subaccount claims a\n * username.\n */\nexport interface MobileServerProfile {\n subaccount: Hex;\n username: string | null;\n display_name: string | null;\n private_mode: boolean;\n}\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"serverModelTypes.cjs","names":[],"sources":["../../src/types/serverModelTypes.ts"],"sourcesContent":["import { BalanceSide } from '@nadohq/shared';\nimport { Hex } from 'viem';\n\n/**\n * Platform of a device registered for push notifications.\n */\nexport type MobileNotificationPlatform = 'ios' | 'android';\n\n/**\n * Category of push notification.\n */\nexport type MobileNotificationCategory =\n | 'order_fill'\n | 'order_update'\n | 'liquidation'\n | 'funding'\n | 'product_listing'\n | 'announcement';\n\n/**\n * Server-side public profile shape (snake_case). Name fields are `null` until the subaccount claims a\n * username.\n */\nexport interface MobileServerProfile {\n subaccount: Hex;\n username: string | null;\n display_name: string | null;\n private_mode: boolean;\n}\n\n/**\n * Direction of the position a feed trade resulted in — for `closed`, the direction that was closed. This is\n * NOT the execution buy/sell side, which the feed does not expose. Aliases {@link BalanceSide} so the feed's\n * direction values stay in lockstep with the rest of the SDK.\n */\nexport type MobileFeedTradePositionDirection = BalanceSide;\n\n/**\n * Every {@link MobileFeedTradePositionDirection} the feed can report, for callers that need the values at\n * runtime (validation, filters, UI enumeration).\n */\nexport const MOBILE_FEED_TRADE_POSITION_DIRECTIONS = [\n 'long',\n 'short',\n] as const satisfies readonly MobileFeedTradePositionDirection[];\n\n/**\n * Every {@link MobileFeedTradePositionEffect} the feed can report, for callers that need the values at\n * runtime (validation, filters, UI enumeration).\n */\nexport const MOBILE_FEED_TRADE_POSITION_EFFECTS = [\n 'opened',\n 'increased',\n 'reduced',\n 'closed',\n 'flipped',\n] as const;\n\n/**\n * How a feed trade changed the trader's position in the product.\n */\nexport type MobileFeedTradePositionEffect =\n (typeof MOBILE_FEED_TRADE_POSITION_EFFECTS)[number];\n\n/**\n * Position change of a feed trade. Both keys are single words, so the wire and client shapes are identical\n * and this type is shared by {@link MobileServerFeedTrade} and the client-side `MobileFeedTrade`.\n */\nexport interface MobileFeedTradePosition {\n direction: MobileFeedTradePositionDirection;\n effect: MobileFeedTradePositionEffect;\n}\n\n/**\n * Every {@link MobileFeedMarginMode} the feed can report, for callers that need the values at runtime\n * (validation, filters, UI enumeration).\n */\nexport const MOBILE_FEED_MARGIN_MODES = ['cross', 'isolated'] as const;\n\n/**\n * Margin mode a feed trade was executed under. Shared by the wire and client margin shapes.\n */\nexport type MobileFeedMarginMode = (typeof MOBILE_FEED_MARGIN_MODES)[number];\n\n/**\n * Server-side margin of a feed trade. Branch on `mode` — do not infer isolated state from leverage presence:\n * `estimated_leverage` (a rounded whole-number estimate, not exact submitted leverage) is omitted on `cross`,\n * and also omitted inside `isolated` when no estimate is available.\n */\nexport interface MobileServerFeedMargin {\n mode: MobileFeedMarginMode;\n estimated_leverage?: number;\n}\n\n/**\n * Server-side feed trade shape (snake_case): one row per order digest, enriched at read time with the\n * trader's current identity. Amounts are display-oriented human-unit JSON numbers — do not use them for\n * accounting, order construction, or exact threshold decisions.\n */\nexport interface MobileServerFeedTrade {\n /** Order digest this row is keyed by; the stable id clients use to reconcile live pagination. */\n order_digest: Hex;\n subaccount: Hex;\n username: string | null;\n display_name: string | null;\n /** Reserved for a future avatar source; `null` until one is implemented. */\n avatar_url: string | null;\n product_id: number;\n /** Executed quantity in human units. */\n quantity: number;\n /** Trade notional in whole-dollar human units. */\n notional: number;\n /** Average execution price in human units. */\n average_price: number;\n margin: MobileServerFeedMargin;\n position: MobileFeedTradePosition;\n /** Realized PnL of the trade in human units; can be negative. */\n realized_pnl: number;\n /** Fill time as JavaScript-safe integer Unix milliseconds. */\n filled_at_ms: number;\n}\n\n/**\n * Server-side scope limiting a notification category preference. Scopes are rejected by the backend for the\n * MVP (`scopes` must be empty) but are part of the wire format.\n */\nexport type MobileServerNotificationPreferenceScope =\n | { type: 'subaccount'; subaccount: Hex }\n | { type: 'product'; product_id: number };\n\n/**\n * Server-side per-category notification preference (snake_case).\n */\nexport interface MobileServerNotificationCategoryPreference {\n category: MobileNotificationCategory;\n enabled: boolean;\n scopes: MobileServerNotificationPreferenceScope[];\n}\n\n/**\n * Server-side notification preferences shape (snake_case), used in both the `update_preferences` public\n * execute and the `notification_preferences` public query response.\n */\nexport interface MobileServerNotificationPreferences {\n /** Only `1` is accepted by the backend for the MVP. */\n schema_version: 1;\n categories: MobileServerNotificationCategoryPreference[];\n}\n"],"mappings":";;;;;;AAyCA,MAAa,wCAAwC,CACnD,QACA,OACF;;;;;AAMA,MAAa,qCAAqC;CAChD;CACA;CACA;CACA;CACA;AACF;;;;;AAqBA,MAAa,2BAA2B,CAAC,SAAS,UAAU"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MobileFeedTradePosition, c as MobileNotificationCategory, d as MobileServerFeedTrade, f as
|
|
2
|
-
export { MOBILE_FEED_MARGIN_MODES, MOBILE_FEED_TRADE_POSITION_DIRECTIONS, MOBILE_FEED_TRADE_POSITION_EFFECTS, MobileFeedMarginMode, MobileFeedTradePosition, MobileFeedTradePositionDirection, MobileFeedTradePositionEffect, MobileNotificationCategory, MobileNotificationPlatform, MobileServerFeedMargin, MobileServerFeedTrade,
|
|
1
|
+
import { a as MobileFeedTradePosition, c as MobileNotificationCategory, d as MobileServerFeedTrade, f as MobileServerNotificationCategoryPreference, h as MobileServerProfile, i as MobileFeedMarginMode, l as MobileNotificationPlatform, m as MobileServerNotificationPreferences, n as MOBILE_FEED_TRADE_POSITION_DIRECTIONS, o as MobileFeedTradePositionDirection, p as MobileServerNotificationPreferenceScope, r as MOBILE_FEED_TRADE_POSITION_EFFECTS, s as MobileFeedTradePositionEffect, t as MOBILE_FEED_MARGIN_MODES, u as MobileServerFeedMargin } from "../serverModelTypes-CwgibK-l.cjs";
|
|
2
|
+
export { MOBILE_FEED_MARGIN_MODES, MOBILE_FEED_TRADE_POSITION_DIRECTIONS, MOBILE_FEED_TRADE_POSITION_EFFECTS, MobileFeedMarginMode, MobileFeedTradePosition, MobileFeedTradePositionDirection, MobileFeedTradePositionEffect, MobileNotificationCategory, MobileNotificationPlatform, MobileServerFeedMargin, MobileServerFeedTrade, MobileServerNotificationCategoryPreference, MobileServerNotificationPreferenceScope, MobileServerNotificationPreferences, MobileServerProfile };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MobileFeedTradePosition, c as MobileNotificationCategory, d as MobileServerFeedTrade, f as
|
|
2
|
-
export { MOBILE_FEED_MARGIN_MODES, MOBILE_FEED_TRADE_POSITION_DIRECTIONS, MOBILE_FEED_TRADE_POSITION_EFFECTS, MobileFeedMarginMode, MobileFeedTradePosition, MobileFeedTradePositionDirection, MobileFeedTradePositionEffect, MobileNotificationCategory, MobileNotificationPlatform, MobileServerFeedMargin, MobileServerFeedTrade,
|
|
1
|
+
import { a as MobileFeedTradePosition, c as MobileNotificationCategory, d as MobileServerFeedTrade, f as MobileServerNotificationCategoryPreference, h as MobileServerProfile, i as MobileFeedMarginMode, l as MobileNotificationPlatform, m as MobileServerNotificationPreferences, n as MOBILE_FEED_TRADE_POSITION_DIRECTIONS, o as MobileFeedTradePositionDirection, p as MobileServerNotificationPreferenceScope, r as MOBILE_FEED_TRADE_POSITION_EFFECTS, s as MobileFeedTradePositionEffect, t as MOBILE_FEED_MARGIN_MODES, u as MobileServerFeedMargin } from "../serverModelTypes-_cX99seo.js";
|
|
2
|
+
export { MOBILE_FEED_MARGIN_MODES, MOBILE_FEED_TRADE_POSITION_DIRECTIONS, MOBILE_FEED_TRADE_POSITION_EFFECTS, MobileFeedMarginMode, MobileFeedTradePosition, MobileFeedTradePositionDirection, MobileFeedTradePositionEffect, MobileNotificationCategory, MobileNotificationPlatform, MobileServerFeedMargin, MobileServerFeedTrade, MobileServerNotificationCategoryPreference, MobileServerNotificationPreferenceScope, MobileServerNotificationPreferences, MobileServerProfile };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverModelTypes.js","names":[],"sources":["../../src/types/serverModelTypes.ts"],"sourcesContent":["import { BalanceSide } from '@nadohq/shared';\nimport { Hex } from 'viem';\n\n/**\n * Platform of a device registered for push notifications.\n */\nexport type MobileNotificationPlatform = 'ios' | 'android';\n\n/**\n * Category of push notification.\n */\nexport type MobileNotificationCategory =\n | 'order_fill'\n | 'order_update'\n | 'liquidation'\n | 'funding'\n | 'product_listing'\n | 'announcement';\n\n/**\n * Server-side public profile shape (snake_case). Name fields are `null` until the subaccount claims a\n * username.\n */\nexport interface MobileServerProfile {\n subaccount: Hex;\n username: string | null;\n display_name: string | null;\n private_mode: boolean;\n}\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"serverModelTypes.js","names":[],"sources":["../../src/types/serverModelTypes.ts"],"sourcesContent":["import { BalanceSide } from '@nadohq/shared';\nimport { Hex } from 'viem';\n\n/**\n * Platform of a device registered for push notifications.\n */\nexport type MobileNotificationPlatform = 'ios' | 'android';\n\n/**\n * Category of push notification.\n */\nexport type MobileNotificationCategory =\n | 'order_fill'\n | 'order_update'\n | 'liquidation'\n | 'funding'\n | 'product_listing'\n | 'announcement';\n\n/**\n * Server-side public profile shape (snake_case). Name fields are `null` until the subaccount claims a\n * username.\n */\nexport interface MobileServerProfile {\n subaccount: Hex;\n username: string | null;\n display_name: string | null;\n private_mode: boolean;\n}\n\n/**\n * Direction of the position a feed trade resulted in — for `closed`, the direction that was closed. This is\n * NOT the execution buy/sell side, which the feed does not expose. Aliases {@link BalanceSide} so the feed's\n * direction values stay in lockstep with the rest of the SDK.\n */\nexport type MobileFeedTradePositionDirection = BalanceSide;\n\n/**\n * Every {@link MobileFeedTradePositionDirection} the feed can report, for callers that need the values at\n * runtime (validation, filters, UI enumeration).\n */\nexport const MOBILE_FEED_TRADE_POSITION_DIRECTIONS = [\n 'long',\n 'short',\n] as const satisfies readonly MobileFeedTradePositionDirection[];\n\n/**\n * Every {@link MobileFeedTradePositionEffect} the feed can report, for callers that need the values at\n * runtime (validation, filters, UI enumeration).\n */\nexport const MOBILE_FEED_TRADE_POSITION_EFFECTS = [\n 'opened',\n 'increased',\n 'reduced',\n 'closed',\n 'flipped',\n] as const;\n\n/**\n * How a feed trade changed the trader's position in the product.\n */\nexport type MobileFeedTradePositionEffect =\n (typeof MOBILE_FEED_TRADE_POSITION_EFFECTS)[number];\n\n/**\n * Position change of a feed trade. Both keys are single words, so the wire and client shapes are identical\n * and this type is shared by {@link MobileServerFeedTrade} and the client-side `MobileFeedTrade`.\n */\nexport interface MobileFeedTradePosition {\n direction: MobileFeedTradePositionDirection;\n effect: MobileFeedTradePositionEffect;\n}\n\n/**\n * Every {@link MobileFeedMarginMode} the feed can report, for callers that need the values at runtime\n * (validation, filters, UI enumeration).\n */\nexport const MOBILE_FEED_MARGIN_MODES = ['cross', 'isolated'] as const;\n\n/**\n * Margin mode a feed trade was executed under. Shared by the wire and client margin shapes.\n */\nexport type MobileFeedMarginMode = (typeof MOBILE_FEED_MARGIN_MODES)[number];\n\n/**\n * Server-side margin of a feed trade. Branch on `mode` — do not infer isolated state from leverage presence:\n * `estimated_leverage` (a rounded whole-number estimate, not exact submitted leverage) is omitted on `cross`,\n * and also omitted inside `isolated` when no estimate is available.\n */\nexport interface MobileServerFeedMargin {\n mode: MobileFeedMarginMode;\n estimated_leverage?: number;\n}\n\n/**\n * Server-side feed trade shape (snake_case): one row per order digest, enriched at read time with the\n * trader's current identity. Amounts are display-oriented human-unit JSON numbers — do not use them for\n * accounting, order construction, or exact threshold decisions.\n */\nexport interface MobileServerFeedTrade {\n /** Order digest this row is keyed by; the stable id clients use to reconcile live pagination. */\n order_digest: Hex;\n subaccount: Hex;\n username: string | null;\n display_name: string | null;\n /** Reserved for a future avatar source; `null` until one is implemented. */\n avatar_url: string | null;\n product_id: number;\n /** Executed quantity in human units. */\n quantity: number;\n /** Trade notional in whole-dollar human units. */\n notional: number;\n /** Average execution price in human units. */\n average_price: number;\n margin: MobileServerFeedMargin;\n position: MobileFeedTradePosition;\n /** Realized PnL of the trade in human units; can be negative. */\n realized_pnl: number;\n /** Fill time as JavaScript-safe integer Unix milliseconds. */\n filled_at_ms: number;\n}\n\n/**\n * Server-side scope limiting a notification category preference. Scopes are rejected by the backend for the\n * MVP (`scopes` must be empty) but are part of the wire format.\n */\nexport type MobileServerNotificationPreferenceScope =\n | { type: 'subaccount'; subaccount: Hex }\n | { type: 'product'; product_id: number };\n\n/**\n * Server-side per-category notification preference (snake_case).\n */\nexport interface MobileServerNotificationCategoryPreference {\n category: MobileNotificationCategory;\n enabled: boolean;\n scopes: MobileServerNotificationPreferenceScope[];\n}\n\n/**\n * Server-side notification preferences shape (snake_case), used in both the `update_preferences` public\n * execute and the `notification_preferences` public query response.\n */\nexport interface MobileServerNotificationPreferences {\n /** Only `1` is accepted by the backend for the MVP. */\n schema_version: 1;\n categories: MobileServerNotificationCategoryPreference[];\n}\n"],"mappings":";;;;;AAyCA,MAAa,wCAAwC,CACnD,QACA,OACF;;;;;AAMA,MAAa,qCAAqC;CAChD;CACA;CACA;CACA;CACA;AACF;;;;;AAqBA,MAAa,2BAA2B,CAAC,SAAS,UAAU"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MobileServerPublicQueryResponseByType, c as
|
|
2
|
-
export { MobileServerFeedResponse, MobileServerNotificationPreferencesResponse, MobileServerProfileResponse, MobileServerPublicQueryRequest, MobileServerPublicQueryResponseByType, MobileServerPublicQuerySuccessResponse, MobileServerRegisteredWalletResponse,
|
|
1
|
+
import { a as MobileServerPublicQueryResponseByType, c as MobileServerUsernameAvailabilityResponse, i as MobileServerPublicQueryRequest, n as MobileServerNotificationPreferencesResponse, o as MobileServerPublicQuerySuccessResponse, r as MobileServerProfileResponse, s as MobileServerRegisteredWalletResponse, t as MobileServerFeedResponse } from "../serverQueryTypes-DwE1iJ9f.cjs";
|
|
2
|
+
export { MobileServerFeedResponse, MobileServerNotificationPreferencesResponse, MobileServerProfileResponse, MobileServerPublicQueryRequest, MobileServerPublicQueryResponseByType, MobileServerPublicQuerySuccessResponse, MobileServerRegisteredWalletResponse, MobileServerUsernameAvailabilityResponse };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MobileServerPublicQueryResponseByType, c as
|
|
2
|
-
export { MobileServerFeedResponse, MobileServerNotificationPreferencesResponse, MobileServerProfileResponse, MobileServerPublicQueryRequest, MobileServerPublicQueryResponseByType, MobileServerPublicQuerySuccessResponse, MobileServerRegisteredWalletResponse,
|
|
1
|
+
import { a as MobileServerPublicQueryResponseByType, c as MobileServerUsernameAvailabilityResponse, i as MobileServerPublicQueryRequest, n as MobileServerNotificationPreferencesResponse, o as MobileServerPublicQuerySuccessResponse, r as MobileServerProfileResponse, s as MobileServerRegisteredWalletResponse, t as MobileServerFeedResponse } from "../serverQueryTypes-NIrPm2Sl.js";
|
|
2
|
+
export { MobileServerFeedResponse, MobileServerNotificationPreferencesResponse, MobileServerProfileResponse, MobileServerPublicQueryRequest, MobileServerPublicQueryResponseByType, MobileServerPublicQuerySuccessResponse, MobileServerRegisteredWalletResponse, MobileServerUsernameAvailabilityResponse };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MobileServerPublicQueryRequestType,
|
|
2
|
-
export { MobileServerExecuteRequestType, MobileServerPublicExecuteRequestByType, MobileServerPublicExecuteRequestType, MobileServerPublicQueryRequestByType, MobileServerPublicQueryRequestType, MobileServerRequestType
|
|
1
|
+
import { a as MobileServerPublicQueryRequestType, i as MobileServerPublicQueryRequestByType, n as MobileServerPublicExecuteRequestByType, o as MobileServerRequestType, r as MobileServerPublicExecuteRequestType, t as MobileServerExecuteRequestType } from "../serverRequestTypes-GAtVYIda.cjs";
|
|
2
|
+
export { MobileServerExecuteRequestType, MobileServerPublicExecuteRequestByType, MobileServerPublicExecuteRequestType, MobileServerPublicQueryRequestByType, MobileServerPublicQueryRequestType, MobileServerRequestType };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MobileServerPublicQueryRequestType,
|
|
2
|
-
export { MobileServerExecuteRequestType, MobileServerPublicExecuteRequestByType, MobileServerPublicExecuteRequestType, MobileServerPublicQueryRequestByType, MobileServerPublicQueryRequestType, MobileServerRequestType
|
|
1
|
+
import { a as MobileServerPublicQueryRequestType, i as MobileServerPublicQueryRequestByType, n as MobileServerPublicExecuteRequestByType, o as MobileServerRequestType, r as MobileServerPublicExecuteRequestType, t as MobileServerExecuteRequestType } from "../serverRequestTypes-516zXnQ6.js";
|
|
2
|
+
export { MobileServerExecuteRequestType, MobileServerPublicExecuteRequestByType, MobileServerPublicExecuteRequestType, MobileServerPublicQueryRequestByType, MobileServerPublicQueryRequestType, MobileServerRequestType };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as MobileNotificationPlatform } from "./serverModelTypes-
|
|
2
|
-
import {
|
|
1
|
+
import { l as MobileNotificationPlatform } from "./serverModelTypes-CwgibK-l.cjs";
|
|
2
|
+
import { _ as MobileSignedRequestParams } from "./clientTypes-BwakovWk.cjs";
|
|
3
3
|
import { WalletClientWithAccount } from "@nadohq/shared";
|
|
4
4
|
import { Hex } from "viem";
|
|
5
5
|
|
|
@@ -19,8 +19,6 @@ type MobileSignedInner = {
|
|
|
19
19
|
} | {
|
|
20
20
|
type: 'set_private_mode';
|
|
21
21
|
private_mode: boolean;
|
|
22
|
-
} | {
|
|
23
|
-
type: 'self_identity';
|
|
24
22
|
} | {
|
|
25
23
|
type: 'register_expo_token';
|
|
26
24
|
expo_token: string;
|
|
@@ -57,4 +55,4 @@ interface BuildSignedMobileRequestParams extends MobileSignedRequestParams {
|
|
|
57
55
|
}
|
|
58
56
|
//#endregion
|
|
59
57
|
export { MobileSignedRequest as i, MobileSignedInner as n, MobileSignedInnerParams as r, BuildSignedMobileRequestParams as t };
|
|
60
|
-
//# sourceMappingURL=types-
|
|
58
|
+
//# sourceMappingURL=types-47IPsDyA.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-47IPsDyA.d.cts","names":[],"sources":["../src/signing/src/signing/types.ts"],"mappings":";;;;;;;;AAcA;;;;;;;KAAY,iBAAA;EACN,IAAA;EAAsB,YAAA;AAAA;EACtB,IAAA;EAA0B,YAAA;AAAA;EAE1B,IAAA;EACA,UAAA;EACA,QAAA,EAAU,0BAA0B;EAGpC,MAAA;EACA,WAAA;AAAA;;;;;KAOM,uBAAA,WAAkC,iBAAA,YAA6B,IAAA,CACzE,OAAA,CAAQ,iBAAA;EAAqB,IAAA,EAAM,CAAA;AAAA;;;;;KAQzB,mBAAA,WACA,iBAAA,GAAoB,iBAAA,IAC5B,CAAA;EACF,SAAA,EAAW,GAAA;EACX,MAAA,EAAQ,GAAA;EACR,KAAA;AAAA;;;;UAMe,8BAAA,SAAuC,yBAAA;EACtD,YAAA,EAAc,uBAAA;EACd,KAAA,EAAO,iBAAA;EATC;;;EAaR,KAAA;AAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as MobileNotificationPlatform } from "./serverModelTypes-
|
|
2
|
-
import {
|
|
1
|
+
import { l as MobileNotificationPlatform } from "./serverModelTypes-_cX99seo.js";
|
|
2
|
+
import { _ as MobileSignedRequestParams } from "./clientTypes-D-o1_2Yc.js";
|
|
3
3
|
import { WalletClientWithAccount } from "@nadohq/shared";
|
|
4
4
|
import { Hex } from "viem";
|
|
5
5
|
|
|
@@ -19,8 +19,6 @@ type MobileSignedInner = {
|
|
|
19
19
|
} | {
|
|
20
20
|
type: 'set_private_mode';
|
|
21
21
|
private_mode: boolean;
|
|
22
|
-
} | {
|
|
23
|
-
type: 'self_identity';
|
|
24
22
|
} | {
|
|
25
23
|
type: 'register_expo_token';
|
|
26
24
|
expo_token: string;
|
|
@@ -57,4 +55,4 @@ interface BuildSignedMobileRequestParams extends MobileSignedRequestParams {
|
|
|
57
55
|
}
|
|
58
56
|
//#endregion
|
|
59
57
|
export { MobileSignedRequest as i, MobileSignedInner as n, MobileSignedInnerParams as r, BuildSignedMobileRequestParams as t };
|
|
60
|
-
//# sourceMappingURL=types-
|
|
58
|
+
//# sourceMappingURL=types-D5kFJzEX.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-D5kFJzEX.d.ts","names":[],"sources":["../src/signing/src/signing/types.ts"],"mappings":";;;;;;;;AAcA;;;;;;;KAAY,iBAAA;EACN,IAAA;EAAsB,YAAA;AAAA;EACtB,IAAA;EAA0B,YAAA;AAAA;EAE1B,IAAA;EACA,UAAA;EACA,QAAA,EAAU,0BAA0B;EAGpC,MAAA;EACA,WAAA;AAAA;;;;;KAOM,uBAAA,WAAkC,iBAAA,YAA6B,IAAA,CACzE,OAAA,CAAQ,iBAAA;EAAqB,IAAA,EAAM,CAAA;AAAA;;;;;KAQzB,mBAAA,WACA,iBAAA,GAAoB,iBAAA,IAC5B,CAAA;EACF,SAAA,EAAW,GAAA;EACX,MAAA,EAAQ,GAAA;EACR,KAAA;AAAA;;;;UAMe,8BAAA,SAAuC,yBAAA;EACtD,YAAA,EAAc,uBAAA;EACd,KAAA,EAAO,iBAAA;EATC;;;EAaR,KAAA;AAAA"}
|
package/dist/utils/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { n as MOBILE_FEED_MIN_NOTIONAL_FLOOR, t as MOBILE_FEED_MAX_PAGE_SIZE } from "../feed-CBIwOhTO.cjs";
|
|
2
2
|
import { t as MOBILE_DISPLAY_NAME_PATTERN } from "../patterns-Db6fgz8i.cjs";
|
|
3
|
-
import { n as isMobileServerSuccessResponse, t as isMobileServerFailureResponse } from "../serverResponseGuards-
|
|
3
|
+
import { n as isMobileServerSuccessResponse, t as isMobileServerFailureResponse } from "../serverResponseGuards-Dxt9_aGh.cjs";
|
|
4
4
|
export { MOBILE_DISPLAY_NAME_PATTERN, MOBILE_FEED_MAX_PAGE_SIZE, MOBILE_FEED_MIN_NOTIONAL_FLOOR, isMobileServerFailureResponse, isMobileServerSuccessResponse };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { n as MOBILE_FEED_MIN_NOTIONAL_FLOOR, t as MOBILE_FEED_MAX_PAGE_SIZE } from "../feed-BF5k6Ryu.js";
|
|
2
2
|
import { t as MOBILE_DISPLAY_NAME_PATTERN } from "../patterns-B5gi7OfV.js";
|
|
3
|
-
import { n as isMobileServerSuccessResponse, t as isMobileServerFailureResponse } from "../serverResponseGuards-
|
|
3
|
+
import { n as isMobileServerSuccessResponse, t as isMobileServerFailureResponse } from "../serverResponseGuards-Cep5s7j5.js";
|
|
4
4
|
export { MOBILE_DISPLAY_NAME_PATTERN, MOBILE_FEED_MAX_PAGE_SIZE, MOBILE_FEED_MIN_NOTIONAL_FLOOR, isMobileServerFailureResponse, isMobileServerSuccessResponse };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as isMobileServerSuccessResponse, t as isMobileServerFailureResponse } from "../serverResponseGuards-
|
|
1
|
+
import { n as isMobileServerSuccessResponse, t as isMobileServerFailureResponse } from "../serverResponseGuards-Dxt9_aGh.cjs";
|
|
2
2
|
export { isMobileServerFailureResponse, isMobileServerSuccessResponse };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as isMobileServerSuccessResponse, t as isMobileServerFailureResponse } from "../serverResponseGuards-
|
|
1
|
+
import { n as isMobileServerSuccessResponse, t as isMobileServerFailureResponse } from "../serverResponseGuards-Cep5s7j5.js";
|
|
2
2
|
export { isMobileServerFailureResponse, isMobileServerSuccessResponse };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nadohq/mobile-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "HTTP client for the Nado mobile service API — username claims, profiles, privacy settings, and push notification devices & preferences",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"types": "./dist/index.d.ts",
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@msgpack/msgpack": "3.1.3",
|
|
45
|
-
"@nadohq/shared": "^0.
|
|
45
|
+
"@nadohq/shared": "^0.35.0",
|
|
46
46
|
"axios": "1.16.1"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"bignumber.js": "11.1.1",
|
|
55
55
|
"viem": "2.52.0"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "232349cb0f432b024dab1b1c623e8ad3b74b8f85"
|
|
58
58
|
}
|
package/src/MobileClient.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
getNadoClientTypeHeaders,
|
|
2
3
|
subaccountToHex,
|
|
3
4
|
WalletClientWithAccount,
|
|
4
5
|
WalletNotProvidedError,
|
|
@@ -6,7 +7,6 @@ import {
|
|
|
6
7
|
import axios, { AxiosInstance, AxiosResponse } from 'axios';
|
|
7
8
|
import {
|
|
8
9
|
mapMobileFeedPage,
|
|
9
|
-
mapMobileIdentity,
|
|
10
10
|
mapMobileNotificationPreferences,
|
|
11
11
|
mapMobileNotificationPreferencesToServer,
|
|
12
12
|
mapMobilePublicProfile,
|
|
@@ -23,10 +23,8 @@ import {
|
|
|
23
23
|
GetMobileNotificationPreferencesParams,
|
|
24
24
|
GetMobilePublicProfileParams,
|
|
25
25
|
GetMobileRegisteredWalletParams,
|
|
26
|
-
GetMobileSelfIdentityParams,
|
|
27
26
|
GetMobileUsernameAvailabilityParams,
|
|
28
27
|
MobileFeedPage,
|
|
29
|
-
MobileIdentity,
|
|
30
28
|
MobileNotificationPreferences,
|
|
31
29
|
MobilePublicProfile,
|
|
32
30
|
MobileRegisteredWallet,
|
|
@@ -47,12 +45,10 @@ import {
|
|
|
47
45
|
import {
|
|
48
46
|
MobileServerPublicQueryRequest,
|
|
49
47
|
MobileServerPublicQuerySuccessResponse,
|
|
50
|
-
MobileServerSignedQuerySuccessResponse,
|
|
51
48
|
} from './types/serverQueryTypes';
|
|
52
49
|
import {
|
|
53
50
|
MobileServerPublicQueryRequestByType,
|
|
54
51
|
MobileServerPublicQueryRequestType,
|
|
55
|
-
MobileServerSignedQueryRequestType,
|
|
56
52
|
} from './types/serverRequestTypes';
|
|
57
53
|
import {
|
|
58
54
|
isMobileServerFailureResponse,
|
|
@@ -75,6 +71,10 @@ export interface MobileClientOpts {
|
|
|
75
71
|
* If provided, this signer is used instead of `walletClient` for all signed requests.
|
|
76
72
|
*/
|
|
77
73
|
linkedSignerWalletClient?: WalletClientWithAccount;
|
|
74
|
+
/**
|
|
75
|
+
* If provided, identifies the calling client, sent as a header with every request.
|
|
76
|
+
*/
|
|
77
|
+
clientType?: string;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
@@ -91,6 +91,7 @@ export class MobileClient {
|
|
|
91
91
|
withCredentials: true,
|
|
92
92
|
// We have custom logic to validate response status and create an appropriate error
|
|
93
93
|
validateStatus: () => true,
|
|
94
|
+
headers: getNadoClientTypeHeaders(opts.clientType),
|
|
94
95
|
});
|
|
95
96
|
}
|
|
96
97
|
|
|
@@ -252,30 +253,6 @@ export class MobileClient {
|
|
|
252
253
|
return this.publicExecute(body);
|
|
253
254
|
}
|
|
254
255
|
|
|
255
|
-
/*
|
|
256
|
-
Signed queries
|
|
257
|
-
*/
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Fetches the caller's own identity for a subaccount. Every non-isolated subaccount has an implicit
|
|
261
|
-
* identity, so this resolves for any valid sender with `username` and `displayName` `null` until a username
|
|
262
|
-
* is claimed.
|
|
263
|
-
*
|
|
264
|
-
* @throws {MobileServerFailureError} With error code `INVALID_IDENTITY_TARGET` if the sender is in the
|
|
265
|
-
* engine-created isolated namespace, which cannot own an identity.
|
|
266
|
-
*/
|
|
267
|
-
async getSelfIdentity(
|
|
268
|
-
params: GetMobileSelfIdentityParams,
|
|
269
|
-
): Promise<MobileIdentity | null> {
|
|
270
|
-
const signedRequest = await this.getSignedRequest(
|
|
271
|
-
'self_identity',
|
|
272
|
-
params,
|
|
273
|
-
{},
|
|
274
|
-
);
|
|
275
|
-
const data = await this.query<'self_identity'>(signedRequest);
|
|
276
|
-
return data.identity ? mapMobileIdentity(data.identity) : null;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
256
|
/*
|
|
280
257
|
Signed executes
|
|
281
258
|
*/
|
|
@@ -354,7 +331,7 @@ export class MobileClient {
|
|
|
354
331
|
throw new WalletNotProvidedError();
|
|
355
332
|
}
|
|
356
333
|
|
|
357
|
-
const inner = { type, ...innerParams } as MobileSignedInner;
|
|
334
|
+
const inner = { type, ...innerParams } as unknown as MobileSignedInner;
|
|
358
335
|
return buildSignedMobileRequest({ ...params, walletClient, inner });
|
|
359
336
|
}
|
|
360
337
|
|
|
@@ -390,21 +367,6 @@ export class MobileClient {
|
|
|
390
367
|
return response.data as MobileServerSuccessResponse;
|
|
391
368
|
}
|
|
392
369
|
|
|
393
|
-
protected async query<T extends MobileServerSignedQueryRequestType>(
|
|
394
|
-
body: MobileSignedRequest,
|
|
395
|
-
): Promise<MobileServerSignedQuerySuccessResponse<T>> {
|
|
396
|
-
const response = await this.axiosInstance.post<unknown>(
|
|
397
|
-
`${this.opts.url}/mobile/query`,
|
|
398
|
-
body,
|
|
399
|
-
);
|
|
400
|
-
|
|
401
|
-
this.checkResponseStatus(response);
|
|
402
|
-
this.checkServerStatus(response);
|
|
403
|
-
|
|
404
|
-
// checkServerStatus throws on failure responses so the cast to the success response is acceptable here
|
|
405
|
-
return response.data as MobileServerSignedQuerySuccessResponse<T>;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
370
|
protected async execute(
|
|
409
371
|
body: MobileSignedRequest,
|
|
410
372
|
): Promise<MobileServerSuccessResponse> {
|
package/src/dataMappers.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MobileFeedPage,
|
|
3
3
|
MobileFeedTrade,
|
|
4
|
-
MobileIdentity,
|
|
5
4
|
MobileNotificationPreferenceScope,
|
|
6
5
|
MobileNotificationPreferences,
|
|
7
6
|
MobilePublicProfile,
|
|
@@ -9,7 +8,6 @@ import {
|
|
|
9
8
|
} from './types/clientTypes';
|
|
10
9
|
import {
|
|
11
10
|
MobileServerFeedTrade,
|
|
12
|
-
MobileServerIdentity,
|
|
13
11
|
MobileServerNotificationPreferenceScope,
|
|
14
12
|
MobileServerNotificationPreferences,
|
|
15
13
|
MobileServerProfile,
|
|
@@ -19,20 +17,6 @@ import {
|
|
|
19
17
|
MobileServerRegisteredWalletResponse,
|
|
20
18
|
} from './types/serverQueryTypes';
|
|
21
19
|
|
|
22
|
-
/**
|
|
23
|
-
* Maps a server-side identity (snake_case) to its client-side (camelCase) representation.
|
|
24
|
-
*/
|
|
25
|
-
export function mapMobileIdentity(
|
|
26
|
-
server: MobileServerIdentity,
|
|
27
|
-
): MobileIdentity {
|
|
28
|
-
return {
|
|
29
|
-
subaccount: server.subaccount,
|
|
30
|
-
username: server.username,
|
|
31
|
-
displayName: server.display_name,
|
|
32
|
-
privateMode: server.private_mode,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
20
|
/**
|
|
37
21
|
* Maps a server-side public profile (snake_case) to its client-side (camelCase) representation.
|
|
38
22
|
*/
|
|
@@ -15,8 +15,6 @@ export function canonicalizeMobileInner(
|
|
|
15
15
|
return { type: 'set_username', display_name: inner.display_name };
|
|
16
16
|
case 'set_private_mode':
|
|
17
17
|
return { type: 'set_private_mode', private_mode: inner.private_mode };
|
|
18
|
-
case 'self_identity':
|
|
19
|
-
return { type: 'self_identity' };
|
|
20
18
|
case 'register_expo_token':
|
|
21
19
|
return {
|
|
22
20
|
type: 'register_expo_token',
|
|
@@ -9,6 +9,5 @@ export const MOBILE_EIP712_METHOD_BY_TYPE: Record<
|
|
|
9
9
|
> = {
|
|
10
10
|
set_username: 'mobile:execute_set_username',
|
|
11
11
|
set_private_mode: 'mobile:execute_set_private_mode',
|
|
12
|
-
self_identity: 'mobile:query_self_identity',
|
|
13
12
|
register_expo_token: 'mobile:execute_register_expo_token',
|
|
14
13
|
};
|
|
@@ -26,8 +26,6 @@ const PINNED_HASHES = {
|
|
|
26
26
|
'0xb4a55d9eb0be4e5c9457761c0c34c75cf39f7c07bd170700d8dd5e9c7de4a659',
|
|
27
27
|
set_private_mode:
|
|
28
28
|
'0x4d12a06234d751e6ddcc01d8f70836bb5b7e207e573641d1efb5aaf2b0f30d10',
|
|
29
|
-
self_identity:
|
|
30
|
-
'0x10e94c4502cade0a0b4d7469717bcc1d266fc6a3b7635236fa1d3600b58c9954',
|
|
31
29
|
register_expo_token:
|
|
32
30
|
'0x1b9471afc9bde66f9bffd576d3326420e1bade4e16afa3a73ddc65f27155611c',
|
|
33
31
|
} as const;
|
|
@@ -52,12 +50,6 @@ describe('[mobile-client]: signing (offline)', () => {
|
|
|
52
50
|
expect(hash).toBe(PINNED_HASHES.set_private_mode);
|
|
53
51
|
});
|
|
54
52
|
|
|
55
|
-
it('self_identity', () => {
|
|
56
|
-
const inner: MobileSignedInner = { type: 'self_identity' };
|
|
57
|
-
const hash = getMobilePayloadHash(canonicalizeMobileInner(inner));
|
|
58
|
-
expect(hash).toBe(PINNED_HASHES.self_identity);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
53
|
it('register_expo_token', () => {
|
|
62
54
|
const inner: MobileSignedInner = {
|
|
63
55
|
type: 'register_expo_token',
|
package/src/signing/types.ts
CHANGED
|
@@ -15,7 +15,6 @@ import { MobileNotificationPlatform } from '../types/serverModelTypes';
|
|
|
15
15
|
export type MobileSignedInner =
|
|
16
16
|
| { type: 'set_username'; display_name: string }
|
|
17
17
|
| { type: 'set_private_mode'; private_mode: boolean }
|
|
18
|
-
| { type: 'self_identity' }
|
|
19
18
|
| {
|
|
20
19
|
type: 'register_expo_token';
|
|
21
20
|
expo_token: string;
|
package/src/types/clientTypes.ts
CHANGED
|
@@ -7,30 +7,6 @@ import {
|
|
|
7
7
|
MobileNotificationPlatform,
|
|
8
8
|
} from './serverModelTypes';
|
|
9
9
|
|
|
10
|
-
/**
|
|
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`.
|
|
14
|
-
*
|
|
15
|
-
* `username` and `displayName` are two representations of the same claimed name: `displayName` is what the
|
|
16
|
-
* user entered (preserving casing, e.g. `Alice.One`), while `username` is the canonical, lowercased handle
|
|
17
|
-
* derived from it (e.g. `alice.one`), unique across identities.
|
|
18
|
-
*/
|
|
19
|
-
export interface MobileIdentity {
|
|
20
|
-
subaccount: Hex;
|
|
21
|
-
/**
|
|
22
|
-
* Canonical, lowercased handle derived from {@link MobileIdentity.displayName}, unique across identities,
|
|
23
|
-
* or `null` if no username has been claimed.
|
|
24
|
-
*/
|
|
25
|
-
username: string | null;
|
|
26
|
-
/**
|
|
27
|
-
* User-facing name as claimed, preserving original casing, or `null` if no username has been claimed.
|
|
28
|
-
* Validated against `MOBILE_DISPLAY_NAME_PATTERN`.
|
|
29
|
-
*/
|
|
30
|
-
displayName: string | null;
|
|
31
|
-
privateMode: boolean;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
10
|
/**
|
|
35
11
|
* A subaccount's public profile, as returned by an unsigned profile lookup. Private Mode hides the account's
|
|
36
12
|
* activity, not its profile, so `privateMode` is exposed here too.
|
|
@@ -201,11 +177,6 @@ export interface GetMobileFeedParams {
|
|
|
201
177
|
cursor?: string;
|
|
202
178
|
}
|
|
203
179
|
|
|
204
|
-
/**
|
|
205
|
-
* Params for {@link MobileClient.getSelfIdentity}.
|
|
206
|
-
*/
|
|
207
|
-
export type GetMobileSelfIdentityParams = MobileSignedRequestParams;
|
|
208
|
-
|
|
209
180
|
/**
|
|
210
181
|
* Params for {@link MobileClient.setUsername}.
|
|
211
182
|
*/
|
|
@@ -28,17 +28,6 @@ export interface MobileServerProfile {
|
|
|
28
28
|
private_mode: boolean;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
/**
|
|
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.
|
|
34
|
-
*/
|
|
35
|
-
export interface MobileServerIdentity {
|
|
36
|
-
subaccount: Hex;
|
|
37
|
-
username: string | null;
|
|
38
|
-
display_name: string | null;
|
|
39
|
-
private_mode: boolean;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
31
|
/**
|
|
43
32
|
* Direction of the position a feed trade resulted in — for `closed`, the direction that was closed. This is
|
|
44
33
|
* NOT the execution buy/sell side, which the feed does not expose. Aliases {@link BalanceSide} so the feed's
|
|
@@ -3,14 +3,12 @@ import { MobileServerSuccessResponse } from './serverBaseTypes';
|
|
|
3
3
|
import {
|
|
4
4
|
MobileNotificationPlatform,
|
|
5
5
|
MobileServerFeedTrade,
|
|
6
|
-
MobileServerIdentity,
|
|
7
6
|
MobileServerNotificationPreferences,
|
|
8
7
|
MobileServerProfile,
|
|
9
8
|
} from './serverModelTypes';
|
|
10
9
|
import {
|
|
11
10
|
MobileServerPublicQueryRequestByType,
|
|
12
11
|
MobileServerPublicQueryRequestType,
|
|
13
|
-
MobileServerSignedQueryRequestType,
|
|
14
12
|
} from './serverRequestTypes';
|
|
15
13
|
|
|
16
14
|
/**
|
|
@@ -53,15 +51,6 @@ export interface MobileServerFeedResponse {
|
|
|
53
51
|
next_cursor: string | null;
|
|
54
52
|
}
|
|
55
53
|
|
|
56
|
-
/**
|
|
57
|
-
* Payload of the signed `self_identity` query success response. Every non-isolated subaccount has an implicit
|
|
58
|
-
* identity, so the backend returns one for any valid sender, with `null` name fields when no username has
|
|
59
|
-
* been claimed; `identity` stays nullable to match the backend's `Option`.
|
|
60
|
-
*/
|
|
61
|
-
export interface MobileServerSelfIdentityResponse {
|
|
62
|
-
identity: MobileServerIdentity | null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
54
|
/**
|
|
66
55
|
* Payload of the `notification_preferences` public query success response.
|
|
67
56
|
*/
|
|
@@ -96,16 +85,6 @@ export interface MobileServerPublicQueryResponseByType {
|
|
|
96
85
|
registered_wallet: MobileServerRegisteredWalletResponse;
|
|
97
86
|
}
|
|
98
87
|
|
|
99
|
-
/**
|
|
100
|
-
* Success payloads for each signed `query`, keyed by request `type`. Counterpart to
|
|
101
|
-
* {@link MobileServerSignedQueryRequestByType} so a signed query's request params and response share one
|
|
102
|
-
* lookup, matching the public route. Holds the unwrapped payload; the envelope is applied by
|
|
103
|
-
* {@link MobileServerSignedQuerySuccessResponse}.
|
|
104
|
-
*/
|
|
105
|
-
export interface MobileServerSignedQueryResponseByType {
|
|
106
|
-
self_identity: MobileServerSelfIdentityResponse;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
88
|
/**
|
|
110
89
|
* Full success response for an unsigned `public_query`: the {@link MobileServerSuccessResponse} envelope with
|
|
111
90
|
* the query's payload inlined alongside `status`. Derived from {@link MobileServerPublicQueryResponseByType},
|
|
@@ -115,12 +94,3 @@ export type MobileServerPublicQuerySuccessResponse<
|
|
|
115
94
|
T extends MobileServerPublicQueryRequestType =
|
|
116
95
|
MobileServerPublicQueryRequestType,
|
|
117
96
|
> = MobileServerSuccessResponse & MobileServerPublicQueryResponseByType[T];
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Full success response for a signed `query`: the {@link MobileServerSuccessResponse} envelope with the
|
|
121
|
-
* query's payload inlined alongside `status`. Derived from {@link MobileServerSignedQueryResponseByType}.
|
|
122
|
-
*/
|
|
123
|
-
export type MobileServerSignedQuerySuccessResponse<
|
|
124
|
-
T extends MobileServerSignedQueryRequestType =
|
|
125
|
-
MobileServerSignedQueryRequestType,
|
|
126
|
-
> = MobileServerSuccessResponse & MobileServerSignedQueryResponseByType[T];
|
|
@@ -52,40 +52,18 @@ export interface MobileServerPublicExecuteRequestByType {
|
|
|
52
52
|
export type MobileServerPublicExecuteRequestType =
|
|
53
53
|
keyof MobileServerPublicExecuteRequestByType;
|
|
54
54
|
|
|
55
|
-
/**
|
|
56
|
-
* Params for each signed `query`, keyed by request `type`. These queries identify the caller through the
|
|
57
|
-
* signed envelope (`sender`) and take no further params, so every entry is empty — the signed counterpart to
|
|
58
|
-
* {@link MobileServerPublicQueryRequestByType}, kept so both query routes expose one params lookup keyed by
|
|
59
|
-
* type (matching engine's `EngineServerQueryRequestByType`, which likewise uses `Record<string, never>` for
|
|
60
|
-
* param-less queries).
|
|
61
|
-
*/
|
|
62
|
-
export interface MobileServerSignedQueryRequestByType {
|
|
63
|
-
self_identity: Record<string, never>;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Discriminant `type` values for signed `query` requests: the read-only subset of {@link MobileSignedInner}
|
|
68
|
-
* tags, keyed the same way as {@link MobileServerPublicQueryRequestType}.
|
|
69
|
-
*/
|
|
70
|
-
export type MobileServerSignedQueryRequestType =
|
|
71
|
-
keyof MobileServerSignedQueryRequestByType;
|
|
72
|
-
|
|
73
55
|
/**
|
|
74
56
|
* Discriminant `type` values for signed `execute` requests: the write subset of {@link MobileSignedInner}
|
|
75
|
-
* tags
|
|
57
|
+
* tags. With no signed queries remaining, every signed inner type is an execute.
|
|
76
58
|
*/
|
|
77
|
-
export type MobileServerExecuteRequestType =
|
|
78
|
-
MobileSignedInner['type'],
|
|
79
|
-
MobileServerSignedQueryRequestType
|
|
80
|
-
>;
|
|
59
|
+
export type MobileServerExecuteRequestType = MobileSignedInner['type'];
|
|
81
60
|
|
|
82
61
|
/**
|
|
83
62
|
* Wire `request_type` the backend echoes on failure envelopes, prefixed by the route that produced it:
|
|
84
|
-
* `public_query_*` for unsigned queries, `public_execute_*` for unsigned writes, `
|
|
85
|
-
*
|
|
63
|
+
* `public_query_*` for unsigned queries, `public_execute_*` for unsigned writes, and `execute_*` for signed
|
|
64
|
+
* writes (e.g. `execute_set_username`).
|
|
86
65
|
*/
|
|
87
66
|
export type MobileServerRequestType =
|
|
88
67
|
| `public_query_${MobileServerPublicQueryRequestType}`
|
|
89
68
|
| `public_execute_${MobileServerPublicExecuteRequestType}`
|
|
90
|
-
| `query_${MobileServerSignedQueryRequestType}`
|
|
91
69
|
| `execute_${MobileServerExecuteRequestType}`;
|