Skip to content

Instantly share code, notes, and snippets.

@marco-martins
Last active June 15, 2022 10:47
Show Gist options
  • Save marco-martins/1c189237780ae527aa9d36ddb9bdb6fb to your computer and use it in GitHub Desktop.
Save marco-martins/1c189237780ae527aa9d36ddb9bdb6fb to your computer and use it in GitHub Desktop.
homework04.js
{"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":[]}
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"),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment