@lawrenceliang-btc/atel-sdk 1.1.14 → 1.1.16
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 +36 -2
- package/package.json +1 -1
package/bin/atel.mjs
CHANGED
|
@@ -3086,7 +3086,8 @@ ${callbackFailed}
|
|
|
3086
3086
|
function sanitizeHookSessionId(value) {
|
|
3087
3087
|
const raw = String(value || '').trim();
|
|
3088
3088
|
if (!raw) return `atel-hook-${Date.now()}`;
|
|
3089
|
-
|
|
3089
|
+
// Replace colons with dashes — openclaw rejects colons in session IDs
|
|
3090
|
+
const cleaned = raw.replace(/:/g, '-').replace(/[^a-zA-Z0-9._-]+/g, '-').replace(/^-+|-+$/g, '');
|
|
3090
3091
|
return (cleaned || `atel-hook-${Date.now()}`).slice(0, 120);
|
|
3091
3092
|
}
|
|
3092
3093
|
|
|
@@ -5614,6 +5615,24 @@ async function cmdBalance() {
|
|
|
5614
5615
|
console.log(` ${chain.toUpperCase()}: query failed (${e.message})`);
|
|
5615
5616
|
}
|
|
5616
5617
|
}
|
|
5618
|
+
|
|
5619
|
+
// Platform ledger balance
|
|
5620
|
+
try {
|
|
5621
|
+
const balResp = await fetch(`${PLATFORM_URL}/account/v1/balance?did=${encodeURIComponent(id.did)}`, { signal: AbortSignal.timeout(5000) });
|
|
5622
|
+
if (balResp.ok) {
|
|
5623
|
+
const bal = await balResp.json();
|
|
5624
|
+
const available = parseFloat(bal.available ?? bal.balance ?? 0).toFixed(2);
|
|
5625
|
+
const frozen = parseFloat(bal.frozen ?? 0).toFixed(2);
|
|
5626
|
+
const total = (parseFloat(available) + parseFloat(frozen)).toFixed(2);
|
|
5627
|
+
console.log(` Platform: $${total}`);
|
|
5628
|
+
console.log(` Available: $${available}`);
|
|
5629
|
+
console.log(` Frozen: $${frozen}`);
|
|
5630
|
+
} else {
|
|
5631
|
+
console.log(` Platform: query failed (HTTP ${balResp.status})`);
|
|
5632
|
+
}
|
|
5633
|
+
} catch (e) {
|
|
5634
|
+
console.log(` Platform: query failed (${e.message})`);
|
|
5635
|
+
}
|
|
5617
5636
|
}
|
|
5618
5637
|
|
|
5619
5638
|
async function cmdDeposit(amount, channel) {
|
|
@@ -5750,6 +5769,10 @@ async function cmdTradeTask(capability, description) {
|
|
|
5750
5769
|
|
|
5751
5770
|
async function cmdOrder(executorDid, capType, price) {
|
|
5752
5771
|
if (!executorDid || !capType || !price) { console.error('Usage: atel order <executorDid> <capabilityType> <price> [--desc "task description"]'); process.exit(1); }
|
|
5772
|
+
// Resolve @alias to full DID
|
|
5773
|
+
if (executorDid.startsWith('@')) {
|
|
5774
|
+
try { executorDid = resolveDID(executorDid); } catch (e) { console.error(e.message); process.exit(1); }
|
|
5775
|
+
}
|
|
5753
5776
|
const description = rawArgs.find((a, i) => rawArgs[i-1] === '--desc') || '';
|
|
5754
5777
|
const id = requireIdentity();
|
|
5755
5778
|
|
|
@@ -6550,6 +6573,17 @@ async function cmdOfferList(did) {
|
|
|
6550
6573
|
}
|
|
6551
6574
|
}
|
|
6552
6575
|
|
|
6576
|
+
async function cmdOfferInfo(offerId) {
|
|
6577
|
+
if (!offerId) { console.error('Usage: atel offer-info <offerId>'); process.exit(1); }
|
|
6578
|
+
const resp = await fetch(`${PLATFORM_URL}/trade/v1/offer/${encodeURIComponent(offerId)}`, { signal: AbortSignal.timeout(10000) });
|
|
6579
|
+
if (!resp.ok) {
|
|
6580
|
+
console.error(`Error: Failed to fetch offer (HTTP ${resp.status})`);
|
|
6581
|
+
process.exit(1);
|
|
6582
|
+
}
|
|
6583
|
+
const data = await resp.json();
|
|
6584
|
+
console.log(JSON.stringify(data, null, 2));
|
|
6585
|
+
}
|
|
6586
|
+
|
|
6553
6587
|
async function cmdOfferUpdate(offerId) {
|
|
6554
6588
|
if (!offerId) { console.error('Usage: atel offer-update <offerId> [--price N] [--title "..."] [--desc "..."] [--status active|paused]'); process.exit(1); }
|
|
6555
6589
|
const body = {};
|
|
@@ -7847,7 +7881,7 @@ const commands = {
|
|
|
7847
7881
|
// Offers
|
|
7848
7882
|
offer: () => cmdOfferCreate(args[0], args[1]),
|
|
7849
7883
|
offers: () => cmdOfferList(args[0]),
|
|
7850
|
-
'offer-info': () =>
|
|
7884
|
+
'offer-info': () => cmdOfferInfo(args[0]),
|
|
7851
7885
|
'offer-update': () => cmdOfferUpdate(args[0]),
|
|
7852
7886
|
'offer-close': () => cmdOfferClose(args[0]),
|
|
7853
7887
|
'offer-buy': () => cmdOfferBuy(args[0], args[1]),
|