finished week 9

This commit is contained in:
Lars Brünjes 2021-06-03 01:07:19 +02:00
parent 41f8127224
commit 8265f44589
No known key found for this signature in database
GPG key ID: B488B9045DC1A087
5 changed files with 19 additions and 74 deletions

Binary file not shown.

View file

@ -51,6 +51,12 @@
- Property based testing with `QuickCheck`. - Property based testing with `QuickCheck`.
- Testing Plutus contracts with property based testing. - 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 ## Code Examples
- Lecture #1: [English Auction](code/week01) - Lecture #1: [English Auction](code/week01)
@ -61,6 +67,7 @@
- Lecture #6: [Oracles](code/week06) - Lecture #6: [Oracles](code/week06)
- Lecture #7: [State Machines](code/week07) - Lecture #7: [State Machines](code/week07)
- Lecture #8: [Testing](code/week08) - Lecture #8: [Testing](code/week08)
- Lecture #9: [Marlowe](code/week09)
## Exercises ## Exercises
@ -112,6 +119,11 @@
retrieve all remaining funds (including the NFT). retrieve all remaining funds (including the NFT).
- Modify the tests accordingly. - 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 ## Solutions
- Week #2 - Week #2
@ -138,8 +150,15 @@
- [`RockPaperScissors`](code/week07/src/Week07/RockPaperScissors.hs) - [`RockPaperScissors`](code/week07/src/Week07/RockPaperScissors.hs)
- [`TestRockPaperScissors`](code/week07/src/Week07/TestRockPaperScissors.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 ## 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.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`](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. - [`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.

View file

@ -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
)

View file

@ -2,5 +2,3 @@ cradle:
cabal: cabal:
- path: "./app/marlowe.hs" - path: "./app/marlowe.hs"
component: "exe:marlowe" component: "exe:marlowe"
- path: "./app/homework.hs"
component: "exe:homework"

View file

@ -15,11 +15,3 @@ executable marlowe
, marlowe , marlowe
default-language: Haskell2010 default-language: Haskell2010
ghc-options: -Wall -O2 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