feat(trader): add sphere trader withdraw subcommand#12
Open
feat(trader): add sphere trader withdraw subcommand#12
Conversation
Mirrors the pattern in trader-service, escrow-service, agentic-hosting, and js-faucet. When set to a comma-separated list of WebSocket URLs, overrides the network preset's relay list. Used by the trader-service local-infra e2e harness so 'sphere wallet init', 'sphere host spawn', 'sphere trader create-intent', etc., target the same Docker-hosted relay as the spawned tenants. Falls back to SPHERE_NOSTR_RELAYS if UNICITY_NOSTR_RELAYS is unset. Empty/unset → use network default (no behavioral change). Patches both initSphere() in src/host/sphere-init.ts (the new 'sphere host …' / 'sphere trader …' inits) AND the legacy-cli's getSphere() in src/legacy/legacy-cli.ts (the 'sphere wallet init' path).
Wires the missing controller-side CLI for the trader's WITHDRAW_TOKEN ACP command. Validates --asset / --amount / --to-address up-front (so malformed inputs fail with clear messages before reaching the trader's own validation gate), then sends the WITHDRAW_TOKEN command via the existing transport. The trader image already implements WITHDRAW_TOKEN end-to-end (split selected token + send + history record + balance update), and the HMA-trade-settlement e2e helper has been calling `sphere trader withdraw` for a while — but the subcommand was never registered, so every test run failed at the withdraw step with "unknown command 'withdraw'". Verified: HMA-trade-settlement.e2e-live Pair-2 reaches deal COMPLETED, runs withdraw, prints transfer_id, and the post-withdraw balance delta matches the withdrawn amount. Pair-1 failed only on a transient testnet Market API 502 (external infra), not on the withdraw path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Registers the
sphere trader withdrawsubcommand, which sends aWITHDRAW_TOKENACP command via the existing transport layer. The subcommand was missing fromsrc/trader/trader-commands.tsdespite already being invoked by the trader-service e2e helpers — this PR closes that gap. Inputs (--asset,--amount,--to-address) are validated up-front before the ACP command is dispatched.Test plan
The help output should show the new subcommand with its three required flags. For an end-to-end check, run the trader-service
hma-trade-settlement.e2e-live.test.tslive test — it shells out tosphere trader withdrawto drive the withdraw step.