HeliosLang / compiler

Helios is a DSL for writing Cardano smart contracts. This library lets you compile Helios scripts and build Cardano transactions.
https://www.hyperion-bt.org/helios-book
BSD 3-Clause "New" or "Revised" License
142 stars 31 forks source link

Feat/generic list pair #50

Closed nielstron closed 1 year ago

nielstron commented 1 year ago

Fixes #49

Note that this leaves the shortcuts implemented before in place... I have the feeling that they are used for some unclean matters internally and prefer not to mess with this.

nielstron commented 1 year ago

I tested this with this funny script

import { ByteArray as HeliosByteArray, Int as HeliosInt, deserializeUplcBytes, hexToBytes, bytesToHex, CborData, textToBytes } from "./helios.js"

const script = deserializeUplcBytes(
    CborData.decodeBytes(
        hexToBytes(
            "4d0100004bd6f7b42f5a205c8261"
        )
    )
)
console.log(script)

The cbor decompiles to the original UPLC source

(program 1.0.0 (con list<pair<integer, list<bool>>> [(1, [True, False]), (2, [True])]))
nielstron commented 1 year ago

I had made a number of fixes, but applied them directly to helios.js and got them overwritten by npm run prebuild :facepalm: re-added them now again

nielstron commented 1 year ago

Note that mkCons and tailList/headList currently assume the list being either a UplcMap or UplcDataList, which is too strong of an assumption

christianschmitz commented 1 year ago

Thanks for working on this Niels! Don't worry about mkCons, that can be improved later

christianschmitz commented 1 year ago

I've cleaned everything up and removed UplcDataList, UplcMap and UplcMapItem. Changes are in the dev branch. Could you test that against the script you're deserializing?