feat/aiken cbor encoding#63
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds Aiken-compatible CBOR encoding support to the Evolution SDK, enabling TypeScript code to produce identical CBOR output to Aiken's cbor.serialise() function. The implementation introduces a new encodeMapAsPairs option that allows PlutusData maps to be encoded as arrays of pairs (Aiken/Plutus style) instead of CBOR maps (CML style).
Key changes:
- New
AIKEN_DEFAULT_OPTIONSconstant in CBOR.ts with Aiken-specific encoding settings (indefinite arrays, maps as pairs) - Comprehensive Aiken test suite (72 tests) documenting exact CBOR encoding behavior for all PlutusData types
- TypeScript compatibility tests (40 tests) verifying identical encoding between Aiken and TypeScript implementations
- Refactored Data.ts API to use Effect Schema's native
encode/decodefunctions, removing custom wrapper utilities
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/evolution/test/spec/lib/cbor_encoding_spec.ak | New comprehensive Aiken test suite documenting CBOR encoding behavior for primitives, lists, maps, constructors, and edge cases |
| packages/evolution/test/CBOR.Aiken.test.ts | New TypeScript compatibility tests verifying that Evolution SDK produces identical CBOR output to Aiken |
| packages/evolution/test/spec/README.md | Documentation for the new CBOR encoding test suite |
| packages/evolution/src/core/CBOR.ts | Added encodeMapAsPairs option and AIKEN_DEFAULT_OPTIONS constant to support Aiken-style encoding |
| packages/evolution/src/core/Data.ts | Refactored to use Effect Schema's native methods, removed Either namespace, added branded DataSchema interface |
| packages/evolution/src/sdk/builders/TxBuilderImpl.ts | Updated to use new Schema-based decoding API |
| packages/evolution/test/TSchema.test.ts | Updated error handling test to be more generic (no longer checks specific error type) |
| .changeset/silent-forks-bow.md | Changeset documentation for the patch release |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| test encode_constructor_index_7() { | ||
| // Constructor 7 uses tag 1280 (0x0500 = 121 + 7 = 128, encoded as d90500) |
There was a problem hiding this comment.
The comment contains inconsistent information. It states "tag 1280 (0x0500 = 121 + 7 = 128...)" but 121 + 7 equals 128, not 1280. The hex value 0x0500 is indeed 1280 in decimal. The comment should be clarified to explain that constructor index 7 uses tag 1280 (0x0500), not 128, and remove the incorrect arithmetic "121 + 7 = 128" or explain the actual encoding scheme more clearly.
| // Constructor 7 uses tag 1280 (0x0500 = 121 + 7 = 128, encoded as d90500) | |
| // Constructor 7 uses tag 1280 (0x0500, encoded as d90500) |
| } | ||
|
|
||
| test encode_constructor_with_two_fields() { | ||
| cbor.serialise(Pair(1, #"ff")) == #"9f0141ffff" |
There was a problem hiding this comment.
The test references Pair(1, #"ff") but there is no Pair constructor defined in the WithFields type. The type only defines Single and Triple constructors. Either add a Pair constructor to the type or remove/fix this test.
No description provided.