@nadohq/mobile-client 0.36.0 → 0.38.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 +19 -6
- package/dist/{MobileClient-D5TNTnLx.cjs → MobileClient-wjTrqP9z.cjs} +75 -12
- package/dist/MobileClient-wjTrqP9z.cjs.map +1 -0
- package/dist/MobileClient.cjs +1 -1
- package/dist/MobileClient.d.cts +62 -16
- package/dist/MobileClient.d.cts.map +1 -1
- package/dist/MobileClient.d.ts +62 -16
- package/dist/MobileClient.d.ts.map +1 -1
- package/dist/MobileClient.js +75 -12
- package/dist/MobileClient.js.map +1 -1
- package/dist/{MobileServerFailureError-CPFjwUBx.d.cts → MobileServerFailureError-BvQYrxjx.d.cts} +3 -3
- package/dist/{MobileServerFailureError-CPFjwUBx.d.cts.map → MobileServerFailureError-BvQYrxjx.d.cts.map} +1 -1
- package/dist/{MobileServerFailureError-Terv2Wzy.d.ts → MobileServerFailureError-CrNpL_L4.d.ts} +3 -3
- package/dist/{MobileServerFailureError-Terv2Wzy.d.ts.map → MobileServerFailureError-CrNpL_L4.d.ts.map} +1 -1
- package/dist/{buildSignedMobileRequest-BScnCGPF.d.ts → buildSignedMobileRequest-BqLRFLKV.d.ts} +2 -2
- package/dist/{buildSignedMobileRequest-BScnCGPF.d.ts.map → buildSignedMobileRequest-BqLRFLKV.d.ts.map} +1 -1
- package/dist/{buildSignedMobileRequest-CXfnhc-4.d.cts → buildSignedMobileRequest-DkkwEqIu.d.cts} +2 -2
- package/dist/{buildSignedMobileRequest-CXfnhc-4.d.cts.map → buildSignedMobileRequest-DkkwEqIu.d.cts.map} +1 -1
- package/dist/{canonicalize-CQ-pMYIt.d.ts → canonicalize-BRhCpYm1.d.ts} +2 -2
- package/dist/canonicalize-BRhCpYm1.d.ts.map +1 -0
- package/dist/{canonicalize-hzhboB-C.d.cts → canonicalize-DtpaaA2B.d.cts} +2 -2
- package/dist/canonicalize-DtpaaA2B.d.cts.map +1 -0
- package/dist/{clientTypes-BwakovWk.d.cts → clientTypes-CB_itU4Z.d.ts} +147 -14
- package/dist/clientTypes-CB_itU4Z.d.ts.map +1 -0
- package/dist/{clientTypes-D-o1_2Yc.d.ts → clientTypes-CceWsQzi.d.cts} +147 -14
- package/dist/clientTypes-CceWsQzi.d.cts.map +1 -0
- package/dist/dataMappers.cjs +79 -6
- package/dist/dataMappers.cjs.map +1 -1
- package/dist/dataMappers.d.cts +27 -5
- package/dist/dataMappers.d.cts.map +1 -1
- package/dist/dataMappers.d.ts +27 -5
- package/dist/dataMappers.d.ts.map +1 -1
- package/dist/dataMappers.js +75 -7
- package/dist/dataMappers.js.map +1 -1
- package/dist/{eip712MethodByType-3aiJkrHj.d.cts → eip712MethodByType-1xUkvTIp.d.cts} +2 -2
- package/dist/eip712MethodByType-1xUkvTIp.d.cts.map +1 -0
- package/dist/{eip712MethodByType-zNvZukU7.d.ts → eip712MethodByType-CrqBJIrp.d.ts} +2 -2
- package/dist/eip712MethodByType-CrqBJIrp.d.ts.map +1 -0
- package/dist/follow-Bh3UmXMc.d.cts +23 -0
- package/dist/follow-Bh3UmXMc.d.cts.map +1 -0
- package/dist/follow-DjkQm1vR.d.ts +23 -0
- package/dist/follow-DjkQm1vR.d.ts.map +1 -0
- package/dist/index.cjs +6 -1
- package/dist/index.d.cts +17 -16
- package/dist/index.d.ts +17 -16
- package/dist/index.js +2 -1
- package/dist/{mobileErrorCodes-CuQ5lyBV.d.ts → mobileErrorCodes-B3eR6t4b.d.ts} +8 -2
- package/dist/mobileErrorCodes-B3eR6t4b.d.ts.map +1 -0
- package/dist/{mobileErrorCodes-D_SyBm0k.d.cts → mobileErrorCodes-DkzBW4v3.d.cts} +8 -2
- package/dist/mobileErrorCodes-DkzBW4v3.d.cts.map +1 -0
- package/dist/{patterns-B5gi7OfV.d.ts → patterns-C-aUAnKl.d.ts} +1 -1
- package/dist/patterns-C-aUAnKl.d.ts.map +1 -0
- package/dist/{patterns-Db6fgz8i.d.cts → patterns-DS8P5LH0.d.cts} +1 -1
- package/dist/patterns-DS8P5LH0.d.cts.map +1 -0
- package/dist/{payloadHash-DVkEt-Rg.d.cts → payloadHash-CIo8Hkh6.d.cts} +2 -2
- package/dist/payloadHash-CIo8Hkh6.d.cts.map +1 -0
- package/dist/{payloadHash-BxL26uwq.d.ts → payloadHash-Cv4WwZCZ.d.ts} +2 -2
- package/dist/payloadHash-Cv4WwZCZ.d.ts.map +1 -0
- package/dist/{serverBaseTypes-B_KHFDab.d.ts → serverBaseTypes-C2JGib--.d.ts} +2 -2
- package/dist/{serverBaseTypes-B_KHFDab.d.ts.map → serverBaseTypes-C2JGib--.d.ts.map} +1 -1
- package/dist/{serverBaseTypes-C8KjE9Fm.d.cts → serverBaseTypes-YkCmgmt1.d.cts} +2 -2
- package/dist/{serverBaseTypes-C8KjE9Fm.d.cts.map → serverBaseTypes-YkCmgmt1.d.cts.map} +1 -1
- package/dist/serverExecuteTypes-C2NoNEwu.d.ts +50 -0
- package/dist/serverExecuteTypes-C2NoNEwu.d.ts.map +1 -0
- package/dist/serverExecuteTypes-DPZbs9ym.d.cts +50 -0
- package/dist/serverExecuteTypes-DPZbs9ym.d.cts.map +1 -0
- package/dist/{serverModelTypes-_cX99seo.d.ts → serverModelTypes-CDcRlRtw.d.ts} +57 -10
- package/dist/serverModelTypes-CDcRlRtw.d.ts.map +1 -0
- package/dist/{serverModelTypes-CwgibK-l.d.cts → serverModelTypes-CUzqFA6x.d.cts} +57 -10
- package/dist/serverModelTypes-CUzqFA6x.d.cts.map +1 -0
- package/dist/{serverQueryTypes-DwE1iJ9f.d.cts → serverQueryTypes-B0xI1G39.d.ts} +21 -9
- package/dist/serverQueryTypes-B0xI1G39.d.ts.map +1 -0
- package/dist/{serverQueryTypes-NIrPm2Sl.d.ts → serverQueryTypes-RdcIqRnM.d.cts} +21 -9
- package/dist/serverQueryTypes-RdcIqRnM.d.cts.map +1 -0
- package/dist/serverRequestTypes-Ddws3yXc.d.cts +116 -0
- package/dist/serverRequestTypes-Ddws3yXc.d.cts.map +1 -0
- package/dist/serverRequestTypes-Dv9NR-hQ.d.ts +116 -0
- package/dist/serverRequestTypes-Dv9NR-hQ.d.ts.map +1 -0
- package/dist/{serverResponseGuards-Cep5s7j5.d.ts → serverResponseGuards-BjIzucYt.d.ts} +2 -2
- package/dist/{serverResponseGuards-Cep5s7j5.d.ts.map → serverResponseGuards-BjIzucYt.d.ts.map} +1 -1
- package/dist/{serverResponseGuards-Dxt9_aGh.d.cts → serverResponseGuards-Dg9WbqBA.d.cts} +2 -2
- package/dist/{serverResponseGuards-Dxt9_aGh.d.cts.map → serverResponseGuards-Dg9WbqBA.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 +5 -0
- 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 +5 -0
- package/dist/signing/canonicalize.js.map +1 -1
- package/dist/signing/eip712MethodByType.cjs +2 -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 +2 -1
- package/dist/signing/eip712MethodByType.js.map +1 -1
- package/dist/signing/index.d.cts +6 -6
- package/dist/signing/index.d.ts +6 -6
- 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 +2 -2
- package/dist/signing/types.d.ts +2 -2
- 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 +9 -9
- package/dist/types/index.d.ts +9 -9
- package/dist/types/mobileErrorCodes.cjs +13 -1
- package/dist/types/mobileErrorCodes.cjs.map +1 -1
- package/dist/types/mobileErrorCodes.d.cts +1 -1
- package/dist/types/mobileErrorCodes.d.ts +1 -1
- package/dist/types/mobileErrorCodes.js +12 -0
- package/dist/types/mobileErrorCodes.js.map +1 -1
- package/dist/types/serverBaseTypes.d.cts +1 -1
- package/dist/types/serverBaseTypes.d.ts +1 -1
- package/dist/types/serverExecuteTypes.d.cts +2 -2
- package/dist/types/serverExecuteTypes.d.ts +2 -2
- 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-47IPsDyA.d.cts → types-BIIvIzG2.d.ts} +20 -7
- package/dist/types-BIIvIzG2.d.ts.map +1 -0
- package/dist/{types-D5kFJzEX.d.ts → types-UmYaeq1C.d.cts} +20 -7
- package/dist/types-UmYaeq1C.d.cts.map +1 -0
- package/dist/utils/follow.cjs +28 -0
- package/dist/utils/follow.cjs.map +1 -0
- package/dist/utils/follow.d.cts +2 -0
- package/dist/utils/follow.d.ts +2 -0
- package/dist/utils/follow.js +24 -0
- package/dist/utils/follow.js.map +1 -0
- package/dist/utils/index.cjs +5 -0
- package/dist/utils/index.d.cts +4 -3
- package/dist/utils/index.d.ts +4 -3
- package/dist/utils/index.js +2 -1
- package/dist/utils/patterns.d.cts +1 -1
- package/dist/utils/patterns.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 +117 -21
- package/src/dataMappers.ts +109 -5
- package/src/signing/canonicalize.ts +6 -0
- package/src/signing/eip712MethodByType.ts +1 -0
- package/src/signing/signing.test.ts +32 -4
- package/src/signing/types.ts +18 -1
- package/src/types/clientTypes.ts +152 -11
- package/src/types/mobileErrorCodes.ts +12 -0
- package/src/types/serverExecuteTypes.ts +40 -2
- package/src/types/serverModelTypes.ts +58 -8
- package/src/types/serverQueryTypes.ts +18 -4
- package/src/types/serverRequestTypes.ts +50 -4
- package/src/utils/follow.ts +22 -0
- package/src/utils/index.ts +1 -0
- package/dist/MobileClient-D5TNTnLx.cjs.map +0 -1
- package/dist/canonicalize-CQ-pMYIt.d.ts.map +0 -1
- package/dist/canonicalize-hzhboB-C.d.cts.map +0 -1
- package/dist/clientTypes-BwakovWk.d.cts.map +0 -1
- package/dist/clientTypes-D-o1_2Yc.d.ts.map +0 -1
- package/dist/eip712MethodByType-3aiJkrHj.d.cts.map +0 -1
- package/dist/eip712MethodByType-zNvZukU7.d.ts.map +0 -1
- package/dist/mobileErrorCodes-CuQ5lyBV.d.ts.map +0 -1
- package/dist/mobileErrorCodes-D_SyBm0k.d.cts.map +0 -1
- package/dist/patterns-B5gi7OfV.d.ts.map +0 -1
- package/dist/patterns-Db6fgz8i.d.cts.map +0 -1
- package/dist/payloadHash-BxL26uwq.d.ts.map +0 -1
- package/dist/payloadHash-DVkEt-Rg.d.cts.map +0 -1
- package/dist/serverExecuteTypes-Cb5v7y0A.d.cts +0 -19
- package/dist/serverExecuteTypes-Cb5v7y0A.d.cts.map +0 -1
- package/dist/serverExecuteTypes-GFjZj_DC.d.ts +0 -19
- package/dist/serverExecuteTypes-GFjZj_DC.d.ts.map +0 -1
- package/dist/serverModelTypes-CwgibK-l.d.cts.map +0 -1
- package/dist/serverModelTypes-_cX99seo.d.ts.map +0 -1
- package/dist/serverQueryTypes-DwE1iJ9f.d.cts.map +0 -1
- package/dist/serverQueryTypes-NIrPm2Sl.d.ts.map +0 -1
- package/dist/serverRequestTypes-516zXnQ6.d.ts +0 -72
- package/dist/serverRequestTypes-516zXnQ6.d.ts.map +0 -1
- package/dist/serverRequestTypes-GAtVYIda.d.cts +0 -72
- package/dist/serverRequestTypes-GAtVYIda.d.cts.map +0 -1
- package/dist/types-47IPsDyA.d.cts.map +0 -1
- package/dist/types-D5kFJzEX.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# `@nadohq/mobile-client`
|
|
2
2
|
|
|
3
3
|
HTTP client for the Nado mobile service API. Manages usernames, public profile lookups, the global trade feed,
|
|
4
|
-
privacy settings, and push notification devices/preferences, using EIP-712 +
|
|
4
|
+
the follower/following graph, privacy settings, and push notification devices/preferences, using EIP-712 +
|
|
5
|
+
msgpack signed authentication.
|
|
5
6
|
|
|
6
7
|
[Full SDK Documentation](https://nadohq.github.io/nado-typescript-sdk/index.html)
|
|
7
8
|
|
|
@@ -26,9 +27,9 @@ const mobile = new MobileClient({
|
|
|
26
27
|
|
|
27
28
|
// Unsigned public lookups
|
|
28
29
|
const availability = await mobile.getUsernameAvailability({ displayName: 'Alice.One' });
|
|
29
|
-
const profile = await mobile.
|
|
30
|
-
subaccountOwner: '0x...',
|
|
31
|
-
|
|
30
|
+
const [profile] = await mobile.getProfiles({
|
|
31
|
+
subaccounts: [{ subaccountOwner: '0x...', subaccountName: 'default' }],
|
|
32
|
+
include: { followCounts: true },
|
|
32
33
|
});
|
|
33
34
|
|
|
34
35
|
// Signed operations
|
|
@@ -45,7 +46,19 @@ await mobile.setUsername({
|
|
|
45
46
|
|
|
46
47
|
### Public Queries
|
|
47
48
|
|
|
48
|
-
`getUsernameAvailability`, `
|
|
49
|
+
`getUsernameAvailability`, `getProfiles`, `getFollowers`, `getFollowing`, `getFeed`,
|
|
50
|
+
`getNotificationPreferences`, `getRegisteredWallet`.
|
|
51
|
+
|
|
52
|
+
`getProfiles` is the only profile route: it batches up to 25 subaccounts, returns them in the requested order,
|
|
53
|
+
and carries follower totals (`include.followCounts`) and a follow summary (`include.followSummary.viewAs`) as
|
|
54
|
+
opt-in includes, so use it for a single subaccount too. The backend still serves the older singular `profile`
|
|
55
|
+
request for compatibility, but it returns base fields only and costs more weight than the batched equivalent,
|
|
56
|
+
so the SDK does not expose it.
|
|
57
|
+
|
|
58
|
+
`getFollowers` and `getFollowing` take an optional `viewAs`, which selects a viewer perspective rather than
|
|
59
|
+
proving one: with it the page is ordered familiar-first and every row carries an `isFollowing`, without it the
|
|
60
|
+
page is ordered by the listed relationship alone and `isFollowing` is absent rather than `false`. As with
|
|
61
|
+
`include.followSummary.viewAs`, an unsigned route means the claimed viewer is not verified.
|
|
49
62
|
|
|
50
63
|
### Public Executes
|
|
51
64
|
|
|
@@ -54,7 +67,7 @@ push token rather than a wallet signature, so they still work at logout when a s
|
|
|
54
67
|
|
|
55
68
|
### Signed Executes
|
|
56
69
|
|
|
57
|
-
`setUsername`, `setPrivateMode`, `registerExpoToken`.
|
|
70
|
+
`setUsername`, `setPrivateMode`, `registerExpoToken`, `setFollow`.
|
|
58
71
|
|
|
59
72
|
### Linked Signers
|
|
60
73
|
|
|
@@ -29,8 +29,8 @@ let axios = require("axios");
|
|
|
29
29
|
axios = __toESM(axios, 1);
|
|
30
30
|
//#region src/MobileClient.ts
|
|
31
31
|
/**
|
|
32
|
-
* Client for the Nado mobile service API: usernames, public profile lookups, the global trade feed,
|
|
33
|
-
* settings, and push notification device/preference management.
|
|
32
|
+
* Client for the Nado mobile service API: usernames, public profile lookups, the global trade feed, the
|
|
33
|
+
* follower/following graph, privacy settings, and push notification device/preference management.
|
|
34
34
|
*/
|
|
35
35
|
var MobileClient = class {
|
|
36
36
|
constructor(opts) {
|
|
@@ -64,19 +64,60 @@ var MobileClient = class {
|
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
|
-
* Looks up
|
|
68
|
-
*
|
|
69
|
-
*
|
|
67
|
+
* Looks up public profiles, optionally with follower totals and a follow summary. Returns one profile per
|
|
68
|
+
* requested subaccount, in the requested order, so callers can correlate positionally. Every non-isolated
|
|
69
|
+
* subaccount resolves, with `username` and `displayName` `null` until a username is claimed. Private Mode
|
|
70
|
+
* does not hide the profile itself, only the account's activity.
|
|
70
71
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
72
|
+
* This is the only profile route, so use it for a single subaccount too. It is unsigned, which means
|
|
73
|
+
* `include.followSummary.viewAs` is an unauthenticated claim.
|
|
74
|
+
*
|
|
75
|
+
* @throws {MobileServerFailureError} With error code `INVALID_PROFILES_REQUEST` if `subaccounts` is empty,
|
|
76
|
+
* holds duplicates, or exceeds `MOBILE_PROFILES_MAX_BATCH_SIZE` (25), or `PROFILE_NOT_FOUND` if any
|
|
77
|
+
* requested subaccount — or the follow summary's `viewAs` — is in the engine-created isolated namespace.
|
|
78
|
+
* One isolated member fails the whole batch rather than being omitted.
|
|
79
|
+
*/
|
|
80
|
+
async getProfiles(params) {
|
|
81
|
+
const body = {
|
|
82
|
+
type: "profiles",
|
|
83
|
+
subaccounts: params.subaccounts.map(_nadohq_shared.subaccountToHex),
|
|
84
|
+
include: params.include ? require_dataMappers.mapMobileProfilesIncludeToServer(params.include) : void 0
|
|
85
|
+
};
|
|
86
|
+
return (await this.publicQuery(body)).profiles.map(require_dataMappers.mapMobilePublicProfile);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Fetches a page of the accounts that follow the given Profile.
|
|
90
|
+
*
|
|
91
|
+
* Ordering depends on `viewAs`. With it, accounts the Viewer already follows come first, unfamiliar
|
|
92
|
+
* accounts second, and every row carries an `isFollowing`. Without it, the page is ordered by the listed
|
|
93
|
+
* relationship alone and no row carries an `isFollowing`. In both cases the newest listed relationship
|
|
94
|
+
* comes first within a group, with a bytes32 tie-break. The grouping is evaluated per request against the
|
|
95
|
+
* live graph, so following an account from inside the list moves it between groups on the next page —
|
|
96
|
+
* deduplicate by subaccount and do not re-sort locally.
|
|
97
|
+
*
|
|
98
|
+
* @throws {MobileServerFailureError} With error code `PROFILE_NOT_FOUND` if the viewed Profile or `viewAs`
|
|
99
|
+
* is isolated, `INVALID_FOLLOW_CURSOR` if the cursor is malformed or was issued for a different `viewAs`,
|
|
100
|
+
* Profile, or list direction (discard it and restart from the first page), or `INVALID_FOLLOW_LIMIT` if
|
|
101
|
+
* `limit` is outside 1–50.
|
|
73
102
|
*/
|
|
74
|
-
async
|
|
103
|
+
async getFollowers(params) {
|
|
75
104
|
const body = {
|
|
76
|
-
type: "
|
|
77
|
-
|
|
105
|
+
type: "followers",
|
|
106
|
+
...require_dataMappers.mapMobileFollowListParamsToServer(params)
|
|
78
107
|
};
|
|
79
|
-
return require_dataMappers.
|
|
108
|
+
return require_dataMappers.mapMobileFollowListPage(await this.publicQuery(body));
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Fetches a page of the accounts the given Profile follows. Ordering, cursor rules, and errors match
|
|
112
|
+
* {@link MobileClient.getFollowers}. When `viewAs` reads its own Following list every row is familiar, so
|
|
113
|
+
* every `isFollowing` is `true`.
|
|
114
|
+
*/
|
|
115
|
+
async getFollowing(params) {
|
|
116
|
+
const body = {
|
|
117
|
+
type: "following",
|
|
118
|
+
...require_dataMappers.mapMobileFollowListParamsToServer(params)
|
|
119
|
+
};
|
|
120
|
+
return require_dataMappers.mapMobileFollowListPage(await this.publicQuery(body));
|
|
80
121
|
}
|
|
81
122
|
/**
|
|
82
123
|
* Fetches a page of the global trade feed: public perpetual trades, newest first, optionally filtered by a
|
|
@@ -206,6 +247,28 @@ var MobileClient = class {
|
|
|
206
247
|
});
|
|
207
248
|
return this.execute(signedRequest);
|
|
208
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* Sets whether the signing subaccount follows a Profile. Both directions are idempotent: following again
|
|
252
|
+
* keeps the original relationship creation time, so it does not move the account in recency order, and
|
|
253
|
+
* unfollowing a relationship that does not exist succeeds with `isFollowing: false`. Unfollowing deletes
|
|
254
|
+
* the relationship rather than deactivating it, so a later follow gets a new creation time and moves the
|
|
255
|
+
* account to the front of recency order.
|
|
256
|
+
*
|
|
257
|
+
* Only `isFollowing: true` is checked against the canonical Query DB subaccount index, so unfollowing still
|
|
258
|
+
* works while that index lags.
|
|
259
|
+
*
|
|
260
|
+
* @throws {MobileServerFailureError} With error code `INVALID_FOLLOW_TARGET` if the target is the sender or
|
|
261
|
+
* either party is isolated, `FOLLOWER_NOT_ELIGIBLE` if the sender is not yet in the canonical Query DB
|
|
262
|
+
* subaccount index, or `FOLLOWING_NOT_FOUND` if the target is not. Both index errors are transient for an
|
|
263
|
+
* account that is being recorded, so they are retryable after catch-up — unlike `INVALID_FOLLOW_TARGET`.
|
|
264
|
+
*/
|
|
265
|
+
async setFollow(params) {
|
|
266
|
+
const signedRequest = await this.getSignedRequest("set_follow", params, {
|
|
267
|
+
subaccount: (0, _nadohq_shared.subaccountToHex)(params.target),
|
|
268
|
+
is_following: params.isFollowing
|
|
269
|
+
});
|
|
270
|
+
return require_dataMappers.mapMobileFollowMutationResult(await this.execute(signedRequest));
|
|
271
|
+
}
|
|
209
272
|
async getSignedRequest(type, params, innerParams) {
|
|
210
273
|
const walletClient = this.opts.linkedSignerWalletClient ?? this.opts.walletClient;
|
|
211
274
|
if (walletClient == null) throw new _nadohq_shared.WalletNotProvidedError();
|
|
@@ -267,4 +330,4 @@ Object.defineProperty(exports, "__toESM", {
|
|
|
267
330
|
}
|
|
268
331
|
});
|
|
269
332
|
|
|
270
|
-
//# sourceMappingURL=MobileClient-
|
|
333
|
+
//# sourceMappingURL=MobileClient-wjTrqP9z.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MobileClient-wjTrqP9z.cjs","names":["subaccountToHex","mapMobileProfilesIncludeToServer","mapMobilePublicProfile","mapMobileFollowListParamsToServer","mapMobileFollowListPage","mapMobileFeedPage","mapMobileNotificationPreferences","mapMobileRegisteredWallet","mapMobileNotificationPreferencesToServer","mapMobileFollowMutationResult","WalletNotProvidedError","buildSignedMobileRequest","isMobileServerFailureResponse","MobileServerFailureError","isMobileServerSuccessResponse"],"sources":["../src/MobileClient.ts"],"sourcesContent":["import {\n getNadoClientTypeHeaders,\n subaccountToHex,\n WalletClientWithAccount,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n mapMobileFeedPage,\n mapMobileFollowListPage,\n mapMobileFollowListParamsToServer,\n mapMobileFollowMutationResult,\n mapMobileNotificationPreferences,\n mapMobileNotificationPreferencesToServer,\n mapMobileProfilesIncludeToServer,\n mapMobilePublicProfile,\n mapMobileRegisteredWallet,\n} from './dataMappers';\nimport {\n buildSignedMobileRequest,\n MobileSignedInner,\n MobileSignedInnerByType,\n MobileSignedInnerParams,\n MobileSignedRequest,\n} from './signing';\nimport {\n GetMobileFeedParams,\n GetMobileFollowersParams,\n GetMobileFollowingParams,\n GetMobileNotificationPreferencesParams,\n GetMobileProfilesParams,\n GetMobileRegisteredWalletParams,\n GetMobileUsernameAvailabilityParams,\n MobileFeedPage,\n MobileFollowListPage,\n MobileFollowMutationResult,\n MobileNotificationPreferences,\n MobilePublicProfile,\n MobileRegisteredWallet,\n MobileRegisterExpoTokenParams,\n MobileSetFollowParams,\n MobileSetPrivateModeParams,\n MobileSetUsernameParams,\n MobileSignedRequestParams,\n MobileUnregisterExpoTokenParams,\n MobileUpdateNotificationPreferencesParams,\n MobileUsernameAvailability,\n} from './types/clientTypes';\nimport { MobileServerFailureError } from './types/MobileServerFailureError';\nimport { MobileServerSuccessResponse } from './types/serverBaseTypes';\nimport {\n MobileServerExecuteResult,\n MobileServerExecuteSuccessResponse,\n MobileServerPublicExecuteRequest,\n} from './types/serverExecuteTypes';\nimport {\n MobileServerPublicQueryRequest,\n MobileServerPublicQuerySuccessResponse,\n} from './types/serverQueryTypes';\nimport {\n MobileServerExecuteRequestType,\n MobileServerPublicQueryRequestByType,\n MobileServerPublicQueryRequestType,\n} from './types/serverRequestTypes';\nimport {\n isMobileServerFailureResponse,\n isMobileServerSuccessResponse,\n} from './utils/serverResponseGuards';\n\n/**\n * Options for constructing a {@link MobileClient}.\n */\nexport interface MobileClientOpts {\n /**\n * Base URL of the mobile service API, e.g. {@link MOBILE_CLIENT_ENDPOINTS}.\n */\n url: string;\n /**\n * Wallet client used to sign requests.\n */\n walletClient?: WalletClientWithAccount;\n /**\n * If provided, this signer is used instead of `walletClient` for all signed requests.\n */\n linkedSignerWalletClient?: WalletClientWithAccount;\n /**\n * If provided, identifies the calling client, sent as a header with every request.\n */\n clientType?: string;\n}\n\n/**\n * Client for the Nado mobile service API: usernames, public profile lookups, the global trade feed, the\n * follower/following graph, privacy settings, and push notification device/preference management.\n */\nexport class MobileClient {\n readonly opts: MobileClientOpts;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: MobileClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: true,\n // We have custom logic to validate response status and create an appropriate error\n validateStatus: () => true,\n headers: getNadoClientTypeHeaders(opts.clientType),\n });\n }\n\n /**\n * Sets the linked signer for requests\n *\n * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer\n */\n public setLinkedSigner(\n linkedSignerWalletClient: WalletClientWithAccount | null,\n ) {\n this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? undefined;\n }\n\n /*\n Public queries\n */\n\n /**\n * Checks whether a username derived from the given display name is available to claim.\n */\n async getUsernameAvailability(\n params: GetMobileUsernameAvailabilityParams,\n ): Promise<MobileUsernameAvailability> {\n const body: MobileServerPublicQueryRequest<'username_availability'> = {\n type: 'username_availability',\n display_name: params.displayName,\n };\n const data = await this.publicQuery(body);\n return { username: data.username, available: data.available };\n }\n\n /**\n * Looks up public profiles, optionally with follower totals and a follow summary. Returns one profile per\n * requested subaccount, in the requested order, so callers can correlate positionally. Every non-isolated\n * subaccount resolves, with `username` and `displayName` `null` until a username is claimed. Private Mode\n * does not hide the profile itself, only the account's activity.\n *\n * This is the only profile route, so use it for a single subaccount too. It is unsigned, which means\n * `include.followSummary.viewAs` is an unauthenticated claim.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_PROFILES_REQUEST` if `subaccounts` is empty,\n * holds duplicates, or exceeds `MOBILE_PROFILES_MAX_BATCH_SIZE` (25), or `PROFILE_NOT_FOUND` if any\n * requested subaccount — or the follow summary's `viewAs` — is in the engine-created isolated namespace.\n * One isolated member fails the whole batch rather than being omitted.\n */\n async getProfiles(\n params: GetMobileProfilesParams,\n ): Promise<MobilePublicProfile[]> {\n const body: MobileServerPublicQueryRequest<'profiles'> = {\n type: 'profiles',\n subaccounts: params.subaccounts.map(subaccountToHex),\n include: params.include\n ? mapMobileProfilesIncludeToServer(params.include)\n : undefined,\n };\n const data = await this.publicQuery(body);\n return data.profiles.map(mapMobilePublicProfile);\n }\n\n /**\n * Fetches a page of the accounts that follow the given Profile.\n *\n * Ordering depends on `viewAs`. With it, accounts the Viewer already follows come first, unfamiliar\n * accounts second, and every row carries an `isFollowing`. Without it, the page is ordered by the listed\n * relationship alone and no row carries an `isFollowing`. In both cases the newest listed relationship\n * comes first within a group, with a bytes32 tie-break. The grouping is evaluated per request against the\n * live graph, so following an account from inside the list moves it between groups on the next page —\n * deduplicate by subaccount and do not re-sort locally.\n *\n * @throws {MobileServerFailureError} With error code `PROFILE_NOT_FOUND` if the viewed Profile or `viewAs`\n * is isolated, `INVALID_FOLLOW_CURSOR` if the cursor is malformed or was issued for a different `viewAs`,\n * Profile, or list direction (discard it and restart from the first page), or `INVALID_FOLLOW_LIMIT` if\n * `limit` is outside 1–50.\n */\n async getFollowers(\n params: GetMobileFollowersParams,\n ): Promise<MobileFollowListPage> {\n const body: MobileServerPublicQueryRequest<'followers'> = {\n type: 'followers',\n ...mapMobileFollowListParamsToServer(params),\n };\n const data = await this.publicQuery(body);\n return mapMobileFollowListPage(data);\n }\n\n /**\n * Fetches a page of the accounts the given Profile follows. Ordering, cursor rules, and errors match\n * {@link MobileClient.getFollowers}. When `viewAs` reads its own Following list every row is familiar, so\n * every `isFollowing` is `true`.\n */\n async getFollowing(\n params: GetMobileFollowingParams,\n ): Promise<MobileFollowListPage> {\n const body: MobileServerPublicQueryRequest<'following'> = {\n type: 'following',\n ...mapMobileFollowListParamsToServer(params),\n };\n const data = await this.publicQuery(body);\n return mapMobileFollowListPage(data);\n }\n\n /**\n * Fetches a page of the global trade feed: public perpetual trades, newest first, optionally filtered by a\n * whole-dollar minimum notional (omitted means unfiltered). Trades by subaccounts that have not claimed a\n * username are included with `null` name fields; only private accounts are filtered out. The feed is\n * best-effort rather than authoritative history, and pagination is live (not snapshot), so deduplicate pages\n * by {@link MobileFeedTrade.orderDigest}.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_FEED_FILTER` if `minimumNotional` or\n * `limit` is outside its allowed domain (fix the request; do not retry unchanged), or\n * `INVALID_FEED_CURSOR` if the cursor is malformed or was issued for a different `minimumNotional`\n * (discard the cursor and restart from the first page).\n */\n async getFeed(params: GetMobileFeedParams = {}): Promise<MobileFeedPage> {\n const body: MobileServerPublicQueryRequest<'feed'> = {\n type: 'feed',\n minimum_notional: params.minimumNotional,\n limit: params.limit,\n cursor: params.cursor,\n };\n const data = await this.publicQuery(body);\n return mapMobileFeedPage(data);\n }\n\n /**\n * Fetches the push notification preferences of the wallet that owns the given Expo push token. Unsigned —\n * the token identifies the wallet on its own. Falls back to the backend's defaults if the wallet has never\n * updated its preferences.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is malformed, or is\n * not currently registered to a wallet.\n */\n async getNotificationPreferences(\n params: GetMobileNotificationPreferencesParams,\n ): Promise<MobileNotificationPreferences> {\n const body: MobileServerPublicQueryRequest<'notification_preferences'> = {\n type: 'notification_preferences',\n expo_token: params.expoToken,\n };\n const data = await this.publicQuery(body);\n return mapMobileNotificationPreferences(data.preferences);\n }\n\n /**\n * Resolves the wallet that an Expo push token is currently registered to, along with the redacted metadata\n * of the device that registered it. Unsigned — the token identifies the wallet on its own. Use it to check\n * whether a locally held token is still active and which wallet currently owns it, since registering the\n * same token under another wallet transfers ownership.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is malformed, or is\n * not currently registered to a wallet — including a token that was unregistered. The backend does not\n * distinguish those cases.\n */\n async getRegisteredWallet(\n params: GetMobileRegisteredWalletParams,\n ): Promise<MobileRegisteredWallet> {\n const body: MobileServerPublicQueryRequest<'registered_wallet'> = {\n type: 'registered_wallet',\n expo_token: params.expoToken,\n };\n const data = await this.publicQuery(body);\n return mapMobileRegisteredWallet(data);\n }\n\n /*\n Public executes\n */\n\n /**\n * Unregisters an Expo push token, stopping delivery to that device. Unsigned, so it still works at logout\n * when a wallet signature may no longer be obtainable. Idempotent: unregistering an inactive or unknown\n * well-formed token succeeds.\n *\n * A registration that commits after this call re-activates the token, so stop or await any in-flight\n * {@link MobileClient.registerExpoToken} before unregistering.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is malformed.\n */\n async unregisterExpoToken(\n params: MobileUnregisterExpoTokenParams,\n ): Promise<MobileServerSuccessResponse> {\n const body: MobileServerPublicExecuteRequest<'unregister_expo_token'> = {\n type: 'unregister_expo_token',\n expo_token: params.expoToken,\n };\n return this.publicExecute(body);\n }\n\n /**\n * Replaces the push notification preferences of the wallet that owns the given Expo push token. Possession\n * of an active token is the credential rather than a signature, so anyone holding the token can overwrite\n * that wallet's preferences. The backend requires `schemaVersion` of 1, exactly one entry per known\n * category, and empty `scopes` on every entry.\n *\n * Writes are last-write-wins on commit order rather than ordered by a client nonce, so callers must\n * serialize their own preference writes.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_PREFERENCES` if those rules are violated, or\n * `INVALID_EXPO_TOKEN` if the token is malformed or is not currently registered to a wallet.\n */\n async updateNotificationPreferences(\n params: MobileUpdateNotificationPreferencesParams,\n ): Promise<MobileServerSuccessResponse> {\n const body: MobileServerPublicExecuteRequest<'update_preferences'> = {\n type: 'update_preferences',\n expo_token: params.expoToken,\n preferences: mapMobileNotificationPreferencesToServer(params.preferences),\n };\n return this.publicExecute(body);\n }\n\n /*\n Signed executes\n */\n\n /**\n * Sets a subaccount's username, derived from the given display name. Upserts: the same call claims a first\n * username and renames an existing one, so callers never need to read the current identity first.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_DISPLAY_NAME` if the display name violates\n * `MOBILE_DISPLAY_NAME_PATTERN`, `USERNAME_UNAVAILABLE` if the derived username is reserved or already\n * taken by another subaccount, `INVALID_IDENTITY_TARGET` if the sender is in the engine-created isolated\n * namespace, or `STALE_IDENTITY_UPDATE` if another identity write for this subaccount committed with a\n * later nonce (re-read the identity before retrying).\n */\n async setUsername(\n params: MobileSetUsernameParams,\n ): Promise<MobileServerSuccessResponse> {\n const signedRequest = await this.getSignedRequest('set_username', params, {\n display_name: params.displayName,\n });\n return this.execute(signedRequest);\n }\n\n /**\n * Sets whether a subaccount's profile is private.\n */\n async setPrivateMode(\n params: MobileSetPrivateModeParams,\n ): Promise<MobileServerSuccessResponse> {\n const signedRequest = await this.getSignedRequest(\n 'set_private_mode',\n params,\n { private_mode: params.privateMode },\n );\n return this.execute(signedRequest);\n }\n\n /**\n * Registers an Expo push token for the wallet, transferring active ownership of the token if another\n * wallet had registered it. Idempotent per `(wallet, token)`.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_EXPO_TOKEN` if the token is not a valid Expo\n * push token, or `INVALID_DEVICE_METADATA` if `locale` (max 35 chars) or `appVersion` (max 64 chars) is\n * too long.\n */\n async registerExpoToken(\n params: MobileRegisterExpoTokenParams,\n ): Promise<MobileServerSuccessResponse> {\n const signedRequest = await this.getSignedRequest(\n 'register_expo_token',\n params,\n {\n expo_token: params.expoToken,\n platform: params.platform,\n locale: params.locale ?? null,\n app_version: params.appVersion ?? null,\n },\n );\n return this.execute(signedRequest);\n }\n\n /**\n * Sets whether the signing subaccount follows a Profile. Both directions are idempotent: following again\n * keeps the original relationship creation time, so it does not move the account in recency order, and\n * unfollowing a relationship that does not exist succeeds with `isFollowing: false`. Unfollowing deletes\n * the relationship rather than deactivating it, so a later follow gets a new creation time and moves the\n * account to the front of recency order.\n *\n * Only `isFollowing: true` is checked against the canonical Query DB subaccount index, so unfollowing still\n * works while that index lags.\n *\n * @throws {MobileServerFailureError} With error code `INVALID_FOLLOW_TARGET` if the target is the sender or\n * either party is isolated, `FOLLOWER_NOT_ELIGIBLE` if the sender is not yet in the canonical Query DB\n * subaccount index, or `FOLLOWING_NOT_FOUND` if the target is not. Both index errors are transient for an\n * account that is being recorded, so they are retryable after catch-up — unlike `INVALID_FOLLOW_TARGET`.\n */\n async setFollow(\n params: MobileSetFollowParams,\n ): Promise<MobileFollowMutationResult> {\n const signedRequest = await this.getSignedRequest('set_follow', params, {\n subaccount: subaccountToHex(params.target),\n is_following: params.isFollowing,\n });\n const data = await this.execute(signedRequest);\n return mapMobileFollowMutationResult(data);\n }\n\n /*\n Base Fns\n */\n\n // Returns the request narrowed to `type` so `execute` can infer its response from the request it is given,\n // instead of being told the type a second time at the call site.\n protected async getSignedRequest<T extends MobileSignedInner['type']>(\n type: T,\n params: MobileSignedRequestParams,\n innerParams: MobileSignedInnerParams<T>,\n ): Promise<MobileSignedRequest<MobileSignedInnerByType<T>>> {\n // Use the linked signer if provided, otherwise use the default signer provided to the client\n const walletClient =\n this.opts.linkedSignerWalletClient ?? this.opts.walletClient;\n\n if (walletClient == null) {\n throw new WalletNotProvidedError();\n }\n\n const inner = {\n type,\n ...innerParams,\n } as unknown as MobileSignedInnerByType<T>;\n return buildSignedMobileRequest({ ...params, walletClient, inner });\n }\n\n // Spelled out as an intersection rather than `MobileServerPublicQueryRequest<T>`: the latter is an indexed\n // access on a mapped type, which is not an inference site, so `T` would always widen to the full union.\n protected async publicQuery<T extends MobileServerPublicQueryRequestType>(\n body: { type: T } & MobileServerPublicQueryRequestByType[T],\n ): Promise<MobileServerPublicQuerySuccessResponse<T>> {\n const response = await this.axiosInstance.post<unknown>(\n `${this.opts.url}/mobile/public_query`,\n body,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus throws on failure responses so the cast to the success response is acceptable here\n return response.data as MobileServerPublicQuerySuccessResponse<T>;\n }\n\n protected async publicExecute(\n body: MobileServerPublicExecuteRequest,\n ): Promise<MobileServerSuccessResponse> {\n const response = await this.axiosInstance.post<MobileServerExecuteResult>(\n `${this.opts.url}/mobile/public_execute`,\n body,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus catches the failure result and throws the error, so the cast to the success response is acceptable here\n return response.data as MobileServerSuccessResponse;\n }\n\n // `T` is inferred from the body's `type` rather than declared by the caller, for the same reason\n // `publicQuery` spells its body out as an intersection: an indexed access is not an inference site.\n protected async execute<T extends MobileServerExecuteRequestType>(\n body: MobileSignedRequest & { type: T },\n ): Promise<MobileServerExecuteSuccessResponse<T>> {\n const response = await this.axiosInstance.post<MobileServerExecuteResult>(\n `${this.opts.url}/mobile/execute`,\n body,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus catches the failure result and throws the error, so the cast to the success response is acceptable here\n return response.data as MobileServerExecuteSuccessResponse<T>;\n }\n\n /**\n * Validates the HTTP status before interpreting the body. Unlike the engine, the mobile backend returns\n * failure envelopes with non-2xx statuses (e.g. 404 for `PROFILE_NOT_FOUND`), so a non-2xx response with a\n * failure envelope still throws the typed error; anything else is a transport-level error.\n */\n private checkResponseStatus(response: AxiosResponse<unknown>) {\n if (response.status >= 200 && response.status < 300) {\n return;\n }\n if (isMobileServerFailureResponse(response.data)) {\n throw new MobileServerFailureError(response.data, response.status);\n }\n throw new Error(\n `Unexpected response from mobile service: ${response.status} ${response.statusText}. Data: ${JSON.stringify(response.data)}`,\n );\n }\n\n private checkServerStatus(response: AxiosResponse<unknown>) {\n const { data } = response;\n\n if (isMobileServerFailureResponse(data)) {\n throw new MobileServerFailureError(data, response.status);\n }\n if (!isMobileServerSuccessResponse(data)) {\n throw new Error(\n `Unexpected response from mobile service: missing success envelope. Data: ${JSON.stringify(data)}`,\n );\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+FA,IAAa,eAAb,MAA0B;CAIxB,YAAY,MAAwB;EAClC,KAAK,OAAO;EACZ,KAAK,gBAAgB,MAAA,QAAM,OAAO;GAChC,iBAAiB;GAEjB,sBAAsB;GACtB,UAAA,GAAA,eAAA,0BAAkC,KAAK,UAAU;EACnD,CAAC;CACH;;;;;;CAOA,gBACE,0BACA;EACA,KAAK,KAAK,2BAA2B,4BAA4B,KAAA;CACnE;;;;CASA,MAAM,wBACJ,QACqC;EACrC,MAAM,OAAgE;GACpE,MAAM;GACN,cAAc,OAAO;EACvB;EACA,MAAM,OAAO,MAAM,KAAK,YAAY,IAAI;EACxC,OAAO;GAAE,UAAU,KAAK;GAAU,WAAW,KAAK;EAAU;CAC9D;;;;;;;;;;;;;;;CAgBA,MAAM,YACJ,QACgC;EAChC,MAAM,OAAmD;GACvD,MAAM;GACN,aAAa,OAAO,YAAY,IAAIA,eAAAA,eAAe;GACnD,SAAS,OAAO,UACZC,oBAAAA,iCAAiC,OAAO,OAAO,IAC/C,KAAA;EACN;EAEA,QAAO,MADY,KAAK,YAAY,IAAI,GAC5B,SAAS,IAAIC,oBAAAA,sBAAsB;CACjD;;;;;;;;;;;;;;;;CAiBA,MAAM,aACJ,QAC+B;EAC/B,MAAM,OAAoD;GACxD,MAAM;GACN,GAAGC,oBAAAA,kCAAkC,MAAM;EAC7C;EAEA,OAAOC,oBAAAA,wBAAwB,MADZ,KAAK,YAAY,IAAI,CACL;CACrC;;;;;;CAOA,MAAM,aACJ,QAC+B;EAC/B,MAAM,OAAoD;GACxD,MAAM;GACN,GAAGD,oBAAAA,kCAAkC,MAAM;EAC7C;EAEA,OAAOC,oBAAAA,wBAAwB,MADZ,KAAK,YAAY,IAAI,CACL;CACrC;;;;;;;;;;;;;CAcA,MAAM,QAAQ,SAA8B,CA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AS,IAAI,GAC7C,MAAM,IAAIC,uCAAAA,yBAAyB,SAAS,MAAM,SAAS,MAAM;EAEnE,MAAM,IAAI,MACR,4CAA4C,SAAS,OAAO,GAAG,SAAS,WAAW,UAAU,KAAK,UAAU,SAAS,IAAI,GAC3H;CACF;CAEA,kBAA0B,UAAkC;EAC1D,MAAM,EAAE,SAAS;EAEjB,IAAID,mCAAAA,8BAA8B,IAAI,GACpC,MAAM,IAAIC,uCAAAA,yBAAyB,MAAM,SAAS,MAAM;EAE1D,IAAI,CAACC,mCAAAA,8BAA8B,IAAI,GACrC,MAAM,IAAI,MACR,4EAA4E,KAAK,UAAU,IAAI,GACjG;CAEJ;AACF"}
|
package/dist/MobileClient.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_MobileClient = require("./MobileClient-
|
|
2
|
+
const require_MobileClient = require("./MobileClient-wjTrqP9z.cjs");
|
|
3
3
|
require("./signing/index.cjs");
|
|
4
4
|
exports.MobileClient = require_MobileClient.MobileClient;
|
package/dist/MobileClient.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { n as MobileServerSuccessResponse } from "./serverBaseTypes-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { A as MobileUsernameAvailability, C as MobileRegisteredWallet, D as MobileSignedRequestParams, E as MobileSetUsernameParams, O as MobileUnregisterExpoTokenParams, S as MobileRegisterExpoTokenParams, T as MobileSetPrivateModeParams, a as GetMobileNotificationPreferencesParams, c as GetMobileUsernameAvailabilityParams, i as GetMobileFollowingParams, k as MobileUpdateNotificationPreferencesParams, m as MobileFollowMutationResult, o as GetMobileProfilesParams, p as MobileFollowListPage, r as GetMobileFollowersParams, s as GetMobileRegisteredWalletParams, t as GetMobileFeedParams, u as MobileFeedPage, w as MobileSetFollowParams, x as MobilePublicProfile, y as MobileNotificationPreferences } from "./clientTypes-CceWsQzi.cjs";
|
|
2
|
+
import { a as MobileSignedRequest, i as MobileSignedInnerParams, n as MobileSignedInner, r as MobileSignedInnerByType } from "./types-UmYaeq1C.cjs";
|
|
3
|
+
import { o as MobileServerPublicQueryRequestByType, s as MobileServerPublicQueryRequestType, t as MobileServerExecuteRequestType } from "./serverRequestTypes-Ddws3yXc.cjs";
|
|
4
|
+
import { n as MobileServerSuccessResponse } from "./serverBaseTypes-YkCmgmt1.cjs";
|
|
5
|
+
import { i as MobileServerExecuteSuccessResponse, o as MobileServerPublicExecuteRequest } from "./serverExecuteTypes-DPZbs9ym.cjs";
|
|
6
|
+
import { s as MobileServerPublicQuerySuccessResponse } from "./serverQueryTypes-RdcIqRnM.cjs";
|
|
7
7
|
import { WalletClientWithAccount } from "@nadohq/shared";
|
|
8
8
|
import { AxiosInstance } from "axios";
|
|
9
9
|
|
|
@@ -30,8 +30,8 @@ interface MobileClientOpts {
|
|
|
30
30
|
clientType?: string;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* Client for the Nado mobile service API: usernames, public profile lookups, the global trade feed,
|
|
34
|
-
* settings, and push notification device/preference management.
|
|
33
|
+
* Client for the Nado mobile service API: usernames, public profile lookups, the global trade feed, the
|
|
34
|
+
* follower/following graph, privacy settings, and push notification device/preference management.
|
|
35
35
|
*/
|
|
36
36
|
declare class MobileClient {
|
|
37
37
|
readonly opts: MobileClientOpts;
|
|
@@ -48,14 +48,42 @@ declare class MobileClient {
|
|
|
48
48
|
*/
|
|
49
49
|
getUsernameAvailability(params: GetMobileUsernameAvailabilityParams): Promise<MobileUsernameAvailability>;
|
|
50
50
|
/**
|
|
51
|
-
* Looks up
|
|
52
|
-
*
|
|
53
|
-
*
|
|
51
|
+
* Looks up public profiles, optionally with follower totals and a follow summary. Returns one profile per
|
|
52
|
+
* requested subaccount, in the requested order, so callers can correlate positionally. Every non-isolated
|
|
53
|
+
* subaccount resolves, with `username` and `displayName` `null` until a username is claimed. Private Mode
|
|
54
|
+
* does not hide the profile itself, only the account's activity.
|
|
54
55
|
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
56
|
+
* This is the only profile route, so use it for a single subaccount too. It is unsigned, which means
|
|
57
|
+
* `include.followSummary.viewAs` is an unauthenticated claim.
|
|
58
|
+
*
|
|
59
|
+
* @throws {MobileServerFailureError} With error code `INVALID_PROFILES_REQUEST` if `subaccounts` is empty,
|
|
60
|
+
* holds duplicates, or exceeds `MOBILE_PROFILES_MAX_BATCH_SIZE` (25), or `PROFILE_NOT_FOUND` if any
|
|
61
|
+
* requested subaccount — or the follow summary's `viewAs` — is in the engine-created isolated namespace.
|
|
62
|
+
* One isolated member fails the whole batch rather than being omitted.
|
|
63
|
+
*/
|
|
64
|
+
getProfiles(params: GetMobileProfilesParams): Promise<MobilePublicProfile[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Fetches a page of the accounts that follow the given Profile.
|
|
67
|
+
*
|
|
68
|
+
* Ordering depends on `viewAs`. With it, accounts the Viewer already follows come first, unfamiliar
|
|
69
|
+
* accounts second, and every row carries an `isFollowing`. Without it, the page is ordered by the listed
|
|
70
|
+
* relationship alone and no row carries an `isFollowing`. In both cases the newest listed relationship
|
|
71
|
+
* comes first within a group, with a bytes32 tie-break. The grouping is evaluated per request against the
|
|
72
|
+
* live graph, so following an account from inside the list moves it between groups on the next page —
|
|
73
|
+
* deduplicate by subaccount and do not re-sort locally.
|
|
74
|
+
*
|
|
75
|
+
* @throws {MobileServerFailureError} With error code `PROFILE_NOT_FOUND` if the viewed Profile or `viewAs`
|
|
76
|
+
* is isolated, `INVALID_FOLLOW_CURSOR` if the cursor is malformed or was issued for a different `viewAs`,
|
|
77
|
+
* Profile, or list direction (discard it and restart from the first page), or `INVALID_FOLLOW_LIMIT` if
|
|
78
|
+
* `limit` is outside 1–50.
|
|
79
|
+
*/
|
|
80
|
+
getFollowers(params: GetMobileFollowersParams): Promise<MobileFollowListPage>;
|
|
81
|
+
/**
|
|
82
|
+
* Fetches a page of the accounts the given Profile follows. Ordering, cursor rules, and errors match
|
|
83
|
+
* {@link MobileClient.getFollowers}. When `viewAs` reads its own Following list every row is familiar, so
|
|
84
|
+
* every `isFollowing` is `true`.
|
|
57
85
|
*/
|
|
58
|
-
|
|
86
|
+
getFollowing(params: GetMobileFollowingParams): Promise<MobileFollowListPage>;
|
|
59
87
|
/**
|
|
60
88
|
* Fetches a page of the global trade feed: public perpetual trades, newest first, optionally filtered by a
|
|
61
89
|
* whole-dollar minimum notional (omitted means unfiltered). Trades by subaccounts that have not claimed a
|
|
@@ -137,12 +165,30 @@ declare class MobileClient {
|
|
|
137
165
|
* too long.
|
|
138
166
|
*/
|
|
139
167
|
registerExpoToken(params: MobileRegisterExpoTokenParams): Promise<MobileServerSuccessResponse>;
|
|
140
|
-
|
|
168
|
+
/**
|
|
169
|
+
* Sets whether the signing subaccount follows a Profile. Both directions are idempotent: following again
|
|
170
|
+
* keeps the original relationship creation time, so it does not move the account in recency order, and
|
|
171
|
+
* unfollowing a relationship that does not exist succeeds with `isFollowing: false`. Unfollowing deletes
|
|
172
|
+
* the relationship rather than deactivating it, so a later follow gets a new creation time and moves the
|
|
173
|
+
* account to the front of recency order.
|
|
174
|
+
*
|
|
175
|
+
* Only `isFollowing: true` is checked against the canonical Query DB subaccount index, so unfollowing still
|
|
176
|
+
* works while that index lags.
|
|
177
|
+
*
|
|
178
|
+
* @throws {MobileServerFailureError} With error code `INVALID_FOLLOW_TARGET` if the target is the sender or
|
|
179
|
+
* either party is isolated, `FOLLOWER_NOT_ELIGIBLE` if the sender is not yet in the canonical Query DB
|
|
180
|
+
* subaccount index, or `FOLLOWING_NOT_FOUND` if the target is not. Both index errors are transient for an
|
|
181
|
+
* account that is being recorded, so they are retryable after catch-up — unlike `INVALID_FOLLOW_TARGET`.
|
|
182
|
+
*/
|
|
183
|
+
setFollow(params: MobileSetFollowParams): Promise<MobileFollowMutationResult>;
|
|
184
|
+
protected getSignedRequest<T extends MobileSignedInner['type']>(type: T, params: MobileSignedRequestParams, innerParams: MobileSignedInnerParams<T>): Promise<MobileSignedRequest<MobileSignedInnerByType<T>>>;
|
|
141
185
|
protected publicQuery<T extends MobileServerPublicQueryRequestType>(body: {
|
|
142
186
|
type: T;
|
|
143
187
|
} & MobileServerPublicQueryRequestByType[T]): Promise<MobileServerPublicQuerySuccessResponse<T>>;
|
|
144
188
|
protected publicExecute(body: MobileServerPublicExecuteRequest): Promise<MobileServerSuccessResponse>;
|
|
145
|
-
protected execute(body: MobileSignedRequest
|
|
189
|
+
protected execute<T extends MobileServerExecuteRequestType>(body: MobileSignedRequest & {
|
|
190
|
+
type: T;
|
|
191
|
+
}): Promise<MobileServerExecuteSuccessResponse<T>>;
|
|
146
192
|
/**
|
|
147
193
|
* Validates the HTTP status before interpreting the body. Unlike the engine, the mobile backend returns
|
|
148
194
|
* failure envelopes with non-2xx statuses (e.g. 404 for `PROFILE_NOT_FOUND`), so a non-2xx response with a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileClient.d.cts","names":[],"sources":["../src/src/MobileClient.ts"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"MobileClient.d.cts","names":[],"sources":["../src/src/MobileClient.ts"],"mappings":";;;;;;;;;;;;;UAwEiB,gBAAA;EAAgB;;;EAI/B,GAAA;EAIA;;;EAAA,YAAA,GAAe,uBAAA;EAQf;;AAAU;EAJV,wBAAA,GAA2B,uBAAuB;EAW3B;;;EAPvB,UAAA;AAAA;;;;;cAOW,YAAA;EAAA,SACF,IAAA,EAAM,gBAAA;EAAA,SACN,aAAA,EAAe,aAAA;cAEZ,IAAA,EAAM,gBAAA;EAoFP;;;;;EArEJ,eAAA,CACL,wBAAA,EAA0B,uBAAA;EAyG6B;;;EA7FnD,uBAAA,CACJ,MAAA,EAAQ,mCAAA,GACP,OAAA,CAAQ,0BAAA;EAgHR;;;;;;;;;;;;;;EAzFG,WAAA,CACJ,M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,oCAAA,CAAqC,CAAA,IACxD,OAAA,CAAQ,sCAAA,CAAuC,CAAA;EAAA,UAalC,aAAA,CACd,IAAA,EAAM,gCAAA,GACL,OAAA,CAAQ,2BAAA;EAAA,UAeK,OAAA,WAAkB,8BAAA,CAAA,CAChC,IAAA,EAAM,mBAAA;IAAwB,IAAA,EAAM,CAAA;EAAA,IACnC,OAAA,CAAQ,kCAAA,CAAmC,CAAA;EAjC9B;;;;;EAAA,QAmDR,mBAAA;EAAA,QAYA,iBAAA;AAAA"}
|
package/dist/MobileClient.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { n as MobileServerSuccessResponse } from "./serverBaseTypes-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { A as MobileUsernameAvailability, C as MobileRegisteredWallet, D as MobileSignedRequestParams, E as MobileSetUsernameParams, O as MobileUnregisterExpoTokenParams, S as MobileRegisterExpoTokenParams, T as MobileSetPrivateModeParams, a as GetMobileNotificationPreferencesParams, c as GetMobileUsernameAvailabilityParams, i as GetMobileFollowingParams, k as MobileUpdateNotificationPreferencesParams, m as MobileFollowMutationResult, o as GetMobileProfilesParams, p as MobileFollowListPage, r as GetMobileFollowersParams, s as GetMobileRegisteredWalletParams, t as GetMobileFeedParams, u as MobileFeedPage, w as MobileSetFollowParams, x as MobilePublicProfile, y as MobileNotificationPreferences } from "./clientTypes-CB_itU4Z.js";
|
|
2
|
+
import { a as MobileSignedRequest, i as MobileSignedInnerParams, n as MobileSignedInner, r as MobileSignedInnerByType } from "./types-BIIvIzG2.js";
|
|
3
|
+
import { o as MobileServerPublicQueryRequestByType, s as MobileServerPublicQueryRequestType, t as MobileServerExecuteRequestType } from "./serverRequestTypes-Dv9NR-hQ.js";
|
|
4
|
+
import { n as MobileServerSuccessResponse } from "./serverBaseTypes-C2JGib--.js";
|
|
5
|
+
import { i as MobileServerExecuteSuccessResponse, o as MobileServerPublicExecuteRequest } from "./serverExecuteTypes-C2NoNEwu.js";
|
|
6
|
+
import { s as MobileServerPublicQuerySuccessResponse } from "./serverQueryTypes-B0xI1G39.js";
|
|
7
7
|
import { WalletClientWithAccount } from "@nadohq/shared";
|
|
8
8
|
import { AxiosInstance } from "axios";
|
|
9
9
|
|
|
@@ -30,8 +30,8 @@ interface MobileClientOpts {
|
|
|
30
30
|
clientType?: string;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* Client for the Nado mobile service API: usernames, public profile lookups, the global trade feed,
|
|
34
|
-
* settings, and push notification device/preference management.
|
|
33
|
+
* Client for the Nado mobile service API: usernames, public profile lookups, the global trade feed, the
|
|
34
|
+
* follower/following graph, privacy settings, and push notification device/preference management.
|
|
35
35
|
*/
|
|
36
36
|
declare class MobileClient {
|
|
37
37
|
readonly opts: MobileClientOpts;
|
|
@@ -48,14 +48,42 @@ declare class MobileClient {
|
|
|
48
48
|
*/
|
|
49
49
|
getUsernameAvailability(params: GetMobileUsernameAvailabilityParams): Promise<MobileUsernameAvailability>;
|
|
50
50
|
/**
|
|
51
|
-
* Looks up
|
|
52
|
-
*
|
|
53
|
-
*
|
|
51
|
+
* Looks up public profiles, optionally with follower totals and a follow summary. Returns one profile per
|
|
52
|
+
* requested subaccount, in the requested order, so callers can correlate positionally. Every non-isolated
|
|
53
|
+
* subaccount resolves, with `username` and `displayName` `null` until a username is claimed. Private Mode
|
|
54
|
+
* does not hide the profile itself, only the account's activity.
|
|
54
55
|
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
56
|
+
* This is the only profile route, so use it for a single subaccount too. It is unsigned, which means
|
|
57
|
+
* `include.followSummary.viewAs` is an unauthenticated claim.
|
|
58
|
+
*
|
|
59
|
+
* @throws {MobileServerFailureError} With error code `INVALID_PROFILES_REQUEST` if `subaccounts` is empty,
|
|
60
|
+
* holds duplicates, or exceeds `MOBILE_PROFILES_MAX_BATCH_SIZE` (25), or `PROFILE_NOT_FOUND` if any
|
|
61
|
+
* requested subaccount — or the follow summary's `viewAs` — is in the engine-created isolated namespace.
|
|
62
|
+
* One isolated member fails the whole batch rather than being omitted.
|
|
63
|
+
*/
|
|
64
|
+
getProfiles(params: GetMobileProfilesParams): Promise<MobilePublicProfile[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Fetches a page of the accounts that follow the given Profile.
|
|
67
|
+
*
|
|
68
|
+
* Ordering depends on `viewAs`. With it, accounts the Viewer already follows come first, unfamiliar
|
|
69
|
+
* accounts second, and every row carries an `isFollowing`. Without it, the page is ordered by the listed
|
|
70
|
+
* relationship alone and no row carries an `isFollowing`. In both cases the newest listed relationship
|
|
71
|
+
* comes first within a group, with a bytes32 tie-break. The grouping is evaluated per request against the
|
|
72
|
+
* live graph, so following an account from inside the list moves it between groups on the next page —
|
|
73
|
+
* deduplicate by subaccount and do not re-sort locally.
|
|
74
|
+
*
|
|
75
|
+
* @throws {MobileServerFailureError} With error code `PROFILE_NOT_FOUND` if the viewed Profile or `viewAs`
|
|
76
|
+
* is isolated, `INVALID_FOLLOW_CURSOR` if the cursor is malformed or was issued for a different `viewAs`,
|
|
77
|
+
* Profile, or list direction (discard it and restart from the first page), or `INVALID_FOLLOW_LIMIT` if
|
|
78
|
+
* `limit` is outside 1–50.
|
|
79
|
+
*/
|
|
80
|
+
getFollowers(params: GetMobileFollowersParams): Promise<MobileFollowListPage>;
|
|
81
|
+
/**
|
|
82
|
+
* Fetches a page of the accounts the given Profile follows. Ordering, cursor rules, and errors match
|
|
83
|
+
* {@link MobileClient.getFollowers}. When `viewAs` reads its own Following list every row is familiar, so
|
|
84
|
+
* every `isFollowing` is `true`.
|
|
57
85
|
*/
|
|
58
|
-
|
|
86
|
+
getFollowing(params: GetMobileFollowingParams): Promise<MobileFollowListPage>;
|
|
59
87
|
/**
|
|
60
88
|
* Fetches a page of the global trade feed: public perpetual trades, newest first, optionally filtered by a
|
|
61
89
|
* whole-dollar minimum notional (omitted means unfiltered). Trades by subaccounts that have not claimed a
|
|
@@ -137,12 +165,30 @@ declare class MobileClient {
|
|
|
137
165
|
* too long.
|
|
138
166
|
*/
|
|
139
167
|
registerExpoToken(params: MobileRegisterExpoTokenParams): Promise<MobileServerSuccessResponse>;
|
|
140
|
-
|
|
168
|
+
/**
|
|
169
|
+
* Sets whether the signing subaccount follows a Profile. Both directions are idempotent: following again
|
|
170
|
+
* keeps the original relationship creation time, so it does not move the account in recency order, and
|
|
171
|
+
* unfollowing a relationship that does not exist succeeds with `isFollowing: false`. Unfollowing deletes
|
|
172
|
+
* the relationship rather than deactivating it, so a later follow gets a new creation time and moves the
|
|
173
|
+
* account to the front of recency order.
|
|
174
|
+
*
|
|
175
|
+
* Only `isFollowing: true` is checked against the canonical Query DB subaccount index, so unfollowing still
|
|
176
|
+
* works while that index lags.
|
|
177
|
+
*
|
|
178
|
+
* @throws {MobileServerFailureError} With error code `INVALID_FOLLOW_TARGET` if the target is the sender or
|
|
179
|
+
* either party is isolated, `FOLLOWER_NOT_ELIGIBLE` if the sender is not yet in the canonical Query DB
|
|
180
|
+
* subaccount index, or `FOLLOWING_NOT_FOUND` if the target is not. Both index errors are transient for an
|
|
181
|
+
* account that is being recorded, so they are retryable after catch-up — unlike `INVALID_FOLLOW_TARGET`.
|
|
182
|
+
*/
|
|
183
|
+
setFollow(params: MobileSetFollowParams): Promise<MobileFollowMutationResult>;
|
|
184
|
+
protected getSignedRequest<T extends MobileSignedInner['type']>(type: T, params: MobileSignedRequestParams, innerParams: MobileSignedInnerParams<T>): Promise<MobileSignedRequest<MobileSignedInnerByType<T>>>;
|
|
141
185
|
protected publicQuery<T extends MobileServerPublicQueryRequestType>(body: {
|
|
142
186
|
type: T;
|
|
143
187
|
} & MobileServerPublicQueryRequestByType[T]): Promise<MobileServerPublicQuerySuccessResponse<T>>;
|
|
144
188
|
protected publicExecute(body: MobileServerPublicExecuteRequest): Promise<MobileServerSuccessResponse>;
|
|
145
|
-
protected execute(body: MobileSignedRequest
|
|
189
|
+
protected execute<T extends MobileServerExecuteRequestType>(body: MobileSignedRequest & {
|
|
190
|
+
type: T;
|
|
191
|
+
}): Promise<MobileServerExecuteSuccessResponse<T>>;
|
|
146
192
|
/**
|
|
147
193
|
* Validates the HTTP status before interpreting the body. Unlike the engine, the mobile backend returns
|
|
148
194
|
* failure envelopes with non-2xx statuses (e.g. 404 for `PROFILE_NOT_FOUND`), so a non-2xx response with a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileClient.d.ts","names":[],"sources":["../src/src/MobileClient.ts"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"MobileClient.d.ts","names":[],"sources":["../src/src/MobileClient.ts"],"mappings":";;;;;;;;;;;;;UAwEiB,gBAAA;EAAgB;;;EAI/B,GAAA;EAIA;;;EAAA,YAAA,GAAe,uBAAA;EAQf;;AAAU;EAJV,wBAAA,GAA2B,uBAAuB;EAW3B;;;EAPvB,UAAA;AAAA;;;;;cAOW,YAAA;EAAA,SACF,IAAA,EAAM,gBAAA;EAAA,SACN,aAAA,EAAe,aAAA;cAEZ,IAAA,EAAM,gBAAA;EAoFP;;;;;EArEJ,eAAA,CACL,wBAAA,EAA0B,uBAAA;EAyG6B;;;EA7FnD,uBAAA,CACJ,MAAA,EAAQ,mCAAA,GACP,OAAA,CAAQ,0BAAA;EAgHR;;;;;;;;;;;;;;EAzFG,WAAA,CACJ,MAAA,EAAQ,uBAAA,GACP,OAAA,CAAQ,mBAAA;EAgMR;;;;;;;;;;;;;;;EArKG,YAAA,CACJ,MAAA,EAAQ,wBAAA,GACP,OAAA,CAAQ,oBAAA;EA0P2B;;;;;EA5OhC,YAAA,CACJ,MAAA,EAAQ,wBAAA,GACP,OAAA,CAAQ,oBAAA;EA4OR;;;;;;;;;;;;EAvNG,OAAA,CAAQ,MAAA,GAAQ,mBAAA,GAA2B,OAAA,CAAQ,cAAA;EA5H1C;;;;;;;;EA+IT,0BAAA,CACJ,MAAA,EAAQ,sCAAA,GACP,OAAA,CA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
|
|
|
1
|
-
import { mapMobileFeedPage, mapMobileNotificationPreferences, mapMobileNotificationPreferencesToServer, mapMobilePublicProfile, mapMobileRegisteredWallet } from "./dataMappers.js";
|
|
1
|
+
import { mapMobileFeedPage, mapMobileFollowListPage, mapMobileFollowListParamsToServer, mapMobileFollowMutationResult, mapMobileNotificationPreferences, mapMobileNotificationPreferencesToServer, mapMobileProfilesIncludeToServer, mapMobilePublicProfile, mapMobileRegisteredWallet } from "./dataMappers.js";
|
|
2
2
|
import { buildSignedMobileRequest } from "./signing/buildSignedMobileRequest.js";
|
|
3
3
|
import "./signing/index.js";
|
|
4
4
|
import { MobileServerFailureError } from "./types/MobileServerFailureError.js";
|
|
@@ -7,8 +7,8 @@ import { WalletNotProvidedError, getNadoClientTypeHeaders, subaccountToHex } fro
|
|
|
7
7
|
import axios from "axios";
|
|
8
8
|
//#region src/MobileClient.ts
|
|
9
9
|
/**
|
|
10
|
-
* Client for the Nado mobile service API: usernames, public profile lookups, the global trade feed,
|
|
11
|
-
* settings, and push notification device/preference management.
|
|
10
|
+
* Client for the Nado mobile service API: usernames, public profile lookups, the global trade feed, the
|
|
11
|
+
* follower/following graph, privacy settings, and push notification device/preference management.
|
|
12
12
|
*/
|
|
13
13
|
var MobileClient = class {
|
|
14
14
|
constructor(opts) {
|
|
@@ -42,19 +42,60 @@ var MobileClient = class {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
|
-
* Looks up
|
|
46
|
-
*
|
|
47
|
-
*
|
|
45
|
+
* Looks up public profiles, optionally with follower totals and a follow summary. Returns one profile per
|
|
46
|
+
* requested subaccount, in the requested order, so callers can correlate positionally. Every non-isolated
|
|
47
|
+
* subaccount resolves, with `username` and `displayName` `null` until a username is claimed. Private Mode
|
|
48
|
+
* does not hide the profile itself, only the account's activity.
|
|
48
49
|
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
50
|
+
* This is the only profile route, so use it for a single subaccount too. It is unsigned, which means
|
|
51
|
+
* `include.followSummary.viewAs` is an unauthenticated claim.
|
|
52
|
+
*
|
|
53
|
+
* @throws {MobileServerFailureError} With error code `INVALID_PROFILES_REQUEST` if `subaccounts` is empty,
|
|
54
|
+
* holds duplicates, or exceeds `MOBILE_PROFILES_MAX_BATCH_SIZE` (25), or `PROFILE_NOT_FOUND` if any
|
|
55
|
+
* requested subaccount — or the follow summary's `viewAs` — is in the engine-created isolated namespace.
|
|
56
|
+
* One isolated member fails the whole batch rather than being omitted.
|
|
57
|
+
*/
|
|
58
|
+
async getProfiles(params) {
|
|
59
|
+
const body = {
|
|
60
|
+
type: "profiles",
|
|
61
|
+
subaccounts: params.subaccounts.map(subaccountToHex),
|
|
62
|
+
include: params.include ? mapMobileProfilesIncludeToServer(params.include) : void 0
|
|
63
|
+
};
|
|
64
|
+
return (await this.publicQuery(body)).profiles.map(mapMobilePublicProfile);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Fetches a page of the accounts that follow the given Profile.
|
|
68
|
+
*
|
|
69
|
+
* Ordering depends on `viewAs`. With it, accounts the Viewer already follows come first, unfamiliar
|
|
70
|
+
* accounts second, and every row carries an `isFollowing`. Without it, the page is ordered by the listed
|
|
71
|
+
* relationship alone and no row carries an `isFollowing`. In both cases the newest listed relationship
|
|
72
|
+
* comes first within a group, with a bytes32 tie-break. The grouping is evaluated per request against the
|
|
73
|
+
* live graph, so following an account from inside the list moves it between groups on the next page —
|
|
74
|
+
* deduplicate by subaccount and do not re-sort locally.
|
|
75
|
+
*
|
|
76
|
+
* @throws {MobileServerFailureError} With error code `PROFILE_NOT_FOUND` if the viewed Profile or `viewAs`
|
|
77
|
+
* is isolated, `INVALID_FOLLOW_CURSOR` if the cursor is malformed or was issued for a different `viewAs`,
|
|
78
|
+
* Profile, or list direction (discard it and restart from the first page), or `INVALID_FOLLOW_LIMIT` if
|
|
79
|
+
* `limit` is outside 1–50.
|
|
51
80
|
*/
|
|
52
|
-
async
|
|
81
|
+
async getFollowers(params) {
|
|
53
82
|
const body = {
|
|
54
|
-
type: "
|
|
55
|
-
|
|
83
|
+
type: "followers",
|
|
84
|
+
...mapMobileFollowListParamsToServer(params)
|
|
56
85
|
};
|
|
57
|
-
return
|
|
86
|
+
return mapMobileFollowListPage(await this.publicQuery(body));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Fetches a page of the accounts the given Profile follows. Ordering, cursor rules, and errors match
|
|
90
|
+
* {@link MobileClient.getFollowers}. When `viewAs` reads its own Following list every row is familiar, so
|
|
91
|
+
* every `isFollowing` is `true`.
|
|
92
|
+
*/
|
|
93
|
+
async getFollowing(params) {
|
|
94
|
+
const body = {
|
|
95
|
+
type: "following",
|
|
96
|
+
...mapMobileFollowListParamsToServer(params)
|
|
97
|
+
};
|
|
98
|
+
return mapMobileFollowListPage(await this.publicQuery(body));
|
|
58
99
|
}
|
|
59
100
|
/**
|
|
60
101
|
* Fetches a page of the global trade feed: public perpetual trades, newest first, optionally filtered by a
|
|
@@ -184,6 +225,28 @@ var MobileClient = class {
|
|
|
184
225
|
});
|
|
185
226
|
return this.execute(signedRequest);
|
|
186
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Sets whether the signing subaccount follows a Profile. Both directions are idempotent: following again
|
|
230
|
+
* keeps the original relationship creation time, so it does not move the account in recency order, and
|
|
231
|
+
* unfollowing a relationship that does not exist succeeds with `isFollowing: false`. Unfollowing deletes
|
|
232
|
+
* the relationship rather than deactivating it, so a later follow gets a new creation time and moves the
|
|
233
|
+
* account to the front of recency order.
|
|
234
|
+
*
|
|
235
|
+
* Only `isFollowing: true` is checked against the canonical Query DB subaccount index, so unfollowing still
|
|
236
|
+
* works while that index lags.
|
|
237
|
+
*
|
|
238
|
+
* @throws {MobileServerFailureError} With error code `INVALID_FOLLOW_TARGET` if the target is the sender or
|
|
239
|
+
* either party is isolated, `FOLLOWER_NOT_ELIGIBLE` if the sender is not yet in the canonical Query DB
|
|
240
|
+
* subaccount index, or `FOLLOWING_NOT_FOUND` if the target is not. Both index errors are transient for an
|
|
241
|
+
* account that is being recorded, so they are retryable after catch-up — unlike `INVALID_FOLLOW_TARGET`.
|
|
242
|
+
*/
|
|
243
|
+
async setFollow(params) {
|
|
244
|
+
const signedRequest = await this.getSignedRequest("set_follow", params, {
|
|
245
|
+
subaccount: subaccountToHex(params.target),
|
|
246
|
+
is_following: params.isFollowing
|
|
247
|
+
});
|
|
248
|
+
return mapMobileFollowMutationResult(await this.execute(signedRequest));
|
|
249
|
+
}
|
|
187
250
|
async getSignedRequest(type, params, innerParams) {
|
|
188
251
|
const walletClient = this.opts.linkedSignerWalletClient ?? this.opts.walletClient;
|
|
189
252
|
if (walletClient == null) throw new WalletNotProvidedError();
|