Skip to content

Commit a083202

Browse files
Merge pull request #90 from IntersectMBO/feat/uplc-decoder
feat: add uplc decoder
2 parents b0d1202 + ca5178e commit a083202

File tree

10 files changed

+2458
-1
lines changed

10 files changed

+2458
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { UplcDecoder } from "./uplc-decoder"
2+
import type { Metadata } from 'next'
3+
4+
export const metadata: Metadata = {
5+
title: 'UPLC Decoder | Evolution SDK',
6+
description: 'Decode UPLC (Untyped Plutus Core) programs from CBOR hex format',
7+
}
8+
9+
export default function UplcDecoderPage() {
10+
return (
11+
<div className="container mx-auto px-4 py-8 max-w-6xl">
12+
<div className="mb-8">
13+
<h1 className="text-4xl font-bold mb-4">UPLC Decoder</h1>
14+
<p className="text-muted-foreground text-lg">
15+
Decode UPLC (Untyped Plutus Core) programs from CBOR hex format. Automatically handles single or double CBOR encoding.
16+
</p>
17+
</div>
18+
<UplcDecoder />
19+
</div>
20+
)
21+
}

docs/app/tools/uplc-decoder/uplc-decoder.tsx

Lines changed: 350 additions & 0 deletions
Large diffs are not rendered by default.

docs/next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
import "./.next/types/routes.d.ts";
3+
import "./out/dev/types/routes.d.ts";
44

55
// NOTE: This file should not be edited
66
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

docs/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"next-themes": "^0.4.6",
2626
"react": "^19.2.0",
2727
"react-dom": "^19.2.0",
28+
"react18-json-view": "^0.2.9",
2829
"twoslash": "^0.3.4"
2930
},
3031
"devDependencies": {

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)