(args: string)
| 66 | } |
| 67 | |
| 68 | function handleSetup(args: string): string { |
| 69 | const parts = args.trim().split(/\s+/) |
| 70 | const keyArg = parts[1] |
| 71 | |
| 72 | if (keyArg) { |
| 73 | // Import existing key |
| 74 | try { |
| 75 | const address = saveX402PrivateKey(keyArg) |
| 76 | saveX402Config({ enabled: true }) |
| 77 | return `Wallet imported and enabled.\nAddress: ${address}\n\nFund this address with USDC on ${getX402Config().network} to enable payments.` |
| 78 | } catch (err) { |
| 79 | return `Error importing key: ${err instanceof Error ? err.message : String(err)}` |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // Generate new key |
| 84 | const privateKey = generateX402PrivateKey() |
| 85 | const address = saveX402PrivateKey(privateKey) |
| 86 | saveX402Config({ enabled: true }) |
| 87 | |
| 88 | return `New wallet generated and enabled. |
| 89 | Address: ${address} |
| 90 | Network: ${getX402Config().network} |
| 91 | |
| 92 | IMPORTANT: Fund this address with USDC to enable payments. |
| 93 | Your private key is stored in ~/.claude/config.json |
| 94 | |
| 95 | To use on testnet first: /x402 network base-sepolia` |
| 96 | } |
| 97 | |
| 98 | function handleStatus(): string { |
| 99 | const config = getX402Config() |
no test coverage detected