|
| 1 | +#!/usr/bin/env node |
| 2 | +import { Command } from 'commander'; |
| 3 | +import { PlatformApiClient } from '@thanos/sdk-api'; |
| 4 | +import { WalletEngine } from '@thanos/sdk-core'; |
| 5 | + |
| 6 | +const program = new Command(); |
| 7 | +program.name('thanos').description('CLI for wallet platform operations').version('0.9.0'); |
| 8 | + |
| 9 | +program.option('--api <url>', 'Platform API base URL', process.env.THANOS_API_URL || 'http://localhost:4020'); |
| 10 | + |
| 11 | +program.command('health').action(async () => { |
| 12 | + const api = new PlatformApiClient({ baseUrl: program.opts().api }); |
| 13 | + console.log(JSON.stringify(await api.health(), null, 2)); |
| 14 | +}); |
| 15 | + |
| 16 | +program.command('wallet:create').description('Create a new local wallet in memory').action(async () => { |
| 17 | + const engine = new WalletEngine(); |
| 18 | + const state = await engine.createWallet(); |
| 19 | + console.log(JSON.stringify({ mnemonic: state.mnemonic, accounts: state.accounts }, null, 2)); |
| 20 | +}); |
| 21 | + |
| 22 | +program.command('portfolio <address>').action(async (address: string) => { |
| 23 | + const api = new PlatformApiClient({ baseUrl: program.opts().api }); |
| 24 | + console.log(JSON.stringify(await api.portfolio(address), null, 2)); |
| 25 | +}); |
| 26 | + |
| 27 | +program.command('lep100:tokens').option('--chain-id <id>', 'Chain id', '700777').action(async (opts: { chainId: string }) => { |
| 28 | + const api = new PlatformApiClient({ baseUrl: program.opts().api }); |
| 29 | + console.log(JSON.stringify(await api.lep100Tokens(Number(opts.chainId)), null, 2)); |
| 30 | +}); |
| 31 | + |
| 32 | +program.command('lep100:balances <address>').action(async (address: string) => { |
| 33 | + const api = new PlatformApiClient({ baseUrl: program.opts().api }); |
| 34 | + console.log(JSON.stringify(await api.lep100Balances(address), null, 2)); |
| 35 | +}); |
| 36 | + |
| 37 | +program.command('lep100:sync').option('--mode <mode>', 'bootstrap|incremental|backfill', 'incremental').action(async (opts: { mode: 'bootstrap' | 'incremental' | 'backfill' }) => { |
| 38 | + const api = new PlatformApiClient({ baseUrl: program.opts().api }); |
| 39 | + console.log(JSON.stringify(await api.lep100Sync(opts.mode), null, 2)); |
| 40 | +}); |
| 41 | + |
| 42 | +program.command('dnns:resolve <name>').action(async (name: string) => { |
| 43 | + const api = new PlatformApiClient({ baseUrl: program.opts().api }); |
| 44 | + console.log(JSON.stringify(await api.dnnsResolve(name), null, 2)); |
| 45 | +}); |
| 46 | + |
| 47 | +program.parseAsync(process.argv); |
0 commit comments