-
Notifications
You must be signed in to change notification settings - Fork 463
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CIP-0057: Extend the Blueprint test case with the
AsData
example. (#…
…5837) * refactor: s/schema/itemSchema/ * Blueprint example extended with the AsData type. * refactor: extract Unroll functionality into a dedicated module * chore: refactor asDataFor, remove long lines, etc.
- Loading branch information
Showing
13 changed files
with
429 additions
and
287 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
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
26 changes: 26 additions & 0 deletions
26
plutus-tx-plugin/test/Blueprint/Tests/Lib/AsData/Blueprint.hs
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,26 @@ | ||
{-# LANGUAGE DeriveAnyClass #-} | ||
{-# LANGUAGE FlexibleInstances #-} | ||
{-# LANGUAGE MultiParamTypeClasses #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# LANGUAGE TypeApplications #-} | ||
{-# LANGUAGE UndecidableInstances #-} | ||
|
||
{- | This module contains data type declarations to use in blueprints **only** | ||
The problem with using the 'AsData' types in blueprints is that such types are opaque and | ||
do not reveal their schema when deriving a 'HasSchema' instance for a blueprint. | ||
To work around this problem we generate a separate data type declaration for each 'AsData' type | ||
and use these in blueprints. | ||
Do not use these types in real validators, instead use the 'AsData' declarations. | ||
-} | ||
module Blueprint.Tests.Lib.AsData.Blueprint where | ||
|
||
import Blueprint.Tests.Lib.AsData.Decls (datum2) | ||
import PlutusTx.Blueprint.Definition (definitionRef) | ||
import PlutusTx.Blueprint.TH (makeHasSchemaInstance) | ||
|
||
$(datum2) | ||
|
||
$(pure <$> makeHasSchemaInstance ''Datum2 [('MkDatum2, 0)]) |
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,23 @@ | ||
{-# LANGUAGE TemplateHaskellQuotes #-} | ||
|
||
{- | This module contains TH data type declarations from which 'AsData' declarations are derived. | ||
These declarations are used for two purposes: | ||
1. To generate an 'AsData' type declaration to be used in real validators. | ||
2. To generate a regular data type declaration to be used in a blueprint. | ||
Because of the GHC stage restriction, we have to keep these TH declarations in a separate module. | ||
-} | ||
module Blueprint.Tests.Lib.AsData.Decls where | ||
|
||
import GHC.Generics (Generic) | ||
import Language.Haskell.TH qualified as TH | ||
import PlutusTx.Blueprint.Definition.Id (AsDefinitionId) | ||
|
||
datum2 :: TH.DecsQ | ||
datum2 = | ||
[d| | ||
data Datum2 = MkDatum2 {datum2integer :: Integer, datum2bool :: Bool} | ||
deriving stock (Generic) | ||
deriving anyclass (AsDefinitionId) | ||
|] |
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.
b22f5ad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible performance regression was detected for benchmark 'Plutus Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
1.05
.validation-decode-multisig-sm-3
586.8
μs553.2
μs1.06
validation-decode-uniswap-2
234.7
μs223.5
μs1.05
This comment was automatically generated by workflow using github-action-benchmark.
CC: @input-output-hk/plutus-core