Last active
June 15, 2022 10:47
-
-
Save marco-martins/1c189237780ae527aa9d36ddb9bdb6fb to your computer and use it in GitHub Desktop.
homework04.js
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":[["Bank Deposit Amount",{"valueParameterFormat":{"contents":[6,"ADA"],"tag":"DecimalFormat"},"valueParameterDescription":"Bank deposit in ADA"}],["Client Deposit Amount",{"valueParameterFormat":{"contents":[6,"ADA"],"tag":"DecimalFormat"},"valueParameterDescription":"Client deposit in ADA"}]],"timeParameterDescriptions":[["Bank Deposit Deadline","Bank deposit deadline"],["Client Deposit Deadline","Client deposit deadline"]],"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
function deposit(from: Party, to: Party, amount: Value): Action { | |
return Deposit(to, from, ada, amount) | |
} | |
function payment(from: Party, to: Party, amount: Value): Contract { | |
return Pay(from, Party(to), ada, amount, Close) | |
} | |
function mainFunction(bank: Party, client: Party, bankDepositAmount: Value, clientDepositAmount: Value, bankDepositDeadline: Timeout, clientDepositDeadline: Timeout): Contract { | |
return When([ | |
Case( | |
deposit(bank, bank, bankDepositAmount), | |
When([ | |
Case( | |
deposit(client, bank, clientDepositAmount), | |
When([ | |
Case( | |
deposit(client, bank, clientDepositAmount), | |
When([ | |
Case( | |
deposit(client, bank, clientDepositAmount), | |
When([ | |
Case( | |
deposit(client, bank, clientDepositAmount), | |
When([ | |
Case( | |
deposit(client, bank, clientDepositAmount), | |
payment(bank, client, AvailableMoney(ada, bank)) | |
) | |
], clientDepositDeadline, Close) | |
) | |
], clientDepositDeadline, Close) | |
) | |
], clientDepositDeadline, Close) | |
) | |
], clientDepositDeadline, Close) | |
) | |
], clientDepositDeadline, Close) | |
) | |
], bankDepositDeadline, Close) | |
} | |
return mainFunction( | |
Role("Bank"), | |
Role("Client"), | |
ConstantParam("Bank Deposit Amount"), | |
ConstantParam("Client Deposit Amount"), | |
TimeParam("Bank Deposit Deadline"), | |
TimeParam("Client Deposit Deadline"), | |
); |
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