update agent wallet to 2.3.0 - #14
Conversation
Code Audit ReportRepository: 1. PR OverviewBranch Info
Commit Summary
Files Changed (25 total)Statistics: 395 insertions, 739 deletions (net reduction of ~344 lines) 2. Change Summary2.1 Core Architectural Change: "Register-Then-Check" ModelThe primary change replaces the previous "register-only-if-configured" model with an always-register, check-at-runtime approach:
2.2 Dependency Upgrade:
|
| Category | Status | Notes |
|---|---|---|
| Correctness & Logic | Needs Attention | Double getAddress() call (MAJOR-4); singleton state edge case (MAJOR-3) |
| Security | Pass | No hardcoded secrets; private keys still never in tool arguments; legacy plaintext-key env vars removed |
| Performance | Minor Issue | Redundant getAddress() call (MAJOR-4); no N+1 or unbounded operations introduced |
| Code Quality | Needs Attention | Dead duplicate function signTransactionRaw (SUGGESTION-2); stale tool description (MINOR-1); empty-list ambiguity (MINOR-2) |
| Testing | Needs Attention | Write-path tests permanently disabled (MAJOR-1); missing test for new tuple format (SUGGESTION-3); temp directory not cleaned (MINOR-4) |
| Documentation & Maintainability | Pass | Docs accurately reflect new model; CHANGELOG updated; inline comments explain SDK version differences |
| Dependency Risks | Pass | Version bump from 2.2.0 → 2.3.0 is a minor release; dual-format handling mitigates format change risk |
6. Review Verdict
Verdict: Request Changes
Rationale
The core architectural change — registering all tools unconditionally and checking wallet availability at runtime — is sound and makes the server more useful to MCP clients that cannot inspect server-side state before listing tools. The removal of the legacy TRON_* env var mapping is appropriate given the SDK's new file-backed configuration model.
However, two issues warrant fixes before merge:
-
MAJOR-1 (hardcoded
hasWallet = false) is the most impactful: all write-operation integration tests are now permanently dead code. The test guards existed specifically to protect against regressions in the most sensitive user-facing operations (fund transfers, staking, governance). Replacingfalsewith a live env-var check preserves the guard semantics while enabling CI coverage when credentials are available. -
MAJOR-4 (double
getAddress()call) is a correctness issue that should be fixed before the module-level singleton pattern causes confusion in future debugging sessions.
MAJOR-2 and MAJOR-3 are worth noting but are lower priority — they address edge cases (malformed wallet provider responses, re-configuration after startup) that are unlikely to occur in normal operation with agent-wallet 2.3.0.
The MINOR and SUGGESTION items can be addressed in a follow-up PR without blocking merge after the two required fixes above are in place.
Code Review Audit ReportProject: 1. PR Overview
Commit HistoryFiles Changed (Grouped)
2. Change Summary2.1 Dependency Upgrade:
|
| Category | Check | Result | Notes |
|---|---|---|---|
| Correctness & Logic | Core logic correctly implements intended behavior | Pass | Eager registration + runtime check is logically sound |
| Correctness & Logic | No dead code paths | Fail | getOwnerAddress() null guard is dead code (FINDING-M2) |
| Correctness & Logic | signTransactionRaw vs signTransaction duplication |
Warn | Functionally identical; should be merged (FINDING-S2) |
| Correctness & Logic | API shape compatibility handled correctly | Pass with caveat | Dual-shape parser present; new tuple format untested (FINDING-m6) |
| Security | Private keys not passed as tool arguments | Pass | Confirmed — no key material in tool schemas |
| Security | Env variable removal does not introduce new leak vectors | Pass | Removal is clean; no new plaintext exposure |
| Security | Error messages do not leak sensitive data | Pass | Errors are generic enough |
| Security | Backward compatibility break is documented | Fail | No migration warning in code; only in CHANGELOG (FINDING-C1) |
| Performance | Provider singleton caching works correctly | Pass | provider, activeWallet, activeAddress are module-level singletons |
| Performance | No unnecessary async operations | Pass | getProvider() is synchronous; lazy initialization pattern is efficient |
| Code Quality | Removed requiresWallet annotation consistently |
Pass | Removed from types.ts, tools/index.ts, wallet.ts |
| Code Quality | Tool descriptions updated to match new behavior | Partial Fail | select_wallet still references "Encrypted Storage mode" (FINDING-M3) |
| Code Quality | No unused imports | Pass | import * as services from "./services/index.js" removed from tools/index.ts and prompts.ts |
| Code Quality | package.json module field corrected |
Pass | Changed from src/index.ts to build/index.js |
| Testing | Unit test coverage for changed functions | Pass | agent-wallet.test.ts comprehensively covers new paths |
| Testing | Integration tests remain runnable | Fail | hasWallet = false permanently disables wallet-path integration tests (FINDING-M4) |
| Testing | New behavior (always-registered tools) tested | Pass | tools.test.ts validates tools are registered without wallet |
| Testing | Runtime error path for wallet-absent tools tested | Pass | Both unit and integration tests validate isError: true |
| Testing | listWallets tuple format tested |
Fail | Only legacy object format tested in new test suite (FINDING-m6) |
| Documentation | README.md updated for new wallet flow |
Pass | Thoroughly updated |
| Documentation | AGENTS.md updated |
Pass | Updated accurately |
| Documentation | CHANGELOG.md updated |
Pass | Entry added for 1.1.7 |
| Documentation | In-code error messages provide actionable guidance | Fail | Error messages stripped to bare statements (FINDING-m4) |
| Documentation | mcp_example.json reflects new configuration |
Partial Fail | Wallet config removed without replacement guidance (FINDING-S4) |
6. Review Verdict
Verdict: Request Changes
This PR achieves its stated goals — upgrading @bankofai/agent-wallet to 2.3.0, simplifying the registration model, and cleaning up legacy TRON_* env var support. The code is generally clean, the test improvements are meaningful, and the architectural direction is sound.
However, the following issues require resolution before merge:
Must Fix (Blocking):
- FINDING-C1 — The silent removal of
TRON_PRIVATE_KEY/TRON_MNEMONICsupport is a breaking change that will affect all existing static-key deployments without in-band warning. Add a runtime startup warning or handle this as a semver-major release. - FINDING-M4 — Permanently hardcoding
const hasWallet = falsein seven integration test files removes all CI coverage for wallet-backed write operations. Restore a conditional (env-gated) mechanism.
Should Fix (Non-blocking but important):
- FINDING-M2 — Remove the dead null check in
getOwnerAddress(). - FINDING-M3 — Update
select_walletdescription to remove stale "Encrypted Storage mode" reference. - FINDING-m4 — Restore actionable guidance in wallet error messages.
- FINDING-m6 — Add test coverage for the
listWalletstuple return format.
Nice to Have:
- FINDING-S1 — Add wallet status logging at startup.
- FINDING-S2 — Merge
signTransactionRawintosignTransaction. - FINDING-S3 — Log swallowed
resolveWalletProvidererrors. - FINDING-S4 — Improve
mcp_example.jsonwith wallet setup hint.
Report generated by automated code review on 2026-03-21.
No description provided.