Skip to content

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

Description

@robercano-ghbot

Follow-up to #140 (PR #146 delivered the module:config half: a first-class read config-call arg kind).

Scope (module:studio)

Wire the new read arg kind into the Studio config-call argument editor so a user can pass a value read from a deployed contract's view function as an argument to another config call.

What PR #146 already shipped (the spec shape to target)

@redeploy/config now exposes:

interface ReadArg { kind: "read"; contract: string; function: string; args?: (RefArg | LiteralArg)[] }
type ConfigArg = RefArg | LiteralArg | ReadArg;

ConfigArgExtended also includes ReadArg.

Work

  • Add a read option to the arg-kind toggle in the arg editors (ConfigPanel.tsx ConfigArgInput, ContractNode.tsx ConfigArgInput, OrderedConfigPanel.tsx OrderedArgInput), alongside the existing literal / address-ref options.
  • When read is selected: let the user pick a source contract (reuse the existing deployTargets deployId picker) and a view/pure function on it. Discover view functions from the manifest (apps/studio/src/manifest/index.ts — add a getViewFunctions(name) helper filtering stateMutability === "view" | "pure"; today only getStateChangingFunctions exists). Optionally collect the view function's own args (literal/ref) for a v2; a no-arg view (e.g. token.decimals()) is the minimum.
  • Model it in the studio state types (apps/studio/src/spec/types.ts): add a StudioReadRef-style variant to StudioConfigArg.
  • Serialize it in apps/studio/src/spec/graph-to-spec.ts normalizeStudioArg{ kind: "read", contract, function, args }.
  • Tests (vitest + RTL) in apps/studio/test/: editor renders/selects the read source + function; graph-to-spec emits a correct read ConfigArg.

Why deferred from #140

Studio's serializer must compile against config's new ConfigArg type, which only exists once PR #146 merges; and doing config + studio in one worker would violate the repo's hard module-boundary rule. So this was split off to run on a later loop tick once #146 is on main.

Acceptance

In the Studio config-call arg editor a user can choose a source contract + view function for an argument, and the emitted config spec contains a valid read ConfigArg that @redeploy/config validates and executes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    module:studio@redeploy/studio visual toolplannedOwner-approved for the autonomous loop (assigned ONLY by the owner)type:featureFeature work scoped to one module

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions