@dakota-xyz/ts-sdk 1.4.0 → 1.6.0

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/dist/index.mjs CHANGED
@@ -612,6 +612,15 @@ var CustomersResource = class extends BaseResource {
612
612
  * { idempotencyKey: 'create-acme-corp-001' }
613
613
  * );
614
614
  * console.log(customer.applicationUrl); // KYB onboarding URL
615
+ *
616
+ * // Designate as a sub-client at creation (ENG-2454).
617
+ * // `is_sub_client` can only be set here — a regular customer cannot
618
+ * // be promoted afterwards. Cannot be combined with `sub_client_id`.
619
+ * const subClient = await client.customers.create({
620
+ * name: 'Partner Corp',
621
+ * customer_type: 'business',
622
+ * is_sub_client: true,
623
+ * });
615
624
  * ```
616
625
  */
617
626
  async create(data, options) {
@@ -854,30 +863,39 @@ var DestinationsResource = class extends BaseResource {
854
863
  /**
855
864
  * Create a new destination for a recipient.
856
865
  *
857
- * Destinations can be bank accounts (fiat_us) or crypto wallets (crypto).
866
+ * Destinations can be bank accounts (fiat_us / fiat_iban) or crypto
867
+ * wallets (crypto).
868
+ *
869
+ * The platform returns just `{ id }` here (per `IDResponse`), not the
870
+ * full destination object. Call `destinations.list(recipientId)` if
871
+ * you need the rest of the fields.
858
872
  *
859
873
  * @param recipientId - Recipient ID
860
874
  * @param data - Destination creation data
861
- * @returns Created destination
875
+ * @returns `{ id }` of the newly-created destination
862
876
  *
863
877
  * @example
864
878
  * ```typescript
865
- * // Create a bank destination (for off-ramp)
866
- * const bankDest = await client.destinations.create(recipientId, {
867
- * destination_type: 'fiat_us',
868
- * bank_name: 'Chase Bank',
869
- * account_holder_name: 'Acme Corp',
870
- * account_number: '123456789',
871
- * routing_number: '021000021',
872
- * account_type: 'checking',
873
- * });
874
- *
875
- * // Create a crypto destination (for on-ramp)
879
+ * // Crypto destination (for on-ramp)
876
880
  * const cryptoDest = await client.destinations.create(recipientId, {
877
881
  * destination_type: 'crypto',
882
+ * name: 'Treasury USDC',
878
883
  * crypto_address: '0x742d35Cc6634C0532925a3b844Bc9e7595f...',
879
884
  * network_id: 'ethereum-mainnet',
880
885
  * });
886
+ * // → cryptoDest.id
887
+ *
888
+ * // Fiat US destination (for off-ramp)
889
+ * const bankDest = await client.destinations.create(recipientId, {
890
+ * destination_type: 'fiat_us',
891
+ * name: 'Acme Chase Checking',
892
+ * bank_name: 'JPMorgan Chase',
893
+ * account_holder_name: 'Acme Corp',
894
+ * account_number: '000123456789',
895
+ * aba_routing_number: '021000021',
896
+ * account_type: 'checking',
897
+ * });
898
+ * // → bankDest.id
881
899
  * ```
882
900
  */
883
901
  async create(recipientId, data, options) {
@@ -1113,6 +1131,13 @@ var TransactionsResource = class extends BaseResource {
1113
1131
  * customer_id: customerId,
1114
1132
  * status: 'completed',
1115
1133
  * });
1134
+ *
1135
+ * // Wallet-scoped filters (require transaction_type: 'wallet')
1136
+ * const sent = client.transactions.list({
1137
+ * transaction_type: 'wallet',
1138
+ * wallet_id: walletId,
1139
+ * direction: 'out',
1140
+ * });
1116
1141
  * ```
1117
1142
  */
