Skip to content

Commit 2e29d9a

Browse files
committed
feat: add uplc decoder
1 parent b0d1202 commit 2e29d9a

File tree

5 files changed

+2060
-0
lines changed

5 files changed

+2060
-0
lines changed

packages/evolution/src/core/CBOR.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,29 @@ export const STRUCT_FRIENDLY_OPTIONS: CodecOptions = {
161161
mapsAsObjects: true
162162
} as const
163163

164+
/**
165+
* Cardano Node compatible CBOR encoding options for PlutusData
166+
*
167+
* Uses definite-length encoding for arrays and maps, matching the format
168+
* produced by CML's `to_cardano_node_format().to_cbor_hex()`.
169+
*
170+
* Note: The on-chain format uses indefinite-length (AIKEN_DEFAULT_OPTIONS),
171+
* but this option is useful for testing compatibility with tools that
172+
* expect definite-length encoding.
173+
*
174+
* @since 2.0.0
175+
* @category constants
176+
*/
177+
export const CARDANO_NODE_DATA_OPTIONS: CodecOptions = {
178+
mode: "custom",
179+
useIndefiniteArrays: false,
180+
useIndefiniteMaps: false,
181+
useDefiniteForEmpty: true,
182+
sortMapKeys: false,
183+
useMinimalEncoding: true,
184+
mapsAsObjects: false
185+
} as const
186+
164187
const DEFAULT_OPTIONS: CodecOptions = {
165188
mode: "custom",
166189
useIndefiniteArrays: false,

packages/evolution/src/core/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export * as TransactionOutput from "./TransactionOutput.js"
106106
export * as TransactionWitnessSet from "./TransactionWitnessSet.js"
107107
export * as TSchema from "./TSchema.js"
108108
export * as UnitInterval from "./UnitInterval.js"
109+
export * as UPLC from "./uplc/index.js"
109110
export * as Url from "./Url.js"
110111
export * as Value from "./Value.js"
111112
export * as VKey from "./VKey.js"

0 commit comments

Comments
 (0)