feat/use json compatible schemas#61
Conversation
…BigInt and Schema.Uint8ArrayFromHex
There was a problem hiding this comment.
Pull Request Overview
This PR migrates the codebase to use JSON-compatible schemas by replacing Schema.BigIntFromSelf with Schema.BigInt and updating data type representations from string-based to typed primitives (e.g., hex strings to Uint8Array for byte arrays).
- Changed ByteArray schema from string-based to
Uint8Arrayruntime type with hex string encoding - Replaced
Schema.BigIntFromSelfwithSchema.BigIntthroughout for JSON serialization compatibility - Updated Map schemas from
ReadonlyMapFromSelftoSchema.Mapfor proper JSON encoding
Reviewed Changes
Copilot reviewed 68 out of 69 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/evolution/src/core/TSchema.ts | Updated ByteArray schema to use Uint8Array runtime type; added equivalence function export |
| packages/evolution/src/core/Data.ts | Changed Data type to use Uint8Array for bytes and Map for maps; added encoded type definitions |
| packages/evolution/src/core/TransactionMetadatum.ts | Updated metadata schemas to use Schema.Map and Schema.BigInt for JSON compatibility |
| packages/evolution/src/core/NativeScripts.ts | Refactored equality/hash implementations; changed slot/required fields to use Schema.BigInt |
| packages/evolution/test/*.test.ts | Updated tests to use fromHex() and TSchema.equivalence() for comparisons |
| packages/evolution/src/core/*.ts | Replaced BigIntFromSelf with BigInt across Coin, Numeric, PositiveCoin, and other modules |
| packages/evolution/src/sdk/*.ts | Updated SDK schemas to use Schema.BigInt for JSON-compatible serialization |
| docs/* | Regenerated documentation reflecting schema type changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| return h | ||
| } | ||
| return Hash.hash(JSON.stringify(toJSON(this.script))) |
There was a problem hiding this comment.
The imported function toJSON is used on line 167 but it's not imported or defined in this file. This will cause a runtime error.
| export type TransactionMetadatumVariantsEncoded = | ||
| | { readonly _tag: "TextMetadatum"; readonly value: string } | ||
| | { readonly _tag: "IntMetadatum"; readonly value: string } | ||
| | { readonly _tag: "BytesMetadatum"; readonly value: Uint8Array } |
There was a problem hiding this comment.
The documentation comment in line 204 incorrectly states "BytesMetadatum" has value type Uint8Array, but according to line 69, it's actually Uint8ArrayFromHex which means the encoded format is a hex string, not Uint8Array.
No description provided.