@0xmonaco/core 0.1.0 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/api/auth/api.d.ts +2 -2
  2. package/dist/api/auth/api.d.ts.map +1 -1
  3. package/dist/api/auth/api.js.map +1 -1
  4. package/dist/api/auth/index.d.ts +1 -1
  5. package/dist/api/base.d.ts +99 -0
  6. package/dist/api/base.d.ts.map +1 -0
  7. package/dist/api/base.js +132 -0
  8. package/dist/api/base.js.map +1 -0
  9. package/dist/api/index.d.ts +2 -0
  10. package/dist/api/index.d.ts.map +1 -1
  11. package/dist/api/index.js +2 -0
  12. package/dist/api/index.js.map +1 -1
  13. package/dist/api/profile/api.d.ts +54 -0
  14. package/dist/api/profile/api.d.ts.map +1 -0
  15. package/dist/api/profile/api.js +77 -0
  16. package/dist/api/profile/api.js.map +1 -0
  17. package/dist/api/profile/index.d.ts +7 -0
  18. package/dist/api/profile/index.d.ts.map +1 -0
  19. package/dist/api/profile/index.js +7 -0
  20. package/dist/api/profile/index.js.map +1 -0
  21. package/dist/api/trading/api.d.ts +57 -18
  22. package/dist/api/trading/api.d.ts.map +1 -1
  23. package/dist/api/trading/api.js +108 -38
  24. package/dist/api/trading/api.js.map +1 -1
  25. package/dist/api/trading/index.d.ts +1 -1
  26. package/dist/api/vault/api.d.ts +3 -9
  27. package/dist/api/vault/api.d.ts.map +1 -1
  28. package/dist/api/vault/api.js +23 -41
  29. package/dist/api/vault/api.js.map +1 -1
  30. package/dist/api/vault/index.d.ts +1 -1
  31. package/dist/chains.d.ts +101 -81
  32. package/dist/chains.js +46 -46
  33. package/dist/errors.d.ts +76 -67
  34. package/dist/errors.d.ts.map +1 -1
  35. package/dist/errors.js.map +1 -1
  36. package/dist/index.d.ts +1 -1
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js.map +1 -1
  39. package/dist/networks.d.ts +1 -1
  40. package/dist/networks.js +2 -2
  41. package/dist/networks.js.map +1 -1
  42. package/dist/sdk.d.ts +30 -34
  43. package/dist/sdk.d.ts.map +1 -1
  44. package/dist/sdk.js +102 -121
  45. package/dist/sdk.js.map +1 -1
  46. package/package.json +7 -5
@@ -28,8 +28,8 @@
28
28
  * const backendAuth = await authAPI.authenticateBackend(secretKey);
