Skip to content

feat/aiken cbor encoding#63

Merged
solidsnakedev merged 5 commits into
mainfrom
feat/aiken-cbor-encoding
Nov 20, 2025
Merged

feat/aiken cbor encoding#63
solidsnakedev merged 5 commits into
mainfrom
feat/aiken-cbor-encoding

Conversation

@solidsnakedev
Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings November 19, 2025 03:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_OPTIONS constant 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/decode functions, 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)
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// Constructor 7 uses tag 1280 (0x0500 = 121 + 7 = 128, encoded as d90500)
// Constructor 7 uses tag 1280 (0x0500, encoded as d90500)

Copilot uses AI. Check for mistakes.
}

test encode_constructor_with_two_fields() {
cbor.serialise(Pair(1, #"ff")) == #"9f0141ffff"
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@solidsnakedev solidsnakedev merged commit 136e125 into main Nov 20, 2025
5 checks passed
@solidsnakedev solidsnakedev deleted the feat/aiken-cbor-encoding branch November 20, 2025 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants