-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Completely change API to declarative DSL and implement Plutarch trans…
…piler Changes: * Completely change API to declarative DSL (closes #24 #81, part of #29) * Implement Plutarch transpiler (closes #48 #79) * Support lifting Plutus functions to declarative DSL (closes #68) * Compilation pass changing all error messages to codes and saving their correspondence to table * Remove `Stages` concept altogeter (see issue #92)
- Loading branch information
Showing
24 changed files
with
1,535 additions
and
713 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
--command="cabal repl test-suite:cem-sdk-test" -W -T ":main --failure-report=/tmp/hspec-report.txt -r" | ||
--command="cabal repl test-suite:cem-sdk-test" -W -T ":main" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{-# LANGUAGE QualifiedDo #-} | ||
|
||
module Plutarch.Extras where | ||
|
||
import Prelude | ||
|
||
import Plutarch | ||
import Plutarch.Builtin | ||
import Plutarch.LedgerApi | ||
import Plutarch.LedgerApi.AssocMap (KeyGuarantees (..)) | ||
import Plutarch.LedgerApi.Value | ||
import Plutarch.Maybe (pfromJust) | ||
import Plutarch.Monadic qualified as P | ||
import Plutarch.Prelude | ||
|
||
pMkAdaOnlyValue :: Term s (PInteger :--> PValue Unsorted _) | ||
pMkAdaOnlyValue = phoistAcyclic $ plam $ \lovelaces -> | ||
pforgetSorted $ | ||
psingletonData # padaSymbolData # pdata padaToken # pdata lovelaces | ||
|
||
pscriptHashAddress :: Term s (PAsData PScriptHash :--> PAddress) | ||
pscriptHashAddress = plam $ \datahash -> | ||
let credential = pcon (PScriptCredential (pdcons @"_0" # datahash #$ pdnil)) | ||
nothing = pdata $ pcon (PDNothing pdnil) | ||
inner = pdcons @"credential" # pdata credential #$ pdcons @"stakingCredential" # nothing #$ pdnil | ||
in pcon (PAddress inner) | ||
|
||
ppkhAddress :: Term s (PAsData PPubKeyHash :--> PAddress) | ||
ppkhAddress = plam $ \datahash -> | ||
let credential = pcon (PPubKeyCredential (pdcons @"_0" # datahash #$ pdnil)) | ||
nothing = pdata $ pcon (PDNothing pdnil) | ||
inner = pdcons @"credential" # pdata credential #$ pdcons @"stakingCredential" # nothing #$ pdnil | ||
in pcon (PAddress inner) | ||
|
||
getOwnAddress :: ClosedTerm (PAsData PScriptContext :--> PAsData PAddress) | ||
getOwnAddress = phoistAcyclic $ plam $ \ctx -> P.do | ||
PSpending outRef' <- pmatch $ pfromData $ pfield @"purpose" # ctx | ||
pfield @"address" | ||
#$ pfield @"resolved" | ||
#$ pfromJust | ||
#$ (pfindOwnInput # (pfield @"inputs" #$ pfield @"txInfo" # ctx)) | ||
#$ pfield @"_0" | ||
# outRef' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.