aiken-lang / aiken

A modern smart contract platform for Cardano
https://aiken-lang.org
Apache License 2.0
477 stars 94 forks source link

Handle all the types from `DefaultUni` #26

Closed Saizan closed 2 years ago

Saizan commented 2 years ago

Currently aiken's Constant type handles only a subset of plutus-core's DefaultUni, in particular it's missing lists, pairs and "Data".

data DefaultUni a where
    DefaultUniInteger    :: DefaultUni (Esc Integer)
    DefaultUniByteString :: DefaultUni (Esc BS.ByteString)
    DefaultUniString     :: DefaultUni (Esc Text.Text)
    DefaultUniUnit       :: DefaultUni (Esc ())
    DefaultUniBool       :: DefaultUni (Esc Bool)
    DefaultUniProtoList  :: DefaultUni (Esc [])
    DefaultUniProtoPair  :: DefaultUni (Esc (,))
    DefaultUniApply      :: !(DefaultUni (Esc f)) -> !(DefaultUni (Esc a)) -> DefaultUni (Esc (f a))
    DefaultUniData       :: DefaultUni (Esc Data)

https://github.com/input-output-hk/plutus/blob/9ef6a65067893b4f9099215ff7947da00c5cd7ac/plutus-core/plutus-core/src/PlutusCore/Default/Universe.hs#L89-L98

e.g. trying to decode a script with a "Data" constant results in an Unknown constant constructor tag: 8 error, which matches the tag number used in plutus-core for "Data":

        8 -> k DefaultUniData

https://github.com/input-output-hk/plutus/blob/9ef6a65067893b4f9099215ff7947da00c5cd7ac/plutus-core/plutus-core/src/PlutusCore/Default/Universe.hs#L351

rvcas commented 2 years ago

@Saizan thanks, this is on our radar already so we'll just use this as a tracking issue. Thank you for documenting this.