forked from mlabs-haskell/cem-script
-
Notifications
You must be signed in to change notification settings - Fork 0
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 mlabs-haskell#24 mlabs-haskell#81, part of mlabs-haskell#29) * Implement Plutarch transpiler (closes mlabs-haskell#48 mlabs-haskell#79, part of mlabs-haskell#50) * Support lifting Plutus functions to declarative DSL (closes mlabs-haskell#68) * Compilation pass changing all error messages to codes and saving their correspondence to table * Remove `Stages` concept altogeter (see issue mlabs-haskell#92)
- Loading branch information
Showing
24 changed files
with
1,810 additions
and
842 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,42 @@ | ||
{-# LANGUAGE QualifiedDo #-} | ||
|
||
module Plutarch.Extras where | ||
|
||
import Prelude | ||
|
||
import Plutarch | ||
import Plutarch.Builtin | ||
import Plutarch.LedgerApi | ||
import Plutarch.LedgerApi.Value | ||
import Plutarch.Maybe (pfromJust) | ||
import Plutarch.Monadic qualified as P | ||
import Plutarch.Prelude | ||
|
||
pMkAdaOnlyValue :: Term s (PInteger :--> PValue Unsorted NonZero) | ||
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.