awal 1.0.0
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/README.md +84 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +32 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/address.d.ts +3 -0
- package/dist/commands/address.d.ts.map +1 -0
- package/dist/commands/address.js +33 -0
- package/dist/commands/address.js.map +1 -0
- package/dist/commands/auth.d.ts +3 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +76 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/balance.d.ts +3 -0
- package/dist/commands/balance.d.ts.map +1 -0
- package/dist/commands/balance.js +72 -0
- package/dist/commands/balance.js.map +1 -0
- package/dist/commands/bazaar.d.ts +3 -0
- package/dist/commands/bazaar.d.ts.map +1 -0
- package/dist/commands/bazaar.js +134 -0
- package/dist/commands/bazaar.js.map +1 -0
- package/dist/commands/discover.d.ts +3 -0
- package/dist/commands/discover.d.ts.map +1 -0
- package/dist/commands/discover.js +76 -0
- package/dist/commands/discover.js.map +1 -0
- package/dist/commands/pay.d.ts +3 -0
- package/dist/commands/pay.d.ts.map +1 -0
- package/dist/commands/pay.js +78 -0
- package/dist/commands/pay.js.map +1 -0
- package/dist/commands/send.d.ts +3 -0
- package/dist/commands/send.d.ts.map +1 -0
- package/dist/commands/send.js +144 -0
- package/dist/commands/send.js.map +1 -0
- package/dist/commands/show.d.ts +3 -0
- package/dist/commands/show.d.ts.map +1 -0
- package/dist/commands/show.js +31 -0
- package/dist/commands/show.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +89 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/trade.d.ts +3 -0
- package/dist/commands/trade.d.ts.map +1 -0
- package/dist/commands/trade.js +163 -0
- package/dist/commands/trade.js.map +1 -0
- package/dist/formatters/output.d.ts +38 -0
- package/dist/formatters/output.d.ts.map +1 -0
- package/dist/formatters/output.js +83 -0
- package/dist/formatters/output.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/ipcClient.d.ts +14 -0
- package/dist/ipcClient.d.ts.map +1 -0
- package/dist/ipcClient.js +127 -0
- package/dist/ipcClient.js.map +1 -0
- package/dist/utils/authCheck.d.ts +13 -0
- package/dist/utils/authCheck.d.ts.map +1 -0
- package/dist/utils/authCheck.js +34 -0
- package/dist/utils/authCheck.js.map +1 -0
- package/dist/utils/errors.d.ts +21 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +76 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/processCheck.d.ts +11 -0
- package/dist/utils/processCheck.d.ts.map +1 -0
- package/dist/utils/processCheck.js +68 -0
- package/dist/utils/processCheck.js.map +1 -0
- package/dist/utils/serverManager.d.ts +10 -0
- package/dist/utils/serverManager.d.ts.map +1 -0
- package/dist/utils/serverManager.js +167 -0
- package/dist/utils/serverManager.js.map +1 -0
- package/package.json +50 -0
- package/server-bundle/assets/fallback.html +112 -0
- package/server-bundle/assets/icon.png +0 -0
- package/server-bundle/assets/menubar-iconTemplate.png +0 -0
- package/server-bundle/assets/menubar-iconTemplate@2x.png +0 -0
- package/server-bundle/bundle-electron.js +22 -0
- package/server-bundle/package.json +15 -0
- package/server-bundle/preload.js +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# awal
|
|
2
|
+
|
|
3
|
+
Coinbase Wallet CLI for payments and crypto.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx awal status
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or install globally:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g awal
|
|
15
|
+
awal status
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Check status (will install server on first run)
|
|
22
|
+
awal status
|
|
23
|
+
|
|
24
|
+
# Sign in with email
|
|
25
|
+
awal auth login your@email.com
|
|
26
|
+
awal auth verify <flow-id> <6-digit-code>
|
|
27
|
+
|
|
28
|
+
# Check your balance
|
|
29
|
+
awal balance
|
|
30
|
+
|
|
31
|
+
# Get your wallet address
|
|
32
|
+
awal address
|
|
33
|
+
|
|
34
|
+
# Send USDC
|
|
35
|
+
awal send $1.00 0x...recipient...
|
|
36
|
+
|
|
37
|
+
# Swap tokens
|
|
38
|
+
awal trade $1 usdc eth
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Commands
|
|
42
|
+
|
|
43
|
+
### Wallet
|
|
44
|
+
|
|
45
|
+
- `awal status` - Check server and auth status
|
|
46
|
+
- `awal balance` - Get wallet balances (USDC, ETH, WETH)
|
|
47
|
+
- `awal address` - Get wallet address
|
|
48
|
+
- `awal show` - Open wallet UI
|
|
49
|
+
|
|
50
|
+
### Authentication
|
|
51
|
+
|
|
52
|
+
- `awal auth login <email>` - Start email OTP sign-in
|
|
53
|
+
- `awal auth verify <flowId> <code>` - Complete sign-in with 6-digit code
|
|
54
|
+
|
|
55
|
+
### Transactions
|
|
56
|
+
|
|
57
|
+
- `awal send <amount> <recipient>` - Send USDC to address or ENS
|
|
58
|
+
- `awal trade <amount> <from> <to>` - Swap tokens
|
|
59
|
+
|
|
60
|
+
### X402 Payments
|
|
61
|
+
|
|
62
|
+
- `awal bazaar list` - List X402 payment services
|
|
63
|
+
- `awal bazaar details <url>` - Get service details
|
|
64
|
+
- `awal pay <baseURL> <path>` - Make X402 payment request
|
|
65
|
+
- `awal discover <baseURL> <path>` - Discover payment requirements
|
|
66
|
+
|
|
67
|
+
## Options
|
|
68
|
+
|
|
69
|
+
Most commands support:
|
|
70
|
+
- `--json` - Output as JSON
|
|
71
|
+
- `--chain <chain>` - Specify blockchain (default: base)
|
|
72
|
+
|
|
73
|
+
## Architecture
|
|
74
|
+
|
|
75
|
+
The CLI communicates with an Electron-based wallet server via file-based IPC. On first run, the server bundle and Electron runtime are installed to `~/.local/share/awal/`.
|
|
76
|
+
|
|
77
|
+
## Requirements
|
|
78
|
+
|
|
79
|
+
- Node.js 18+
|
|
80
|
+
- macOS, Linux, or Windows
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
Apache-2.0
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAcpC,wBAAgB,aAAa,IAAI,OAAO,CAqBvC"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { createStatusCommand } from './commands/status.js';
|
|
3
|
+
import { createBalanceCommand } from './commands/balance.js';
|
|
4
|
+
import { createAddressCommand } from './commands/address.js';
|
|
5
|
+
import { createShowCommand } from './commands/show.js';
|
|
6
|
+
import { createBazaarCommand } from './commands/bazaar.js';
|
|
7
|
+
import { createPayCommand } from './commands/pay.js';
|
|
8
|
+
import { createDiscoverCommand } from './commands/discover.js';
|
|
9
|
+
import { createAuthCommand } from './commands/auth.js';
|
|
10
|
+
import { createSendCommand } from './commands/send.js';
|
|
11
|
+
import { createTradeCommand } from './commands/trade.js';
|
|
12
|
+
const VERSION = '1.0.0';
|
|
13
|
+
export function createProgram() {
|
|
14
|
+
const program = new Command();
|
|
15
|
+
program
|
|
16
|
+
.name('awal')
|
|
17
|
+
.description('Coinbase Wallet CLI for payments and crypto')
|
|
18
|
+
.version(VERSION);
|
|
19
|
+
// Add commands
|
|
20
|
+
program.addCommand(createStatusCommand());
|
|
21
|
+
program.addCommand(createBalanceCommand());
|
|
22
|
+
program.addCommand(createAddressCommand());
|
|
23
|
+
program.addCommand(createShowCommand());
|
|
24
|
+
program.addCommand(createBazaarCommand());
|
|
25
|
+
program.addCommand(createPayCommand());
|
|
26
|
+
program.addCommand(createDiscoverCommand());
|
|
27
|
+
program.addCommand(createAuthCommand());
|
|
28
|
+
program.addCommand(createSendCommand());
|
|
29
|
+
program.addCommand(createTradeCommand());
|
|
30
|
+
return program;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB,MAAM,UAAU,aAAa;IAC3B,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,OAAO;SACJ,IAAI,CAAC,MAAM,CAAC;SACZ,WAAW,CAAC,6CAA6C,CAAC;SAC1D,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpB,eAAe;IACf,OAAO,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC,CAAC;IACvC,OAAO,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,CAAC;IAC5C,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,UAAU,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAEzC,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/commands/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC,wBAAgB,oBAAoB,IAAI,OAAO,CA2B9C"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { sendIpcRequest } from '../ipcClient.js';
|
|
5
|
+
import { requireAuth } from '../utils/authCheck.js';
|
|
6
|
+
import { formatError } from '../utils/errors.js';
|
|
7
|
+
import { formatJson } from '../formatters/output.js';
|
|
8
|
+
export function createAddressCommand() {
|
|
9
|
+
return new Command('address')
|
|
10
|
+
.description('Get wallet address')
|
|
11
|
+
.option('--json', 'Output as JSON')
|
|
12
|
+
.action(async (options) => {
|
|
13
|
+
const spinner = ora('Fetching wallet address...').start();
|
|
14
|
+
try {
|
|
15
|
+
// Check authentication first
|
|
16
|
+
await requireAuth();
|
|
17
|
+
const result = (await sendIpcRequest('get-wallet-address', {}));
|
|
18
|
+
spinner.stop();
|
|
19
|
+
if (options.json) {
|
|
20
|
+
console.log(formatJson(result));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// Text output - just the address
|
|
24
|
+
console.log(result.address);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
spinner.fail('Failed to fetch address');
|
|
28
|
+
console.error(chalk.red(formatError(error)));
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../src/commands/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAMrD,MAAM,UAAU,oBAAoB;IAClC,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC;SAC1B,WAAW,CAAC,oBAAoB,CAAC;SACjC,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAClC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACxB,MAAM,OAAO,GAAG,GAAG,CAAC,4BAA4B,CAAC,CAAC,KAAK,EAAE,CAAC;QAE1D,IAAI,CAAC;YACH,6BAA6B;YAC7B,MAAM,WAAW,EAAE,CAAC;YAEpB,MAAM,MAAM,GAAG,CAAC,MAAM,cAAc,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAkB,CAAC;YACjF,OAAO,CAAC,IAAI,EAAE,CAAC;YAEf,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACjB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;gBAChC,OAAO;YACT,CAAC;YAED,iCAAiC;YACjC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;YACxC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC,wBAAgB,iBAAiB,IAAI,OAAO,CA4E3C"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { sendIpcRequest } from '../ipcClient.js';
|
|
5
|
+
import { formatError } from '../utils/errors.js';
|
|
6
|
+
import { formatJson, formatSuccess, formatInfo } from '../formatters/output.js';
|
|
7
|
+
export function createAuthCommand() {
|
|
8
|
+
const auth = new Command('auth').description('Authentication commands');
|
|
9
|
+
auth
|
|
10
|
+
.command('login')
|
|
11
|
+
.description('Start email OTP authentication')
|
|
12
|
+
.argument('<email>', 'Email address')
|
|
13
|
+
.option('--json', 'Output as JSON')
|
|
14
|
+
.action(async (email, options) => {
|
|
15
|
+
const spinner = ora('Sending verification code...').start();
|
|
16
|
+
try {
|
|
17
|
+
const result = (await sendIpcRequest('sign-in-with-email', { email }));
|
|
18
|
+
spinner.stop();
|
|
19
|
+
if (options.json) {
|
|
20
|
+
console.log(formatJson(result));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
console.log(formatSuccess('Verification code sent!'));
|
|
24
|
+
console.log(formatInfo(`Check your email (${email}) for a 6-digit code.`));
|
|
25
|
+
console.log(`\n${chalk.bold('Flow ID:')} ${chalk.yellow(result.flowId)}`);
|
|
26
|
+
console.log(`\nTo complete sign-in, run:`);
|
|
27
|
+
console.log(chalk.cyan(` awal auth verify ${result.flowId} <6-digit-code>`));
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
spinner.fail('Failed to send verification code');
|
|
31
|
+
console.error(chalk.red(formatError(error)));
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
auth
|
|
36
|
+
.command('verify')
|
|
37
|
+
.description('Complete email OTP verification')
|
|
38
|
+
.argument('<flowId>', 'Flow ID from login command')
|
|
39
|
+
.argument('<otp>', '6-digit verification code')
|
|
40
|
+
.option('--json', 'Output as JSON')
|
|
41
|
+
.action(async (flowId, otp, options) => {
|
|
42
|
+
// Validate OTP format
|
|
43
|
+
if (!/^\d{6}$/.test(otp)) {
|
|
44
|
+
console.error(chalk.red('OTP must be exactly 6 digits'));
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
const spinner = ora('Verifying code...').start();
|
|
48
|
+
try {
|
|
49
|
+
// The wallet returns a success message string on success, throws on failure
|
|
50
|
+
const result = await sendIpcRequest('verify-email-otp', { flowId, otp });
|
|
51
|
+
spinner.succeed('Authentication successful!');
|
|
52
|
+
if (options.json) {
|
|
53
|
+
// Normalize to object format for JSON output
|
|
54
|
+
const jsonResult = typeof result === 'string'
|
|
55
|
+
? { success: true, message: result }
|
|
56
|
+
: result;
|
|
57
|
+
console.log(formatJson(jsonResult));
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
// Show the success message from the wallet if available
|
|
61
|
+
if (typeof result === 'string' && result) {
|
|
62
|
+
console.log(chalk.dim(result));
|
|
63
|
+
}
|
|
64
|
+
console.log(`\nYou can now use wallet commands:`);
|
|
65
|
+
console.log(chalk.cyan(' awal balance'));
|
|
66
|
+
console.log(chalk.cyan(' awal address'));
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
spinner.fail('Verification failed');
|
|
70
|
+
console.error(chalk.red(formatError(error)));
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return auth;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAOhF,MAAM,UAAU,iBAAiB;IAC/B,MAAM,IAAI,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC;IAExE,IAAI;SACD,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,gCAAgC,CAAC;SAC7C,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;SACpC,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAClC,MAAM,CAAC,KAAK,EAAE,KAAa,EAAE,OAAO,EAAE,EAA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C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAC5C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;YACpC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"balance.d.ts","sourceRoot":"","sources":["../../src/commands/balance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsCpC,wBAAgB,oBAAoB,IAAI,OAAO,CAqD9C"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { sendIpcRequest } from '../ipcClient.js';
|
|
5
|
+
import { requireAuth } from '../utils/authCheck.js';
|
|
6
|
+
import { formatError } from '../utils/errors.js';
|
|
7
|
+
import { formatJson } from '../formatters/output.js';
|
|
8
|
+
const DEFAULT_ASSETS = ['USDC', 'ETH', 'WETH'];
|
|
9
|
+
function formatAssetBalance(asset, raw, decimals) {
|
|
10
|
+
const balance = Number(raw) / Math.pow(10, decimals);
|
|
11
|
+
if (asset === 'USDC') {
|
|
12
|
+
return `$${balance.toFixed(2)}`;
|
|
13
|
+
}
|
|
14
|
+
// For ETH/WETH, show more precision for small amounts
|
|
15
|
+
if (balance === 0) {
|
|
16
|
+
return '0.00';
|
|
17
|
+
}
|
|
18
|
+
if (balance < 0.0001) {
|
|
19
|
+
return balance.toFixed(6);
|
|
20
|
+
}
|
|
21
|
+
return balance.toFixed(4);
|
|
22
|
+
}
|
|
23
|
+
export function createBalanceCommand() {
|
|
24
|
+
return new Command('balance')
|
|
25
|
+
.description('Get wallet balances (USDC, ETH, WETH)')
|
|
26
|
+
.option('--asset <asset>', 'Show specific asset only (usdc, eth, weth)')
|
|
27
|
+
.option('--chain <chain>', 'Blockchain network (e.g., base, base-sepolia)')
|
|
28
|
+
.option('--json', 'Output as JSON')
|
|
29
|
+
.action(async (options) => {
|
|
30
|
+
const spinner = ora('Fetching balances...').start();
|
|
31
|
+
try {
|
|
32
|
+
// Check authentication first
|
|
33
|
+
await requireAuth();
|
|
34
|
+
// Determine which assets to fetch
|
|
35
|
+
let assets;
|
|
36
|
+
if (options.asset) {
|
|
37
|
+
assets = [options.asset.toUpperCase()];
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
assets = DEFAULT_ASSETS;
|
|
41
|
+
}
|
|
42
|
+
const data = { assets };
|
|
43
|
+
if (options.chain) {
|
|
44
|
+
data.chain = options.chain;
|
|
45
|
+
}
|
|
46
|
+
const result = (await sendIpcRequest('get-wallet-balance', data));
|
|
47
|
+
spinner.stop();
|
|
48
|
+
if (options.json) {
|
|
49
|
+
console.log(formatJson(result));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
// Text output - display balances in a clean format
|
|
53
|
+
const chainDisplay = result.chain ?? options.chain ?? 'base';
|
|
54
|
+
console.log(chalk.bold(`\nWallet Balances (${chainDisplay})`));
|
|
55
|
+
console.log(chalk.dim('─'.repeat(24)));
|
|
56
|
+
for (const asset of assets) {
|
|
57
|
+
const assetData = result.balances?.[asset];
|
|
58
|
+
const raw = assetData?.raw ?? '0';
|
|
59
|
+
const decimals = assetData?.decimals ?? (asset === 'USDC' ? 6 : 18);
|
|
60
|
+
const formatted = formatAssetBalance(asset, raw, decimals);
|
|
61
|
+
console.log(`${chalk.cyan(asset.padEnd(8))}${formatted}`);
|
|
62
|
+
}
|
|
63
|
+
console.log();
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
spinner.fail('Failed to fetch balances');
|
|
67
|
+
console.error(chalk.red(formatError(error)));
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=balance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"balance.js","sourceRoot":"","sources":["../../src/commands/balance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAe/C,SAAS,kBAAkB,CAAC,KAAa,EAAE,GAAW,EAAE,QAAgB;IACtE,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IACrD,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;QACrB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IAClC,CAAC;IACD,sDAAsD;IACtD,IAAI,OAAO,KAAK,CAAC,EAAE,CAAC;QAClB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,OAAO,GAAG,MAAM,EAAE,CAAC;QACrB,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC;AAED,MA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@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { sendIpcRequest } from '../ipcClient.js';
|
|
5
|
+
import { formatError } from '../utils/errors.js';
|
|
6
|
+
import { formatJson, formatTable, formatUsdcAmount } from '../formatters/output.js';
|
|
7
|
+
export function createBazaarCommand() {
|
|
8
|
+
const bazaar = new Command('bazaar').description('Browse X402 payment-enabled services');
|
|
9
|
+
bazaar
|
|
10
|
+
.command('list')
|
|
11
|
+
.description('List available bazaar resources')
|
|
12
|
+
.option('--network <network>', 'Filter by network (base, base-sepolia)')
|
|
13
|
+
.option('--full', 'Return complete details for all resources')
|
|
14
|
+
.option('--json', 'Output as JSON')
|
|
15
|
+
.action(async (options) => {
|
|
16
|
+
const spinner = ora('Fetching bazaar resources...').start();
|
|
17
|
+
try {
|
|
18
|
+
const data = {};
|
|
19
|
+
if (options.network) {
|
|
20
|
+
data.network = options.network;
|
|
21
|
+
}
|
|
22
|
+
if (options.full) {
|
|
23
|
+
data.full = true;
|
|
24
|
+
}
|
|
25
|
+
const result = (await sendIpcRequest('bazaar-list', data));
|
|
26
|
+
spinner.stop();
|
|
27
|
+
if (options.json) {
|
|
28
|
+
console.log(formatJson(result));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// Table output
|
|
32
|
+
if (!result.items || result.items.length === 0) {
|
|
33
|
+
console.log('No resources found');
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (options.full) {
|
|
37
|
+
// Full details - print each resource (handles nested accepts array)
|
|
38
|
+
for (const item of result.items) {
|
|
39
|
+
const fullItem = item;
|
|
40
|
+
const accept = fullItem.accepts?.[0];
|
|
41
|
+
console.log(chalk.bold(`\n${item.resource}`));
|
|
42
|
+
if (accept?.description) {
|
|
43
|
+
console.log(chalk.dim(accept.description));
|
|
44
|
+
}
|
|
45
|
+
if (accept?.maxAmountRequired) {
|
|
46
|
+
console.log(`Price: ${formatUsdcAmount(parseInt(accept.maxAmountRequired, 10))}`);
|
|
47
|
+
}
|
|
48
|
+
if (accept?.network) {
|
|
49
|
+
console.log(`Network: ${accept.network}`);
|
|
50
|
+
}
|
|
51
|
+
if (accept?.scheme) {
|
|
52
|
+
console.log(`Scheme: ${accept.scheme}`);
|
|
53
|
+
}
|
|
54
|
+
if (fullItem.metadata?.confidence?.overallScore !== undefined) {
|
|
55
|
+
console.log(`Quality Score: ${fullItem.metadata.confidence.overallScore}`);
|
|
56
|
+
}
|
|
57
|
+
if (accept?.outputSchema) {
|
|
58
|
+
console.log(`Schema: ${JSON.stringify(accept.outputSchema, null, 2)}`);
|
|
59
|
+
}
|
|
60
|
+
console.log('---');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
// Summary table (uses flat structure from summary format)
|
|
65
|
+
const tableData = result.items.map((r) => {
|
|
66
|
+
const summary = r;
|
|
67
|
+
return {
|
|
68
|
+
resource: summary.resource,
|
|
69
|
+
description: summary.description ?? '-',
|
|
70
|
+
price: summary.maxAmountRequired
|
|
71
|
+
? formatUsdcAmount(parseInt(summary.maxAmountRequired, 10))
|
|
72
|
+
: '-',
|
|
73
|
+
network: summary.network ?? '-',
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
console.log(formatTable(tableData, [
|
|
77
|
+
{ key: 'resource', header: 'Resource', width: 50 },
|
|
78
|
+
{ key: 'description', header: 'Description', width: 40 },
|
|
79
|
+
{ key: 'price', header: 'Price', width: 12 },
|
|
80
|
+
{ key: 'network', header: 'Network', width: 12 },
|
|
81
|
+
]));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
spinner.fail('Failed to fetch bazaar resources');
|
|
86
|
+
console.error(chalk.red(formatError(error)));
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
bazaar
|
|
91
|
+
.command('details')
|
|
92
|
+
.description('Get details for a specific bazaar resource')
|
|
93
|
+
.argument('<url>', 'Resource URL')
|
|
94
|
+
.option('--json', 'Output as JSON')
|
|
95
|
+
.action(async (url, options) => {
|
|
96
|
+
const spinner = ora('Fetching resource details...').start();
|
|
97
|
+
try {
|
|
98
|
+
const result = (await sendIpcRequest('bazaar-get-resource-details', {
|
|
99
|
+
resource: url,
|
|
100
|
+
}));
|
|
101
|
+
spinner.stop();
|
|
102
|
+
if (options.json) {
|
|
103
|
+
console.log(formatJson(result));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
// Text output
|
|
107
|
+
console.log(chalk.bold(`\n${result.name}`));
|
|
108
|
+
if (result.description) {
|
|
109
|
+
console.log(chalk.dim(result.description));
|
|
110
|
+
}
|
|
111
|
+
console.log(`\nURL: ${result.url}`);
|
|
112
|
+
console.log(`Method: ${result.method}`);
|
|
113
|
+
if (result.price !== undefined) {
|
|
114
|
+
console.log(`Price: ${formatUsdcAmount(result.price)}`);
|
|
115
|
+
}
|
|
116
|
+
if (result.network) {
|
|
117
|
+
console.log(`Network: ${result.network}`);
|
|
118
|
+
}
|
|
119
|
+
if (result.schema) {
|
|
120
|
+
console.log(`\nSchema:\n${JSON.stringify(result.schema, null, 2)}`);
|
|
121
|
+
}
|
|
122
|
+
if (result.paymentRequirements) {
|
|
123
|
+
console.log(`\nPayment Requirements:\n${JSON.stringify(result.paymentRequirements, null, 2)}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
spinner.fail('Failed to fetch resource details');
|
|
128
|
+
console.error(chalk.red(formatError(error)));
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
return bazaar;
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=bazaar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bazaar.js","sourceRoot":"","sources":["../../src/commands/bazaar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,E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,qBAAqB,IAAI,OAAO,CAiF/C"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import ora from 'ora';
|
|
4
|
+
import { sendIpcRequest } from '../ipcClient.js';
|
|
5
|
+
import { requireAuth } from '../utils/authCheck.js';
|
|
6
|
+
import { formatError } from '../utils/errors.js';
|
|
7
|
+
import { formatJson, formatUsdcAmount } from '../formatters/output.js';
|
|
8
|
+
export function createDiscoverCommand() {
|
|
9
|
+
return new Command('discover')
|
|
10
|
+
.description('Discover X402 payment requirements for an endpoint')
|
|
11
|
+
.argument('<baseURL>', 'Base URL of the X402-enabled endpoint')
|
|
12
|
+
.argument('<path>', 'Request path')
|
|
13
|
+
.option('-X, --method <method>', 'HTTP method (GET, POST, PUT, DELETE, PATCH)', 'GET')
|
|
14
|
+
.option('-q, --query <params>', 'Query parameters as JSON')
|
|
15
|
+
.option('-d, --data <json>', 'Request body as JSON')
|
|
16
|
+
.option('--json', 'Output as JSON')
|
|
17
|
+
.action(async (baseURL, path, options) => {
|
|
18
|
+
const spinner = ora('Discovering payment requirements...').start();
|
|
19
|
+
try {
|
|
20
|
+
// Check authentication first
|
|
21
|
+
await requireAuth();
|
|
22
|
+
const data = {
|
|
23
|
+
baseURL,
|
|
24
|
+
path,
|
|
25
|
+
method: options.method.toUpperCase(),
|
|
26
|
+
};
|
|
27
|
+
if (options.query) {
|
|
28
|
+
try {
|
|
29
|
+
data.queryParams = JSON.parse(options.query);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
spinner.fail('Invalid JSON in --query');
|
|
33
|
+
console.error(chalk.red('The --query option must be valid JSON'));
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (options.data) {
|
|
38
|
+
try {
|
|
39
|
+
data.body = JSON.parse(options.data);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
spinner.fail('Invalid JSON in --data');
|
|
43
|
+
console.error(chalk.red('The --data option must be valid JSON'));
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const result = (await sendIpcRequest('discover-x402-requirements', data));
|
|
48
|
+
spinner.stop();
|
|
49
|
+
if (options.json) {
|
|
50
|
+
console.log(formatJson(result));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// Text output
|
|
54
|
+
console.log(chalk.bold('Payment Requirements'));
|
|
55
|
+
console.log('---');
|
|
56
|
+
if (result.maxAmountRequired !== undefined) {
|
|
57
|
+
console.log(`Max Amount: ${formatUsdcAmount(result.maxAmountRequired)}`);
|
|
58
|
+
}
|
|
59
|
+
if (result.network) {
|
|
60
|
+
console.log(`Network: ${result.network}`);
|
|
61
|
+
}
|
|
62
|
+
if (result.accepts && result.accepts.length > 0) {
|
|
63
|
+
console.log(`Accepts: ${result.accepts.join(', ')}`);
|
|
64
|
+
}
|
|
65
|
+
if (result.paymentRequirements) {
|
|
66
|
+
console.log(`\nFull Requirements:\n${JSON.stringify(result.paymentRequirements, null, 2)}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
spinner.fail('Discovery failed');
|
|
71
|
+
console.error(chalk.red(formatError(error)));
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=discover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discover.js","sourceRoot":"","sources":["../../src/commands/discover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,E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