Skip to content

feat(studio): read-from-view-function config-call arg kind (#147) - #149

Merged
robercano-ghbot merged 2 commits into
mainfrom
feat/issue-147-studio-read-arg
Jul 20, 2026
Merged

feat(studio): read-from-view-function config-call arg kind (#147)#149
robercano-ghbot merged 2 commits into
mainfrom
feat/issue-147-studio-read-arg

Conversation

@robercano-ghbot

Copy link
Copy Markdown
Collaborator

Closes #147

Summary

Follow-up to #140 / PR #146 (which added the read config-call arg kind to @redeploy/config). This wires that read arg kind into the Studio config-call argument editor: a user can now pass a value read from a deployed contract's view/pure function as an argument to another config call. Module:studio only — no changes outside apps/studio/.

What changed (all under apps/studio/)

  • src/manifest/index.ts — new getViewFunctions(name) helper (filters ABI by stateMutability === "view" | "pure", mirrors getStateChangingFunctions: dedup-by-signature, manifest order).
  • src/spec/types.ts — new StudioReadRef variant in the StudioConfigArg union (source contract deployId, function name, optional nested ref/literal args).
  • src/spec/graph-to-spec.tsnormalizeStudioArg emits { kind: "read", contract, function, args? } matching @redeploy/config's ReadArg exactly (omits empty args, never nests a read; args restricted to ref/literal).
  • src/components/{ConfigPanel,ContractNode,OrderedConfigPanel}.tsx — added a read option to the arg-kind toggle in all three arg editors, reusing the existing deployTargets deployId picker for the source contract and getViewFunctions for the view-function picker.
  • src/hooks/useGraph.tsstepReferencesDeployId now also tracks references made through a read arg (its contract and nested addressRef call-args) so deleting a source-contract node prunes the referencing config step (prevents exporting a spec with a dangling read.contract).

Tests (vitest + RTL, apps/studio/test/)

  • getViewFunctions unit tests (view/pure inclusion, exclusion of state-changing, no-arg decimals(), dedup via a forced-collision fixture, declared order, partition vs getStateChangingFunctions).
  • Per-editor read toggle rendering; source-contract + view-function pickers; default-first selection; switching source contract re-picks the new contract's first view function (asserted full emitted arg); empty "— no view functions —" fallback.
  • graph-to-spec emits a valid read ConfigArg (no-arg, ordered-step, own ref/literal args, mixed arrays, exact key shape) with a validateSpec + validateConfig round-trip.
  • useGraph node-deletion pruning for read-arg references (unit + integration).

Gates

Studio module gates via .claude/scripts/gate.sh / pnpm -F @redeploy/studio: build, typecheck, lint, test (1142/1142), coverage all pass. Studio coverage 97.04% stmts / 88.64% branch; every touched file >80% (DoD threshold).

Review

Routed through all four review lenses (.claude/gates.json, consensus "all"): correctness, tests, security, performance — all APPROVE (correctness + tests approved after a fix pass that added read-arg reference tracking on node delete and strengthened the read-arg assertions/coverage).

🤖 Generated with Claude Code

robercano and others added 2 commits July 19, 2026 14:24
Wires @redeploy/config's ReadArg (merged in PR #146) into the studio's
config-call argument editors, so a user can pass a value read from a
deployed contract's view/pure function (e.g. token.decimals()) as an
argument to another config call, alongside the existing literal and
address-ref arg kinds.

- manifest: add getViewFunctions(name), mirroring getStateChangingFunctions
  but filtered to view/pure functions, for the read-source function picker.
- spec/types.ts: add StudioReadRef ({ kind: "read", contract, function,
  args? }) to the StudioConfigArg union, mirroring ReadArg's shape 1:1.
- ConfigPanel.tsx, ContractNode.tsx, OrderedConfigPanel.tsx: add a "read"
  option to each arg-kind toggle; selecting it lets the author pick a
  source contract from the existing deployTargets list and a view/pure
  function on it via getViewFunctions. Defaults to the first deploy target
  and its first view function. v1 keeps it simple (no nested-arg editor for
  the view call's own args) but the type carries an optional `args` field
  for a future editor.
- graph-to-spec.ts: extend normalizeStudioArg to pass StudioReadRef through
  to ReadArg unchanged (contract/function pass straight through; any own
  args are normalized via a new normalizeReadCallArg, ref/literal only, no
  nested reads — matching ReadCallArg's restriction).
- Tests: getViewFunctions unit tests (manifest.test.ts); read-arg rendering
  and interaction tests in all three editors (ConfigPanel.test.tsx,
  config-panel-ordered.test.tsx); graph-to-spec read normalization tests
  (config-panel-ordered.test.tsx), including own-arg normalization and
  validateConfig round-trip.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… tests (#147)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@robercano-ghbot
robercano-ghbot merged commit 756aa53 into main Jul 20, 2026
6 checks passed
@robercano-ghbot
robercano-ghbot deleted the feat/issue-147-studio-read-arg branch July 20, 2026 06:02
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.

studio: pick a contract view-function read as a config-call argument (follow-up to #140)

2 participants