Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
73004a9
fix(deps): bump jackson-databind 2.16.1 -> 2.18.8
gummy789j Jul 7, 2026
d5ebade
Merge pull request #951 from tronprotocol/fix/bump-jackson-2.18.8
gummy789j Jul 15, 2026
d723e18
docs: re-organize
gummy789j Jul 10, 2026
69ce102
docs(skill): ts wallet-cli SKILL.md
gummy789j Jul 10, 2026
65c06da
docs(readme): root README improve routing
gummy789j Jul 13, 2026
9a4e4cc
docs(readme): optimize per command document
gummy789j Jul 14, 2026
c05d2be
Merge pull request #953 from tronprotocol/doc/readme-optimization
gummy789j Jul 15, 2026
8da4be6
refactor(cli): family-keyed command contract with unified command id
gummy789j Jul 7, 2026
288de3e
refactor(cli): split render/index.ts by command domain
gummy789j Jul 7, 2026
4e84d37
feat(ts): add vote and reward commands
Jul 8, 2026
0ac4d74
feat(ts): v0.1.1 — stake/chain queries, change-password, waitTimeoutM…
gummy789j Jul 9, 2026
4a8dd5a
docs: update source of truth and remove others deprecated file
gummy789j Jul 9, 2026
0ee77df
feat(ts): add fuller leaf-help descriptions and tree-style unstake list
gummy789j Jul 14, 2026
d257b24
feat(ts): fail-fast watch-only guard on write ops; rename backup error
gummy789j Jul 14, 2026
94a2b53
fix: package verison & document wording & comment wording & error cat…
gummy789j Jul 14, 2026
a5a5e12
fix(ts): recoverable keystore password rotation; validate waitTimeout…
gummy789j Jul 15, 2026
f3a4a86
feat(docs): updated README with adding badge & updated CLAUDE.md deve…
gummy789j Jul 15, 2026
41dc0f0
feat: fsync ensure write in file & clear cache secret & avoid backup …
gummy789j Jul 15, 2026
9f34014
fix(ts): fsync durability on rollback path & propagate real dir-fsync…
gummy789j Jul 15, 2026
4bebaab
fix(ts): don't mislabel a post-fsync failure as a clean rollback
gummy789j Jul 15, 2026
0b410ed
fix(ts): correct doc command ids to unprefixed form & ship docs+skill…
gummy789j Jul 16, 2026
3e8e97e
fix(ts): correct missed message.sign command id in docs
gummy789j Jul 16, 2026
d3e2fc2
docs(ts): add output examples to block and import ledger reference pages
gummy789j Jul 16, 2026
e1fa2e4
Merge pull request #950 from tronprotocol/feat/ts-v0.1.1
gummy789j Jul 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 3 additions & 2 deletions .github/workflows/build-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
cache: gradle

- name: Build
working-directory: java
run: ./gradlew clean build shadowJar shadowDistZip

- name: Package artifacts
Expand All @@ -43,8 +44,8 @@ jobs:
artifact_name="wallet-cli-artifact-${GITHUB_REF_NAME}"

