Last active
June 14, 2022 16:31
-
-
Save marco-martins/f25102edf6050fb10908bc956b9d505c to your computer and use it in GitHub Desktop.
double-pay.js
This file contains hidden or 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":[["Deposit",{"valueParameterFormat":{"contents":[6,""],"tag":"DecimalFormat"},"valueParameterDescription":""}]],"timeParameterDescriptions":[],"roleDescriptions":[["Giver1",""]],"contractType":"Other","contractShortDescription":"","contractName":"Double Pay","contractLongDescription":"We couldn't find information about this contract","choiceInfo":[]} |
This file contains hidden or 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
| function makeDeposit (party: Party, amount: Value): Action { | |
| return Deposit(party, party, ada, amount) | |
| } | |
| function makePayment (giver1: Party, giver2: Party, receiver: Party, amount: Value) : Contract { | |
| return Pay(giver1, Party(receiver), ada, amount, | |
| Pay(giver2, Party(receiver), ada, amount, Close)) | |
| } | |
| function mainFunction (giver1: Party, giver2: Party, receiver: Party, amount: Value, deadline: Timeout): Contract { | |
| //const makePayment: Contract = Pay(giver1, Party(receiver), ada, amount, Pay(giver2, Party(receiver), ada, amount, Close)) | |
| function deposits (p1: Party, p2: Party): Case { | |
| return Case( | |
| makeDeposit(p1, amount), | |
| When([Case( | |
| makeDeposit(p2, amount), | |
| makePayment(giver1, giver2, receiver, amount) | |
| )], | |
| deadline, Close) | |
| ) | |
| } | |
| return When([ | |
| deposits(giver1, giver2), | |
| deposits(giver2, giver1) | |
| ], | |
| deadline, Close | |
| ) | |
| } | |
| return mainFunction( | |
| Role("Giver1"), | |
| Role("Giver2"), | |
| Role("Receiver"), | |
| ConstantParam("Deposit"), | |
| TimeParam("Deadline") | |
| ) |
This file contains hidden or 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