29
29
  * ```
30
30
  */
31
- import { type WalletClient, type Chain } from "viem";
32
- import { type AuthAPI, type ChallengeResponse, type VerifyResponse, type BackendAuthResponse, type TokenRefreshResponse } from "@0xmonaco/types";
31
+ import type { AuthAPI, BackendAuthResponse, ChallengeResponse, TokenRefreshResponse, VerifyResponse } from "@0xmonaco/types";
32
+ import type { Chain, WalletClient } from "viem";
33
33
  export declare class AuthAPIImpl implements AuthAPI {
34
34
  private readonly walletClient;
35
35
  private readonly apiUrl;
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/api/auth/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,KAAK,EAAE,MAAM,MAAM,CAAC;AACrD,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EAC1B,MAAM,iBAAiB,CAAC;AAGzB,qBAAa,WAAY,YAAW,OAAO;IASvC,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAVxB;;;;;;OAMG;gBAEgB,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK;IAG/B;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAgC7D;;;;;;;;;;;;;;;;;OAiBG;IACG,a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,CAAC;oBACpB,aAAa,EAAE,YAAY;iBAC3B,CAAC;aACF,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBAClB,MAAM,IAAI,QAAQ,CACjB,uBAAuB,QAAQ,CAAC,MAAM,EAAE,EACxC,GAAG,IAAI,CAAC,MAAM,qBAAqB,EACnC,QAAQ,CAAC,MAAM,CACf,CAAC;YACH,CAAC;QACF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,QAAQ,CACjB,wBAAwB,EACxB,GAAG,IAAI,CAAC,MAAM,qBAAqB,EACnC,SAAS,CACT,CAAC;QACH,CAAC;IACF,CAAC;CACD"}
@@ -3,4 +3,4 @@
3
3
  */
4
4
  export { AuthAPIImpl } from "./api";
5
5
  export type { AuthAPI } from "@0xmonaco/types";
6
- //# sourceMappingURL=index.d.ts.map
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Base API Implementation
3
+ *
4
+ * Provides common functionality for all API classes including access token management,
5
+ * authenticated request handling, and standardized error responses.
6
+ *
7
+ * This base class eliminates code duplication across API implementations and provides
8
+ * a consistent interface for token-based authentication and HTTP request handling.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * class MyAPIImpl extends BaseAPI implements MyAPI {
13
+ * constructor(apiUrl: string) {
14
+ * super(apiUrl);
15
+ * }
16
+ *
17
+ * async getData(): Promise<any> {
18
+ * return this.makeAuthenticatedRequest<any>('/api/v1/data');
19
+ * }
20
+ * }
21
+ * ```
22
+ */
23
+ export declare abstract class BaseAPI {
24
+ protected readonly apiUrl: string;
25
+ protected accessToken?: string;
26
+ /**
27
+ * Creates a new BaseAPI instance.
28
+ *
29
+ * @param apiUrl - The base URL for the Monaco API Gateway
30
+ */
31
+ constructor(apiUrl: string);
32
+ /**
33
+ * Set the access token for authenticated requests.
34
+ *
35
+ * @param token - JWT access token
36
+ */
37
+ setAccessToken(token: string): void;
38
+ /**
39
+ * Get the current access token.
40
+ *
41
+ * @returns The current access token or undefined if not set
42
+ */
43
+ protected getAccessToken(): string | undefined;
44
+ /**
45
+ * Makes an authenticated API request with automatic token handling.
46
+ *
47
+ * This method automatically includes the Authorization header with the Bearer token
48
+ * and provides consistent error handling across all API operations.
49
+ *
50
+ * @param endpoint - The API endpoint to call (should start with /)
51
+ * @param options - Request options (method, body, headers, etc.)
52
+ * @returns Promise resolving to the response data
53
+ * @throws {APIError} When access token is not set or API request fails
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * // GET request
58
+ * const data = await this.makeAuthenticatedRequest<UserProfile>('/api/v1/profile');
59
+ *
60
+ * // POST request
61
+ * const result = await this.makeAuthenticatedRequest<CreateOrderResponse>(
62
+ * '/api/v1/orders',
63
+ * {
64
+ * method: 'POST',
65
+ * body: JSON.stringify({ trading_pair: 'ETH-USD', side: 'BUY' })
66
+ * }
67
+ * );
68
+ * ```
69
+ */
70
+ protected makeAuthenticatedRequest<T>(endpoint: string, options?: RequestInit): Promise<T>;
71
+ /**
72
+ * Makes an unauthenticated API request.
73
+ *
74
+ * This method is useful for endpoints that don't require authentication,
75
+ * such as public data endpoints or authentication endpoints themselves.
76
+ *
77
+ * @param endpoint - The API endpoint to call (should start with /)
78
+ * @param options - Request options (method, body, headers, etc.)
79
+ * @returns Promise resolving to the response data
80
+ * @throws {APIError} When API request fails
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * // Public endpoint
85
+ * const data = await this.makePublicRequest<PublicData>('/api/v1/public/markets');
86
+ *
87
+ * // Authentication endpoint
88
+ * const challenge = await this.makePublicRequest<ChallengeResponse>(
89
+ * '/api/v1/auth/challenge',
90
+ * {
91
+ * method: 'POST',
92
+ * body: JSON.stringify({ address, client_id: clientId })
93
+ * }
94
+ * );
95
+ * ```
96
+ */
97
+ protected makePublicRequest<T>(endpoint: string, options?: RequestInit): Promise<T>;
98
+ }
99
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/api/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,8BAAsB,OAAO;IAQhB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM;IAP7C,SAAS,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE/B;;;;OAIG;gBAC4B,MAAM,EAAE,MAAM;IAE7C;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAInC;;;;OAIG;IACH,SAAS,CAAC,cAAc,IAAI,MAAM,GAAG,SAAS;IAI9C;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;cACa,wBAAwB,CAAC,CAAC,EACzC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,WAAgB,GACvB,OAAO,CAAC,CAAC,CAAC;IA6Bb;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;cACa,iBAAiB,CAAC,CAAC,EAClC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,WAAgB,GACvB,OAAO,CAAC,CAAC,CAAC;CAmBb"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Base API Implementation
3
+ *
4
+ * Provides common functionality for all API classes including access token management,
5
+ * authenticated request handling, and standardized error responses.
6
+ *
7
+ * This base class eliminates code duplication across API implementations and provides
8
+ * a consistent interface for token-based authentication and HTTP request handling.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * class MyAPIImpl extends BaseAPI implements MyAPI {
13
+ * constructor(apiUrl: string) {
14
+ * super(apiUrl);
15
+ * }
16
+ *
17
+ * async getData(): Promise<any> {
18
+ * return this.makeAuthenticatedRequest<any>('/api/v1/data');
19
+ * }
20
+ * }
21
+ * ```
22
+ */
23
+ import { APIError } from "../errors";
24
+ export class BaseAPI {
25
+ /**
26
+ * Creates a new BaseAPI instance.
27
+ *
28
+ * @param apiUrl - The base URL for the Monaco API Gateway
29
+ */
30
+ constructor(apiUrl) {
31
+ this.apiUrl = apiUrl;
32
+ }
33
+ /**
34
+ * Set the access token for authenticated requests.
35
+ *
36
+ * @param token - JWT access token
37
+ */
38
+ setAccessToken(token) {
39
+ this.accessToken = token;
40
+ }
41
+ /**
42
+ * Get the current access token.
43
+ *
44
+ * @returns The current access token or undefined if not set
45
+ */
46
+ getAccessToken() {
47
+ return this.accessToken;
48
+ }
49
+ /**
50
+ * Makes an authenticated API request with automatic token handling.
51
+ *
52
+ * This method automatically includes the Authorization header with the Bearer token
53
+ * and provides consistent error handling across all API operations.
54
+ *
55
+ * @param endpoint - The API endpoint to call (should start with /)
56
+ * @param options - Request options (method, body, headers, etc.)
57
+ * @returns Promise resolving to the response data
58
+ * @throws {APIError} When access token is not set or API request fails
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * // GET request
63
+ * const data = await this.makeAuthenticatedRequest<UserProfile>('/api/v1/profile');
64
+ *
65
+ * // POST request
66
+ * const result = await this.makeAuthenticatedRequest<CreateOrderResponse>(
67
+ * '/api/v1/orders',
68
+ * {
69
+ * method: 'POST',
70
+ * body: JSON.stringify({ trading_pair: 'ETH-USD', side: 'BUY' })
71
+ * }
72
+ * );
73
+ * ```
74
+ */
75
+ async makeAuthenticatedRequest(endpoint, options = {}) {
76
+ if (!this.accessToken) {
77
+ throw new APIError("Access token not set. Call setAccessToken() first.", `${this.apiUrl}${endpoint}`, 401);
78
+ }
79
+ const response = await fetch(`${this.apiUrl}${endpoint}`, {
80
+ headers: {
81
+ "Content-Type": "application/json",
82
+ Authorization: `Bearer ${this.accessToken}`,
83
+ ...options.headers,
84
+ },
85
+ ...options,
86
+ });
87
+ if (!response.ok) {
88
+ throw new APIError(`API request failed: ${response.status}`, `${this.apiUrl}${endpoint}`, response.status);
89
+ }
90
+ return response.json();
91
+ }
92
+ /**
93
+ * Makes an unauthenticated API request.
94
+ *
95
+ * This method is useful for endpoints that don't require authentication,
96
+ * such as public data endpoints or authentication endpoints themselves.
97
+ *
98
+ * @param endpoint - The API endpoint to call (should start with /)
99
+ * @param options - Request options (method, body, headers, etc.)
100
+ * @returns Promise resolving to the response data
101
+ * @throws {APIError} When API request fails
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * // Public endpoint
106
+ * const data = await this.makePublicRequest<PublicData>('/api/v1/public/markets');
107
+ *
108
+ * // Authentication endpoint
109
+ * const challenge = await this.makePublicRequest<ChallengeResponse>(
110
+ * '/api/v1/auth/challenge',
111
+ * {
112
+ * method: 'POST',
113
+ * body: JSON.stringify({ address, client_id: clientId })
114
+ * }
115
+ * );
116
+ * ```
117
+ */
118
+ async makePublicRequest(endpoint, options = {}) {
119
+ const response = await fetch(`${this.apiUrl}${endpoint}`, {
120
+ headers: {
121
+ "Content-Type": "application/json",
122
+ ...options.headers,
123
+ },
124
+ ...options,
125
+ });
126
+ if (!response.ok) {
127
+ throw new APIError(`API request failed: ${response.status}`, `${this.apiUrl}${endpoint}`, response.status);
128
+ }
129
+ return response.json();
130
+ }
131
+ }
132
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/api/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,OAAgB,OAAO;IAG5B;;;;OAIG;IACH,YAA+B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAEjD;;;;OAIG;IACH,cAAc,CAAC,KAAa;QAC3B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACO,cAAc;QACvB,OAAO,IAAI,CAAC,WAAW,CAAC;IACzB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACO,KAAK,CAAC,wBAAwB,CACvC,QAAgB,EAChB,UAAuB,EAAE;QAEzB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACvB,MAAM,IA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
3
3
  *
