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

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 (2) hide show
  1. package/README.md +46 -37
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -66,7 +66,7 @@ The v2 flow covers the full trading lifecycle: onboarding, deposits, trading, an
66
66
  1. Check onboarding → isUserOnboarded(party)
67
67
  If NOT onboarded → onboardUser(party)
68
68
 
69
- 2. Deposit funds → depositFunds({ sender, assetId, amount, holdingCids, ... })
69
+ 2. Deposit funds → deposit(amount, symbol)
70
70
 
71
71
  3. Check balance → getTradingBalance()
72
72
 
@@ -98,35 +98,30 @@ if (!delegation) {
98
98
 
99
99
  ### 2. Deposit Funds
100
100
 
101
- Deposit funds into the user's trading balance. Use `prepareDepositHoldings` to resolve the holdings for the deposit amount.
101
+ The simplest way to deposit is the `deposit()` helper pass the amount and symbol, and it handles everything:
102
102
 
103
103
  ```javascript
104
- import { prepareDepositHoldings, depositFunds } from "@temple-digital-group/temple-canton-js";
105
-
106
- // Prepare holdings for the deposit
107
- const depositOpts = await prepareDepositHoldings(100, "USDCx");
104
+ import { deposit } from "@temple-digital-group/temple-canton-js";
108
105
 
109
- // Submit the deposit
110
- const result = await depositFunds(depositOpts);
106
+ const result = await deposit(100, "USDCx");
107
+ // or
108
+ const result = await deposit(10, "CC");
111
109
  ```
112
110
 
113
- `depositFunds` accepts:
111
+ `deposit()` requires the wallet adapter to be connected. It:
112
+ 1. Checks your CC balance to ensure at least 10 CC is reserved for transaction fees
113
+ 2. For utility deposits (USDCx, CBTC), verifies you have enough of the token **and** 10 CC for fees
114
+ 3. Selects the right UTXOs from your wallet
115
+ 4. Submits the deposit allocation
116
+
117
+ If you need more control, use `prepareDepositHoldings` + `depositFunds` directly:
114
118
 
115
- | Option | Required | Description |
116
- | ---------------- | -------- | ---------------------------------------------------------- |
117
- | `sender` | Yes | Party allocating the assets |
118
- | `assetId` | Yes | Instrument symbol (`USDCx`, `Amulet`, `CBTC`) |
119
- | `amount` | Yes | Amount to allocate |
120
- | `holdingCids` | Yes | Holding contract IDs that fund the allocation |
121
- | `receiver` | No | Counterparty (defaults to sender) |
122
- | `settlementId` | No | Reference ID for the settlement |
123
- | `transferLegId` | No | Unique ID for this transfer leg |
124
- | `allocateBefore` | No | ISO timestamp; allocation deadline (default: +1h) |
125
- | `settleBefore` | No | ISO timestamp; settlement deadline (default: +2h) |
126
- | `disclosures` | No | Pre-fetched Amulet disclosures (for FE without API access) |
127
- | `userId` | No | User ID (falls back to wallet adapter / config) |
119
+ ```javascript
120
+ import { prepareDepositHoldings, depositFunds } from "@temple-digital-group/temple-canton-js";
128
121
 
129
- For Amulet deposits, the SDK fetches disclosures automatically. You can also pass them manually via `opts.disclosures`.
122
+ const depositOpts = await prepareDepositHoldings(100, "USDCx");
123
+ const result = await depositFunds(depositOpts);
124
+ ```
130
125
 
131
126
  ### 3. Trading Balance
132
127
 
@@ -144,14 +139,21 @@ Use this to check available funds before placing orders or withdrawals.
144
139
  ```javascript
145
140
  import { createOrderRequest } from "@temple-digital-group/temple-canton-js";
146
141
 
142
+ // Single order
147
143
  const result = await createOrderRequest({
148
- symbol: "Amulet/USDCx",
144
+ symbol: "CC/USDCx",
149
145
  side: "buy",
150
146
  quantity: 10.5,
151
147
  price: 1.25,
152
148
  order_type: "limit",
153
- expires_at: new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString(),
154
149
  });
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 }
155
157
  ```
156
158
 
157
159
  ### 5. Cancel Orders
@@ -159,11 +161,15 @@ const result = await createOrderRequest({
159
161
  ```javascript
160
162
  import { cancelOrder, cancelAllOrders } from "@temple-digital-group/temple-canton-js";
161
163
 
162
- // Cancel a specific order
163
- await cancelOrder("order-id-123");
164
+ // Cancel a single order
165
+ await cancelOrder("ord_abc123");
166
+
167
+ // Cancel multiple orders (max 20)
168
+ await cancelOrder(["ord_abc123", "ord_def456", "ord_ghi789"]);
169
+ // Returns { success, canceled, already_queued, not_found, message }
164
170
 
165
171
  // Cancel all orders for a symbol
166
- await cancelAllOrders({ symbol: "Amulet/USDCx" });
172
+ await cancelAllOrders({ symbol: "CC/USDCx" });
167
173
 
168
174
  // Cancel ALL orders
169
175
  await cancelAllOrders();
@@ -368,8 +374,9 @@ const unsubOrder = ws.onUserEvent("user_order", (data) => { ... });
368
374
 
369
375
  | Function | Provider | Description |
370
376
  | ----------------------------------------- | -------- | ----------------------------------------------------- |
371
- | `prepareDepositHoldings(amount, assetId)` | **W** | Resolve holdings for a deposit amount |
372
- | `depositFunds(opts)` | **W** | Deposit funds into the user's trading balance |
377
+ | `deposit(amount, symbol)` | **W** | Deposit funds (validates balance, reserves 10 CC for fees) |
378
+ | `prepareDepositHoldings(amount, assetId)` | **W** | Resolve holdings for a deposit amount (low-level) |
379
+ | `depositFunds(opts)` | **W** | Submit deposit allocation (low-level) |
373
380
  | `withdrawFunds({ asset_id, amount })` | **W** | Withdraw available trading balance back to wallet |
374
381
  | `emergencyWithdrawFunds(opts)` | **W** | Cancel all orders and withdraw everything immediately |
375
382
 
@@ -413,13 +420,15 @@ const unsubOrder = ws.onUserEvent("user_order", (data) => { ... });
413
420
 
414
421
  #### Trading
415
422
 
416
- | Function | Description |
417
- | --------------------------- | ------------------------------------------------------ |
418
- | `createOrderRequest(opts)` | Place a buy/sell order via the trading backend |
419
- | `cancelOrder(orderId)` | Cancel a specific order |
420
- | `cancelAllOrders(options?)` | Cancel all orders (options: `symbol` filter) |
421
- | `getTradingBalance()` | Get user's trading balance (unlocked/locked/in-flight) |
422
- | `getActiveOrders(options?)` | Get active orders (options: `symbol`, `limit`) |
423
+ | Function | Description |
424
+ | ----------------------------------- | ------------------------------------------------------ |
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 |
429
+ | `cancelAllOrders(options?)` | Cancel all orders (options: `symbol` filter) |
430
+ | `getTradingBalance()` | Get user's trading balance (unlocked/locked/in-flight) |
431
+ | `getActiveOrders(options?)` | Get active orders (options: `symbol`, `limit`) |
423
432
 
424
433
  #### Withdrawals
425
434
 
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.6",
3
+ "version": "2.0.0-beta.7",
4
4
  "description": "JavaScript library for interacting with Temple Canton blockchain",
5
5
  "type": "module",
6
6
  "main": "index.js",