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

Plutarch 1.2 #317

Merged
merged 738 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
738 commits
Select commit Hold shift + click to select a range
b2b9e05
Use explicit imports
TotallyNotChase May 4, 2022
6a93287
Update CHANGELOG
TotallyNotChase May 4, 2022
dedcf33
Merge pull request #466 from Plutonomicon/some-exports
L-as May 6, 2022
0399120
Added AssocMap.singleton and Value.singleton
blamario Mar 23, 2022
03ff1c5
Added valueOf, lookup, lookupData, and pmaybe
blamario Mar 24, 2022
ac58aee
Added AssocMap.singletonData
blamario Mar 24, 2022
5e08c0f
More tests
blamario Mar 24, 2022
3141d18
Optimized lookup using precList
blamario Mar 24, 2022
98eec12
Added tests for pmaybe and pfromJust
blamario Apr 1, 2022
6f42768
Added AssocMap tests
blamario Apr 1, 2022
5837ce1
Added Value.unionWith and everything it depends on
blamario Apr 5, 2022
76a686c
Added insert & insertData
blamario Apr 7, 2022
99a4014
Added delete & deleteData
blamario Apr 7, 2022
192bbd5
Factored out the common logic of insert & delete
blamario Apr 7, 2022
2c77a22
Restored the deleted golden files
blamario Apr 7, 2022
1c506d0
Applied testing suggestions
blamario Apr 7, 2022
5df4ff0
Added PValue equality and its dependencies
blamario Apr 8, 2022
0b84e43
Fixed the merge
blamario Apr 8, 2022
4cb0ea8
Added some FFI benchmarks
blamario Apr 15, 2022
26452fc
Made fourmolu ignore the tmp/ directory
blamario Apr 18, 2022
38707e4
More benchmarks, native Plutarch vs FFI for Value operations
blamario Apr 18, 2022
814bd6f
Added Value.unionWithData
blamario Apr 18, 2022
7518cfa
Benchmarks for valueOf
blamario Apr 18, 2022
2bb4c57
Introduced AssocMap.foldAt & findWithDefault to optimize valueOf
blamario Apr 18, 2022
41e3581
Reverted a stupid kind annotation
blamario Apr 21, 2022
ad0e5b9
More tests
blamario Apr 21, 2022
2e0208e
Keep the AssocMap sorted by key data
blamario Apr 21, 2022
fd1677b
Added Value.normalize and AssocMap.filter/mapMaybe/null
blamario Apr 21, 2022
a2a5953
Switched the equality to the quicker implementation
blamario Apr 21, 2022
68bfa71
Added Semigroup instances
blamario Apr 21, 2022
9779968
Fixed tests with GHC 8.10
blamario Apr 21, 2022
afe5a92
Added goldens that were missing for some reason
blamario Apr 21, 2022
fc1ed5f
Added Monoid instances
blamario Apr 22, 2022
de3d78e
Fix for the unsused goldens CI failure
blamario Apr 22, 2022
fad3e15
Formatting
blamario Apr 22, 2022
0062b51
Added asertSorted
blamario Apr 22, 2022
97a5626
assertSorted tests
blamario Apr 22, 2022
ee824e3
Split the dev/nodev Value API goldens
blamario Apr 25, 2022
0343b2f
Added Value.normalize tests
blamario Apr 25, 2022
01156f6
Added Value.singletonData
blamario Apr 26, 2022
f9f97ac
Added a nominal ValueState parameter to PValue
blamario Apr 27, 2022
cdcdca5
p all over the API
blamario Apr 27, 2022
4b18c46
Added the Positive values
blamario Apr 27, 2022
3430364
No need to resort the currency symbols in passertPositive
blamario Apr 27, 2022
6dd6c37
Rebase fixes
blamario May 3, 2022
5969e06
Removed pmaybe, peither, pmapEitherWithKey[Data] of dubious efficiency
blamario May 3, 2022
294609f
Removed a (..) import
blamario May 6, 2022
a3c2ae9
Narrowed the type of fee and UTxO value to Positive
blamario May 6, 2022
8c44bde
Formatting
blamario May 6, 2022
61b485a
Generalized the return type of pforgetPositive
blamario May 6, 2022
f92383f
Added a warning to UTxO value field
blamario May 6, 2022
f04107c
Removed the kind signatures off of (s :: S) in use sites
blamario May 6, 2022
b62487d
Removed extraneous golden outputs
blamario May 6, 2022
ae4cc22
No Haddock allowed in a type-level list
blamario May 6, 2022
cfd0e37
Inlined the Rank2.TH instances
blamario May 6, 2022
874946e
Added plet y $ \y ->
blamario May 6, 2022
889a41f
Update emanote (to get rid of lint-utils)
srid May 9, 2022
f49ab79
Composable smart names and improvements
TotallyNotChase May 9, 2022
fa69cc3
Pretty if/then/else
TotallyNotChase May 9, 2022
cbb1b0f
fix `pfindOwnInput`
TotallyNotChase May 11, 2022
5e45877
Merge pull request #469 from Plutonomicon/findownipn-fix
L-as May 11, 2022
6cd074c
Merge pull request #467 from Plutonomicon/srid/lint-utils-fix
L-as May 11, 2022
96e83e9
Fix some typos in documentation
TotallyNotChase May 12, 2022
007643d
Clarify `PLift` laws
TotallyNotChase May 12, 2022
d62c38b
Add `PIsData` constraint to `PConstantData` and `PLiftData`
TotallyNotChase May 12, 2022
ae2059f
Merge pull request #470 from Plutonomicon/cleanup
L-as May 12, 2022
4dc31f4
Merge branch 'staging' into mario/value-api
blamario May 12, 2022
683c653
Shortened the *Guarantees names and moved KeyGuarantees into AssocMap
blamario May 12, 2022
874d3e7
Added a KeyGuarantees parameter to PMap
blamario May 12, 2022
fffe864
Added pmap and PlutusTx.Group instances
blamario May 12, 2022
04f90d5
Fixed the type roles
blamario May 13, 2022
1594234
Added -Wredundant-constraints and acted on the warnings
blamario May 13, 2022
9f6326d
Update dependencies
L-as Apr 17, 2022
41caa60
Fix `Plutarch.Lift`
L-as Apr 18, 2022
14432b5
test: getSpecDescriptionPath now returns list in different order
srid Apr 18, 2022
be9c8c0
Fix incorrect let binding pretty print
TotallyNotChase May 16, 2022
ff3e123
Update dependencies again, use `applyPlutarchDep`, and stop using for…
L-as Apr 19, 2022
0df7165
Removed -Wredundant-constraints, too many false positives
blamario May 16, 2022
6de73b5
Merge branch 'staging' into rational-experiment
TotallyNotChase May 16, 2022
52476c4
Rename `pnonZero'` -> `ptryNonZero`
TotallyNotChase May 16, 2022
b07d97a
Deduplicate `Flip`
TotallyNotChase May 16, 2022
88916a0
`PTryFrom` instances for `PNonZero`
TotallyNotChase May 16, 2022
0ea3b7c
Unexport `PRational` constructor...
TotallyNotChase May 17, 2022
3ca3ef4
`TryFrom` instance for `PRational` and cleanup
TotallyNotChase May 17, 2022
2f66f92
`TryFrom` tests for `PRational`
TotallyNotChase May 17, 2022
33aceff
Actually run `TryFromSpec` tests
TotallyNotChase May 17, 2022
219eb47
Amend `pconstant` law
TotallyNotChase May 17, 2022
ecad1cb
Allow the PTxInfo.mint field to contain zero Ada
blamario May 18, 2022
0baae53
Use a stateful monad stack for pretty printing
TotallyNotChase May 24, 2022
e1f237b
Interval utils
May 28, 2022
e527218
`nix flake update`
L-as May 30, 2022
7fb9395
Merge pull request #396 from Plutonomicon/mario/value-api
L-as May 30, 2022
d9691f1
use `haskell-nix-extra-hackage`
L-as May 30, 2022
8a93ac0
replace haskell.nix fourmolu with nixpkgs fourmolu
MangoIV May 31, 2022
17cc393
Update stuff
L-as May 31, 2022
4d3b7a4
Update Nixpkgs
L-as May 31, 2022
7340706
add link in guide (README -> PTryFrom )
May 31, 2022
382791d
Ada-related functionality
blamario May 31, 2022
f81954e
A slight optimization most of the time
blamario May 31, 2022
5df0fad
Formatting
blamario May 31, 2022
8b470bd
Fixed a typo
blamario May 31, 2022
da570fb
Always use cabalProjectLocal
L-as May 31, 2022
ff35eaa
Replaced FFI.foreignImport with pconstant
blamario May 31, 2022
978433f
Use ghc923 and re-enable HLS
L-as Jun 1, 2022
42def00
Use nixpkgs-latest's lib
L-as Jun 1, 2022
974373a
Fix HLS
L-as Jun 1, 2022
a7da898
./bin/format
L-as Jun 1, 2022
7e0806b
add `PTryFrom` hyperlink to `Typeclasses.md`
Jun 1, 2022
df975a4
Disable unused golden checking temporarily
L-as Jun 1, 2022
34aaec7
Add remaining hyperlinks
TotallyNotChase Jun 1, 2022
9796868
Merge #475
L-as Jun 1, 2022
be1f0b0
Merge pull request #476 from peter-mlabs/patch-4
TotallyNotChase Jun 1, 2022
eb40218
Fix issue with fourmolu
L-as Jun 1, 2022
af7fbcb
Merge staging
L-as Jun 1, 2022
44ddd19
Merge pull request #477 from Plutonomicon/mario/value-ada
L-as Jun 1, 2022
6a2ae09
Update goldens
L-as Jun 1, 2022
6f7fc09
Merge branch 'staging' of github.com:Plutonomicon/plutarch into las/u…
L-as Jun 1, 2022
9da025c
Fix tests
L-as Jun 1, 2022
dc75fa3
Merge pull request #443 from Plutonomicon/las/update
L-as Jun 1, 2022
144ccad
Merge branch 'staging' into tryfrom-tests
L-as Jun 1, 2022
e7ef565
Merge pull request #471 from Plutonomicon/tryfrom-tests
L-as Jun 1, 2022
803108d
Thread hard-coded monad through Term
L-as Jun 1, 2022
5f4ea0d
Make Term monadic, remove CPP, and Plutarch.Rec (sorry)
L-as Jun 2, 2022
d7a040b
Add `evalScriptHuge` and use it in `plift'`
L-as Jun 3, 2022
6d47f7d
Deprecate `PCon` and `PMatch`
L-as Jun 3, 2022
7117eef
Merge pull request #479 from Plutonomicon/las/monadic
L-as Jun 3, 2022
db7baab
Simplify module structure by not re-exporting from `Plutarch.Internal…
L-as Jun 3, 2022
006da12
Make tests work again
L-as Jun 3, 2022
d779942
Add `PForall`
L-as Jun 3, 2022
e8fe502
adjusted the docs to work with current api
MangoIV Jun 8, 2022
dca9e65
Merge pull request #480 from Plutonomicon/mangoiv/run-guide
L-as Jun 9, 2022
436680b
Update Run.md
MangoIV Jun 11, 2022
a9bd6f2
Merge pull request #481 from Plutonomicon/mangoiv/fix-docs-mistake
L-as Jun 17, 2022
ee776e8
Rework stuff
L-as Jun 22, 2022
1142a27
Fix nix
L-as Jun 22, 2022
31ffe47
made things compile
MangoIV Jun 22, 2022
d120098
Add `PTryFrom` instance for un-dataed `PDataSum`
L-as Jun 27, 2022
e9cfbc7
Remove mistaken use of `OVERLAPPING`
L-as Jun 27, 2022
ee2798d
Try to fix `pfield`
L-as Jun 27, 2022
e4a02f6
Fix `PTryFrom` for `PDataSum`
L-as Jun 27, 2022
1362c32
Add `PlutusType` for `PString`, `PByteString`, and `PInteger`
L-as Jun 27, 2022
43ad014
Fix `PUnit` implementation
L-as Jun 27, 2022
63baa19
Make `PInner (PAsData a)` finer
L-as Jun 28, 2022
c8ad2b8
started tests fixing, minor changes
MangoIV Jun 28, 2022
752a012
Merge remote-tracking branch 'origin/las/plutustype' into mangoiv/fix…
MangoIV Jun 28, 2022
f9ced91
tests compile
MangoIV Jun 28, 2022
8acb3d9
fix tests; fix rational, regenerate goldens (bench and code)
MangoIV Jun 28, 2022
0222fc6
set -Wno-unrecognised-warning-flags
MangoIV Jun 28, 2022
a9089a5
Merge pull request #492 from Plutonomicon/mangoiv/fix-tests
L-as Jun 28, 2022
ca38fdc
revert change that broke 8.10
MangoIV Jun 28, 2022
12f4e5e
added ghc810 devShell
MangoIV Jun 28, 2022
076d3e4
fix haskell-language-server in ghc8107 devShell
MangoIV Jun 28, 2022
ff6afc6
Remove `punsafeAsClosedTerm` again
L-as Jun 29, 2022
e8be176
fixed some bugs in ghc810 and simplified some stuff but it's still br…
MangoIV Jun 29, 2022
cbc61eb
some more additions, commiting to save some other changes to another …
MangoIV Jul 2, 2022
5176221
finished adding types
MangoIV Jul 3, 2022
c4e359b
removed nonsense from V2.hs and added TODO list
MangoIV Jul 3, 2022
38fcbb3
some reexports to make working with the new types easier
MangoIV Jul 3, 2022
52491d5
Merge pull request #486 from Plutonomicon/las/plutustype
L-as Jul 4, 2022
058722a
Merge branch 'staging' into mangoiv/vasil
L-as Jul 4, 2022
079a873
fix assocmap
MangoIV Jul 4, 2022
10da8a1
Merge branch 'mangoiv/vasil' of github.com:Plutonomicon/plutarch-plut…
MangoIV Jul 4, 2022
45123c4
stop building ghc810
MangoIV Jul 4, 2022
25329db
add back ghc810 devShell because why not (hls is reliably cached and …
MangoIV Jul 4, 2022
42d848a
bump plutus version
MangoIV Jul 4, 2022
f003db8
Merge pull request #495 from Plutonomicon/mangoiv/vasil
L-as Jul 6, 2022
e753266
Merge branch 'staging' into mangoiv/remove-810-from-ci
L-as Jul 6, 2022
7e4e71c
Remove ghc 8.10 dev shell
L-as Jul 6, 2022
84acb6f
Merge pull request #499 from Plutonomicon/mangoiv/remove-810-from-ci
L-as Jul 6, 2022
c398e12
Merge branch 'staging' into rational-experiment
TotallyNotChase Jul 7, 2022
a747bcf
Tests and development flag related cleanup
TotallyNotChase Jul 7, 2022
4070f11
Add `Default` instance for `Config`
TotallyNotChase Jul 7, 2022
7ce1976
Add V2 script utils
TotallyNotChase Jul 7, 2022
ee6d21e
Fix formatting
TotallyNotChase Jul 7, 2022
9176363
Update goldens
TotallyNotChase Jul 7, 2022
ef1e083
add builtin functions
MangoIV Jul 7, 2022
b0ef8d6
Merge pull request #506 from Plutonomicon/cleanups
L-as Jul 7, 2022
acd0a4e
Merge branch 'staging' into mangoiv/vasil-builtins
L-as Jul 7, 2022
ea2166f
Merge pull request #507 from Plutonomicon/mangoiv/vasil-builtins
L-as Jul 7, 2022
28edeec
Merge branch 'staging' into rational-experiment
TotallyNotChase Jul 7, 2022
b539f9b
Build fixes and update goldens
TotallyNotChase Jul 7, 2022
a385c8d
Fix formatting
TotallyNotChase Jul 7, 2022
c657d01
fix passertSorted
MangoIV Jul 8, 2022
421b1c8
make map use data equality
MangoIV Jul 8, 2022
1001ce9
Merge branch 'staging' into mangoiv/interval-utils
MangoIV Jul 8, 2022
faba78c
Merge pull request #511 from Plutonomicon/mangoiv/fix-passertsorted
L-as Jul 8, 2022
1162618
formatting
MangoIV Jul 8, 2022
db3dc15
fix pinterval and pinterval tests, add goldens
MangoIV Jul 9, 2022
9b48ad8
fix order of type variables for hrecField and pfield and deprecate hr…
MangoIV Jul 9, 2022
2779abf
remove notion of equality for unsorted Maps
MangoIV Jul 9, 2022
0de4d09
Merge branch 'staging' into mangoiv/map-via-dataequality
L-as Jul 9, 2022
b95fd0f
Merge pull request #512 from Plutonomicon/mangoiv/map-via-dataequality
L-as Jul 9, 2022
4d34a47
Merge branch 'staging' into fix-hrecfield-pfield
L-as Jul 9, 2022
e071cc7
Merge pull request #515 from Plutonomicon/fix-hrecfield-pfield
L-as Jul 9, 2022
064e6cf
Merge branch 'staging' into pretty-scripts
TotallyNotChase Jul 10, 2022
b336549
Improve `freshVarName`
TotallyNotChase Jul 10, 2022
da5e7db
General imrpovements
TotallyNotChase Jul 10, 2022
581ff70
Add semantics documentation
TotallyNotChase Jul 10, 2022
cd74c2e
Fix formatting
TotallyNotChase Jul 10, 2022
ac6b59a
Fix builtin string prettification
TotallyNotChase Jul 10, 2022
b12ede0
Add example
TotallyNotChase Jul 10, 2022
bc7d54b
Merge pull request #461 from Plutonomicon/pretty-scripts
L-as Jul 11, 2022
bb4fe78
Merge branch 'staging' into mangoiv/interval-utils
L-as Jul 11, 2022
0729fed
Actually export `pthrow`
TotallyNotChase Jul 12, 2022
cb73a12
Use `pthrow` for compilation error
TotallyNotChase Jul 12, 2022
03fe4ec
Don't use `punsafeCoerce` unless necessary
TotallyNotChase Jul 12, 2022
74b01ac
Fix formatting
TotallyNotChase Jul 12, 2022
92e3d6d
Add link to Discord
L-as Jul 12, 2022
67dc9cc
Merge pull request #517 from Plutonomicon/las/readme
L-as Jul 12, 2022
9f437c1
Remove `PBuiltinMap`
L-as Jul 12, 2022
e103d25
Merge pull request #518 from Plutonomicon/las/pbuiltinmap
L-as Jul 12, 2022
6363411
Merge branch 'staging' into mangoiv/interval-utils
L-as Jul 12, 2022
585fe59
Put some tests inside `contains` test group
L-as Jul 12, 2022
b808c99
Merge pull request #514 from Plutonomicon/mangoiv/interval-utils
L-as Jul 12, 2022
e1f1936
Fix goldens
L-as Jul 12, 2022
fcc8ed8
Merge pull request #519 from Plutonomicon/las/goldens
L-as Jul 12, 2022
8a5973e
Use `PPositive` rather than `PNonZero` for `PRational`
TotallyNotChase Jul 12, 2022
c99ec7e
Fix formatting
TotallyNotChase Jul 12, 2022
fa14b22
Address review comments
TotallyNotChase Jul 13, 2022
4e02da9
Merge branch 'staging' into rational-experiment
L-as Jul 13, 2022
025b57d
Merge branch 'staging' into mangoiv/upstream-ptryFrom-instances
danielfarrelly Jul 13, 2022
1aecbb4
Merge pull request #435 from Plutonomicon/rational-experiment
L-as Jul 13, 2022
9d482e2
Update `PTryFrom` instances for Plutarch 1.2
danielfarrelly Jul 13, 2022
26e7f86
Merge branch 'staging' into df/upstream-ptryFrom-instances
L-as Jul 13, 2022
160cce0
Drop `PAsData` from TxInfo where it is redundant
emiflake Jul 14, 2022
829f7d6
Merge pull request #521 from Plutonomicon/emiflake/drop-as-data-api
L-as Jul 14, 2022
3574284
Partial ordering relations and type sig fixes
TotallyNotChase Jul 19, 2022
13547f4
Minor changes
TotallyNotChase Jul 20, 2022
4364bd0
More CSE in `pcheckBinRel`
TotallyNotChase Jul 20, 2022
96a58ef
Eta reduction for `pcheckBinRel`
TotallyNotChase Jul 20, 2022
273552f
Merge pull request #524 from Plutonomicon/pvalue-order
L-as Jul 20, 2022
ebc94bf
Fix parens wrapping on prettifier
TotallyNotChase Jul 20, 2022
c25c5a7
Merge pull request #527 from Plutonomicon/pretty-fix
L-as Jul 20, 2022
a8564db
Add `PPartialOrd`
TotallyNotChase Jul 22, 2022
3852f3a
Remove `POrd` instance of PValue
TotallyNotChase Jul 22, 2022
410c1d2
Fixity declaration for `PPartialOrd` methods
TotallyNotChase Jul 22, 2022
af33579
`PPartialOrd` and `POrd` rehaul
TotallyNotChase Jul 26, 2022
e297150
Merge branch 'staging' into pvalue-remove-pord
L-as Jul 26, 2022
e23f2d9
Merge pull request #528 from Plutonomicon/pvalue-remove-pord
L-as Jul 26, 2022
104fdc5
Merge branch 'staging' into df/upstream-ptryFrom-instances
TotallyNotChase Jul 28, 2022
0ecac88
Fix some `PValue` type sigs
TotallyNotChase Jul 28, 2022
3180ae4
`ptryFrom` error convention
TotallyNotChase Jul 28, 2022
d67e1ce
Fix test suite compilation
TotallyNotChase Jul 28, 2022
7bfb370
Improve `PTxId` `PTryFrom` instance
TotallyNotChase Jul 29, 2022
77bbe60
Remove `Flip` export and define inline everywhere
TotallyNotChase Jul 29, 2022
2f6faa2
Merge pull request #520 from danielfarrelly/df/upstream-ptryFrom-inst…
L-as Jul 30, 2022
a89859e
1.2
L-as Aug 1, 2022
ab34e54
Merge remote-tracking branch 'origin/master' into staging
L-as Aug 1, 2022
2629dc2
Merge pull request #530 from Plutonomicon/las/release
L-as Aug 1, 2022
45b7c77
Format
L-as Aug 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flake.lock linguist-generated=true
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/result*
/dist-newstyle
/dist-*
.direnv
bench.csv
110 changes: 108 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
# Revision history for plutarch

# Unreleased
# 1.2 (WIP changelog)

- Changed fields of `PTxInfo` whose only representation is data to not be wrapped by `PAsData`.

Module: `Plutarch.Api.V1.Contexts`; `Plutarch.Api.V2.Contexts`

- Added `plistData` builtin function wrapper.

Module: `Plutarch.Builtin`

- Added `PEq` superclass constraint to `POrd`

Included by [#326](https://github.com/Plutonomicon/plutarch/pull/326)

- Added module `Plutarch.Show` with the `PShow` type class, as well as functions `pshow` and `ptraceShowId`.

Started by [#352](https://github.com/Plutonomicon/plutarch/pull/352)

- Add `puncons` and `ptryUncons` functions for deconstructing list.

Started by: [#333](https://github.com/Plutonomicon/plutarch/pull/333)

- Add generic deriving for `PEq`

Started by [#335](https://github.com/Plutonomicon/plutarch/pull/335)
- `Plutarch.Prelude` and `Plutarch.List` now export pfind, pelemAt, preverse and pcheckSroted.

Started by: [#306](https://github.com/Plutonomicon/plutarch/pull/306)

- Added module `Plutarch.FFI` for interoperability with PlutusTx.

- Added `DerivePConstantViaBuiltin`, deprecating `DerivePConstantViaNewtype`.

- `TermCont`: Parametrize by result type; add `MonadFail` instance; etc.

Expand Down Expand Up @@ -41,7 +72,7 @@
- Added APIs for constructing, compiling, serialising & hashing Plutarch scripts.

Type synonyms for Plutarch-typed scripts `PValidator`,`PMintingPolicy` & `PStakeValidator`.

`mkValidator`, `mkStakeValidator` & `mkMintingPolicy` functions, for creating Plutus API compatible scripts.

`validatorHash`, `mintingPolicySymbol` & `stakeValidatorHash` to obtain script hashes.
Expand Down Expand Up @@ -71,6 +102,81 @@

Added by: [#235](https://github.com/Plutonomicon/plutarch/pull/270)

- Add `Plutarch.Test` for testing Plutarch code with goldens for UPLC printing and Plutus benchmarks.

- Add Conversion types `PTryFrom`, `PMaybeFrom` and `PFrom`

Module: `Plutarch.TryFrom`

Added by: [#326](https://github.com/Plutonomicon/plutarch/pull/326)

- `plutarch-extra`: Add a new directory scaffold "`plutarch-extra`" which will be home to everything too specific to not be in the
main Plutarch repo. Also refactored the test library.

Directory: `plutarch-extra`

Added by: [#329](https://github.com/Plutonomicon/plutarch/pull/329)

- `plutarch-extra` export merged Prelude

Module: `Plutarch.PPrelude`

Added by: [#356](https://github.com/Plutonomicon/plutarch/pull/356)

- Add `PConstant` instance for `Maybe`, with corresponding `PLift` instance for `PMaybeData`.

Added by: [#371](https://github.com/Plutonomicon/plutarch/pull/371)

- Add `POrd` and `PEq` derivation for data encoded types via `PIsDataReprInstances`.

Added by: [#371](https://github.com/Plutonomicon/plutarch/pull/371)

- Make `PRational` construction machinery fail when the denominator is 0.

Fixed by: [#299](https://github.com/Plutonomicon/plutarch/pull/299)

- Rename `PConstant` (the typeclass) to `PConstantDecl`. `PConstant` is now a type alias with extra constraints for better type checking.

Add `PLiftData` and `PConstantData` type aliases.

Added by: [#354](https://github.com/Plutonomicon/plutarch/pull/354)

- Remove `hrecField` export. Use `getField` instead.

Removed by: [#415](https://github.com/Plutonomicon/plutarch/pull/415)

- Rename the `"data"` field of `PTxInfo` to `"datums"`.

Renamed by: [#415](https://github.com/Plutonomicon/plutarch/pull/415)

- Add `Num` instance for `PPOSIXTime` and export its constructor.

Added by: [#415](https://github.com/Plutonomicon/plutarch/pull/415)

- `PlutusType` is now a superclass of `PIsDataRepr`, strengthening the existing `PMatch` superclass constraint.

Added by: [#415](https://github.com/Plutonomicon/plutarch/pull/415)

- Add `PlutusType` instance for `PDataSum`. `PDataSum` can now be hand-constructed.

Added by: [#345](https://github.com/Plutonomicon/plutarch/pull/345)

- Add `HRecOf`, `PMemberFields`, and `PMemberField` utility types.

Module: `Plutarch.DataRepr`.

Added by: [#466](https://github.com/Plutonomicon/plutarch/pull/466)

- Move `Plutarch.ListUtils` to `Plutarch.Extra.List`.

Added by: [#466](https://github.com/Plutonomicon/plutarch/pull/466)

- Add various `TermCont` utilities: `ptraceC`, `pletFieldsC`, `ptryFromC`, `pguardC`, and `pguardC'`.

