Skip to content
Permalink
Browse files

Translate Escrow contract to Marlowe 2.0

  • Loading branch information...
palas committed Mar 15, 2019
1 parent e2ac937 commit 709d09802128517368981b74a281c575cf5c6284
Showing with 4 additions and 3 deletions.
  1. +3 −2 meadow-client/src/Marlowe/Contracts.purs
  2. +1 −1 meadow-client/src/Semantics.purs
@@ -4,7 +4,8 @@ depositIncentive :: String
depositIncentive = "Commit 1 1 1\n (Constant 100)\n 10 200\n (Commit 2 2 2\n (Constant 20)\n 20 200\n (When (ChoseSomething (1, 1))\n 100\n (Both (Pay 3 1 1 (Constant 100) 200 Null Null)\n (Pay 4 2 2 (Constant 20) 200 Null Null))\n (Both (Pay 5 1 1 (Constant 100) 200 Null Null)\n (Pay 6 2 1 (Constant 20) 200 Null Null)))\n (Pay 7 1 1 (Constant 100) 200 Null Null))\n Null"

crowdFunding :: String
crowdFunding = "Both (Both (Both (When (AndObs (ChoseSomething (1, 1))\n (ValueGE (ValueFromChoice (1, 1)\n (Constant 0))\n (Constant 1)))\n 10\n (Commit 1 1 1\n (ValueFromChoice (1, 1)\n (Constant 0))\n 10 20 Null Null)\n Null)\n (When (AndObs (ChoseSomething (2, 2))\n (ValueGE (ValueFromChoice (2, 2)\n (Constant 0))\n (Constant 1)))\n 10\n (Commit 2 2 2\n (ValueFromChoice (2, 2)\n (Constant 0))\n 10 20 Null Null)\n Null))\n (Both (When (AndObs (ChoseSomething (3, 3))\n (ValueGE (ValueFromChoice (3, 3)\n (Constant 0))\n (Constant 1)))\n 10\n (Commit 3 3 3\n (ValueFromChoice (3, 3)\n (Constant 0))\n 10 20 Null Null)\n Null)\n (When (AndObs (ChoseSomething (4, 4))\n (ValueGE (ValueFromChoice (4, 4)\n (Constant 0))\n (Constant 1)))\n 10\n (Commit 4 4 4\n (ValueFromChoice (4, 4)\n (Constant 0))\n 10 20 Null Null)\n Null)))\n (When FalseObs 10 Null\n (Choice (ValueGE (AddValue (AddValue (Committed 1)\n (Committed 2))\n (AddValue (Committed 3)\n (Committed 4)))\n (Constant 1000))\n (Both (Both (Pay 5 1 5\n (Committed 1)\n 20 Null Null)\n (Pay 6 2 5\n (Committed 2)\n 20 Null Null))\n (Both (Pay 7 3 5\n (Committed 3)\n 20 Null Null)\n (Pay 8 4 5\n (Committed 4)\n 20 Null Null)))\n Null))\n"
crowdFunding = "Both (Both (Both (When (AndObs (ChoseSomething (1, 1))\n (ValueGE (ValueFromChoice (1, 1)\n (Constant 0))\n (Constant 1)))\n 10\n (Commit 1 1 1\n (ValueFromChoice (1, 1)\n (Constant 0))\n 10 20 Null Null)\n Null)\n (When (AndObs (ChoseSomething (1, 2))\n (ValueGE (ValueFromChoice (1, 2)\n (Constant 0))\n (Constant 1)))\n 10\n (Commit 2 2 2\n (ValueFromChoice (1, 2)\n (Constant 0))\n 10 20 Null Null)\n Null))\n (Both (When (AndObs (ChoseSomething (1, 3))\n (ValueGE (ValueFromChoice (1, 3)\n (Constant 0))\n (Constant 1)))\n 10\n (Commit 3 3 3\n (ValueFromChoice (1, 3)\n (Constant 0))\n 10 20 Null Null)\n Null)\n (When (AndObs (ChoseSomething (4, 4))\n (ValueGE (ValueFromChoice (4, 4)\n (Constant 0))\n (Constant 1)))\n 10\n (Commit 4 4 4\n (ValueFromChoice (4, 4)\n (Constant 0))\n 10 20 Null Null)\n Null)))\n (When FalseObs 10 Null\n (Choice (ValueGE (AddValue (AddValue (Committed 1)\n (Committed 2))\n (AddValue (Committed 3)\n (Committed 4)))\n (Constant 1000))\n (Both (Both (Pay 5 1 5\n (Committed 1)\n 20 Null Null)\n (Pay 6 2 5\n (Committed 2)\n 20 Null Null))\n (Both (Pay 7 3 5\n (Committed 3)\n 20 Null Null)\n (Pay 8 4 5\n (Committed 4)\n 20 Null Null)))\n Null))\n"

