@darksol/terminal 0.5.3 → 0.5.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darksol/terminal",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "DARKSOL Terminal — unified CLI for all DARKSOL services. Market intel, trading, oracle, casino, and more.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -6,6 +6,42 @@ import { showSection } from '../ui/banner.js';
6
6
 
7
7
  const BASE = () => getServiceURL('cards') || 'https://acp.darksol.net';
8
8
 
9
+ // Verified working ticker/network combos (tested against Trocador API)
10
+ const VALID_CRYPTO = {
11
+ 'usdc': { network: 'base', display: 'USDC on Base' },
12
+ 'usdc_base': { ticker: 'usdc', network: 'base', display: 'USDC on Base' },
13
+ 'usdc_erc20': { ticker: 'usdc', network: 'ERC20', display: 'USDC on Ethereum' },
14
+ 'usdt': { network: 'trc20', display: 'USDT on Tron' },
15
+ 'usdt_trc20': { ticker: 'usdt', network: 'trc20', display: 'USDT on Tron' },
16
+ 'btc': { network: 'Mainnet', display: 'Bitcoin' },
17
+ 'eth': { network: 'ERC20', display: 'ETH on Ethereum' },
18
+ 'sol': { network: 'Mainnet', display: 'Solana' },
19
+ 'xmr': { network: 'Mainnet', display: 'Monero' },
20
+ };
21
+
22
+ // Map user-friendly network names to Trocador-compatible ones
23
+ const NETWORK_MAP = {
24
+ 'base': 'base',
25
+ 'ethereum': 'ERC20', 'eth': 'ERC20', 'erc20': 'ERC20',
26
+ 'tron': 'trc20', 'trc20': 'trc20',
27
+ 'mainnet': 'Mainnet', 'btc': 'Mainnet', 'sol': 'Mainnet', 'xmr': 'Mainnet',
28
+ };
29
+
30
+ function resolveTickerNetwork(ticker, network) {
31
+ const t = (ticker || '').toLowerCase();
32
+ const n = (network || '').toLowerCase();
33
+
34
+ // If just ticker provided, use known defaults
35
+ if (t && !n) {
36
+ const known = VALID_CRYPTO[t];
37
+ if (known) return { ticker: known.ticker || t, network: known.network };
38
+ }
39
+
40
+ // Map network to Trocador format
41
+ const mappedNetwork = NETWORK_MAP[n] || network;
42
+ return { ticker: t, network: mappedNetwork };
43
+ }
44
+
9
45
  export async function cardsCatalog() {
10
46
  const spin = spinner('Loading card catalog...').start();
11
47
  try {
@@ -58,9 +94,13 @@ export async function cardsOrder(provider, amount, opts = {}) {
58
94
  amount: Number(amount),
59
95
  email: opts.email,
60
96
  };
61
- // Optional: custom crypto + network
62
- if (opts.ticker) body.tickerFrom = opts.ticker;
63
- if (opts.network) body.networkFrom = opts.network;
97
+ // Resolve ticker/network to Trocador-compatible values
98
+ if (opts.ticker) {
99
+ const resolved = resolveTickerNetwork(opts.ticker, opts.network);
100
+ body.tickerFrom = resolved.ticker;
101
+ body.networkFrom = resolved.network;
102
+ info(`Payment: ${resolved.ticker.toUpperCase()} on ${resolved.network}`);
103
+ }
64
104
 
65
105
  const data = await fetchJSON(`${BASE()}/api/cards/order`, {
66
106
  method: 'POST',