Skip to content

Instantly share code, notes, and snippets.

@brunjlar
Created June 1, 2022 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save brunjlar/c25ddd94ff103614a1bdc9b1cea3c67a to your computer and use it in GitHub Desktop.
Save brunjlar/c25ddd94ff103614a1bdc9b1cea3c67a to your computer and use it in GitHub Desktop.
MPP - Choice, If & Let
{"valueParameterInfo":[["Amount",{"valueParameterFormat":{"contents":[6,"ada"],"tag":"DecimalFormat"},"valueParameterDescription":"Amount to deposit."}]],"timeParameterDescriptions":[["DepositDeadline","Deadline for the deposit."],["ChoiceDeadline","Deadline for the choice."]],"roleDescriptions":[["Chooser","CHooses who will receive the deposit."],["Giver","Makes the deposit."],["Receiver1","The first potential receiver."],["Receiver2","The second potential receiver."]],"contractType":"Other","contractShortDescription":"Simple choice.","contractName":"MPP - Choice & If","contractLongDescription":"The \"Chooser\" can decide whether to give the money deposited by \"Giver\" to \"Receiver1\" or \"Receiver2\".","choiceInfo":[["Choice",{"choiceFormat":{"contents":null,"tag":"DefaultFormat"},"choiceDescription":"Which receiver should receive the doposit?"}]]}
Let
"amount"
(ConstantParam "Amount")
(When
[Case
(Deposit
(Role "Giver")
(Role "Giver")
(Token "" "")
(UseValue "amount")
)
(When
[Case
(Choice
(ChoiceId
"Choice"
(Role "Chooser")
)
[Bound 1 2]
)
(If
(ValueEQ
(ChoiceValue
(ChoiceId
"Choice"
(Role "Chooser")
))
(Constant 1)
)
(Pay
(Role "Giver")
(Account (Role "Receiver1"))
(Token "" "")
(UseValue "amount")
Close
)
(Pay
(Role "Giver")
(Account (Role "Receiver2"))
(Token "" "")
(UseValue "amount")
Close
)
)]
(TimeParam "ChoiceDeadline")
Close
)]
(TimeParam "DepositDeadline")
Close
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment