Skip to content

refactor(cast): deduplicate Tempo boilerplate - #15748

Merged
mattsse merged 5 commits into
foundry-rs:masterfrom
0xMars42:refactor/cast-tempo-boilerplate
Jul 21, 2026
Merged

refactor(cast): deduplicate Tempo boilerplate#15748
mattsse merged 5 commits into
foundry-rs:masterfrom
0xMars42:refactor/cast-tempo-boilerplate

Conversation

@0xMars42

@0xMars42 0xMars42 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Motivation

Cast-side counterpart of #15641. The Tempo commands in cast repeat the same blocks: the payload query commands each branch the same way between JSON and human output, the keychain hardfork gates repeat the same check-and-bail block seven times, and send_tip20_transaction copies its sponsor attachment and signer resolution across its send paths.

Solution

Three mechanical extractions into the shared cast tempo module, behavior unchanged:

  • print_payload owns the JSON-or-human output branch shared by the payload query commands (tip403 info/check, receive-policy get/validate/receipt, storage-credits balance/mode/budget).
  • ensure_tempo_precompile_active merges the near-identical T6/T7 precompile guards of the receive-policy and storage-credits commands, code-presence fallback included.
  • attach_sponsor and resolve_send_signer own the sponsor fee-token-and-attach block (copied in three of the four send paths) and the signer resolution (copied in two). The four send paths themselves stay separate, they dispatch differently.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Four mechanical extractions, behavior unchanged:

- The Tempo provider construction was spelled out at 33 call sites across
  the cast commands; `tempo_provider(&config)` in the shared tempo module
  owns it, the keychain doctor's error-matching variant included.
- `print_payload` existed as three identical copies in the tip403,
  receive-policy and storage-credits commands; one copy lives in the
  shared tempo module.
- Seven keychain hardfork gates repeated the same check-and-bail block;
  `ensure_tempo_hardfork` owns it, and `ensure_tempo_precompile_active`
  merges the near-identical T6/T7 precompile guards of the receive-policy
  and storage-credits commands, code-presence fallback included.
- Inside `send_tip20_transaction`, the sponsor fee-token-and-attach block
  was copied in three of the four send paths and the signer resolution in
  two; `attach_sponsor` and `resolve_send_signer` own them. The four send
  paths themselves stay separate, they dispatch differently.
stevencartavia
stevencartavia previously approved these changes Jul 15, 2026
Comment thread crates/cast/src/tempo.rs
Comment thread crates/cast/src/tempo.rs Outdated
Restore the inline provider construction at its call sites, including
the doctor error-matching variant and the session tests. The call sites
are back to what master has.

@mablr mablr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

@mattsse
mattsse merged commit ebe3de7 into foundry-rs:master Jul 21, 2026
20 checks passed
@github-project-automation github-project-automation Bot moved this to Done in Foundry Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants