Skip to content

feat(cli): build transfer walkthrough — interactive approval discovery (#0382)#213

Merged
trevormil merged 2 commits intomainfrom
feat/cli-build-transfer-walkthrough
May 7, 2026
Merged

feat(cli): build transfer walkthrough — interactive approval discovery (#0382)#213
trevormil merged 2 commits intomainfrom
feat/cli-build-transfer-walkthrough

Conversation

@trevormil
Copy link
Copy Markdown
Collaborator

Summary

Adds bb cli build transfer — an interactive walkthrough that takes the hardest part of building a transfer (picking which approval to consume) and turns it into a numbered-list prompt.

Implements autopilot ticket #0382.

What it does

  1. Prompts for collectionId, from, to (or pulls from flags).
  2. Fetches the collection + sender's outgoing approvals + recipient's incoming approvals via the existing API client.
  3. Prints a grouped numbered list (collection / outgoing / incoming) with tags surfacing predetermined, payment, must-own, backed.
  4. Prompts for prioritizedApprovals by index (comma-separated, blank to skip).
  5. For each level with a pick, prompts whether to set onlyCheckPrioritized<Level>Approvals.
  6. If any prioritized approval has predeterminedBalances, prompts whether to delegate balance computation via precalculateBalancesFromApproval.
  7. If not precalculated, prompts for amount (default 1) and tokenIds (default all valid).
  8. Emits a /tokenization.MsgTransferTokens payload.

Output flows through the existing emit() pipeline, so --simulate / --deploy-with-browser / auto-validate all just work. --deploy-with-burner is CREATE-only and will fail with its existing clear error.

Flag short-circuits

Every prompt can be short-circuited:

bb cli build transfer --collection-id 1 --from bb1abc --to bb1xyz --amount 5 --token-ids 1-10

--yes skips every prompt for scripts/CI: no prioritization, no precalc, default amount=1, default tokenIds=all valid.

Tests

11 new unit tests cover the pure helpers (token-id-spec parsing, index list parsing, candidate extraction, summary tag flagging). The interactive readline loop + network calls aren't unit-tested — verified manually via --help smoke after npm run build.

Test plan

  • npm run build clean (608 files, no circular deps).
  • jest src/cli/utils/walkthrough-transfer.spec.ts — 11/11 pass.
  • bb cli build transfer --help renders the new options.
  • Reviewer runs against a real collection on testnet and walks the prompts.
  • bb cli build transfer --yes --collection-id <id> --from bb1... --to bb1... produces a structurally-valid MsgTransferTokens (emit() auto-validate should green-light it).

Out of scope

  • Alias-amount lookup (mentioned as "maybe" in the original ask) — separate ticket if desired.
  • Multi-recipient transfers — single recipient only for v1.
  • Suggesting approvals the caller needs to create — separate "suggest_approval" flow.

🤖 Generated with Claude Code

trevormil and others added 2 commits May 7, 2026 08:02
…y (#0382)

Adds `bb cli build transfer` — an interactive walkthrough for
MsgTransferTokens that fetches the collection + sender outgoing +
recipient incoming approvals, displays them as a numbered list, and
walks the user through picking prioritizedApprovals, enabling the
per-level only-check scopes, opting into precalculateBalancesFromApproval
when an approval defines predeterminedBalances, and (when not
precalculated) specifying the transfer amount + tokenIds.

Output is the same /tokenization.MsgTransferTokens shape the existing
build_transfer MCP tool produces, so it flows through the shared
emit() pipeline — auto-validate, --simulate, --deploy-with-browser
all work unchanged. The CREATE-only --deploy-with-burner path will
fail with its existing clear error.

Any prompt can be short-circuited with a flag (--collection-id /
--from / --to / --amount / --token-ids), and --yes skips every
prompt for script/CI use (default amount=1, all valid token IDs, no
prioritization, no precalc).

Includes 11 unit tests for the pure helpers (token-id-spec parsing,
index list parsing, candidate extraction, summary tag flagging).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…Multiplier, auto-validate/simulate

Second-pass polish on the build transfer walkthrough:

- Lenient yes/no parsing (isYes accepts y/Y/yes/YES with whitespace).
- Reject "Mint" as the To address — only valid as From.
- Heads-up block before precalc/balances when picked approvals carry
  payment / must-own side conditions, so the user can ctrl-c out
  before producing a tx that'll fail at sign time.
- scalingMultiplier prompt during precalculation — important for
  consuming N predetermined steps in one tx.
- Renumber the precalc candidate list 1..N (was reusing the prior
  candidate-list index, confusing).
- Always emit prioritizedApprovals: [] (was conditionally omitted) to
  satisfy the validator's "explicitly specified" warning.
- Extend emit() so transfer txs flow through auto-validate (and
  auto-simulate when --simulate is set). Validate now confirms
  structural correctness on the transfer path; simulate hits
  /api/v0/simulate for end-to-end gas + event preview.
- Tightened --yes docstring (was claiming behavior the code didn't do).
- 2 new tests for isYes (13 total).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@trevormil trevormil merged commit 3026aef into main May 7, 2026
1 check was pending
@trevormil trevormil deleted the feat/cli-build-transfer-walkthrough branch May 7, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant