Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions .trix/client-lib/__init__.py.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,18 @@ 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}}",
encoding="{{tir.encoding}}",
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(
Expand Down Expand Up @@ -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}}
}
)
Expand Down
Loading