Module: `Plutarch.Extra.TermCont`.

Added by: [#466](https://github.com/Plutonomicon/plutarch/pull/466)

# 1.1.0

- General repository changes.
Expand Down
92 changes: 61 additions & 31 deletions Plutarch.hs
Original file line number Diff line number Diff line change
@@ -1,40 +1,70 @@
module Plutarch (
(:-->),
ClosedTerm,
compile,
Dig,
hashTerm,
papp,
pdelay,
PDelayed,
perror,
pforce,
phoistAcyclic,
plam',
plet,
Term,
S,
PType,
PlutusType (..),
printTerm,
printScript,
(#$),
(#),
pinl,
PCon (..),
PMatch (..),
pto,
pfix,
POpaque (..),
popaque,
plam,
DerivePNewtype (DerivePNewtype),
(PI.:-->),
PI.ClosedTerm,
PI.compile,
PI.Dig,
PI.hashTerm,
PI.papp,
PI.pdelay,
PI.PDelayed,
PI.perror,
PI.pforce,
PI.phoistAcyclic,
PI.plet,
PI.pthrow,
PI.Term,
PI.S,
PI.PType,
PP.PlutusType,
PP.PInner,
PP.pcon,
PP.pmatch,
PP.PCon,
PP.PMatch,
PPR.prettyTerm,
PPR.prettyScript,
PO.printTerm,
PO.printScript,
(PL.#$),
(PL.#),
PL.pinl,
PO.pto,
PO.pfix,
PO.POpaque (PO.POpaque),
PO.popaque,
PL.plam,
PT.TermCont (TermCont),
PT.hashOpenTerm,
PT.runTermCont,
PT.unTermCont,
PI.Config (Config, tracingMode),
PI.TracingMode (NoTracing, DoTracing, DetTracing),
PI.pgetConfig,
PQ.PForall (PForall),
PQ.PSome (PSome),
PS.PScottEncoded (PScottEncoded),
PS.PlutusTypeScott,
PN.PlutusTypeNewtype,
PP.DerivePlutusType,
PP.DPTStrat,
PP.PCovariant,
PP.PCovariant',
PP.PContravariant,
PP.PContravariant',
PP.PVariant,
PP.PVariant',
) where

import Plutarch.Internal.Other
import qualified Plutarch.Internal as PI
import qualified Plutarch.Internal.Newtype as PN
import qualified Plutarch.Internal.Other as PO
import qualified Plutarch.Internal.PLam as PL
import qualified Plutarch.Internal.PlutusType as PP
import qualified Plutarch.Internal.Quantification as PQ
import qualified Plutarch.Internal.ScottEncoding as PS
import Plutarch.Num ()
import qualified Plutarch.Pretty as PPR
import qualified Plutarch.TermCont as PT

-- import orphan instances
import Prelude ()
44 changes: 44 additions & 0 deletions Plutarch/Api/Internal/Hashing.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module Plutarch.Api.Internal.Hashing (
hashScriptWithPrefix,
hashData,
hashLedgerBytes,
) where

import Codec.Serialise (serialise)
import Crypto.Hash (hashWith)
import Crypto.Hash.Algorithms (
Blake2b_224 (Blake2b_224),
Blake2b_256 (Blake2b_256),
HashAlgorithm,
)
import Data.ByteArray (convert)
import Data.ByteString (ByteString)
import qualified Data.ByteString.Lazy as Lazy

import qualified PlutusLedgerApi.V1 as Plutus
import qualified PlutusLedgerApi.V1.Scripts as Plutus
import qualified PlutusTx.Builtins as PlutusTx

_plutusHashWith :: HashAlgorithm alg => alg -> ByteString -> PlutusTx.BuiltinByteString
_plutusHashWith alg = PlutusTx.toBuiltin . convert @_ @ByteString . hashWith alg

hashBlake2b_224 :: ByteString -> PlutusTx.BuiltinByteString
hashBlake2b_224 = _plutusHashWith Blake2b_224

hashBlake2b_256 :: ByteString -> PlutusTx.BuiltinByteString
hashBlake2b_256 = _plutusHashWith Blake2b_256

-- | Hash a Script with the given version prefix
hashScriptWithPrefix :: ByteString -> Plutus.Script -> Plutus.ScriptHash
hashScriptWithPrefix prefix scr =
Plutus.ScriptHash
. hashBlake2b_224
$ prefix <> Lazy.toStrict (serialise scr)

-- | Hash Plutus 'Data'.
hashData :: Plutus.Data -> PlutusTx.BuiltinByteString
hashData = hashBlake2b_256 . Lazy.toStrict . serialise

-- | Hash 'LedgerBytes'.
hashLedgerBytes :: Plutus.LedgerBytes -> PlutusTx.BuiltinByteString
hashLedgerBytes = hashBlake2b_224 . Plutus.fromBuiltin . Plutus.getLedgerBytes
24 changes: 0 additions & 24 deletions Plutarch/Api/Internal/Scripts.hs

This file was deleted.

44 changes: 32 additions & 12 deletions Plutarch/Api/V1.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ module Plutarch.Api.V1 (
mintingPolicySymbol,
stakeValidatorHash,
scriptHash,
datumHash,
redeemerHash,
dataHash,
mkValidator,
mkStakeValidator,
mkMintingPolicy,
Expand All @@ -28,11 +31,12 @@ module Plutarch.Api.V1 (
Value.PValue (PValue),
Value.PCurrencySymbol (PCurrencySymbol),
Value.PTokenName (PTokenName),
Value.KeyGuarantees (Unsorted, Sorted),
Value.AmountGuarantees (NoGuarantees, NonZero, Positive),

-- ** Crypto
Crypto.PPubKeyHash (PPubKeyHash),
Crypto.PPubKey (PPubKey),
Crypto.PSignature (PSignature),
Crypto.pubKeyHash,

-- ** DCert
DCert.PDCert (
Expand Down Expand Up @@ -95,14 +99,18 @@ import qualified Plutarch.Api.V1.Value as Value

import Data.Coerce (coerce)

import qualified Plutus.V1.Ledger.Api as Plutus
import qualified Plutus.V1.Ledger.Scripts as Plutus
-- note about V2: This should there are no changes in Scripts or V1 itself that affect this module
import qualified PlutusLedgerApi.V1 as Plutus
import qualified PlutusLedgerApi.V1.Scripts as Plutus

import Plutarch (ClosedTerm, POpaque, compile)
import Plutarch.Api.Internal.Scripts (hashScriptWithPrefix)
import Plutarch (Config, compile)
import Plutarch.Api.Internal.Hashing (hashData, hashScriptWithPrefix)
import Plutarch.Api.V1.Contexts (PScriptContext)
import Plutarch.Prelude

import qualified Data.Text as T
import GHC.Stack (HasCallStack)

-- On-chain Script Types

-- | a Validator Term
Expand All @@ -115,16 +123,16 @@ type PMintingPolicy = PData :--> PScriptContext :--> POpaque
type PStakeValidator = PData :--> PScriptContext :--> POpaque

-- | Compile a Validator
mkValidator :: ClosedTerm PValidator -> Plutus.Validator
mkValidator s = Plutus.Validator $ compile s
mkValidator :: HasCallStack => Config -> ClosedTerm PValidator -> Plutus.Validator
mkValidator config s = Plutus.Validator $ either (error . T.unpack) id $ compile config s

-- | Compile a MintingPolicy
mkMintingPolicy :: ClosedTerm PMintingPolicy -> Plutus.MintingPolicy
mkMintingPolicy s = Plutus.MintingPolicy $ compile s
mkMintingPolicy :: HasCallStack => Config -> ClosedTerm PMintingPolicy -> Plutus.MintingPolicy
mkMintingPolicy config s = Plutus.MintingPolicy $ either (error . T.unpack) id $ compile config s

-- | Compile a StakeValidator
mkStakeValidator :: ClosedTerm PStakeValidator -> Plutus.StakeValidator
mkStakeValidator s = Plutus.StakeValidator $ compile s
mkStakeValidator :: HasCallStack => Config -> ClosedTerm PStakeValidator -> Plutus.StakeValidator
mkStakeValidator config s = Plutus.StakeValidator $ either (error . T.unpack) id $ compile config s

-- | Hash a Script, with the correct prefix for Plutus V1
scriptHash :: Plutus.Script -> Plutus.ScriptHash
Expand All @@ -141,3 +149,15 @@ mintingPolicySymbol = coerce scriptHash
-- | Hash a StakeValidator, with the correct prefix for Plutus V1
stakeValidatorHash :: Plutus.StakeValidator -> Plutus.StakeValidatorHash
stakeValidatorHash = coerce scriptHash

-- | Hash a Datum.
datumHash :: Plutus.Datum -> Plutus.DatumHash
datumHash = coerce . dataHash

-- | Hash a Redeemer.
redeemerHash :: Plutus.Redeemer -> Plutus.RedeemerHash
redeemerHash = coerce . dataHash

-- | Hash the data encoded representation of given argument.
dataHash :: Plutus.ToData a => a -> Plutus.BuiltinByteString
dataHash = hashData . Plutus.toData
Loading