From 4b675e50764a3e420be9d47ac818ba93dfde4a15 Mon Sep 17 00:00:00 2001 From: Santiago Date: Sat, 26 Sep 2026 11:20:11 -0300 Subject: [PATCH] refactor(codegen): declare params with the tx3c declarations helper Replace the template's componentTypes block and per-transaction params loop with `declarations`, which renders component and params declarations from the shared tx3c planner. Params type names come from `paramsTypeName`, and field references from `identifier ... "param"`, so they always match what the renderer declared. Generated output is unchanged apart from the section comment and blank lines. Requires a tx3c release that includes tx3-lang/tx3#359. Co-Authored-By: Claude Opus 5.5 (1M context) --- .trix/client-lib/__init__.py.hbs | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/.trix/client-lib/__init__.py.hbs b/.trix/client-lib/__init__.py.hbs index f25934c..6477452 100644 --- a/.trix/client-lib/__init__.py.hbs +++ b/.trix/client-lib/__init__.py.hbs @@ -29,11 +29,9 @@ ENVIRONMENT_SCHEMA: dict[str, Any] = json.loads( ) {{/if}} -{{#if tii.components.schemas}} -# Named types for the protocol's custom (record / variant) types. -{{{componentTypes tii.components.schemas "python"}}} - -{{/if}} +# Named types for the protocol's custom (record / variant) types and the +# arguments of each transaction, declared by the renderer. +{{{declarations tii "python"}}} {{#each tii.transactions}} {{constantCase @key}}_TIR = TirEnvelope( content="{{tir.content}}", @@ -41,16 +39,8 @@ ENVIRONMENT_SCHEMA: dict[str, Any] = json.loads( version="{{tir.version}}", ) -@dataclass -class {{pascalCase @key}}Params: - """Arguments for the {{@key}} transaction.""" - -{{#each params.properties}} - {{snakeCase @key}}: {{schemaTypeFor this "python"}} {{/each}} - -{{/each}} {{#if tii.profiles}} {{#each tii.profiles}} _{{constantCase @key}}_PROFILE = SdkProfile( @@ -117,14 +107,14 @@ class Client: {{/each}} {{#each tii.transactions}} - def {{snakeCase @key}}(self, args: {{pascalCase @key}}Params) -> TxBuilder: + def {{snakeCase @key}}(self, args: {{paramsTypeName @key "python"}}) -> TxBuilder: """Builds the `{{@key}}` transaction. Drive the returned builder with `.resolve()` and the rest of the lifecycle chain. """ return self._inner.tx("{{@key}}").args( { {{#each params.properties}} - "{{@key}}": args.{{snakeCase @key}}, + "{{@key}}": args.{{identifier @key "python" "param"}}, {{/each}} } )