Created
June 10, 2022 04:32
-
-
Save Dave-Lindberg/10c8195af8df61e84ca8c97a0b4f9b10 to your computer and use it in GitHub Desktop.
week-4_double-donation-haskell
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
{-# LANGUAGE OverloadedStrings #-} | |
module Example where | |
import Language.Marlowe.Extended | |
main :: IO () | |
main = printJSON $ contract "giver1" "giver2" "receiver" "amount" "deadline" | |
{- Define a contract, Close is the simplest contract which just ends the contract straight away | |
-} | |
contract :: Party -> Party -> Party -> Value -> Timeout -> Contract | |
contract giver1 giver2 receiver amount deadline = | |
When | |
[deposits giver1 giver2, deposits giver2 giver1] | |
deadline | |
Close | |
where | |
pay :: Contract | |
pay = | |
Pay | |
giver1 | |
(Party receiver) | |
ada | |
amount | |
(Pay | |
giver2 | |
(Party receiver) | |
ada | |
deadline | |
Close | |
) | |
deposit :: Party -> Action | |
deposit p = | |
Deposit p p ada $ ConstantParam "Deposit" | |
deposits :: Party -> Party -> Case | |
deposits p1 p2 = | |
Case | |
(deposit p1) | |
(When | |
[Case (deposit p2) pay] | |
(TimeParam "Deadline") | |
Close | |
) |
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
{"valueParameterInfo":[],"timeParameterDescriptions":[],"roleDescriptions":[],"contractType":"Other","contractShortDescription":"Unknown","contractName":"Unknown","contractLongDescription":"We couldn't find information about this contract","choiceInfo":[]} |
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
{} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment