-
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.
Add script target parameter (debug / production) (#37)
* Add ScriptTarget flag * Add build target in one place * WIP - script dependencies * Fix build error * Use scripts from env everywhere * Parameterise tests by script target * Delete node params (not required anymore) * Add filter for NFT to globalParamsNode * 10x ex units and memory for testing * Rename workflow * github action: Fix concurrency group
- Loading branch information
Showing
15 changed files
with
352 additions
and
346 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
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,18 +1,46 @@ | ||
module SmartTokens.Core.Scripts ( | ||
-- * Build targets | ||
ScriptTarget(..), | ||
targetConfig, | ||
|
||
-- * Compile functions | ||
tryCompile, | ||
tryCompileTracingAndBinds, | ||
tryCompileNoTracing, | ||
) where | ||
|
||
import Data.Aeson (FromJSON, ToJSON) | ||
import GHC.Generics (Generic) | ||
import Plutarch | ||
|
||
tryCompile :: Config -> ClosedTerm a -> Script | ||
tryCompile cfg x = case compile cfg x of | ||
{-| Script target environment | ||
-} | ||
data ScriptTarget | ||
= Debug -- ^ Include debug symbols | ||
| Production -- ^ No debug symbols | ||
deriving stock (Eq, Ord, Show, Generic) | ||
deriving anyclass (ToJSON, FromJSON) | ||
|
||
{-| The plutarch 'Config' for the target | ||
-} | ||
targetConfig :: ScriptTarget -> Config | ||
targetConfig = \case | ||
Debug -> tracingAndBindsConfig | ||
Production -> prodConfig | ||
|
||
tryCompile :: ScriptTarget -> ClosedTerm a -> Script | ||
tryCompile tgt x = case compile (targetConfig tgt) x of | ||
Left e -> error $ "Compilation failed: " <> show e | ||
Right s -> s | ||
|
||
tryCompileTracingAndBinds :: ClosedTerm a -> Script | ||
tryCompileTracingAndBinds = tryCompile (Tracing LogInfo DoTracingAndBinds) | ||
tryCompileTracingAndBinds = tryCompile Debug | ||
|
||
tryCompileNoTracing :: ClosedTerm a -> Script | ||
tryCompileNoTracing = tryCompile NoTracing | ||
tryCompileNoTracing = tryCompile Production | ||
|
||
tracingAndBindsConfig :: Config | ||
tracingAndBindsConfig = Tracing LogInfo DoTracingAndBinds | ||
|
||
prodConfig :: Config | ||
prodConfig = NoTracing |
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
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
Oops, something went wrong.