escrow :: String
escrow = "CommitCash (IdentCC 1) 1\n (ConstMoney 450)\n 10 100\n (When (OrObs (OrObs (AndObs (PersonChoseThis (IdentChoice 1) 1 0)\n (OrObs (PersonChoseThis (IdentChoice 2) 2 0)\n (PersonChoseThis (IdentChoice 3) 3 0)))\n (AndObs (PersonChoseThis (IdentChoice 2) 2 0)\n (PersonChoseThis (IdentChoice 3) 3 0)))\n (OrObs (AndObs (PersonChoseThis (IdentChoice 1) 1 1)\n (OrObs (PersonChoseThis (IdentChoice 2) 2 1)\n (PersonChoseThis (IdentChoice 3) 3 1)))\n (AndObs (PersonChoseThis (IdentChoice 2) 2 1)\n (PersonChoseThis (IdentChoice 3) 3 1))))\n 90\n (Choice (OrObs (AndObs (PersonChoseThis (IdentChoice 1) 1 1)\n (OrObs (PersonChoseThis (IdentChoice 2) 2 1)\n (PersonChoseThis (IdentChoice 3) 3 1)))\n (AndObs (PersonChoseThis (IdentChoice 2) 2 1)\n (PersonChoseThis (IdentChoice 3) 3 1)))\n (Pay (IdentPay 1) 1 2\n (AvailableMoney (IdentCC 1))\n 100\n (RedeemCC (IdentCC 1) Null))\n (RedeemCC (IdentCC 1) Null))\n (RedeemCC (IdentCC 1) Null))\n Null\n"
escrow = "Commit 1 1 1\n (Constant 450)\n 10 100\n (When (OrObs (OrObs (AndObs (ChoseThis (1, 1) 0)\n (OrObs (ChoseThis (1, 2) 0)\n (ChoseThis (1, 3) 0)))\n (AndObs (ChoseThis (1, 2) 0)\n (ChoseThis (1, 3) 0)))\n (OrObs (AndObs (ChoseThis (1, 1) 1)\n (OrObs (ChoseThis (1, 2) 1)\n (ChoseThis (1, 3) 1)))\n (AndObs (ChoseThis (1, 2) 1)\n (ChoseThis (1, 3) 1))))\n 90\n (Choice (OrObs (AndObs (ChoseThis (1, 1) 1)\n (OrObs (ChoseThis (1, 2) 1)\n (ChoseThis (1, 3) 1)))\n (AndObs (ChoseThis (1, 2) 1)\n (ChoseThis (1, 3) 1)))\n (Pay 2 1 2 (Committed 1) 100 Null Null)\n (Pay 3 1 1 (Committed 1) 100 Null Null))\n (Pay 4 1 1 (Committed 1) 100 Null Null))\n Null\n\n"

@@ -459,7 +459,7 @@ evalObservation blockNumber state (AndObs obs1 obs2) = (go obs1) && (go obs2)
where
go = evalObservation blockNumber state

evalObservation blockNumber state (OrObs obs1 obs2) = (go obs1) && (go obs2)
evalObservation blockNumber state (OrObs obs1 obs2) = (go obs1) || (go obs2)
where
go = evalObservation blockNumber state

0 comments on commit 709d098

Please sign in to comment.
You can’t perform that action at this time.