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.
Follow-up to #140 (PR #146 delivered the
module:confighalf: a first-classreadconfig-call arg kind).Scope (module:studio)
Wire the new
readarg 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/confignow exposes:ConfigArgExtendedalso includesReadArg.Work
readoption to the arg-kind toggle in the arg editors (ConfigPanel.tsxConfigArgInput,ContractNode.tsxConfigArgInput,OrderedConfigPanel.tsxOrderedArgInput), alongside the existing literal / address-ref options.readis selected: let the user pick a source contract (reuse the existingdeployTargetsdeployId picker) and a view/pure function on it. Discover view functions from the manifest (apps/studio/src/manifest/index.ts— add agetViewFunctions(name)helper filteringstateMutability === "view" | "pure"; today onlygetStateChangingFunctionsexists). Optionally collect the view function's own args (literal/ref) for a v2; a no-arg view (e.g.token.decimals()) is the minimum.apps/studio/src/spec/types.ts): add aStudioReadRef-style variant toStudioConfigArg.apps/studio/src/spec/graph-to-spec.tsnormalizeStudioArg→{ kind: "read", contract, function, args }.apps/studio/test/: editor renders/selects the read source + function;graph-to-specemits a correctreadConfigArg.Why deferred from #140
Studio's serializer must compile against config's new
ConfigArgtype, 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 onmain.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
readConfigArg that@redeploy/configvalidates and executes.