@darksol/terminal 0.5.8 → 0.5.9
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 +1 -1
- package/src/config/store.js +1 -1
- package/src/services/facilitator.js +27 -6
- package/src/web/commands.js +25 -11
package/package.json
CHANGED
package/src/config/store.js
CHANGED
|
@@ -31,7 +31,7 @@ const config = new Conf({
|
|
|
31
31
|
default: {
|
|
32
32
|
oracle: 'https://acp.darksol.net/oracle',
|
|
33
33
|
casino: 'https://casino.darksol.net',
|
|
34
|
-
cards: 'https://acp.darksol.net
|
|
34
|
+
cards: 'https://acp.darksol.net',
|
|
35
35
|
facilitator: 'https://facilitator.darksol.net',
|
|
36
36
|
builders: 'https://builders.darksol.net',
|
|
37
37
|
market: 'https://acp.darksol.net/market',
|
|
@@ -1,29 +1,50 @@
|
|
|
1
1
|
import { fetchJSON } from '../utils/fetch.js';
|
|
2
2
|
import { getServiceURL } from '../config/store.js';
|
|
3
3
|
import { theme } from '../ui/theme.js';
|
|
4
|
-
import { spinner, kvDisplay, error } from '../ui/components.js';
|
|
4
|
+
import { spinner, kvDisplay, error, info } from '../ui/components.js';
|
|
5
5
|
import { showSection } from '../ui/banner.js';
|
|
6
6
|
|
|
7
|
+
// Facilitator root returns service info (no /api/health path)
|
|
7
8
|
const getURL = () => getServiceURL('facilitator') || 'https://facilitator.darksol.net';
|
|
8
9
|
|
|
9
10
|
export async function facilitatorHealth() {
|
|
10
11
|
const spin = spinner('Checking facilitator...').start();
|
|
11
12
|
try {
|
|
12
|
-
const data = await fetchJSON(`${getURL()}
|
|
13
|
+
const data = await fetchJSON(`${getURL()}/`);
|
|
13
14
|
spin.succeed('Facilitator online');
|
|
14
15
|
|
|
15
|
-
showSection('FACILITATOR
|
|
16
|
-
kvDisplay(
|
|
16
|
+
showSection('x402 FACILITATOR');
|
|
17
|
+
kvDisplay([
|
|
18
|
+
['Service', data.service || 'DARKSOL Facilitator'],
|
|
19
|
+
['Version', data.version || '-'],
|
|
20
|
+
['Protocol', data.protocol || 'x402'],
|
|
21
|
+
['Fee', data.fee || '0%'],
|
|
22
|
+
['Chains', Array.isArray(data.chains) ? data.chains.join(', ') : (data.chains || 'Base, Polygon')],
|
|
23
|
+
['Status', theme.success('● Online')],
|
|
24
|
+
]);
|
|
25
|
+
if (data.description) {
|
|
26
|
+
console.log('');
|
|
27
|
+
console.log(theme.dim(` ${data.description}`));
|
|
28
|
+
}
|
|
29
|
+
if (data.contracts) {
|
|
30
|
+
console.log('');
|
|
31
|
+
for (const [chain, addr] of Object.entries(data.contracts)) {
|
|
32
|
+
console.log(` ${theme.gold(chain.padEnd(10))} ${theme.dim(addr)}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
console.log('');
|
|
36
|
+
info('Docs: https://acp.darksol.net/facilitator');
|
|
17
37
|
} catch (err) {
|
|
18
38
|
spin.fail('Facilitator unreachable');
|
|
19
39
|
error(err.message);
|
|
40
|
+
info('Check: https://facilitator.darksol.net');
|
|
20
41
|
}
|
|
21
42
|
}
|
|
22
43
|
|
|
23
44
|
export async function facilitatorVerify(payment) {
|
|
24
45
|
const spin = spinner('Verifying payment...').start();
|
|
25
46
|
try {
|
|
26
|
-
const data = await fetchJSON(`${getURL()}/
|
|
47
|
+
const data = await fetchJSON(`${getURL()}/verify`, {
|
|
27
48
|
method: 'POST',
|
|
28
49
|
headers: { 'Content-Type': 'application/json' },
|
|
29
50
|
body: JSON.stringify(typeof payment === 'string' ? JSON.parse(payment) : payment),
|
|
@@ -41,7 +62,7 @@ export async function facilitatorVerify(payment) {
|
|
|
41
62
|
export async function facilitatorSettle(payment) {
|
|
42
63
|
const spin = spinner('Settling on-chain...').start();
|
|
43
64
|
try {
|
|
44
|
-
const data = await fetchJSON(`${getURL()}/
|
|
65
|
+
const data = await fetchJSON(`${getURL()}/settle`, {
|
|
45
66
|
method: 'POST',
|
|
46
67
|
headers: { 'Content-Type': 'application/json' },
|
|
47
68
|
body: JSON.stringify(typeof payment === 'string' ? JSON.parse(payment) : payment),
|
package/src/web/commands.js
CHANGED
|
@@ -1138,34 +1138,48 @@ async function cmdOracle(args, ws) {
|
|
|
1138
1138
|
}
|
|
1139
1139
|
|
|
1140
1140
|
async function cmdCasino(args, ws) {
|
|
1141
|
+
ws.sendLine(`${ANSI.gold} ◆ CASINO${ANSI.reset}`);
|
|
1142
|
+
ws.sendLine(`${ANSI.dim} ${'─'.repeat(50)}${ANSI.reset}`);
|
|
1141
1143
|
try {
|
|
1142
|
-
const resp = await fetch('https://casino.darksol.net/
|
|
1144
|
+
const resp = await fetch('https://casino.darksol.net/api/stats');
|
|
1145
|
+
const ct = resp.headers.get('content-type') || '';
|
|
1146
|
+
if (!ct.includes('json')) throw new Error('not json');
|
|
1143
1147
|
const data = await resp.json();
|
|
1144
1148
|
|
|
1145
|
-
ws.sendLine(
|
|
1146
|
-
ws.sendLine(
|
|
1147
|
-
ws.sendLine(` ${ANSI.darkGold}
|
|
1149
|
+
ws.sendLine(` ${ANSI.darkGold}Status${ANSI.reset} ${ANSI.green}● Online${ANSI.reset}`);
|
|
1150
|
+
ws.sendLine(` ${ANSI.darkGold}Bankroll${ANSI.reset} ${ANSI.white}$${data.bankrollUsdc || '0'} USDC${ANSI.reset}`);
|
|
1151
|
+
ws.sendLine(` ${ANSI.darkGold}Total Bets${ANSI.reset} ${ANSI.white}${data.totalBets || 0}${ANSI.reset}`);
|
|
1152
|
+
ws.sendLine(` ${ANSI.darkGold}Win Rate${ANSI.reset} ${ANSI.white}${data.winRate || '0'}%${ANSI.reset}`);
|
|
1148
1153
|
ws.sendLine(` ${ANSI.darkGold}Endpoint${ANSI.reset} ${ANSI.blue}casino.darksol.net${ANSI.reset}`);
|
|
1154
|
+
ws.sendLine(` ${ANSI.darkGold}Docs${ANSI.reset} ${ANSI.blue}casino.darksol.net/docs${ANSI.reset}`);
|
|
1149
1155
|
ws.sendLine('');
|
|
1150
1156
|
} catch {
|
|
1151
|
-
ws.sendLine(` ${ANSI.
|
|
1157
|
+
ws.sendLine(` ${ANSI.red}○ Casino unreachable${ANSI.reset}`);
|
|
1158
|
+
ws.sendLine(` ${ANSI.dim}Check: https://casino.darksol.net/docs${ANSI.reset}`);
|
|
1152
1159
|
ws.sendLine('');
|
|
1153
1160
|
}
|
|
1154
1161
|
return {};
|
|
1155
1162
|
}
|
|
1156
1163
|
|
|
1157
1164
|
async function cmdFacilitator(args, ws) {
|
|
1165
|
+
ws.sendLine(`${ANSI.gold} ◆ x402 FACILITATOR${ANSI.reset}`);
|
|
1166
|
+
ws.sendLine(`${ANSI.dim} ${'─'.repeat(50)}${ANSI.reset}`);
|
|
1158
1167
|
try {
|
|
1159
|
-
const resp = await fetch('https://facilitator.darksol.net/
|
|
1168
|
+
const resp = await fetch('https://facilitator.darksol.net/');
|
|
1169
|
+
const ct = resp.headers.get('content-type') || '';
|
|
1170
|
+
if (!ct.includes('json')) throw new Error('not json');
|
|
1160
1171
|
const data = await resp.json();
|
|
1161
1172
|
|
|
1162
|
-
ws.sendLine(
|
|
1163
|
-
ws.sendLine(
|
|
1164
|
-
ws.sendLine(` ${ANSI.darkGold}
|
|
1165
|
-
ws.sendLine(` ${ANSI.darkGold}
|
|
1173
|
+
ws.sendLine(` ${ANSI.darkGold}Status${ANSI.reset} ${ANSI.green}● Online${ANSI.reset}`);
|
|
1174
|
+
ws.sendLine(` ${ANSI.darkGold}Service${ANSI.reset} ${ANSI.white}${data.service || 'DARKSOL Facilitator'}${ANSI.reset}`);
|
|
1175
|
+
ws.sendLine(` ${ANSI.darkGold}Protocol${ANSI.reset} ${ANSI.white}${data.protocol || 'x402'}${ANSI.reset}`);
|
|
1176
|
+
ws.sendLine(` ${ANSI.darkGold}Fee${ANSI.reset} ${ANSI.green}${data.fee || '0%'}${ANSI.reset}`);
|
|
1177
|
+
ws.sendLine(` ${ANSI.darkGold}Chains${ANSI.reset} ${ANSI.white}${Array.isArray(data.chains) ? data.chains.join(', ') : 'Base, Polygon'}${ANSI.reset}`);
|
|
1178
|
+
ws.sendLine(` ${ANSI.darkGold}Docs${ANSI.reset} ${ANSI.blue}acp.darksol.net/facilitator${ANSI.reset}`);
|
|
1166
1179
|
ws.sendLine('');
|
|
1167
1180
|
} catch {
|
|
1168
|
-
ws.sendLine(` ${ANSI.
|
|
1181
|
+
ws.sendLine(` ${ANSI.red}○ Facilitator unreachable${ANSI.reset}`);
|
|
1182
|
+
ws.sendLine(` ${ANSI.dim}Check: https://acp.darksol.net/facilitator${ANSI.reset}`);
|
|
1169
1183
|
ws.sendLine('');
|
|
1170
1184
|
}
|
|
1171
1185
|
return {};
|