@lawrenceliang-btc/atel-sdk 1.1.14 → 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.
- package/bin/atel.mjs +30 -1
- 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) {
|
|
@@ -6550,6 +6568,17 @@ async function cmdOfferList(did) {
|
|
|
6550
6568
|
}
|
|
6551
6569
|
}
|
|
6552
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
|
+
|
|
6553
6582
|
async function cmdOfferUpdate(offerId) {
|
|
6554
6583
|
if (!offerId) { console.error('Usage: atel offer-update <offerId> [--price N] [--title "..."] [--desc "..."] [--status active|paused]'); process.exit(1); }
|
|
6555
6584
|
const body = {};
|
|
@@ -7847,7 +7876,7 @@ const commands = {
|
|
|
7847
7876
|
// Offers
|
|
7848
7877
|
offer: () => cmdOfferCreate(args[0], args[1]),
|
|
7849
7878
|
offers: () => cmdOfferList(args[0]),
|
|
7850
|
-
'offer-info': () =>
|
|
7879
|
+
'offer-info': () => cmdOfferInfo(args[0]),
|
|
7851
7880
|
'offer-update': () => cmdOfferUpdate(args[0]),
|
|
7852
7881
|
'offer-close': () => cmdOfferClose(args[0]),
|
|
7853
7882
|
'offer-buy': () => cmdOfferBuy(args[0], args[1]),
|