terafab-cli 1.1.6
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 +13 -0
- package/terafab.js +92 -0
package/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "terafab-cli",
|
|
3
|
+
"version": "1.1.6",
|
|
4
|
+
"description": "Official CLI for Terafabpay - Swap & Monero Bridge",
|
|
5
|
+
"main": "terafab.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"terafab": "terafab.js"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"commander": "^11.0.0",
|
|
11
|
+
"ethers": "^6.11.1"
|
|
12
|
+
}
|
|
13
|
+
}
|
package/terafab.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { Command } = require('commander');
|
|
4
|
+
const { ethers } = require('ethers');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
8
|
+
const program = new Command();
|
|
9
|
+
const API_BASE = 'https://terafabpay.de';
|
|
10
|
+
const VAULT_PATH = path.join(process.env.HOME, '.terafab_vault');
|
|
11
|
+
|
|
12
|
+
function getVaultKey() {
|
|
13
|
+
if (fs.existsSync(VAULT_PATH)) {
|
|
14
|
+
try {
|
|
15
|
+
const config = JSON.parse(fs.readFileSync(VAULT_PATH, 'utf8'));
|
|
16
|
+
return config.k;
|
|
17
|
+
} catch (e) { return null; }
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
program
|
|
23
|
+
.name('terafab')
|
|
24
|
+
.description('Terafabpay CLI - Swap & Bridge Tools')
|
|
25
|
+
.version('1.1.5');
|
|
26
|
+
|
|
27
|
+
// --- BRIDGE OHNE TX ---
|
|
28
|
+
program.command('bridge')
|
|
29
|
+
.description('Start a no-KYC swap to Monero (No TX required)')
|
|
30
|
+
.option('-f, --from <chain>', 'sol, eth, btc', 'sol')
|
|
31
|
+
.option('-a, --amount <n>', 'Amount to send', '0.1')
|
|
32
|
+
.requiredOption('-to, --address <addr>', 'Your XMR receiving address')
|
|
33
|
+
.action(async (o) => {
|
|
34
|
+
console.log(`ā³ Initializing bridge: ${o.amount} ${o.from.toUpperCase()} -> XMR...`);
|
|
35
|
+
try {
|
|
36
|
+
const res = await fetch(`${API_BASE}/v1/xmr/create`, {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
headers: { 'Content-Type': 'application/json' },
|
|
39
|
+
body: JSON.stringify({ from: o.from, amount: o.amount, address: o.address })
|
|
40
|
+
});
|
|
41
|
+
const d = await res.json();
|
|
42
|
+
if (d.error) console.log(`\nā Error: ${d.error}`);
|
|
43
|
+
else {
|
|
44
|
+
console.log(`\nā
BRIDGE ORDER CREATED`);
|
|
45
|
+
console.log(`--------------------------------------`);
|
|
46
|
+
console.log(`SEND EXACTLY: ${o.amount} ${o.from.toUpperCase()}`);
|
|
47
|
+
console.log(`TO ADDRESS: ${d.payinAddress}`);
|
|
48
|
+
console.log(`--------------------------------------`);
|
|
49
|
+
console.log(`ESTIMATED: ~${d.estimatedXmr} XMR`);
|
|
50
|
+
console.log(`ORDER ID: ${d.orderId}`);
|
|
51
|
+
console.log(`TRACKING: ${d.trackUrl}`);
|
|
52
|
+
}
|
|
53
|
+
} catch (e) { console.error('ā Server connection failed.'); }
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// --- PUBLIC TOOLS ---
|
|
57
|
+
program.command('status').action(async () => {
|
|
58
|
+
const res = await fetch(`${API_BASE}/v1/watcher`);
|
|
59
|
+
const d = await res.json();
|
|
60
|
+
console.log(`Status: ${d.healthy ? 'š¢' : 'š“'} | Advice: ${d.advice}`);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
program.command('xmr:quote').option('-f, --from <c>', 'sol').option('-a, --amount <n>', '0.1').action(async (o) => {
|
|
64
|
+
const res = await fetch(`${API_BASE}/v1/xmr/quote?from=${o.from}&amount=${o.amount}`);
|
|
65
|
+
const d = await res.json();
|
|
66
|
+
console.log(d.error ? `ā ${d.error}` : `š Estimate: ~${d.estimatedAmount} XMR`);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
program.command('wallet:create').action(() => {
|
|
70
|
+
const w = ethers.Wallet.createRandom();
|
|
71
|
+
console.log(`ā
Address: ${w.address}\nš Key: ${w.privateKey}`);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// --- AI & TRAINING (Auth required) ---
|
|
75
|
+
program.command('auth').argument('<key>').action((key) => {
|
|
76
|
+
fs.writeFileSync(VAULT_PATH, JSON.stringify({ k: key }), { mode: 0o600 });
|
|
77
|
+
console.log('ā
Key vaulted.');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
program.command('agent:prompt').argument('<prompt>').action(async (prompt) => {
|
|
81
|
+
const key = getVaultKey();
|
|
82
|
+
if (!key) { console.log('ā Inference requires Training-TX.'); return; }
|
|
83
|
+
const res = await fetch(`${API_BASE}/v1/inference`, {
|
|
84
|
+
method: 'POST',
|
|
85
|
+
headers: { 'Content-Type': 'application/json' },
|
|
86
|
+
body: JSON.stringify({ prompt, txHash: key })
|
|
87
|
+
});
|
|
88
|
+
const d = await res.json();
|
|
89
|
+
console.log(d.inference || d.error);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
program.parse();
|