@compass-labs/api-sdk 2.2.34-rc.4 → 2.2.34-rc.6
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 +3 -1
- package/codeSamples_typescript.yaml +6 -0
- package/dist/commonjs/funcs/traditionalInvestingTraditionalInvestingEnableUnifiedAccount.d.ts +23 -0
- package/dist/commonjs/funcs/traditionalInvestingTraditionalInvestingEnableUnifiedAccount.d.ts.map +1 -0
- package/dist/commonjs/funcs/traditionalInvestingTraditionalInvestingEnableUnifiedAccount.js +124 -0
- package/dist/commonjs/funcs/traditionalInvestingTraditionalInvestingEnableUnifiedAccount.js.map +1 -0
- package/dist/commonjs/models/components/index.d.ts +2 -0
- package/dist/commonjs/models/components/index.d.ts.map +1 -1
- package/dist/commonjs/models/components/index.js +2 -0
- package/dist/commonjs/models/components/index.js.map +1 -1
- package/dist/commonjs/models/components/traditionalinvestingenableunifiedaccountrequest.d.ts +18 -0
- package/dist/commonjs/models/components/traditionalinvestingenableunifiedaccountrequest.d.ts.map +1 -0
- package/dist/commonjs/models/components/traditionalinvestingenableunifiedaccountrequest.js +49 -0
- package/dist/commonjs/models/components/traditionalinvestingenableunifiedaccountrequest.js.map +1 -0
- package/dist/commonjs/models/components/traditionalinvestingenableunifiedaccountresponse.d.ts +37 -0
- package/dist/commonjs/models/components/traditionalinvestingenableunifiedaccountresponse.d.ts.map +1 -0
- package/dist/commonjs/models/components/traditionalinvestingenableunifiedaccountresponse.js +58 -0
- package/dist/commonjs/models/components/traditionalinvestingenableunifiedaccountresponse.js.map +1 -0
- package/dist/commonjs/sdk/traditionalinvesting.d.ts +12 -0
- package/dist/commonjs/sdk/traditionalinvesting.d.ts.map +1 -1
- package/dist/commonjs/sdk/traditionalinvesting.js +15 -0
- package/dist/commonjs/sdk/traditionalinvesting.js.map +1 -1
- package/dist/esm/funcs/traditionalInvestingTraditionalInvestingEnableUnifiedAccount.d.ts +23 -0
- package/dist/esm/funcs/traditionalInvestingTraditionalInvestingEnableUnifiedAccount.d.ts.map +1 -0
- package/dist/esm/funcs/traditionalInvestingTraditionalInvestingEnableUnifiedAccount.js +88 -0
- package/dist/esm/funcs/traditionalInvestingTraditionalInvestingEnableUnifiedAccount.js.map +1 -0
- package/dist/esm/models/components/index.d.ts +2 -0
- package/dist/esm/models/components/index.d.ts.map +1 -1
- package/dist/esm/models/components/index.js +2 -0
- package/dist/esm/models/components/index.js.map +1 -1
- package/dist/esm/models/components/traditionalinvestingenableunifiedaccountrequest.d.ts +18 -0
- package/dist/esm/models/components/traditionalinvestingenableunifiedaccountrequest.d.ts.map +1 -0
- package/dist/esm/models/components/traditionalinvestingenableunifiedaccountrequest.js +12 -0
- package/dist/esm/models/components/traditionalinvestingenableunifiedaccountrequest.js.map +1 -0
- package/dist/esm/models/components/traditionalinvestingenableunifiedaccountresponse.d.ts +37 -0
- package/dist/esm/models/components/traditionalinvestingenableunifiedaccountresponse.d.ts.map +1 -0
- package/dist/esm/models/components/traditionalinvestingenableunifiedaccountresponse.js +21 -0
- package/dist/esm/models/components/traditionalinvestingenableunifiedaccountresponse.js.map +1 -0
- package/dist/esm/sdk/traditionalinvesting.d.ts +12 -0
- package/dist/esm/sdk/traditionalinvesting.d.ts.map +1 -1
- package/dist/esm/sdk/traditionalinvesting.js +15 -0
- package/dist/esm/sdk/traditionalinvesting.js.map +1 -1
- package/docs/models/components/traditionalinvestingenableunifiedaccountrequest.md +19 -0
- package/docs/models/components/traditionalinvestingenableunifiedaccountresponse.md +25 -0
- package/docs/sdks/traditionalinvesting/README.md +80 -0
- package/package.json +1 -1
- package/src/funcs/traditionalInvestingTraditionalInvestingEnableUnifiedAccount.ts +179 -0
- package/src/models/components/index.ts +2 -0
- package/src/models/components/traditionalinvestingenableunifiedaccountrequest.ts +41 -0
- package/src/models/components/traditionalinvestingenableunifiedaccountresponse.ts +69 -0
- package/src/sdk/traditionalinvesting.ts +25 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { CompassApiSDKCore } from "../core.js";
|
|
6
|
+
import { encodeJSON } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import * as components from "../models/components/index.js";
|
|
14
|
+
import { CompassAPISDKError } from "../models/errors/compassapisdkerror.js";
|
|
15
|
+
import {
|
|
16
|
+
ConnectionError,
|
|
17
|
+
InvalidRequestError,
|
|
18
|
+
RequestAbortedError,
|
|
19
|
+
RequestTimeoutError,
|
|
20
|
+
UnexpectedClientError,
|
|
21
|
+
} from "../models/errors/httpclienterrors.js";
|
|
22
|
+
import * as errors from "../models/errors/index.js";
|
|
23
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
24
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
25
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
26
|
+
import { Result } from "../types/fp.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Enable unified account mode
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* Check account mode and prepare the enable-unified-account action if needed.
|
|
33
|
+
*
|
|
34
|
+
* If the account is already in unified mode (or portfolio margin), returns
|
|
35
|
+
* the current mode with null typed_data — no signing needed. Otherwise,
|
|
36
|
+
* returns EIP-712 typed data for the user to sign. After signing, submit
|
|
37
|
+
* the signature via the /execute endpoint.
|
|
38
|
+
*/
|
|
39
|
+
export function traditionalInvestingTraditionalInvestingEnableUnifiedAccount(
|
|
40
|
+
client: CompassApiSDKCore,
|
|
41
|
+
request: components.TraditionalInvestingEnableUnifiedAccountRequest,
|
|
42
|
+
options?: RequestOptions,
|
|
43
|
+
): APIPromise<
|
|
44
|
+
Result<
|
|
45
|
+
components.TraditionalInvestingEnableUnifiedAccountResponse,
|
|
46
|
+
| errors.HTTPValidationError
|
|
47
|
+
| CompassAPISDKError
|
|
48
|
+
| ResponseValidationError
|
|
49
|
+
| ConnectionError
|
|
50
|
+
| RequestAbortedError
|
|
51
|
+
| RequestTimeoutError
|
|
52
|
+
| InvalidRequestError
|
|
53
|
+
| UnexpectedClientError
|
|
54
|
+
| SDKValidationError
|
|
55
|
+
>
|
|
56
|
+
> {
|
|
57
|
+
return new APIPromise($do(
|
|
58
|
+
client,
|
|
59
|
+
request,
|
|
60
|
+
options,
|
|
61
|
+
));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function $do(
|
|
65
|
+
client: CompassApiSDKCore,
|
|
66
|
+
request: components.TraditionalInvestingEnableUnifiedAccountRequest,
|
|
67
|
+
options?: RequestOptions,
|
|
68
|
+
): Promise<
|
|
69
|
+
[
|
|
70
|
+
Result<
|
|
71
|
+
components.TraditionalInvestingEnableUnifiedAccountResponse,
|
|
72
|
+
| errors.HTTPValidationError
|
|
73
|
+
| CompassAPISDKError
|
|
74
|
+
| ResponseValidationError
|
|
75
|
+
| ConnectionError
|
|
76
|
+
| RequestAbortedError
|
|
77
|
+
| RequestTimeoutError
|
|
78
|
+
| InvalidRequestError
|
|
79
|
+
| UnexpectedClientError
|
|
80
|
+
| SDKValidationError
|
|
81
|
+
>,
|
|
82
|
+
APICall,
|
|
83
|
+
]
|
|
84
|
+
> {
|
|
85
|
+
const parsed = safeParse(
|
|
86
|
+
request,
|
|
87
|
+
(value) =>
|
|
88
|
+
components.TraditionalInvestingEnableUnifiedAccountRequest$outboundSchema
|
|
89
|
+
.parse(value),
|
|
90
|
+
"Input validation failed",
|
|
91
|
+
);
|
|
92
|
+
if (!parsed.ok) {
|
|
93
|
+
return [parsed, { status: "invalid" }];
|
|
94
|
+
}
|
|
95
|
+
const payload = parsed.value;
|
|
96
|
+
const body = encodeJSON("body", payload, { explode: true });
|
|
97
|
+
|
|
98
|
+
const path = pathToFunc("/v2/traditional_investing/enable_unified_account")();
|
|
99
|
+
|
|
100
|
+
const headers = new Headers(compactMap({
|
|
101
|
+
"Content-Type": "application/json",
|
|
102
|
+
Accept: "application/json",
|
|
103
|
+
}));
|
|
104
|
+
|
|
105
|
+
const secConfig = await extractSecurity(client._options.apiKeyAuth);
|
|
106
|
+
const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig };
|
|
107
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
108
|
+
|
|
109
|
+
const context = {
|
|
110
|
+
options: client._options,
|
|
111
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
112
|
+
operationID: "v2_traditional_investing_enable_unified_account",
|
|
113
|
+
oAuth2Scopes: null,
|
|
114
|
+
|
|
115
|
+
resolvedSecurity: requestSecurity,
|
|
116
|
+
|
|
117
|
+
securitySource: client._options.apiKeyAuth,
|
|
118
|
+
retryConfig: options?.retries
|
|
119
|
+
|| client._options.retryConfig
|
|
120
|
+
|| { strategy: "none" },
|
|
121
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const requestRes = client._createRequest(context, {
|
|
125
|
+
security: requestSecurity,
|
|
126
|
+
method: "POST",
|
|
127
|
+
baseURL: options?.serverURL,
|
|
128
|
+
path: path,
|
|
129
|
+
headers: headers,
|
|
130
|
+
body: body,
|
|
131
|
+
userAgent: client._options.userAgent,
|
|
132
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
133
|
+
}, options);
|
|
134
|
+
if (!requestRes.ok) {
|
|
135
|
+
return [requestRes, { status: "invalid" }];
|
|
136
|
+
}
|
|
137
|
+
const req = requestRes.value;
|
|
138
|
+
|
|
139
|
+
const doResult = await client._do(req, {
|
|
140
|
+
context,
|
|
141
|
+
errorCodes: ["422", "4XX", "5XX"],
|
|
142
|
+
retryConfig: context.retryConfig,
|
|
143
|
+
retryCodes: context.retryCodes,
|
|
144
|
+
});
|
|
145
|
+
if (!doResult.ok) {
|
|
146
|
+
return [doResult, { status: "request-error", request: req }];
|
|
147
|
+
}
|
|
148
|
+
const response = doResult.value;
|
|
149
|
+
|
|
150
|
+
const responseFields = {
|
|
151
|
+
HttpMeta: { Response: response, Request: req },
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const [result] = await M.match<
|
|
155
|
+
components.TraditionalInvestingEnableUnifiedAccountResponse,
|
|
156
|
+
| errors.HTTPValidationError
|
|
157
|
+
| CompassAPISDKError
|
|
158
|
+
| ResponseValidationError
|
|
159
|
+
| ConnectionError
|
|
160
|
+
| RequestAbortedError
|
|
161
|
+
| RequestTimeoutError
|
|
162
|
+
| InvalidRequestError
|
|
163
|
+
| UnexpectedClientError
|
|
164
|
+
| SDKValidationError
|
|
165
|
+
>(
|
|
166
|
+
M.json(
|
|
167
|
+
200,
|
|
168
|
+
components.TraditionalInvestingEnableUnifiedAccountResponse$inboundSchema,
|
|
169
|
+
),
|
|
170
|
+
M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
|
|
171
|
+
M.fail("4XX"),
|
|
172
|
+
M.fail("5XX"),
|
|
173
|
+
)(response, req, { extraFields: responseFields });
|
|
174
|
+
if (!result.ok) {
|
|
175
|
+
return [result, { status: "complete", request: req, response }];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return [result, { status: "complete", request: req, response }];
|
|
179
|
+
}
|
|
@@ -247,6 +247,8 @@ export * from "./traditionalinvestingcancelorderrequest.js";
|
|
|
247
247
|
export * from "./traditionalinvestingcategory.js";
|
|
248
248
|
export * from "./traditionalinvestingdepositrequest.js";
|
|
249
249
|
export * from "./traditionalinvestingdepositresponse.js";
|
|
250
|
+
export * from "./traditionalinvestingenableunifiedaccountrequest.js";
|
|
251
|
+
export * from "./traditionalinvestingenableunifiedaccountresponse.js";
|
|
250
252
|
export * from "./traditionalinvestingexecuterequest.js";
|
|
251
253
|
export * from "./traditionalinvestingexecuteresponse.js";
|
|
252
254
|
export * from "./traditionalinvestinglimitorderrequest.js";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Request to enable unified account mode on Hyperliquid.
|
|
9
|
+
*/
|
|
10
|
+
export type TraditionalInvestingEnableUnifiedAccountRequest = {
|
|
11
|
+
/**
|
|
12
|
+
* User's EOA address
|
|
13
|
+
*/
|
|
14
|
+
owner: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** @internal */
|
|
18
|
+
export type TraditionalInvestingEnableUnifiedAccountRequest$Outbound = {
|
|
19
|
+
owner: string;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** @internal */
|
|
23
|
+
export const TraditionalInvestingEnableUnifiedAccountRequest$outboundSchema:
|
|
24
|
+
z.ZodType<
|
|
25
|
+
TraditionalInvestingEnableUnifiedAccountRequest$Outbound,
|
|
26
|
+
z.ZodTypeDef,
|
|
27
|
+
TraditionalInvestingEnableUnifiedAccountRequest
|
|
28
|
+
> = z.object({
|
|
29
|
+
owner: z.string(),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export function traditionalInvestingEnableUnifiedAccountRequestToJSON(
|
|
33
|
+
traditionalInvestingEnableUnifiedAccountRequest:
|
|
34
|
+
TraditionalInvestingEnableUnifiedAccountRequest,
|
|
35
|
+
): string {
|
|
36
|
+
return JSON.stringify(
|
|
37
|
+
TraditionalInvestingEnableUnifiedAccountRequest$outboundSchema.parse(
|
|
38
|
+
traditionalInvestingEnableUnifiedAccountRequest,
|
|
39
|
+
),
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Returned by the enable_unified_account endpoint.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
*
|
|
16
|
+
* If the account is already in unified mode, typed_data/action/nonce are null.
|
|
17
|
+
* If not, they contain the EIP-712 payload the user must sign.
|
|
18
|
+
*/
|
|
19
|
+
export type TraditionalInvestingEnableUnifiedAccountResponse = {
|
|
20
|
+
/**
|
|
21
|
+
* Current account abstraction mode (e.g. 'default', 'unifiedAccount')
|
|
22
|
+
*/
|
|
23
|
+
mode: string;
|
|
24
|
+
/**
|
|
25
|
+
* EIP-712 typed data for wallet signing, or null if already unified
|
|
26
|
+
*/
|
|
27
|
+
typedData?: { [k: string]: any } | null | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Raw Hyperliquid action (passed back to the execute endpoint), or null
|
|
30
|
+
*/
|
|
31
|
+
action?: { [k: string]: any } | null | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Timestamp-based nonce, or null if no action needed
|
|
34
|
+
*/
|
|
35
|
+
nonce?: number | null | undefined;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** @internal */
|
|
39
|
+
export const TraditionalInvestingEnableUnifiedAccountResponse$inboundSchema:
|
|
40
|
+
z.ZodType<
|
|
41
|
+
TraditionalInvestingEnableUnifiedAccountResponse,
|
|
42
|
+
z.ZodTypeDef,
|
|
43
|
+
unknown
|
|
44
|
+
> = z.object({
|
|
45
|
+
mode: z.string(),
|
|
46
|
+
typed_data: z.nullable(z.record(z.any())).optional(),
|
|
47
|
+
action: z.nullable(z.record(z.any())).optional(),
|
|
48
|
+
nonce: z.nullable(z.number().int()).optional(),
|
|
49
|
+
}).transform((v) => {
|
|
50
|
+
return remap$(v, {
|
|
51
|
+
"typed_data": "typedData",
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export function traditionalInvestingEnableUnifiedAccountResponseFromJSON(
|
|
56
|
+
jsonString: string,
|
|
57
|
+
): SafeParseResult<
|
|
58
|
+
TraditionalInvestingEnableUnifiedAccountResponse,
|
|
59
|
+
SDKValidationError
|
|
60
|
+
> {
|
|
61
|
+
return safeParse(
|
|
62
|
+
jsonString,
|
|
63
|
+
(x) =>
|
|
64
|
+
TraditionalInvestingEnableUnifiedAccountResponse$inboundSchema.parse(
|
|
65
|
+
JSON.parse(x),
|
|
66
|
+
),
|
|
67
|
+
`Failed to parse 'TraditionalInvestingEnableUnifiedAccountResponse' from JSON`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { traditionalInvestingTraditionalInvestingApproveBuilderFee } from "../funcs/traditionalInvestingTraditionalInvestingApproveBuilderFee.js";
|
|
6
6
|
import { traditionalInvestingTraditionalInvestingCancelOrder } from "../funcs/traditionalInvestingTraditionalInvestingCancelOrder.js";
|
|
7
7
|
import { traditionalInvestingTraditionalInvestingDeposit } from "../funcs/traditionalInvestingTraditionalInvestingDeposit.js";
|
|
8
|
+
import { traditionalInvestingTraditionalInvestingEnableUnifiedAccount } from "../funcs/traditionalInvestingTraditionalInvestingEnableUnifiedAccount.js";
|
|
8
9
|
import { traditionalInvestingTraditionalInvestingExecute } from "../funcs/traditionalInvestingTraditionalInvestingExecute.js";
|
|
9
10
|
import { traditionalInvestingTraditionalInvestingLimitOrder } from "../funcs/traditionalInvestingTraditionalInvestingLimitOrder.js";
|
|
10
11
|
import { traditionalInvestingTraditionalInvestingMarketOrder } from "../funcs/traditionalInvestingTraditionalInvestingMarketOrder.js";
|
|
@@ -207,4 +208,28 @@ export class TraditionalInvesting extends ClientSDK {
|
|
|
207
208
|
),
|
|
208
209
|
);
|
|
209
210
|
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Enable unified account mode
|
|
214
|
+
*
|
|
215
|
+
* @remarks
|
|
216
|
+
* Check account mode and prepare the enable-unified-account action if needed.
|
|
217
|
+
*
|
|
218
|
+
* If the account is already in unified mode (or portfolio margin), returns
|
|
219
|
+
* the current mode with null typed_data — no signing needed. Otherwise,
|
|
220
|
+
* returns EIP-712 typed data for the user to sign. After signing, submit
|
|
221
|
+
* the signature via the /execute endpoint.
|
|
222
|
+
*/
|
|
223
|
+
async traditionalInvestingEnableUnifiedAccount(
|
|
224
|
+
request: components.TraditionalInvestingEnableUnifiedAccountRequest,
|
|
225
|
+
options?: RequestOptions,
|
|
226
|
+
): Promise<components.TraditionalInvestingEnableUnifiedAccountResponse> {
|
|
227
|
+
return unwrapAsync(
|
|
228
|
+
traditionalInvestingTraditionalInvestingEnableUnifiedAccount(
|
|
229
|
+
this,
|
|
230
|
+
request,
|
|
231
|
+
options,
|
|
232
|
+
),
|
|
233
|
+
);
|
|
234
|
+
}
|
|
210
235
|
}
|