1118
1143
  list(params) {
@@ -1254,40 +1279,76 @@ var WalletsResource = class extends BaseResource {
1254
1279
  /**
1255
1280
  * Get wallet balances.
1256
1281
  *
1282
+ * Returns the platform's full `WalletBalances` response: the wallet id,
1283
+ * its on-chain address, every per-asset balance, and a pre-computed
1284
+ * `total_amount_usd` across all assets. The previous return shape
1285
+ * (`WalletBalance[]`) silently dropped `address` and `total_amount_usd`,
1286
+ * forcing callers to do a second `wallets.get()` and sum the balances
1287
+ * by hand. This is a small breaking change with a one-line migration
1288
+ * (`balances` → `balances.balances`); the prior shape had been broken
1289
+ * since 1.3.x anyway.
1290
+ *
1257
1291
  * @param walletId - Wallet ID
1258
- * @returns Array of balances
1292
+ * @returns `{ wallet_id, address, balances, total_amount_usd }`
1259
1293
  *
1260
1294
  * @example
1261
1295
  * ```typescript
1262
- * const balances = await client.wallets.getBalances(walletId);
1263
- * for (const balance of balances) {
1264
- * console.log(balance.asset, balance.amount);
1296
+ * const { address, total_amount_usd, balances } =
1297
+ * await client.wallets.getBalances(walletId);
1298
+ * console.log(`${address} → $${total_amount_usd}`);
1299
+ * for (const b of balances) {
1300
+ * console.log(b.asset.id, b.amount_usd);
1265
1301
  * }
1266
1302
  * ```
1267
1303
  */
1268
1304
  async getBalances(walletId) {
1269
- const response = await this.transport.request({
1305
+ return this.transport.request({
1270
1306
  method: "GET",
1271
1307
  path: `/wallets/${walletId}/balances`
1272
1308
  });
1273
- return response.balances ? [...response.balances] : [];
1274
1309
  }
1275
1310
  /**
1276
- * Create a wallet transaction.
1311
+ * Send a transaction from a wallet.
1312
+ *
1313
+ * The platform expects an **endorsed request** envelope —
1314
+ * `{ signatures, intent }` — at this endpoint. Build the
1315
+ * `SendTransactionIntent`, canonicalize it per RFC 8785 (JCS), sign
1316
+ * with the wallet's signer-group ECDSA P-256 key, base64-encode the
1317
+ * DER signature, then post the envelope.
1277
1318
  *
1278
1319
  * @param walletId - Wallet ID
1279
- * @param data - Transaction data
1320
+ * @param data - Endorsed wallet transaction request: `{ signatures, intent }`
1280
1321
  * @returns Created transaction
1281
1322
  *
1282
1323
  * @example
1283
1324
  * ```typescript
1325
+ * import canonicalize from 'canonicalize';
1326
+ * import { createSign, createPrivateKey, randomUUID } from 'node:crypto';
1327
+ *
1328
+ * const intent = {
1329
+ * wallet_id: walletId,
1330
+ * caip2: 'eip155:1', // 11155111 for sepolia
1331
+ * operation: {
1332
+ * kind: 'transfer',
1333
+ * from: wallet.address,
1334
+ * to: '0x...',
1335
+ * amount: '100.00',
1336
+ * asset_id: 'USDC',
1337
+ * },
1338
+ * idempotency_key: randomUUID(),
1339
+ * };
1340
+ * const canonical = canonicalize(intent)!;
1341
+ * const sig = createSign('SHA256').update(canonical).sign({
1342
+ * key: createPrivateKey({ key: privateKeyDer, format: 'der', type: 'pkcs8' }),
1343
+ * dsaEncoding: 'der',
1344
+ * });
1284
1345
  * const tx = await client.wallets.createTransaction(walletId, {
1285
- * to: '0x...',
1286
- * amount: '100.00',
1287
- * asset: 'USDC',
1288
- * network_id: 'ethereum-mainnet',
1346
+ * signatures: [sig.toString('base64')],
1347
+ * intent,
1289
1348
  * });
1290
1349
  * ```
1350
+ *
1351
+ * @see https://docs.dakota.xyz/documentation/signing-guide
1291
1352
  */
1292
1353
  async createTransaction(walletId, data, options) {
1293
1354
  return this.transport.request({