@lawrenceliang-btc/atel-sdk 1.1.13 → 1.1.15

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/bin/atel.mjs +32 -2
  2. package/package.json +1 -1
package/bin/atel.mjs CHANGED
@@ -5614,6 +5614,24 @@ async function cmdBalance() {
5614
5614
  console.log(` ${chain.toUpperCase()}: query failed (${e.message})`);
5615
5615
  }
5616
5616
  }
5617
+
5618
+ // Platform ledger balance
5619
+ try {
5620
+ const balResp = await fetch(`${PLATFORM_URL}/account/v1/balance?did=${encodeURIComponent(id.did)}`, { signal: AbortSignal.timeout(5000) });
5621
+ if (balResp.ok) {
5622
+ const bal = await balResp.json();
5623
+ const available = parseFloat(bal.available ?? bal.balance ?? 0).toFixed(2);
5624
+ const frozen = parseFloat(bal.frozen ?? 0).toFixed(2);
5625
+ const total = (parseFloat(available) + parseFloat(frozen)).toFixed(2);
5626
+ console.log(` Platform: $${total}`);
5627
+ console.log(` Available: $${available}`);
5628
+ console.log(` Frozen: $${frozen}`);
5629
+ } else {
5630
+ console.log(` Platform: query failed (HTTP ${balResp.status})`);
5631
+ }
5632
+ } catch (e) {
5633
+ console.log(` Platform: query failed (${e.message})`);
5634
+ }
5617
5635
  }
5618
5636
 
5619
5637
  async function cmdDeposit(amount, channel) {
@@ -5689,7 +5707,8 @@ async function cmdTradeTask(capability, description) {
5689
5707
  if (!executorDid) {
5690
5708
  console.error(`[trade-task] Searching for executor with capability: ${capability}...`);
5691
5709
  const regClient = new RegistryClient({ registryUrl: REGISTRY_URL });
5692
- const results = await regClient.search({ type: capability, limit: 5 });
5710
+ const searchResp = await regClient.search({ type: capability, limit: 5 });
5711
+ const results = searchResp.agents || searchResp || [];
5693
5712
  if (results.length === 0) { console.error('[trade-task] No executor found for capability: ' + capability); process.exit(1); }
5694
5713
  // Pick best by trust score (if available), exclude self
5695
5714
  const candidates = results.filter(r => r.did !== id.did);
@@ -6549,6 +6568,17 @@ async function cmdOfferList(did) {
6549
6568
  }
6550
6569
  }
6551
6570
 
6571
+ async function cmdOfferInfo(offerId) {
6572
+ if (!offerId) { console.error('Usage: atel offer-info <offerId>'); process.exit(1); }
6573
+ const resp = await fetch(`${PLATFORM_URL}/trade/v1/offer/${encodeURIComponent(offerId)}`, { signal: AbortSignal.timeout(10000) });
6574
+ if (!resp.ok) {
6575
+ console.error(`Error: Failed to fetch offer (HTTP ${resp.status})`);
6576
+ process.exit(1);
6577
+ }
6578
+ const data = await resp.json();
6579
+ console.log(JSON.stringify(data, null, 2));
6580
+ }
6581
+
6552
6582
  async function cmdOfferUpdate(offerId) {
6553
6583
  if (!offerId) { console.error('Usage: atel offer-update <offerId> [--price N] [--title "..."] [--desc "..."] [--status active|paused]'); process.exit(1); }
6554
6584
  const body = {};
@@ -7846,7 +7876,7 @@ const commands = {
7846
7876
  // Offers
7847
7877
  offer: () => cmdOfferCreate(args[0], args[1]),
7848
7878
  offers: () => cmdOfferList(args[0]),
7849
- 'offer-info': () => cmdOfferList(args[0]), // alias — single offer uses GET /offer/:id
7879
+ 'offer-info': () => cmdOfferInfo(args[0]),
7850
7880
  'offer-update': () => cmdOfferUpdate(args[0]),
7851
7881
  'offer-close': () => cmdOfferClose(args[0]),
7852
7882
  'offer-buy': () => cmdOfferBuy(args[0], args[1]),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lawrenceliang-btc/atel-sdk",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "description": "ATEL Protocol SDK - Agent Trust & Exchange Layer",
5
5
  "repository": {
6
6
  "type": "git",