You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(cli)(#40): bulk-return amount display + integration test scrub (#41)
Closes follow-ups #1 and #2 from issue #40.
Item #1 — `sphere invoice return <id>` (bulk) shows actual refunded
amount instead of `amount: "0"`. The bug: `getInvoiceStatus()` ran
AFTER `returnAllInvoicePayments()`, by which point the SDK had drained
`senderBalances[].netBalance` to 0 (refunds had been issued), so every
row in the rendered output showed 0. Fix: snapshot status BEFORE the
SDK call, mirror the SDK's iteration filters so `plan[i] ↔ results[i]`.
Static-analysis pin in `legacy-cli-ux.test.ts` asserts the call
ordering doesn't regress (first `await getInvoiceStatus(` must precede
first `await returnAllInvoicePayments(` inside the invoice-return
case).
Item #2 — integration test backlog from PR #33 canonical-UX cutover.
Down from 63 → 3 failures (remaining 3 are unrelated regressions,
called out below).
• `expectUsageHint(out, cmdName, positional?)` helper in
`test/integration/helpers.ts`: tolerates the new
`Usage: npm run cli -- <cmd>` prefix so the next help-format
change is a one-line fix. All ~13 call sites updated.
• JSON-shape stdout captures (`/"directAddress": "..."/` etc.)
updated to canonical-UX labelled-block form
(`/directAddress\s*:\s*.../`) across 9 test files.
• `--asset "1000000 UCT"` quoted single-string form (rejected by
the canonical asset-pair guard) replaced with two-positional form
in cli-invoice/cli-swap.
• `expect.toMatch(/Asset not found/)` → case-insensitive — the
error string is lowercased by `failWithHelp` now. Same for
`No invoice found matching prefix:`.
• `crypto decrypt` now accepts BOTH bare base64 (the new
canonical-UX `crypto encrypt` output) and JSON-quoted base64
(legacy `--json` callers). Restores the
`encrypt foo pw | decrypt - pw` roundtrip.
• Added `swap-ping` HELP_TEXT block and completion entry (the
`failWithHelp('swap-ping', ...)` calls were already there;
only the help registration was missing). Moved swap-ping into
`SWAP_SUBCOMMANDS` and dropped the obsolete
"no help available (HELP_TEXT gap pin)" test.
Items #3 (`--asset-index` / `--target-index`) and #4 (NFT-only
`invoice pay`) deferred per the issue's suggested order.
Out of scope, remaining integration failures (3):
• `cli-multiaddress`: `tokens/` subdir ENOENT after `payments
switch 1` — likely Profile (OrbitDB) cutover relocating the
per-address token store off `.sphere-cli/tokens/`. Separate
bug; not Usage/UX cutover.
• `cli-wallet-lifecycle`: `sphere clear --yes` succeeds, but
`sphere status` afterwards auto-generates a new wallet and
reports it instead of "No wallet found". Real CLI/SDK
regression; needs a separate ticket.
• `cli-wallet-lifecycle`: `init --nametag` flake — testnet
nametag mint sometimes doesn't complete inside the timeout.
Locally green when the mint succeeds; the regex now correctly
matches the canonical UX `nametag : @<name>` form.
Unit tests (127) all green. Type-check + lint clean.
Co-authored-by: Vladimir Rogojin <vrogojin@blockyinnovations.com>
0 commit comments