feat(nodes): support nested-arg refs in argumentValueNode via path#992
Draft
amilz wants to merge 1 commit intocodama-idl:mainfrom
Draft
Conversation
Adds optional path?: readonly CamelCaseString[] to ArgumentValueNode so
PDA seeds and other contextual value refs can target nested struct fields
of an instruction argument (e.g. argument("plan_data.plan_id")), unblocking
auto-derivation of PDAs whose seeds live inside a struct argument.
- IR: optional path on ArgumentValueNode; factory camelCases segments and
drops empty arrays so {} round-trips
- @codama/dynamic-client: shared resolveArgumentPath{Type,Value} walk struct
fields and definedTypeLinkNode (with cycle guard); pda-seed-value picks the
leaf field's typeNode for codec selection; account-default-value and
condition-node-value resolve nested values
- @codama/errors: ARGUMENT_MISSING gains optional argumentPath suffix and the
message formatter renders missing $vars as empty string so other callers
don't leak $argumentPath literals
- visitors-core: getDebugStringVisitor renders dotted refs;
getResolvedInstructionInputsVisitor preserves path when rebuilding deps
- Tests: 5 new pda-seed-value cases (struct walk, definedTypeLinkNode,
missing intermediate, non-struct path, missing leaf field), 3 new
account-default-value cases, 2 new condition-node-value cases, debug+
identity coverage in visitors-core
Renderers-js codegen (DEV-444) and codama-rs derive macro (DEV-445) tracked
as follow-ups.
Refs: DEV-443
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
path?: readonly CamelCaseString[]onArgumentValueNodeso PDA seeds and other contextual value refs can target nested struct fields of an instruction arg (e.g.argument("plan_data.plan_id")).@codama/dynamic-client(pda-seed-value,account-default-value,condition-node-value) via a sharedresolveArgumentPath{Type,Value}helper that walksstructTypeNodefields anddefinedTypeLinkNode(with cycle guard).@codama/errors:ARGUMENT_MISSINGgains optionalargumentPathsuffix; message formatter renders missing$varsas empty so callers without a path don't leak$argumentPathliterals.visitors-core: debug visitor renders dotted refs;getResolvedInstructionInputsVisitorpreservespathwhen rebuilding deps.Test Plan
pnpm vitest run test/unitin@codama/dynamic-client→ 1038 passed (+15 new path-branch cases across pda-seed-value, account-default-value, condition-node-value).pnpm -F @codama/visitors-core test→ 1794 passed (+ debug/identity coverage forargumentValueNodewithpath).pnpm test:types(dynamic-client) clean; lint clean across the 5 changed packages.Out of scope (tracked)
argument("a.b.c")syntax.Closes DEV-443