Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

constitution: Add executable that creates json envelope #6267

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions cardano-constitution/cardano-constitution.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,13 @@ test-suite cardano-constitution-test
, tasty-hunit
, tasty-json
, tasty-quickcheck

executable create-json-envelope
import: lang, ghc-version-support, os-support
hs-source-dirs: create-json-envelope
main-is: Main.hs
build-depends:
, base
, cardano-api ^>=8.48
, cardano-constitution
, plutus-ledger-api
26 changes: 26 additions & 0 deletions cardano-constitution/create-json-envelope/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- editorconfig-checker-disable-file
{-# LANGUAGE OverloadedStrings #-}
module Main where

import Cardano.Api (File (..), PlutusScriptV3, PlutusScriptVersion (PlutusScriptV3),
Script (PlutusScript), writeFileTextEnvelope)
import Cardano.Api.Shelley (PlutusScript (PlutusScriptSerialised))
import Cardano.Constitution.Validator.Sorted (defaultConstitutionCode)
import PlutusLedgerApi.Common (serialiseCompiledCode)
import System.Environment (getArgs)
import System.Exit

main :: IO ()
main = do
args <- getArgs
case args of
[file] -> either (error . show) pure
=<< writeFileTextEnvelope (File file) (Just "*BE CAREFUL* that this is compiled from a release commit of plutus and not from master") compiledScript
_ -> die "USAGE: create-json-envelope OUT_FILE"

compiledScript :: Script PlutusScriptV3
compiledScript =
PlutusScript PlutusScriptV3
. PlutusScriptSerialised
. serialiseCompiledCode
$ defaultConstitutionCode
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2095
2117
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ExBudget {exBudgetCPU = ExCPU 584116400, exBudgetMemory = ExMemory 2883157}
ExBudget {exBudgetCPU = ExCPU 592788400, exBudgetMemory = ExMemory 2937357}
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@
go ds
!`$fOrdInteger_$ccompare` : integer -> integer -> Ordering
= \(eta : integer) (eta : integer) ->
ifThenElse
Bool_match
(ifThenElse {Bool} (equalsInteger eta eta) True False)
{all dead. Ordering}
(equalsInteger eta eta)
(/\dead -> EQ)
(/\dead ->
ifThenElse
Bool_match
(ifThenElse {Bool} (lessThanEqualsInteger eta eta) True False)
{all dead. Ordering}
(lessThanEqualsInteger eta eta)
(/\dead -> LT)
(/\dead -> GT)
{all dead. dead})
Expand Down Expand Up @@ -174,24 +174,24 @@
letrec
!euclid : integer -> integer -> integer
= \(x : integer) (y : integer) ->
ifThenElse
Bool_match
(ifThenElse {Bool} (equalsInteger 0 y) True False)
{all dead. integer}
(equalsInteger 0 y)
(/\dead -> x)
(/\dead -> euclid y (modInteger x y))
{all dead. dead}
in
letrec
!unsafeRatio : integer -> integer -> Rational
= \(n : integer) (d : integer) ->
ifThenElse
Bool_match
(ifThenElse {Bool} (equalsInteger 0 d) True False)
{all dead. Rational}
(equalsInteger 0 d)
(/\dead -> error {Rational})
(/\dead ->
ifThenElse
Bool_match
(ifThenElse {Bool} (lessThanInteger d 0) True False)
{all dead. Rational}
(lessThanInteger d 0)
(/\dead ->
unsafeRatio (subtractInteger 0 n) (subtractInteger 0 d))
(/\dead ->
Expand Down Expand Up @@ -252,16 +252,24 @@
(\(x : integer) (y : integer) ->
ifThenElse {Bool} (lessThanInteger x y) False True)
(\(x : integer) (y : integer) ->
ifThenElse
Bool_match
(ifThenElse
{Bool}
(lessThanEqualsInteger x y)
True
False)
{all dead. integer}
(lessThanEqualsInteger x y)
(/\dead -> y)
(/\dead -> x)
{all dead. dead})
(\(x : integer) (y : integer) ->
ifThenElse
Bool_match
(ifThenElse
{Bool}
(lessThanEqualsInteger x y)
True
False)
{all dead. integer}
(lessThanEqualsInteger x y)
(/\dead -> x)
(/\dead -> y)
{all dead. dead}))
Expand All @@ -284,9 +292,13 @@
ds
{Bool}
(\(n' : integer) (d' : integer) ->
ifThenElse
Bool_match
(ifThenElse
{Bool}
(equalsInteger n n')
True
False)
{all dead. Bool}
(equalsInteger n n')
(/\dead ->
ifThenElse
{Bool}
Expand Down Expand Up @@ -5307,11 +5319,15 @@
(unConstrData ds))))
~si : pair integer (list data) = unConstrData ds
in
ifThenElse
Bool_match
(ifThenElse
{Bool}
(equalsInteger
5
(fstPair {integer} {list data} si))
True
False)
{all dead. data}
(equalsInteger
5
(fstPair {integer} {list data} si))
(/\dead ->
headList
{data}
Expand All @@ -5323,9 +5339,9 @@
~ds : pair integer (list data) = unConstrData ds
!x : integer = fstPair {integer} {list data} ds
in
ifThenElse
Bool_match
(ifThenElse {Bool} (equalsInteger 0 x) True False)
{all dead. Maybe (List (Tuple2 data data))}
(equalsInteger 0 x)
(/\dead ->
Just
{List (Tuple2 data data)}
Expand All @@ -5335,9 +5351,9 @@
{data}
(tailList {data} (sndPair {integer} {list data} ds))))))
(/\dead ->
ifThenElse
Bool_match
(ifThenElse {Bool} (equalsInteger 2 x) True False)
{all dead. Maybe (List (Tuple2 data data))}
(equalsInteger 2 x)
(/\dead -> Nothing {List (Tuple2 data data)})
(/\dead -> error {Maybe (List (Tuple2 data data))})
{all dead. dead})
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ExBudget {exBudgetCPU = ExCPU 85774882, exBudgetMemory = ExMemory 383294}
ExBudget {exBudgetCPU = ExCPU 88974882, exBudgetMemory = ExMemory 403294}
Loading