mirror of
https://github.com/FiloSpaTeam/plutus-pioneer-program.git
synced 2024-12-22 13:31:59 +01:00
finished week 9
This commit is contained in:
parent
41f8127224
commit
8265f44589
5 changed files with 19 additions and 74 deletions
BIN
Marlowe_Plutus_Pioneers_June_2021.pdf
Normal file
BIN
Marlowe_Plutus_Pioneers_June_2021.pdf
Normal file
Binary file not shown.
19
README.md
19
README.md
|
@ -51,6 +51,12 @@
|
|||
- Property based testing with `QuickCheck`.
|
||||
- Testing Plutus contracts with property based testing.
|
||||
|
||||
- [Lecture #9](https://youtu.be/-RpCqHuxfQQ)
|
||||
|
||||
- Marlowe overview ([slides](Marlowe_Plutus_Pioneers_June_2021.pdf))
|
||||
- Marlowe in Plutus
|
||||
- Marlowe Playground demo
|
||||
|
||||
## Code Examples
|
||||
|
||||
- Lecture #1: [English Auction](code/week01)
|
||||
|
@ -61,6 +67,7 @@
|
|||
- Lecture #6: [Oracles](code/week06)
|
||||
- Lecture #7: [State Machines](code/week07)
|
||||
- Lecture #8: [Testing](code/week08)
|
||||
- Lecture #9: [Marlowe](code/week09)
|
||||
|
||||
## Exercises
|
||||
|
||||
|
@ -112,6 +119,11 @@
|
|||
retrieve all remaining funds (including the NFT).
|
||||
- Modify the tests accordingly.
|
||||
|
||||
- Week #9
|
||||
|
||||
- Modify the example Marlowe contract, so that Charlie must put down twice the deposit in the very beginning,
|
||||
which gets split between Alice and Bob if Charlie refuses to make his choice.
|
||||
|
||||
## Solutions
|
||||
|
||||
- Week #2
|
||||
|
@ -138,8 +150,15 @@
|
|||
- [`RockPaperScissors`](code/week07/src/Week07/RockPaperScissors.hs)
|
||||
- [`TestRockPaperScissors`](code/week07/src/Week07/TestRockPaperScissors.hs)
|
||||
|
||||
- Week #8
|
||||
|
||||
- [`TokenSaleWithClose`](code/week08/src/Week08/TokenSaleWithClose.hs)
|
||||
- [`ModelWithClose`](code/week08/test/Spec/ModelWithClose.hs)
|
||||
- [`TraceWithClose`](code/week08/test/Spec/TraceWithClose.hs)
|
||||
|
||||
## Some Plutus Modules
|
||||
|
||||
- [`Language.Marlowe.Semantics`](https://github.com/input-output-hk/plutus/blob/master/marlowe/src/Language/Marlowe/Semantics.hs), contains Marlowe types and semantics.
|
||||
- [`Plutus.Contract.StateMachine`](https://github.com/input-output-hk/plutus/blob/master/plutus-contract/src/Plutus/Contract/StateMachine.hs), contains types and functions for using state machines.
|
||||
- [`Plutus.Contract.Test`](https://github.com/input-output-hk/plutus/blob/master/plutus-contract/src/Plutus/Contract/Test.hs), provides various ways to write tests for Plutus contracts.
|
||||
- [`Plutus.Contract.Test.ContractModel`](https://github.com/input-output-hk/plutus/blob/master/plutus-contract/src/Plutus/Contract/Test/ContractModel.hs), support for property based testing of Plutus contracts.
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
import Language.Marlowe.Extended
|
||||
|
||||
main :: IO ()
|
||||
main = print . pretty $ contract "Charles" "Simon" "Alex" $ Constant 100
|
||||
|
||||
choiceId :: Party -> ChoiceId
|
||||
choiceId p = ChoiceId "Winner" p
|
||||
|
||||
contract :: Party -> Party -> Party -> Value -> Contract
|
||||
contract alice bob charlie deposit =
|
||||
When
|
||||
[ f alice bob
|
||||
, f bob alice
|
||||
]
|
||||
10 Close
|
||||
where
|
||||
f :: Party -> Party -> Case
|
||||
f x y =
|
||||
Case
|
||||
(Deposit
|
||||
x
|
||||
x
|
||||
ada
|
||||
deposit
|
||||
)
|
||||
(When
|
||||
[Case
|
||||
(Deposit
|
||||
y
|
||||
y
|
||||
ada
|
||||
deposit
|
||||
)
|
||||
(When
|
||||
[Case
|
||||
(Choice
|
||||
(choiceId charlie)
|
||||
[Bound 1 2]
|
||||
)
|
||||
(If
|
||||
(ValueEQ
|
||||
(ChoiceValue $ choiceId charlie)
|
||||
(Constant 1)
|
||||
)
|
||||
(Pay
|
||||
bob
|
||||
(Account alice)
|
||||
ada
|
||||
deposit
|
||||
Close
|
||||
)
|
||||
(Pay
|
||||
alice
|
||||
(Account bob)
|
||||
ada
|
||||
deposit
|
||||
Close
|
||||
)
|
||||
)]
|
||||
30 Close
|
||||
)]
|
||||
20 Close
|
||||
)
|
|
@ -2,5 +2,3 @@ cradle:
|
|||
cabal:
|
||||
- path: "./app/marlowe.hs"
|
||||
component: "exe:marlowe"
|
||||
- path: "./app/homework.hs"
|
||||
component: "exe:homework"
|
||||
|
|
|
@ -15,11 +15,3 @@ executable marlowe
|
|||
, marlowe
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall -O2
|
||||
|
||||
executable homework
|
||||
hs-source-dirs: app
|
||||
main-is: homework.hs
|
||||
build-depends: base ^>=4.14.1.0
|
||||
, marlowe
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall -O2
|
||||
|
|
Loading…
Reference in a new issue