mkdir -p "$artifact_dir"
cp build/libs/wallet-cli.jar "$artifact_dir/${artifact_base}.jar"
cp build/distributions/*shadow*.zip "$artifact_dir/${artifact_base}.zip"
cp java/build/libs/wallet-cli.jar "$artifact_dir/${artifact_base}.jar"
cp java/build/distributions/*shadow*.zip "$artifact_dir/${artifact_base}.zip"
git rev-parse HEAD > "$artifact_dir/git-sha.txt"
echo "ARTIFACT_NAME=${artifact_name}" >> "$GITHUB_ENV"

Expand Down
47 changes: 12 additions & 35 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,43 +1,20 @@
.claude/settings.local.json
# Per-implementation ignores live in java/.gitignore and ts/.gitignore.
# Only repo-wide patterns belong here.

# OS / editor / IDE
.DS_Store
build
out
.idea
.gradle
.vscode/
# Eclipse JDT / VS Code Java language server output
/bin/

# Tooling
node_modules
src/main/genjs/api
src/main/genjs/core
src/genjs
src/gen
tools
src/main/resources/static/js/tronjs/tron-protoc.js
logs
docs
!docs/
!docs/standard-cli-contract-spec.md
FileTest
bin

# Wallet keystore files created at runtime
/Wallet/
/Mnemonic/
/wallet_data/

# QA runtime output
qa/results/
qa/runtime/
qa/report.txt
qa/.verify.lock/
graphify-out/

# claude
# Claude
.claude/
.claude/settings.local.json

.private/

# graphify
graphify-out/
.vscode/
docs/superpowers


/ts-deprecated/
8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

70 changes: 66 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,68 @@

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Repository Layout

The repository holds two independent implementations:

- `java/` — the original REPL-first implementation, described by the rest of this file.
- `ts/` — the agent-first TypeScript rewrite (npm package `@tron-walletcli/wallet-cli`). See the
**TypeScript Implementation** section below and `ts/README.md`.

Everything below (except the TypeScript Implementation section) refers to the Java implementation.
**All Java paths are relative to `java/`, and all Java commands are run from that directory**
(`cd java` first).

## TypeScript Implementation

The `ts/` package is a self-contained, agent-first CLI (Node.js 20+, ESM, TypeScript). Every command
has a stable JSON envelope, deterministic exit codes, and discoverable schemas; interactive prompts
are used only for secret input (create / import / backup / delete). **All `ts/` commands run from the
`ts/` directory.**

```bash
cd ts
npm ci # install
npm run build # bundle to dist/ via tsup (bin: wallet-cli -> dist/index.js)
npm run dev -- <args> # run from source via tsx (e.g. npm run dev -- create --label main)
npm test # vitest (tests are co-located as *.test.ts)
npm run typecheck # tsc --noEmit
npm run depcruise # dependency-cruiser — enforces the architecture rules below
```

### Architecture (hexagonal / ports & adapters)

Dependencies point inward. The source of truth is
`ts/docs/typescript-wallet-cli-architecture-source-of-truth.md` — read it before changing
boundaries, ports, command routing, or the JSON contract. `depcruise` enforces these rules in CI.

| Area (`ts/src/…`) | Role | May depend on | Must NOT depend on |
|---|---|---|---|
| `domain` | Pure rules & values, zero I/O (address, amounts, derivation, wallet, family, errors) | Node / pure libs only | application, adapters, bootstrap |
| `application` | Use cases, services, contracts, and **ports** (interfaces it owns) | `domain` | adapters, bootstrap |
| `adapters/inbound` | CLI driving side — parse argv, route to use cases, render output | application, domain | adapters/outbound, bootstrap |
| `adapters/outbound` | Implements application ports — keystore, TronWeb/Tron gateway, Ledger, price, config, persistence | application ports, domain | adapters/inbound, bootstrap |
| `bootstrap` | Composition root + process lifecycle (`runner.ts`, `composition.ts`, `argv.ts`, `families/`) | all areas | — (assembly only) |

Key points:
- **Ports live in `application/ports/`** (e.g. `wallet-repository`, `tron-gateway`, `ledger-device`,
`price-provider`); outbound adapters implement them (dependency inversion).
- **Chain-family differences** are isolated in the `tron` family — `application/use-cases/tron/`,
`adapters/outbound/chain/tron/`, and the family plugin under `bootstrap/families/`. EVM is planned,
not yet public.
- **A single Zod schema per command** drives validation, yargs arity, help text, and JSON Schema.
- **Secrets** (private keys, mnemonics, BIP39 passphrases) are encrypted at rest and never accepted
from argv or env — only a dedicated stdin channel or hidden TTY prompt.

### Adding a TypeScript command

1. Add the command module under `adapters/inbound/cli/commands/` with its Zod schema.
2. Route it to an application use case (`application/use-cases/…`, e.g. `tron/transaction-service.ts`);
do not put I/O or chain logic in the inbound layer.
3. If it needs new I/O, define a **port** in `application/ports/` and implement it in
`adapters/outbound/`. Wire it in `bootstrap/composition.ts`.
4. Add co-located `*.test.ts` and run `npm run depcruise && npm run typecheck && npm test`.

## Build & Run

```bash
Expand Down Expand Up @@ -49,7 +111,7 @@ This is a **TRON blockchain CLI wallet** built on the [Trident SDK](https://gith

### Two CLI Modes

1. **REPL 交互模式** (human-friendly) — `Client` class with JCommander `@Parameters` inner classes. Entry point: `org.tron.walletcli.Client`. Features tab completion, interactive prompts, and conversational output. This is the largest file (~4700 lines). Best for manual exploration and day-to-day wallet management by humans.
1. **REPL 交互模式** (human-friendly) — `Client` class with JCommander `@Parameters` inner classes. Entry point: `org.tron.walletcli.Client`. Features tab completion, interactive prompts, and conversational output. This is the largest file (~4900 lines). Best for manual exploration and day-to-day wallet management by humans.
2. **Standard CLI 模式** (AI-agent-friendly) — `StandardCliRunner` with `CommandRegistry`/`CommandDefinition` pattern in `org.tron.walletcli.cli.*`. Supports `--output json`, `--network`, `--quiet` flags. Commands are registered in `cli/commands/` classes (e.g., `WalletCommands`, `TransactionCommands`, `QueryCommands`). Designed for automation: deterministic exit codes, structured JSON output, no interactive prompts, and env-var-based authentication — ideal for AI agents, scripts, and CI/CD pipelines.

The standard CLI suppresses all stray stdout/stderr in JSON mode to ensure machine-parseable output. Authentication is automatic via `MASTER_PASSWORD` env var + keystore files in `Wallet/`.
Expand All @@ -59,7 +121,7 @@ The standard CLI suppresses all stray stdout/stderr in JSON mode to ensure machi
Before changing parser behavior, auth flow, JSON output, command success/failure semantics, or `qa/` expectations for
the standard CLI, read:

- `docs/standard-cli-contract-spec.md`
- `java/docs/standard-cli-contract-spec.md`

Treat that file as the source of truth for the standard CLI contract unless the repository owner explicitly decides to
revise it.
Expand Down Expand Up @@ -116,9 +178,9 @@ User Input → Client (JCommander) → WalletApiWrapper → WalletApi → Triden

### Key Frameworks & Libraries

- **Trident SDK 0.10.0** — All gRPC API calls to TRON nodes
- **Trident SDK 0.11.0** — All gRPC API calls to TRON nodes
- **JCommander 1.82** — CLI argument parsing (REPL 交互模式)
- **JLine 3.25.0** — Interactive terminal/readline
- **BouncyCastle** — Cryptographic operations
- **Protobuf 3.25.5 / gRPC 1.60.0** — Protocol definitions and transport
- **Protobuf 3.25.8 / gRPC 1.75.0** — Protocol definitions and transport
- **Lombok** — `@Getter`, `@Setter`, `@Slf4j` etc. (annotation processing)
Empty file removed FETCH_HEAD
Empty file.
Loading
Loading