Skip to content

Documentation/example review 260223#300

Open
Crypto2099 wants to merge 2 commits intotx3-lang:mainfrom
Crypto2099:documentation/example-review-260223
Open

Documentation/example review 260223#300
Crypto2099 wants to merge 2 commits intotx3-lang:mainfrom
Crypto2099:documentation/example-review-260223

Conversation

@Crypto2099
Copy link

Summary

  • Add a test harness for validating all examples against trix check
  • Organize aspirational/non-compiling examples into their own directory
  • Fill grammar feature coverage gaps in examples
  • Fix existing examples that were out of date with v0.14.x

Test harness (examples/_test_harness/)

A simple shell script that iterates every .tx3 file in the examples directory, copies it into a minimal trix project, and runs trix check. This makes it easy to verify that all examples stay valid as the language evolves. The only expected failure is semantic_errors.tx3, which is intentionally broken.

Aspirational examples (examples/aspirational/)

Moved jpg.tx3, levvy.tx3, levvy.simple.tx3, plutus_addresses.tx3, spans.tx3, and splash.tx3 into an aspirational/ subdirectory with a README. These files use syntax or features that don't yet compile and were causing confusion when mixed in with working examples.

Example fixes

  • swap_static.tx3 — minor fix to pass current validation
  • transfer_nft.tx3 — updated to work with latest language version

New and updated examples filling grammar coverage gaps

Feature File What changed
Bool literal (true/false) lang_tour.tx3 Added field6: Bool to MyRecord, used true in datum constructor
Address primitive type lang_tour.tx3 Added field_e: Address to env block
Negation operator ! lang_tour.tx3 Added !field_c in locals block
Negative number literal lang_tour.tx3 Used quantity + -1 in datum field
Optional output output? lang_tour.tx3 Added output? optional_change block
cardano::publish with datum reference_script.tx3 Added datum: field to existing publish block
Policy constructor subsets policy_variants.tx3 New file — hash-only assign, hash-only constructor, hash+script, hash+ref
Policy name as expression policy_variants.tx3 Shows AnyAsset(PolicyName, ...) resolving to hash
Named asset vs AnyAsset minting policy_variants.tx3 Side-by-side txs for both patterns
Native witness with minting policy_variants.tx3 cardano::native_witness attached to native script policy mint
Reference input for policy script policy_variants.tx3 reference block supplying plutus script from on-chain UTxO

Test results

28 passing, 1 expected failure (semantic_errors.tx3) — all new and modified files validated.

Notes

During this audit we identified several policy object limitations that are tracked separately:

  • Policy sub-field access (MyPolicy.script) is not supported
  • asset definitions can't reference policy names or env vars
  • Policy constructors missing hash pass trix check but panic at trix build

🤖 Generated with Claude Code

- Create _test_harness in examples folder that allows for quick iteration of all examples to ensure all examples pass `trix check` validation with latest version. The only exception/expected error here is `semantic_errors.tx3` which is intentionally broken.
- Move the non-functional, aspirational examples to an aspirational directory with a README explaining their nature. These are prone to causing confusion if left in the main examples folder.
- Updates to several existing scripts to bring them inline with the latest version of Trix/Tx3 and make sure they pass validation.
- Update lang_tour, reference_script, and introduce new policy_variants examples to document and fill gaps left by current examples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant