@temple-digital-group/temple-canton-js 2.0.0-beta.7 → 2.0.0-beta.8

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 CHANGED
@@ -139,7 +139,6 @@ Use this to check available funds before placing orders or withdrawals.
139
139
  ```javascript
140
140
  import { createOrderRequest } from "@temple-digital-group/temple-canton-js";
141
141
 
142
- // Single order
143
142
  const result = await createOrderRequest({
144
143
  symbol: "CC/USDCx",
145
144
  side: "buy",
@@ -147,13 +146,6 @@ const result = await createOrderRequest({
147
146
  price: 1.25,
148
147
  order_type: "limit",
149
148
  });
150
-
151
- // Batch orders (max 20)
152
- const batchResult = await createOrderRequest([
153
- { symbol: "CC/USDCx", side: "buy", quantity: 100, price: 1.25, order_type: "limit" },
154
- { symbol: "CC/USDCx", side: "sell", quantity: 50, price: 1.50, order_type: "limit" },
155
- ]);
156
- // Returns { success, request_ids, count, message }
157
149
  ```
158
150
 
159
151
  ### 5. Cancel Orders
@@ -161,13 +153,9 @@ const batchResult = await createOrderRequest([
161
153
  ```javascript
162
154
  import { cancelOrder, cancelAllOrders } from "@temple-digital-group/temple-canton-js";
163
155
 
164
- // Cancel a single order
156
+ // Cancel a specific order
165
157
  await cancelOrder("ord_abc123");
166
158
 
167
- // Cancel multiple orders (max 20)
168
- await cancelOrder(["ord_abc123", "ord_def456", "ord_ghi789"]);
169
- // Returns { success, canceled, already_queued, not_found, message }
170
-
171
159
  // Cancel all orders for a symbol
172
160
  await cancelAllOrders({ symbol: "CC/USDCx" });
173
161
 
@@ -422,10 +410,8 @@ const unsubOrder = ws.onUserEvent("user_order", (data) => { ... });
422
410
 
423
411
  | Function | Description |
424
412
  | ----------------------------------- | ------------------------------------------------------ |
425
- | `createOrderRequest(opts)` | Place a single order |
426
- | `createOrderRequest(opts[])` | Place up to 20 orders in one request |
427
- | `cancelOrder(orderId)` | Cancel a single order |
428
- | `cancelOrder(orderIds[])` | Cancel up to 20 orders in one request |
413
+ | `createOrderRequest(opts)` | Place a buy/sell order via the trading backend |
414
+ | `cancelOrder(orderId)` | Cancel a specific order |
429
415
  | `cancelAllOrders(options?)` | Cancel all orders (options: `symbol` filter) |
430
416
  | `getTradingBalance()` | Get user's trading balance (unlocked/locked/in-flight) |
431
417
  | `getActiveOrders(options?)` | Get active orders (options: `symbol`, `limit`) |
@@ -1,5 +1,5 @@
1
- import type { ApiError, Ticker, OrderBook, OrderBookOptions, SymbolConfig, OpenInterest, Trade, RecentTradesOptions, ActiveOrder, ActiveOrdersOptions, CancelOrderResponse, BatchCancelOrdersResponse, CancelAllOrdersOptions, CancelAllOrdersResponse, CreateOrderRequestOpts, CreateOrderRequestResponse, BatchCreateOrderRequestResponse, DelegationResponse, WithdrawalResponse, WithdrawalStatusResponse, TradingBalanceResponse, AmuletDisclosure, DisclosuresResponse } from "./types.js";
2
- export type { ApiError, Ticker, OrderBook, OrderBookOptions, SymbolConfig, OpenInterest, Trade, RecentTradesOptions, ActiveOrder, ActiveOrdersOptions, CancelOrderResponse, BatchCancelOrdersResponse, CancelAllOrdersOptions, CancelAllOrdersResponse, CreateOrderRequestResponse, BatchCreateOrderRequestResponse, DelegationResponse, WithdrawalResponse, WithdrawalStatusResponse, TradingBalanceResponse, AmuletDisclosure, DisclosuresResponse, };
1
+ import type { ApiError, Ticker, OrderBook, OrderBookOptions, SymbolConfig, OpenInterest, Trade, RecentTradesOptions, ActiveOrder, ActiveOrdersOptions, CancelOrderResponse, CancelAllOrdersOptions, CancelAllOrdersResponse, CreateOrderRequestOpts, CreateOrderRequestResponse, DelegationResponse, WithdrawalResponse, WithdrawalStatusResponse, TradingBalanceResponse, AmuletDisclosure, DisclosuresResponse } from "./types.js";
2
+ export type { ApiError, Ticker, OrderBook, OrderBookOptions, SymbolConfig, OpenInterest, Trade, RecentTradesOptions, ActiveOrder, ActiveOrdersOptions, CancelOrderResponse, CancelAllOrdersOptions, CancelAllOrdersResponse, CreateOrderRequestResponse, DelegationResponse, WithdrawalResponse, WithdrawalStatusResponse, TradingBalanceResponse, AmuletDisclosure, DisclosuresResponse, };
3
3
  export { getUserId } from "./tokenStore.js";
4
4
  export { setWalletAdapter } from "../../src/config/index.js";
5
5
  /**
@@ -40,15 +40,10 @@ export declare function getRecentTrades(symbol: string, options?: RecentTradesOp
40
40
  */
41
41
  export declare function getActiveOrders(options?: ActiveOrdersOptions): Promise<ActiveOrder[] | ApiError>;
42
42
  /**
43
- * Cancel a single order by ID.
43
+ * Cancel a specific order by ID.
44
44
  * @param orderId - The order ID to cancel
45
45
  */
46
46
  export declare function cancelOrder(orderId: string): Promise<CancelOrderResponse | ApiError>;
47
- /**
48
- * Cancel multiple orders by ID (max 20).
49
- * @param orderIds - Array of order IDs to cancel
50
- */
51
- export declare function cancelOrder(orderIds: string[]): Promise<BatchCancelOrdersResponse | ApiError>;
52
47
  /**
53
48
  * Cancel all active orders, optionally filtered by symbol.
54
49
  * @param options - Optional symbol filter
@@ -66,10 +61,9 @@ export declare function getDisclosures(partyId: string): Promise<DisclosuresResp
66
61
  export declare function getDelegation(): Promise<DelegationResponse | ApiError>;
67
62
  /**
68
63
  * Create an order request (limit buy/sell) on the Temple trading backend.
69
- * @param opts - Single order or array of orders (max 20)
64
+ * @param opts - Order parameters: symbol, side, quantity, price, order_type, expires_at
70
65
  */
71
66
  export declare function createOrderRequest(opts: CreateOrderRequestOpts): Promise<CreateOrderRequestResponse | ApiError>;
72
- export declare function createOrderRequest(opts: CreateOrderRequestOpts[]): Promise<BatchCreateOrderRequestResponse | ApiError>;
73
67
  /**
74
68
  * Create a withdrawal request.
75
69
  * @param assetId - Instrument symbol (e.g. "USDCx", "Amulet")
package/dist/api/index.js CHANGED
@@ -154,20 +154,15 @@ export async function getActiveOrders(options = {}) {
154
154
  limit: options.limit,
155
155
  });
156
156
  }
157
- export async function cancelOrder(orderIdOrIds) {
158
- if (Array.isArray(orderIdOrIds)) {
159
- if (orderIdOrIds.length === 0) {
160
- return { error: true, status: null, code: "INVALID_PARAMS", message: "At least one order ID is required." };
161
- }
162
- if (orderIdOrIds.length > 20) {
163
- return { error: true, status: null, code: "INVALID_PARAMS", message: "Maximum 20 order IDs per batch." };
164
- }
165
- return authenticatedPost("/api/trading/orders/cancel", { order_ids: orderIdOrIds });
166
- }
167
- if (!orderIdOrIds) {
157
+ /**
158
+ * Cancel a specific order by ID.
159
+ * @param orderId - The order ID to cancel
160
+ */
161
+ export async function cancelOrder(orderId) {
162
+ if (!orderId) {
168
163
  return { error: true, status: null, code: "INVALID_PARAMS", message: "Order ID is required." };
169
164
  }
170
- return authenticatedPost("/api/trading/orders/cancel", { order_id: orderIdOrIds });
165
+ return authenticatedPost(`/api/trading/orders/${encodeURIComponent(orderId)}/cancel`);
171
166
  }
172
167
  /**
173
168
  * Cancel all active orders, optionally filtered by symbol.
@@ -195,23 +190,12 @@ export async function getDisclosures(partyId) {
195
190
  export async function getDelegation() {
196
191
  return authenticatedGet("/api/trading/delegation");
197
192
  }
193
+ // ── Order Requests ──
194
+ /**
195
+ * Create an order request (limit buy/sell) on the Temple trading backend.
196
+ * @param opts - Order parameters: symbol, side, quantity, price, order_type, expires_at
197
+ */
198
198
  export async function createOrderRequest(opts) {
199
- if (Array.isArray(opts)) {
200
- if (opts.length === 0) {
201
- return { error: true, status: null, code: "INVALID_PARAMS", message: "At least one order is required." };
202
- }
203
- if (opts.length > 20) {
204
- return { error: true, status: null, code: "INVALID_PARAMS", message: "Maximum 20 orders per batch." };
205
- }
206
- const body = opts.map((o) => {
207
- const { symbol: rawSymbol, side, quantity, price, order_type = "limit", expires_at } = o;
208
- const order = { symbol: normalizeSymbol(rawSymbol), side, quantity: Number(quantity), price: Number(price), order_type };
209
- if (expires_at)
210
- order.expires_at = expires_at;
211
- return order;
212
- });
213
- return authenticatedPost("/api/trading/orders", body);
214
- }
215
199
  const { symbol: rawSymbol, side, quantity, price, order_type = "limit", expires_at } = opts || {};
216
200
  if (!rawSymbol || !side || quantity == null || price == null) {
217
201
  return { error: true, status: null, code: "INVALID_PARAMS", message: "symbol, side, quantity, and price are required." };
@@ -72,13 +72,6 @@ export interface CancelOrderResponse {
72
72
  already_queued: boolean;
73
73
  message: string;
74
74
  }
75
- export interface BatchCancelOrdersResponse {
76
- success: boolean;
77
- canceled: string[];
78
- already_queued: string[];
79
- not_found: string[];
80
- message: string;
81
- }
82
75
  export interface CancelAllOrdersOptions {
83
76
  symbol?: string;
84
77
  }
@@ -105,12 +98,6 @@ export interface CreateOrderRequestOpts {
105
98
  order_type?: string;
106
99
  expires_at?: string;
107
100
  }
108
- export interface BatchCreateOrderRequestResponse {
109
- success: boolean;
110
- request_ids: number[];
111
- count: number;
112
- message: string;
113
- }
114
101
  export interface CreateOrderRequestResponse {
115
102
  [key: string]: unknown;
116
103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temple-digital-group/temple-canton-js",
3
- "version": "2.0.0-beta.7",
3
+ "version": "2.0.0-beta.8",
4
4
  "description": "JavaScript library for interacting with Temple Canton blockchain",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/src/api/index.ts CHANGED
@@ -16,12 +16,10 @@ import type {
16
16
  ActiveOrder,
17
17
  ActiveOrdersOptions,
18
18
  CancelOrderResponse,
19
- BatchCancelOrdersResponse,
20
19
  CancelAllOrdersOptions,
21
20
  CancelAllOrdersResponse,
22
21
  CreateOrderRequestOpts,
23
22
  CreateOrderRequestResponse,
24
- BatchCreateOrderRequestResponse,
25
23
  DelegationResponse,
26
24
  WithdrawalResponse,
27
25
  WithdrawalStatusResponse,
@@ -43,11 +41,9 @@ export type {
43
41
  ActiveOrder,
44
42
  ActiveOrdersOptions,
45
43
  CancelOrderResponse,
46
- BatchCancelOrdersResponse,
47
44
  CancelAllOrdersOptions,
48
45
  CancelAllOrdersResponse,
49
46
  CreateOrderRequestResponse,
50
- BatchCreateOrderRequestResponse,
51
47
  DelegationResponse,
52
48
  WithdrawalResponse,
53
49
  WithdrawalStatusResponse,
@@ -232,30 +228,14 @@ export async function getActiveOrders(options: ActiveOrdersOptions = {}): Promis
232
228
  }
233
229
 
234
230
  /**
235
- * Cancel a single order by ID.
231
+ * Cancel a specific order by ID.
236
232
  * @param orderId - The order ID to cancel
237
233
  */
238
- export async function cancelOrder(orderId: string): Promise<CancelOrderResponse | ApiError>;
239
- /**
240
- * Cancel multiple orders by ID (max 20).
241
- * @param orderIds - Array of order IDs to cancel
242
- */
243
- export async function cancelOrder(orderIds: string[]): Promise<BatchCancelOrdersResponse | ApiError>;
244
- export async function cancelOrder(orderIdOrIds: string | string[]): Promise<CancelOrderResponse | BatchCancelOrdersResponse | ApiError> {
245
- if (Array.isArray(orderIdOrIds)) {
246
- if (orderIdOrIds.length === 0) {
247
- return { error: true, status: null, code: "INVALID_PARAMS", message: "At least one order ID is required." };
248
- }
249
- if (orderIdOrIds.length > 20) {
250
- return { error: true, status: null, code: "INVALID_PARAMS", message: "Maximum 20 order IDs per batch." };
251
- }
252
- return authenticatedPost("/api/trading/orders/cancel", { order_ids: orderIdOrIds });
253
- }
254
-
255
- if (!orderIdOrIds) {
234
+ export async function cancelOrder(orderId: string): Promise<CancelOrderResponse | ApiError> {
235
+ if (!orderId) {
256
236
  return { error: true, status: null, code: "INVALID_PARAMS", message: "Order ID is required." };
257
237
  }
258
- return authenticatedPost("/api/trading/orders/cancel", { order_id: orderIdOrIds });
238
+ return authenticatedPost(`/api/trading/orders/${encodeURIComponent(orderId)}/cancel`);
259
239
  }
260
240
 
261
241
  /**
@@ -293,27 +273,9 @@ export async function getDelegation(): Promise<DelegationResponse | ApiError> {
293
273
 
294
274
  /**
295
275
  * Create an order request (limit buy/sell) on the Temple trading backend.
296
- * @param opts - Single order or array of orders (max 20)
276
+ * @param opts - Order parameters: symbol, side, quantity, price, order_type, expires_at
297
277
  */
298
- export async function createOrderRequest(opts: CreateOrderRequestOpts): Promise<CreateOrderRequestResponse | ApiError>;
299
- export async function createOrderRequest(opts: CreateOrderRequestOpts[]): Promise<BatchCreateOrderRequestResponse | ApiError>;
300
- export async function createOrderRequest(opts: CreateOrderRequestOpts | CreateOrderRequestOpts[]): Promise<CreateOrderRequestResponse | BatchCreateOrderRequestResponse | ApiError> {
301
- if (Array.isArray(opts)) {
302
- if (opts.length === 0) {
303
- return { error: true, status: null, code: "INVALID_PARAMS", message: "At least one order is required." };
304
- }
305
- if (opts.length > 20) {
306
- return { error: true, status: null, code: "INVALID_PARAMS", message: "Maximum 20 orders per batch." };
307
- }
308
- const body = opts.map((o) => {
309
- const { symbol: rawSymbol, side, quantity, price, order_type = "limit", expires_at } = o;
310
- const order: Record<string, unknown> = { symbol: normalizeSymbol(rawSymbol), side, quantity: Number(quantity), price: Number(price), order_type };
311
- if (expires_at) order.expires_at = expires_at;
312
- return order;
313
- });
314
- return authenticatedPost("/api/trading/orders", body as unknown as Record<string, unknown>);
315
- }
316
-
278
+ export async function createOrderRequest(opts: CreateOrderRequestOpts): Promise<CreateOrderRequestResponse | ApiError> {
317
279
  const { symbol: rawSymbol, side, quantity, price, order_type = "limit", expires_at } = opts || {};
318
280
  if (!rawSymbol || !side || quantity == null || price == null) {
319
281
  return { error: true, status: null, code: "INVALID_PARAMS", message: "symbol, side, quantity, and price are required." };
package/src/api/types.ts CHANGED
@@ -87,14 +87,6 @@ export interface CancelOrderResponse {
87
87
  message: string;
88
88
  }
89
89
 
90
- export interface BatchCancelOrdersResponse {
91
- success: boolean;
92
- canceled: string[];
93
- already_queued: string[];
94
- not_found: string[];
95
- message: string;
96
- }
97
-
98
90
  export interface CancelAllOrdersOptions {
99
91
  symbol?: string;
100
92
  }
@@ -130,12 +122,6 @@ export interface CreateOrderRequestOpts {
130
122
  expires_at?: string;
131
123
  }
132
124
 
133
- export interface BatchCreateOrderRequestResponse {
134
- success: boolean;
135
- request_ids: number[];
136
- count: number;
137
- message: string;
138
- }
139
125
 
140
126
  export interface CreateOrderRequestResponse {
141
127
  [key: string]: unknown;