@0xmonaco/types 0.0.0-develop-20260120180031
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 +391 -0
- package/dist/api/index.d.ts +19 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +8 -0
- package/dist/api/index.js.map +1 -0
- package/dist/applications/index.d.ts +24 -0
- package/dist/applications/index.d.ts.map +1 -0
- package/dist/applications/index.js +7 -0
- package/dist/applications/index.js.map +1 -0
- package/dist/applications/responses.d.ts +21 -0
- package/dist/applications/responses.d.ts.map +1 -0
- package/dist/applications/responses.js +7 -0
- package/dist/applications/responses.js.map +1 -0
- package/dist/auth/index.d.ts +76 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +8 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/responses.d.ts +68 -0
- package/dist/auth/responses.d.ts.map +1 -0
- package/dist/auth/responses.js +7 -0
- package/dist/auth/responses.js.map +1 -0
- package/dist/contracts/balances.d.ts +44 -0
- package/dist/contracts/balances.d.ts.map +1 -0
- package/dist/contracts/balances.js +7 -0
- package/dist/contracts/balances.js.map +1 -0
- package/dist/contracts/index.d.ts +28 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +7 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/fees/index.d.ts +40 -0
- package/dist/fees/index.d.ts.map +1 -0
- package/dist/fees/index.js +7 -0
- package/dist/fees/index.js.map +1 -0
- package/dist/fees/responses.d.ts +47 -0
- package/dist/fees/responses.d.ts.map +1 -0
- package/dist/fees/responses.js +62 -0
- package/dist/fees/responses.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/market/index.d.ts +224 -0
- package/dist/market/index.d.ts.map +1 -0
- package/dist/market/index.js +7 -0
- package/dist/market/index.js.map +1 -0
- package/dist/profile/index.d.ts +228 -0
- package/dist/profile/index.d.ts.map +1 -0
- package/dist/profile/index.js +7 -0
- package/dist/profile/index.js.map +1 -0
- package/dist/sdk/index.d.ts +122 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/index.js +2 -0
- package/dist/sdk/index.js.map +1 -0
- package/dist/sdk/network.d.ts +31 -0
- package/dist/sdk/network.d.ts.map +1 -0
- package/dist/sdk/network.js +7 -0
- package/dist/sdk/network.js.map +1 -0
- package/dist/trading/index.d.ts +88 -0
- package/dist/trading/index.d.ts.map +1 -0
- package/dist/trading/index.js +7 -0
- package/dist/trading/index.js.map +1 -0
- package/dist/trading/orders.d.ts +108 -0
- package/dist/trading/orders.d.ts.map +1 -0
- package/dist/trading/orders.js +7 -0
- package/dist/trading/orders.js.map +1 -0
- package/dist/trading/responses.d.ts +130 -0
- package/dist/trading/responses.d.ts.map +1 -0
- package/dist/trading/responses.js +7 -0
- package/dist/trading/responses.js.map +1 -0
- package/dist/validation/common.d.ts +181 -0
- package/dist/validation/common.d.ts.map +1 -0
- package/dist/validation/common.js +196 -0
- package/dist/validation/common.js.map +1 -0
- package/dist/validation/index.d.ts +20 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +22 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/market.d.ts +215 -0
- package/dist/validation/market.d.ts.map +1 -0
- package/dist/validation/market.js +226 -0
- package/dist/validation/market.js.map +1 -0
- package/dist/validation/trading.d.ts +148 -0
- package/dist/validation/trading.d.ts.map +1 -0
- package/dist/validation/trading.js +139 -0
- package/dist/validation/trading.js.map +1 -0
- package/dist/validation/vault.d.ts +62 -0
- package/dist/validation/vault.d.ts.map +1 -0
- package/dist/validation/vault.js +75 -0
- package/dist/validation/vault.js.map +1 -0
- package/dist/vault/index.d.ts +64 -0
- package/dist/vault/index.d.ts.map +1 -0
- package/dist/vault/index.js +7 -0
- package/dist/vault/index.js.map +1 -0
- package/dist/vault/responses.d.ts +34 -0
- package/dist/vault/responses.d.ts.map +1 -0
- package/dist/vault/responses.js +7 -0
- package/dist/vault/responses.js.map +1 -0
- package/dist/websocket/base.d.ts +32 -0
- package/dist/websocket/base.d.ts.map +1 -0
- package/dist/websocket/base.js +7 -0
- package/dist/websocket/base.js.map +1 -0
- package/dist/websocket/clients/orderbook-client.d.ts +15 -0
- package/dist/websocket/clients/orderbook-client.d.ts.map +1 -0
- package/dist/websocket/clients/orderbook-client.js +5 -0
- package/dist/websocket/clients/orderbook-client.js.map +1 -0
- package/dist/websocket/events/index.d.ts +6 -0
- package/dist/websocket/events/index.d.ts.map +1 -0
- package/dist/websocket/events/index.js +6 -0
- package/dist/websocket/events/index.js.map +1 -0
- package/dist/websocket/events/movement-events.d.ts +53 -0
- package/dist/websocket/events/movement-events.d.ts.map +1 -0
- package/dist/websocket/events/movement-events.js +8 -0
- package/dist/websocket/events/movement-events.js.map +1 -0
- package/dist/websocket/events/ohlcv-events.d.ts +32 -0
- package/dist/websocket/events/ohlcv-events.d.ts.map +1 -0
- package/dist/websocket/events/ohlcv-events.js +7 -0
- package/dist/websocket/events/ohlcv-events.js.map +1 -0
- package/dist/websocket/events/orderbook-events.d.ts +73 -0
- package/dist/websocket/events/orderbook-events.d.ts.map +1 -0
- package/dist/websocket/events/orderbook-events.js +7 -0
- package/dist/websocket/events/orderbook-events.js.map +1 -0
- package/dist/websocket/events/orders-events.d.ts +285 -0
- package/dist/websocket/events/orders-events.d.ts.map +1 -0
- package/dist/websocket/events/orders-events.js +2 -0
- package/dist/websocket/events/orders-events.js.map +1 -0
- package/dist/websocket/events/trade-events.d.ts +35 -0
- package/dist/websocket/events/trade-events.d.ts.map +1 -0
- package/dist/websocket/events/trade-events.js +7 -0
- package/dist/websocket/events/trade-events.js.map +1 -0
- package/dist/websocket/index.d.ts +9 -0
- package/dist/websocket/index.d.ts.map +1 -0
- package/dist/websocket/index.js +9 -0
- package/dist/websocket/index.js.map +1 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
# @0xmonaco/types
|
|
2
|
+
|
|
3
|
+
Core type definitions for the Monaco protocol. This package provides TypeScript types and interfaces used throughout the Monaco ecosystem, focusing on SDK configuration, vault operations, trading operations, market data, and contract management.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @0xmonaco/types
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
**Note:** This package is typically installed as a dependency of `@0xmonaco/core` or `@0xmonaco/react`, but you can install it directly for type definitions in your TypeScript project.
|
|
12
|
+
|
|
13
|
+
## Type Categories
|
|
14
|
+
|
|
15
|
+
### SDK Types
|
|
16
|
+
|
|
17
|
+
Core SDK configuration and main interface types:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { MonacoSDK, SDKConfig } from "@0xmonaco/types";
|
|
21
|
+
|
|
22
|
+
// SDK configuration
|
|
23
|
+
interface SDKConfig {
|
|
24
|
+
walletClient: WalletClient; // Wallet client for signing operations
|
|
25
|
+
network?: Network; // Network override (defaults to 'mainnet')
|
|
26
|
+
transport?: Transport; // Optional transport for the public client
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Main SDK interface
|
|
30
|
+
interface MonacoSDK {
|
|
31
|
+
applications: ApplicationsAPI; // Applications operations API
|
|
32
|
+
auth: AuthAPI; // Auth operations API
|
|
33
|
+
vault: VaultAPI; // Vault operations API
|
|
34
|
+
trading: TradingAPI; // Trading operations API
|
|
35
|
+
market: MarketAPI; // Market metadata API
|
|
36
|
+
profile: ProfileAPI; // Profile operations API
|
|
37
|
+
websocket: {
|
|
38
|
+
orders: OrdersWebSocketClient; // WebSocket client for real-time order events
|
|
39
|
+
ohlcv: OHLCVWebSocketClient; // WebSocket client for real-time OHLCV data
|
|
40
|
+
orderbook: OrderbookWebSocketClient; // WebSocket client for real-time orderbook updates
|
|
41
|
+
};
|
|
42
|
+
walletClient: WalletClient; // Wallet client for blockchain operations
|
|
43
|
+
publicClient: PublicClient; // Public client for read-only operations
|
|
44
|
+
|
|
45
|
+
// Authentication
|
|
46
|
+
login(clientId: string, options?: { connectWebSocket?: boolean }): Promise<AuthState>;
|
|
47
|
+
logout(): Promise<void>;
|
|
48
|
+
refreshAuth(): Promise<AuthState>;
|
|
49
|
+
getAuthState(): AuthState | undefined;
|
|
50
|
+
|
|
51
|
+
// Account management
|
|
52
|
+
isAuthenticated(): boolean;
|
|
53
|
+
isConnected(): boolean;
|
|
54
|
+
getAccountAddress(): string;
|
|
55
|
+
getNetwork(): Network;
|
|
56
|
+
getChainId(): number;
|
|
57
|
+
waitForTransaction(
|
|
58
|
+
hash: string,
|
|
59
|
+
confirmations?: number,
|
|
60
|
+
timeout?: number
|
|
61
|
+
): Promise<TransactionReceipt>;
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Vault Types
|
|
66
|
+
|
|
67
|
+
Types for vault operations including deposits, withdrawals, and balance management:
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { VaultAPI, Balance, TransactionResult } from "@0xmonaco/types";
|
|
71
|
+
|
|
72
|
+
// Vault operations
|
|
73
|
+
interface VaultAPI extends BaseAPI {
|
|
74
|
+
approve(
|
|
75
|
+
assetId: string,
|
|
76
|
+
amount: bigint,
|
|
77
|
+
autoWait?: boolean
|
|
78
|
+
): Promise<TransactionResult>;
|
|
79
|
+
deposit(
|
|
80
|
+
assetId: string,
|
|
81
|
+
amount: bigint,
|
|
82
|
+
autoWait?: boolean
|
|
83
|
+
): Promise<TransactionResult>;
|
|
84
|
+
withdraw(
|
|
85
|
+
assetId: string,
|
|
86
|
+
amount: bigint,
|
|
87
|
+
autoWait?: boolean
|
|
88
|
+
): Promise<TransactionResult>;
|
|
89
|
+
getBalance(assetId: string): Promise<Balance>;
|
|
90
|
+
getAllowance(assetId: string): Promise<bigint>;
|
|
91
|
+
needsApproval(assetId: string, amount: bigint): Promise<boolean>;
|
|
92
|
+
getVaultAddress(): Promise<string>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Vault response types
|
|
96
|
+
interface Balance {
|
|
97
|
+
token: string;
|
|
98
|
+
amount: bigint;
|
|
99
|
+
formatted: string;
|
|
100
|
+
symbol: string;
|
|
101
|
+
decimals: number;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
interface TransactionResult {
|
|
105
|
+
hash: string;
|
|
106
|
+
status: "pending" | "confirmed" | "failed";
|
|
107
|
+
nonce: bigint;
|
|
108
|
+
receipt?: TransactionReceipt;
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Trading Types
|
|
113
|
+
|
|
114
|
+
Types for trading operations including order placement and management:
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import {
|
|
118
|
+
TradingAPI,
|
|
119
|
+
OrderSide,
|
|
120
|
+
OrderType,
|
|
121
|
+
CreateOrderResponse,
|
|
122
|
+
CancelOrderResponse,
|
|
123
|
+
ReplaceOrderResponse,
|
|
124
|
+
GetPaginatedOrdersResponse,
|
|
125
|
+
GetOrderResponse,
|
|
126
|
+
} from "@0xmonaco/types";
|
|
127
|
+
|
|
128
|
+
// Trading operations
|
|
129
|
+
interface TradingAPI extends BaseAPI {
|
|
130
|
+
placeLimitOrder(
|
|
131
|
+
market: string,
|
|
132
|
+
side: OrderSide,
|
|
133
|
+
quantity: string,
|
|
134
|
+
price: string,
|
|
135
|
+
options?: {
|
|
136
|
+
tradingMode?: string;
|
|
137
|
+
useMasterBalance?: boolean;
|
|
138
|
+
expirationDate?: string;
|
|
139
|
+
timeInForce?: string; // "GTC", "IOC", or "FOK"
|
|
140
|
+
}
|
|
141
|
+
): Promise<CreateOrderResponse>;
|
|
142
|
+
|
|
143
|
+
placeMarketOrder(
|
|
144
|
+
market: string,
|
|
145
|
+
side: OrderSide,
|
|
146
|
+
quantity: string,
|
|
147
|
+
options?: {
|
|
148
|
+
tradingMode?: string;
|
|
149
|
+
slippageTolerance?: number;
|
|
150
|
+
timeInForce?: string; // "GTC", "IOC", or "FOK"
|
|
151
|
+
}
|
|
152
|
+
): Promise<CreateOrderResponse>;
|
|
153
|
+
|
|
154
|
+
cancelOrder(orderId: string): Promise<CancelOrderResponse>;
|
|
155
|
+
|
|
156
|
+
replaceOrder(
|
|
157
|
+
orderId: string,
|
|
158
|
+
newOrder: {
|
|
159
|
+
price?: string;
|
|
160
|
+
quantity: string;
|
|
161
|
+
useMasterBalance?: boolean;
|
|
162
|
+
}
|
|
163
|
+
): Promise<ReplaceOrderResponse>;
|
|
164
|
+
|
|
165
|
+
getPaginatedOrders(
|
|
166
|
+
params?: GetPaginatedOrdersParams
|
|
167
|
+
): Promise<GetPaginatedOrdersResponse>;
|
|
168
|
+
getOrder(orderId: string): Promise<GetOrderResponse>;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Trading types
|
|
172
|
+
type OrderSide = "BUY" | "SELL";
|
|
173
|
+
type OrderType = "LIMIT" | "MARKET";
|
|
174
|
+
type OrderStatus = "PENDING" | "FILLED" | "CANCELLED" | "REJECTED";
|
|
175
|
+
type TradingMode = "SPOT";
|
|
176
|
+
type TimeInForce = "GTC" | "IOC" | "FOK"; // GTC: Good Till Cancel, IOC: Immediate or Cancel, FOK: Fill or Kill
|
|
177
|
+
|
|
178
|
+
// Trading response types
|
|
179
|
+
interface CreateOrderResponse {
|
|
180
|
+
order_id: string;
|
|
181
|
+
status: "SUCCESS" | "FAILED";
|
|
182
|
+
match_result?: {
|
|
183
|
+
remaining_quantity: string;
|
|
184
|
+
status: string;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
interface CancelOrderResponse {
|
|
189
|
+
order_id: string;
|
|
190
|
+
status: "SUCCESS" | "FAILED";
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
interface ReplaceOrderResponse {
|
|
194
|
+
order_id: string;
|
|
195
|
+
status: "SUCCESS" | "FAILED";
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Market Types
|
|
200
|
+
|
|
201
|
+
Types for market data operations including trading pair metadata:
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
import {
|
|
205
|
+
MarketAPI,
|
|
206
|
+
TradingPair,
|
|
207
|
+
GetTradingPairsResponse,
|
|
208
|
+
GetTradingPairResponse,
|
|
209
|
+
} from "@0xmonaco/types";
|
|
210
|
+
|
|
211
|
+
// Market operations
|
|
212
|
+
interface MarketAPI extends BaseAPI {
|
|
213
|
+
getTradingPairs(): Promise<TradingPair[]>;
|
|
214
|
+
getTradingPairBySymbol(symbol: string): Promise<TradingPair | undefined>;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Market data types
|
|
218
|
+
interface TradingPair {
|
|
219
|
+
id: string;
|
|
220
|
+
symbol: string;
|
|
221
|
+
base_token: string;
|
|
222
|
+
quote_token: string;
|
|
223
|
+
base_token_contract: string;
|
|
224
|
+
quote_token_contract: string;
|
|
225
|
+
base_decimals: number;
|
|
226
|
+
quote_decimals: number;
|
|
227
|
+
market_type: string;
|
|
228
|
+
is_active: boolean;
|
|
229
|
+
maker_fee_bps: number;
|
|
230
|
+
taker_fee_bps: number;
|
|
231
|
+
min_order_size: string;
|
|
232
|
+
max_order_size: string;
|
|
233
|
+
tick_size: string;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Market response types
|
|
237
|
+
interface GetTradingPairsResponse {
|
|
238
|
+
data: {
|
|
239
|
+
data: TradingPair[];
|
|
240
|
+
limit: number;
|
|
241
|
+
page: number;
|
|
242
|
+
total: number;
|
|
243
|
+
total_pages: number;
|
|
244
|
+
};
|
|
245
|
+
success: boolean;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
interface GetTradingPairResponse {
|
|
249
|
+
data: TradingPair;
|
|
250
|
+
success: boolean;
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Contract Types
|
|
255
|
+
|
|
256
|
+
Types for contract addresses, instances, and contract-related operations:
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
import {
|
|
260
|
+
ContractAddresses,
|
|
261
|
+
ContractInstances,
|
|
262
|
+
Token,
|
|
263
|
+
UserBalance,
|
|
264
|
+
} from "@0xmonaco/types";
|
|
265
|
+
|
|
266
|
+
// Contract addresses
|
|
267
|
+
interface ContractAddresses {
|
|
268
|
+
VAULT: string; // Vault contract address for managing user balances
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Contract instances
|
|
272
|
+
type ContractInstances = {
|
|
273
|
+
vault: GetContractReturnType<typeof CONTRACT_ABIS.vault>;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
// Contract-related types
|
|
277
|
+
interface Token {
|
|
278
|
+
address: string;
|
|
279
|
+
decimals: number;
|
|
280
|
+
symbol: string;
|
|
281
|
+
name: string;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
interface UserBalance {
|
|
285
|
+
token: Token;
|
|
286
|
+
amount: bigint;
|
|
287
|
+
formatted: string;
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Network Types
|
|
292
|
+
|
|
293
|
+
Types for network configuration:
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
import { Network, NetworkEndpoints } from "@0xmonaco/types";
|
|
297
|
+
|
|
298
|
+
type Network = "mainnet" | "testnet";
|
|
299
|
+
|
|
300
|
+
interface NetworkEndpoints {
|
|
301
|
+
rpcUrl: string;
|
|
302
|
+
wsUrl?: string;
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## Type Reference
|
|
307
|
+
|
|
308
|
+
### SDK Types
|
|
309
|
+
|
|
310
|
+
- `MonacoSDK`: Main SDK interface with all API modules
|
|
311
|
+
- `SDKConfig`: Configuration options for the Monaco SDK
|
|
312
|
+
- `Network`: Network type ("mainnet" | "testnet")
|
|
313
|
+
- `AuthState`: Authentication state information
|
|
314
|
+
|
|
315
|
+
### Vault Types
|
|
316
|
+
|
|
317
|
+
- `VaultAPI`: Interface for vault operations (deposits, withdrawals, balances)
|
|
318
|
+
- `Balance`: Token balance information
|
|
319
|
+
- `TransactionResult`: Result of blockchain transactions
|
|
320
|
+
|
|
321
|
+
### Trading Types
|
|
322
|
+
|
|
323
|
+
- `TradingAPI`: Interface for trading operations (orders, positions)
|
|
324
|
+
- `OrderSide`: Order side type ("BUY" | "SELL")
|
|
325
|
+
- `OrderType`: Order type ("LIMIT" | "MARKET")
|
|
326
|
+
- `TimeInForce`: Time in force type ("GTC" | "IOC" | "FOK")
|
|
327
|
+
- `CreateOrderResponse`: Response from order placement
|
|
328
|
+
- `CancelOrderResponse`: Response from order cancellation
|
|
329
|
+
- `ReplaceOrderResponse`: Response from order replacement
|
|
330
|
+
|
|
331
|
+
### Market Types
|
|
332
|
+
|
|
333
|
+
- `MarketAPI`: Interface for market data operations
|
|
334
|
+
- `TradingPair`: Trading pair metadata with all market information
|
|
335
|
+
- `GetTradingPairsResponse`: Response wrapper for trading pairs list
|
|
336
|
+
- `GetTradingPairResponse`: Response wrapper for single trading pair
|
|
337
|
+
|
|
338
|
+
### Contract Types
|
|
339
|
+
|
|
340
|
+
- `ContractAddresses`: Contract address mappings
|
|
341
|
+
- `ContractInstances`: Typed contract instances
|
|
342
|
+
- `Token`: Token interface with metadata
|
|
343
|
+
- `UserBalance`: User's token balance information
|
|
344
|
+
|
|
345
|
+
## Project Structure
|
|
346
|
+
|
|
347
|
+
The types package is organized into domain-specific modules:
|
|
348
|
+
|
|
349
|
+
```
|
|
350
|
+
src/
|
|
351
|
+
├── api/ # Base API types
|
|
352
|
+
│ └── index.ts # Common API interfaces
|
|
353
|
+
├── applications/ # Applications types
|
|
354
|
+
├── auth/ # Authentication types
|
|
355
|
+
├── contracts/ # Contract types
|
|
356
|
+
│ ├── index.ts # Contract interfaces
|
|
357
|
+
│ └── balances.ts # Balance-related types
|
|
358
|
+
├── market/ # Market data types
|
|
359
|
+
│ └── index.ts # Market API interface and types
|
|
360
|
+
├── profile/ # Profile types
|
|
361
|
+
├── sdk/ # SDK types
|
|
362
|
+
│ ├── index.ts # Main SDK interfaces and configuration
|
|
363
|
+
│ └── network.ts # Network-related types
|
|
364
|
+
├── trading/ # Trading types
|
|
365
|
+
│ ├── index.ts # Trading API interface
|
|
366
|
+
│ ├── orders.ts # Order-related types
|
|
367
|
+
│ └── responses.ts # Trading response types
|
|
368
|
+
├── vault/ # Vault types
|
|
369
|
+
│ ├── index.ts # Vault API interface
|
|
370
|
+
│ └── responses.ts # Vault response types
|
|
371
|
+
├── websocket/ # WebSocket types
|
|
372
|
+
└── index.ts # Package exports
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
## Dependencies
|
|
376
|
+
|
|
377
|
+
This package uses `viem` for blockchain-related types:
|
|
378
|
+
|
|
379
|
+
- `Address`, `Hex`, `Account`, `WalletClient`, `PublicClient` from `viem`
|
|
380
|
+
- `GetContractReturnType` for contract instance typing
|
|
381
|
+
|
|
382
|
+
## Best Practices
|
|
383
|
+
|
|
384
|
+
- Keep types focused and single-purpose
|
|
385
|
+
- Use descriptive names that reflect the domain
|
|
386
|
+
- Document complex types with JSDoc comments
|
|
387
|
+
- Use TypeScript's strict mode
|
|
388
|
+
- Maintain backward compatibility
|
|
389
|
+
- Follow the established naming conventions
|
|
390
|
+
- Group related types in the same file
|
|
391
|
+
- Leverage `viem` types for blockchain operations rather than defining custom ones
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base API Types
|
|
3
|
+
*
|
|
4
|
+
* Common interface that all API implementations should inherit from.
|
|
5
|
+
* Provides standardized methods for token management and common functionality.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Base API interface that all API implementations should inherit from.
|
|
9
|
+
* Provides common functionality for access token management.
|
|
10
|
+
*/
|
|
11
|
+
export interface BaseAPI {
|
|
12
|
+
/**
|
|
13
|
+
* Set the access token for authenticated requests.
|
|
14
|
+
*
|
|
15
|
+
* @param token - JWT access token
|
|
16
|
+
*/
|
|
17
|
+
setAccessToken(token: string): void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applications Types
|
|
3
|
+
*
|
|
4
|
+
* Types for application configuration operations.
|
|
5
|
+
*/
|
|
6
|
+
import type { BaseAPI } from "../api";
|
|
7
|
+
import type { ApplicationConfigResponse } from "./responses";
|
|
8
|
+
/**
|
|
9
|
+
* Applications API interface.
|
|
10
|
+
* Provides methods for retrieving application configuration.
|
|
11
|
+
*/
|
|
12
|
+
export interface ApplicationsAPI extends BaseAPI {
|
|
13
|
+
/**
|
|
14
|
+
* Gets the configuration for the authenticated application.
|
|
15
|
+
*
|
|
16
|
+
* Returns the application's configuration including allowed origins,
|
|
17
|
+
* webhook URL, and other settings. Requires valid authentication.
|
|
18
|
+
*
|
|
19
|
+
* @returns Promise resolving to the application configuration
|
|
20
|
+
*/
|
|
21
|
+
getApplicationConfig(): Promise<ApplicationConfigResponse>;
|
|
22
|
+
}
|
|
23
|
+
export type { ApplicationConfigResponse } from "./responses";
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/applications/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAE7D;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,OAAO;IAC9C;;;;;;;OAOG;IACH,oBAAoB,IAAI,OAAO,CAAC,yBAAyB,CAAC,CAAC;CAC5D;AAGD,YAAY,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/applications/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applications Response Types
|
|
3
|
+
*
|
|
4
|
+
* Response types for application configuration operations.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Response to an application configuration request.
|
|
8
|
+
*/
|
|
9
|
+
export interface ApplicationConfigResponse {
|
|
10
|
+
/** Unique identifier for the application */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Human-readable name of the application */
|
|
13
|
+
name: string;
|
|
14
|
+
/** List of allowed origins for CORS */
|
|
15
|
+
allowedOrigins: string[];
|
|
16
|
+
/** Webhook URL for receiving events (optional) */
|
|
17
|
+
webhookUrl?: string;
|
|
18
|
+
/** Vault contract address */
|
|
19
|
+
vaultContractAddress: string;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=responses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/applications/responses.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,4CAA4C;IAC5C,EAAE,EAAE,MAAM,CAAC;IACX,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6BAA6B;IAC7B,oBAAoB,EAAE,MAAM,CAAC;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responses.js","sourceRoot":"","sources":["../../src/applications/responses.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth Types
|
|
3
|
+
*
|
|
4
|
+
* Types for authentication operations including challenge creation,
|
|
5
|
+
* signature verification, and backend authentication.
|
|
6
|
+
*/
|
|
7
|
+
import type { BaseAPI } from "../api";
|
|
8
|
+
import type { AuthState, BackendAuthResponse, ChallengeResponse, TokenRefreshResponse } from "./responses";
|
|
9
|
+
/**
|
|
10
|
+
* Auth API interface.
|
|
11
|
+
* Provides methods for frontend and backend authentication.
|
|
12
|
+
* Handles challenge creation, signature verification, and backend auth.
|
|
13
|
+
*/
|
|
14
|
+
export interface AuthAPI extends BaseAPI {
|
|
15
|
+
/**
|
|
16
|
+
* Complete authentication flow for frontend applications.
|
|
17
|
+
*
|
|
18
|
+
* This method handles the entire authentication process:
|
|
19
|
+
* 1. Creates a challenge
|
|
20
|
+
* 2. Signs the challenge message
|
|
21
|
+
* 3. Verifies the signature and returns JWT tokens
|
|
22
|
+
*
|
|
23
|
+
* @param clientId - Client ID of the application
|
|
24
|
+
* @returns Promise resolving to the authentication state with JWT tokens
|
|
25
|
+
*/
|
|
26
|
+
authenticate(clientId: string): Promise<AuthState>;
|
|
27
|
+
/**
|
|
28
|
+
* Signs a challenge message using the wallet client.
|
|
29
|
+
*
|
|
30
|
+
* Signs the provided message using the wallet's private key.
|
|
31
|
+
* This is used in the authentication flow to prove ownership of the wallet.
|
|
32
|
+
*
|
|
33
|
+
* @param message - The message to sign
|
|
34
|
+
* @returns Promise resolving to the signature
|
|
35
|
+
*/
|
|
36
|
+
signChallenge(message: string): Promise<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a challenge for frontend authentication.
|
|
39
|
+
* Generates a unique nonce and message that the user must sign with their wallet.
|
|
40
|
+
* @param address - Wallet address of the user
|
|
41
|
+
* @param clientId - Client ID of the application
|
|
42
|
+
* @returns Promise resolving to the challenge response
|
|
43
|
+
*/
|
|
44
|
+
createChallenge(address: string, clientId: string): Promise<ChallengeResponse>;
|
|
45
|
+
/**
|
|
46
|
+
* Verifies a signature for frontend authentication.
|
|
47
|
+
* Validates the signature against the challenge and returns JWT tokens.
|
|
48
|
+
* @param address - Wallet address of the user
|
|
49
|
+
* @param signature - Signature of the challenge message
|
|
50
|
+
* @param nonce - Nonce from the challenge response
|
|
51
|
+
* @param clientId - Client ID of the application
|
|
52
|
+
* @returns Promise resolving to the authentication state with JWT tokens
|
|
53
|
+
*/
|
|
54
|
+
verifySignature(address: string, signature: string, nonce: string, clientId: string): Promise<AuthState>;
|
|
55
|
+
/**
|
|
56
|
+
* Authenticates a backend service using a secret key.
|
|
57
|
+
* Returns JWT tokens for API access.
|
|
58
|
+
* @param secretKey - Secret key of the application
|
|
59
|
+
* @returns Promise resolving to the backend auth response with JWT tokens
|
|
60
|
+
*/
|
|
61
|
+
authenticateBackend(secretKey: string): Promise<BackendAuthResponse>;
|
|
62
|
+
/**
|
|
63
|
+
* Refreshes an access token using a refresh token.
|
|
64
|
+
* @param refreshToken - The refresh token to use
|
|
65
|
+
* @returns Promise resolving to new access and refresh tokens
|
|
66
|
+
*/
|
|
67
|
+
refreshToken(refreshToken: string): Promise<TokenRefreshResponse>;
|
|
68
|
+
/**
|
|
69
|
+
* Revokes a refresh token.
|
|
70
|
+
* @param refreshToken - The refresh token to revoke (from authResult.refreshToken)
|
|
71
|
+
* @returns Promise resolving when the token is revoked
|
|
72
|
+
*/
|
|
73
|
+
revokeToken(refreshToken: string): Promise<void>;
|
|
74
|
+
}
|
|
75
|
+
export type { ApplicationInfo, AuthState, BackendAuthResponse, ChallengeResponse, TokenRefreshResponse, User, } from "./responses";
|
|
76
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE3G;;;;GAIG;AACH,MAAM,WAAW,OAAQ,SAAQ,OAAO;IACtC;;;;;;;;;;OAUG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAEnD;;;;;;;;OAQG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEhD;;;;;;OAMG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAE/E;;;;;;;;OAQG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAEzG;;;;;OAKG;IACH,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAErE;;;;OAIG;IACH,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAElE;;;;OAIG;IACH,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClD;AAGD,YAAY,EACV,eAAe,EACf,SAAS,EACT,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,IAAI,GACL,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auth Response Types
|
|
3
|
+
*
|
|
4
|
+
* Response types for authentication operations.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Response to a challenge request.
|
|
8
|
+
*/
|
|
9
|
+
export interface ChallengeResponse {
|
|
10
|
+
/** Unique nonce for this challenge */
|
|
11
|
+
nonce: string;
|
|
12
|
+
/** Message to be signed by the user's wallet */
|
|
13
|
+
message: string;
|
|
14
|
+
/** Unix timestamp when the challenge expires */
|
|
15
|
+
expiresAt: number;
|
|
16
|
+
}
|
|
17
|
+
export interface User {
|
|
18
|
+
/** Unique identifier for the user */
|
|
19
|
+
id: string;
|
|
20
|
+
/** Wallet address of the user */
|
|
21
|
+
address: string;
|
|
22
|
+
/** Username of the user */
|
|
23
|
+
username?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Authentication state containing all tokens and metadata
|
|
27
|
+
*
|
|
28
|
+
* Returned by authentication methods and contains the tokens needed for API access.
|
|
29
|
+
*/
|
|
30
|
+
export interface AuthState {
|
|
31
|
+
/** JWT access token for authenticated requests */
|
|
32
|
+
accessToken: string;
|
|
33
|
+
/** JWT refresh token for token renewal and revocation */
|
|
34
|
+
refreshToken: string;
|
|
35
|
+
/** Unix timestamp (in seconds) when the access token expires */
|
|
36
|
+
expiresAt: number;
|
|
37
|
+
/** Information about the authenticated user */
|
|
38
|
+
user: User;
|
|
39
|
+
}
|
|
40
|
+
export interface ApplicationInfo {
|
|
41
|
+
/** Unique identifier for the application */
|
|
42
|
+
id: string;
|
|
43
|
+
/** Human-readable name of the application */
|
|
44
|
+
name: string;
|
|
45
|
+
/** Client ID for frontend authentication */
|
|
46
|
+
clientId: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Response to a backend authentication request.
|
|
50
|
+
*/
|
|
51
|
+
export interface BackendAuthResponse {
|
|
52
|
+
/** JWT access token for authenticated requests */
|
|
53
|
+
accessToken: string;
|
|
54
|
+
/** Unix timestamp when the access token expires */
|
|
55
|
+
expiresAt: number;
|
|
56
|
+
/** Information about the application */
|
|
57
|
+
application: ApplicationInfo;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Response to a token refresh request.
|
|
61
|
+
*/
|
|
62
|
+
export interface TokenRefreshResponse {
|
|
63
|
+
/** New JWT access token */
|
|
64
|
+
accessToken: string;
|
|
65
|
+
/** Unix timestamp when the access token expires */
|
|
66
|
+
expiresAt: number;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=responses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/auth/responses.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,IAAI;IACnB,qCAAqC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,YAAY,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,eAAe;IAC9B,4CAA4C;IAC5C,EAAE,EAAE,MAAM,CAAC;IACX,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,WAAW,EAAE,eAAe,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responses.js","sourceRoot":"","sources":["../../src/auth/responses.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|