4
4
  * This module exports the new simplified APIs for the Monaco SDK.
5
5
  */
6
+ export * from "./base";
6
7
  export * from "./vault";
7
8
  export * from "./trading";
9
+ export * from "./profile";
8
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
package/dist/api/index.js CHANGED
@@ -3,6 +3,8 @@
3
3
  *
4
4
  * This module exports the new simplified APIs for the Monaco SDK.
5
5
  */
6
+ export * from "./base";
6
7
  export * from "./vault";
7
8
  export * from "./trading";
9
+ export * from "./profile";
8
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Profile API Implementation
3
+ *
4
+ * Handles user profile operations including fetching profile information.
5
+ * All operations use JWT authentication and go through the API Gateway.
6
+ *
7
+ * This class provides a complete interface for profile operations on the Monaco protocol,
8
+ * including fetching user profile data from the /api/v1/accounts/me endpoint.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const profileAPI = new ProfileAPIImpl(apiUrl);
13
+ * profileAPI.setAccessToken(jwtToken);
14
+ *
15
+ * // Get user profile
16
+ * const profile = await profileAPI.getProfile();
17
+ * console.log(`User: ${profile.username} (${profile.address})`);
18
+ * ```
19
+ */
20
+ import type { ProfileAPI, UserProfile } from "@0xmonaco/types";
21
+ import { BaseAPI } from "../base";
22
+ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
23
+ /**
24
+ * Creates a new ProfileAPI instance.
25
+ *
26
+ * @param apiUrl - The base URL for the Monaco API Gateway
27
+ */
28
+ constructor(apiUrl: string);
29
+ /**
30
+ * Get the current user's profile information.
31
+ *
32
+ * Fetches the profile data for the authenticated user using the /api/v1/accounts/me endpoint.
33
+ * Requires a valid access token to be set.
34
+ *
35
+ * @returns Promise resolving to the user's profile information
36
+ * @throws {APIError} When the request fails or user is not authenticated
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * // Set access token first
41
+ * profileAPI.setAccessToken(authResult.accessToken);
42
+ *
43
+ * // Get profile
44
+ * const profile = await profileAPI.getProfile();
45
+ * console.log(`User ID: ${profile.id}`);
46
+ * console.log(`Address: ${profile.address}`);
47
+ * console.log(`Username: ${profile.username}`);
48
+ * console.log(`Account type: ${profile.account_type}`);
49
+ * console.log(`Can withdraw: ${profile.can_withdraw}`);
50
+ * ```
51
+ */
52
+ getProfile(): Promise<UserProfile>;
53
+ }
54
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/api/profile/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,qBAAa,cAAe,SAAQ,OAAQ,YAAW,UAAU;IAChE;;;;OAIG;gBACS,MAAM,EAAE,MAAM;IAI1B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,UAAU,IAAI,OAAO,CAAC,WAAW,CAAC;CA0BxC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Profile API Implementation
3
+ *
4
+ * Handles user profile operations including fetching profile information.
5
+ * All operations use JWT authentication and go through the API Gateway.
6
+ *
7
+ * This class provides a complete interface for profile operations on the Monaco protocol,
8
+ * including fetching user profile data from the /api/v1/accounts/me endpoint.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const profileAPI = new ProfileAPIImpl(apiUrl);
13
+ * profileAPI.setAccessToken(jwtToken);
14
+ *
15
+ * // Get user profile
16
+ * const profile = await profileAPI.getProfile();
17
+ * console.log(`User: ${profile.username} (${profile.address})`);
18
+ * ```
19
+ */
20
+ import { APIError } from "../../errors";
21
+ import { BaseAPI } from "../base";
22
+ export class ProfileAPIImpl extends BaseAPI {
23
+ /**
24
+ * Creates a new ProfileAPI instance.
25
+ *
26
+ * @param apiUrl - The base URL for the Monaco API Gateway
27
+ */
28
+ constructor(apiUrl) {
29
+ super(apiUrl);
30
+ }
31
+ /**
32
+ * Get the current user's profile information.
33
+ *
34
+ * Fetches the profile data for the authenticated user using the /api/v1/accounts/me endpoint.
35
+ * Requires a valid access token to be set.
36
+ *
37
+ * @returns Promise resolving to the user's profile information
38
+ * @throws {APIError} When the request fails or user is not authenticated
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * // Set access token first
43
+ * profileAPI.setAccessToken(authResult.accessToken);
44
+ *
45
+ * // Get profile
46
+ * const profile = await profileAPI.getProfile();
47
+ * console.log(`User ID: ${profile.id}`);
48
+ * console.log(`Address: ${profile.address}`);
49
+ * console.log(`Username: ${profile.username}`);
50
+ * console.log(`Account type: ${profile.account_type}`);
51
+ * console.log(`Can withdraw: ${profile.can_withdraw}`);
52
+ * ```
53
+ */
54
+ async getProfile() {
55
+ try {
56
+ const data = await this.makeAuthenticatedRequest("/api/v1/accounts/me");
57
+ return {
58
+ id: data.id,
59
+ address: data.address,
60
+ username: data.username,
61
+ account_type: data.account_type,
62
+ can_withdraw: data.can_withdraw,
63
+ created_at: data.created_at,
64
+ balances: data.balances || [],
65
+ recent_movements: data.recent_movements || [],
66
+ recent_orders: data.recent_orders || [],
67
+ };
68
+ }
69
+ catch (error) {
70
+ if (error instanceof APIError) {
71
+ throw error;
72
+ }
73
+ throw new APIError("Failed to fetch user profile", "/api/v1/accounts/me", undefined);
74
+ }
75
+ }
76
+ }
77
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/api/profile/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,MAAM,OAAO,cAAe,SAAQ,OAAO;IAC1C;;;;OAIG;IACH,YAAY,MAAc;QACzB,KAAK,CAAC,MAAM,CAAC,CAAC;IACf,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,KAAK,CAAC,UAAU;QACf,IAAI,CAAC;YACJ,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,wBAAwB,CAAM,qBAAqB,CAAC,CAAC;YAE7E,OAAO;gBACN,EAAE,EAAE,IAAI,CAAC,EAAE;gBACX,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE;gBAC7B,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,IAAI,EAAE;gBAC7C,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,EAAE;aACvC,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;gBAC/B,MAAM,KAAK,CAAC;YACb,CAAC;YACD,MAAM,IAAI,QAAQ,CACjB,8BAA8B,EAC9B,qBAAqB,EACrB,SAAS,CACT,CAAC;QACH,CAAC;IACF,CAAC;CACD"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Profile API Module
3
+ *
4
+ * Exports the ProfileAPI implementation for user profile operations.
5
+ */
6
+ export * from "./api";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/profile/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,OAAO,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Profile API Module
3
+ *
4
+ * Exports the ProfileAPI implementation for user profile operations.
5
+ */
6
+ export * from "./api";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/profile/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,OAAO,CAAC"}
@@ -24,30 +24,15 @@
24
24
  * const openOrders = await tradingAPI.getOpenOrders({ market: "ETH-USD" });
25
25
  * ```
26
26
  */
27
- import type { TradingAPI, CreateOrderResponse, CancelOrderResponse, UpdateOrderResponse, OrderSide } from "@0xmonaco/types";
28
- export declare class TradingAPIImpl implements TradingAPI {
29
- private readonly apiUrl;
30
- private accessToken?;
27
+ import type { TradingAPI, CreateOrderResponse, CancelOrderResponse, UpdateOrderResponse, ReplaceOrderResponse, GetPaginatedOrdersResponse, GetPaginatedOrdersParams, GetOrderResponse, OrderSide } from "@0xmonaco/types";
28
+ import { BaseAPI } from "../base";
29
+ export declare class TradingAPIImpl extends BaseAPI implements TradingAPI {
31
30
  /**
32
31
  * Creates a new TradingAPI instance.
33
32
  *
34
33
  * @param apiUrl - The base URL for the Monaco API Gateway
35
34
  */
36
35
  constructor(apiUrl: string);
37
- /**
38
- * Set the access token for the TradingAPI
39
- * @param token - The access token to set
40
- */
41
- setAccessToken(token: string): void;
42
- /**
43
- * Internal method to make authenticated API requests.
44
- *
45
- * @param endpoint - The API endpoint to call
46
- * @param options - Request options
47
- * @returns Promise resolving to the response data
48
- * @throws {APIError} When API communication fails
49
- */
50
- private makeRequest;
51
36
  /**
52
37
  * Places a limit order on the order book.
53
38
  *
@@ -148,5 +133,59 @@ export declare class TradingAPIImpl implements TradingAPI {
148
133
  price?: string;
149
134
  quantity?: string;
150
135
  }): Promise<UpdateOrderResponse>;
136
+ replaceOrder(orderId: string, newOrder: {
137
+ price?: string;
138
+ quantity: string;
139
+ useMasterBalance?: boolean;
140
+ }): Promise<ReplaceOrderResponse>;
141
+ /**
142
+ * Gets paginated orders based on query parameters with automatic pagination.
143
+ *
144
+ * Retrieves orders with optional filtering by status, trading pair, and pagination.
145
+ * Pagination parameters are always included with sensible defaults for consistent API behavior.
146
+ *
147
+ * @param params - Query parameters for filtering orders
148
+ * @param params.status - Filter by order status (e.g., "PENDING", "FILLED") (optional)
149
+ * @param params.trading_pair - Filter by trading pair (e.g., "USDCo/MTK") (optional)
150
+ * @param params.page - Page number for pagination (defaults to 1, must be > 0)
151
+ * @param params.page_size - Number of orders per page (defaults to 10, max 100, must be > 0)
152
+ * @returns Promise resolving to GetPaginatedOrdersResponse with orders and pagination info
153
+ * @throws {APIError} When API communication fails
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * // Get pending orders for a specific trading pair with custom pagination
158
+ * const orders = await tradingAPI.getPaginatedOrders({
159
+ * status: "PENDING",
160
+ * trading_pair: "USDCo/MTK",
161
+ * page: 1,
162
+ * page_size: 20
163
+ * });
164
+ * console.log(`Found ${orders.total} orders, showing page ${orders.page}`);
165
+ *
166
+ * // Get all orders with default pagination (page=1, page_size=10)
167
+ * const allOrders = await tradingAPI.getPaginatedOrders();
168
+ * ```
169
+ */
170
+ getPaginatedOrders(params?: GetPaginatedOrdersParams): Promise<GetPaginatedOrdersResponse>;
171
+ /**
172
+ * Gets a single order by its ID.
173
+ *
174
+ * Retrieves detailed information about a specific order using its unique identifier.
175
+ * This endpoint provides complete order details including status, quantities, and timestamps.
176
+ *
177
+ * @param orderId - The unique identifier of the order to retrieve
178
+ * @returns Promise resolving to GetOrderResponse with order details
179
+ * @throws {APIError} When API communication fails or order is not found
180
+ *
181
+ * @example
182
+ * ```typescript
183
+ * // Get order details by ID
184
+ * const orderDetails = await tradingAPI.getOrder("order_123");
185
+ * console.log(`Order status: ${orderDetails.order.status}`);
186
+ * console.log(`Remaining quantity: ${orderDetails.order.remaining_quantity}`);
187
+ * ```
188
+ */
189
+ getOrder(orderId: string): Promise<GetOrderResponse>;
151
190
  }
152
191
  //# sourceMappingURL=api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/api/trading/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,SAAS,EAEV,MAAM,iBAAiB,CAAC;AAGzB,qBAAa,cAAe,YAAW,UAAU;IAQnC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAPnC,OAAO,CAAC,WAAW,CAAC,CAAS;IAE7B;;;;OAIG;gBAC0B,MAAM,EAAE,MAAM;IAE3C;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAInC;;;;;;;OAOG;YACW,WAAW;IAgCzB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,eAAe,CACnB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE;QACR,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,GACA,OAAO,CAAC,mBAAmB,CAAC;IA2B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