How dfinity/hardware-wallet-cli works
Project type and purpose
• This is a Node.js‐based command-line interface (CLI) tool named hardware-wallet-cli.
• Purpose: allow users to send commands (e.g., balance queries, transfers) to the Internet Computer App on a Ledger Nano S/X via USB, handling identity, signing (secp256k1), and network calls to the DFINITY Internet Computer.
File structure
• Top-level:
• src/ – TypeScript source, containing:
– index.ts – CLI entry point & dispatcher
– parsers.ts – argument parsing & command definitions
– ledger/ – Ledger transport & app identity (identity.ts + secp256k1.ts)
– utils.ts, constants.ts – shared helpers & config
• scripts/ – build/time utilities (version bump, packaging for npm/next)
• esbuild.mjs – bundling config to produce a single executable
• dfx.json – local Internet Computer/DFX network definitions
• .github/workflows/publish.yml – CI for packaging & publishing to npm
• Patterns: layered separation (CLI → parsing → command handlers → transport/crypto → network)
README for additional insights
• CLI supports commands like ic-hardware-wallet icp balance
• Relies on Node ≥18.13, esbuild for bundling, supports custom network URLs
• Warns about token decimals & unsupported tokens (CKETH, ckERC20)