Skip to content

fix(serializer,compiler): fix SSigmaProp round-trip, constant buffer sizing, SColl empty hex string, and compile option checks - #239

Open
a-shannon wants to merge 1 commit into
fleet-sdk:masterfrom
a-shannon:fix/serializer-sigmaprop-size-compiler
Open

a-shannon wants to merge 1 commit into
fleet-sdk:masterfrom
a-shannon:fix/serializer-sigmaprop-size-compiler

Conversation

@a-shannon

Copy link
Copy Markdown

Summary

Fixes four serialization and compilation issues across @fleet-sdk/serializer and @fleet-sdk/compiler:

  1. SSigmaProp serialize/deserialize round-trip (packages/serializer/src/serializers/dataSerializer.ts)
    • dataSerializer.deserialize returns a 33-byte Uint8Array for SSigmaProp, whereas dataSerializer.serialize only accepted an SConstant wrapping SGroupElement, causing SConstant.from("08cd...").toHex(), deserializeBox(), and deserializeTransaction() to throw on any SigmaProp register or context extension.
    • dataSerializer.serialize now accepts both Uint8Array and SConstant<Uint8Array, SGroupElementType> while preserving existing error behavior for unsupported operands.
  2. Constant buffer size estimation (packages/serializer/src/sigmaConstant.ts)
    • Replaces the previous fixed heuristic in guessConstantBytesSize with recursive estimateTypeSize + estimateDataSize helpers (using estimateBoxSize for SBox), fixing under-allocation on empty non-embeddable collections (e.g., Coll[AvlTree] "0c6400", Coll[Box] "0c6300", Coll[Unit] "0c6200") and nested collections/tuples exceeding 4096 bytes.
  3. SColl(SByte, "") empty hex string (packages/serializer/src/types/constructors.ts)
    • Checks isUndefined(elements) instead of !elements so passing an empty string "" constructs an empty SColl[SByte] constant ("0e00") rather than returning a curried type constructor.
  4. Compiler version and network validation (packages/compiler/src/compiler.ts)
    • Enforces version === 0 || version === 1 (rejecting negative, fractional, NaN, or out-of-range values).
    • Accepts "mainnet", "testnet", Network.Mainnet, and Network.Testnet, and throws on unrecognized network values instead of silently defaulting typos to testnet.

Includes unit tests targeting full branch coverage and a .changeset patch entry.

Verification

  • Verified statically against tsconfig.json (strict: true), biome.json, constructors.test-d.ts, and existing specs; full Biome, multi-runtime unit tests, and coverage run in CI.

…sizing, SColl empty byte string, and compile option checks
@changeset-bot

changeset-bot Bot commented Nov 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a418542

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@fleet-sdk/serializer Patch
@fleet-sdk/compiler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

1 participant