Last active
January 12, 2021 09:24
-
-
Save bitm4ster/1d3e2e2e747b9fbff77f8267792f9f80 to your computer and use it in GitHub Desktop.
New Project
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
<xml xmlns="https://developers.google.com/blockly/xml"><block type="BaseContractType" id="root_contract" deletable="false" x="13" y="187"><statement name="BaseContractType"><block type="CloseContractType" id="4O,C,:P.twf:e#oW:Wl}"/></statement></block></xml> |
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
const lovelacePerAda : SomeNumber = 1000000n; | |
const amountOfAda : SomeNumber = 1000n; | |
const amountOfLovelace : SomeNumber = lovelacePerAda * amountOfAda; | |
const amountOfDollars : SomeNumber = 100n; | |
const dollars : Token = Token("85bb65", "dollar") | |
type SwapParty = { | |
party: Party; | |
currency: Token; | |
amount: SomeNumber; | |
}; | |
const alice : SwapParty = { | |
party: Role("alice"), | |
currency: ada, | |
amount: amountOfLovelace | |
} | |
const bob : SwapParty = { | |
party: Role("bob"), | |
currency: dollars, | |
amount: amountOfDollars | |
} | |
const makeDeposit = function(src : SwapParty, timeout : SomeNumber, | |
continuation : Contract) : Contract | |
{ | |
return When([Case(Deposit(src.party, src.party, src.currency, src.amount), | |
continuation)], | |
timeout, | |
Close); | |
} | |
const makePayment = function(src : SwapParty, dest : SwapParty, | |
continuation : Contract) : Contract | |
{ | |
return Pay(src.party, Party(dest.party), src.currency, src.amount, | |
continuation); | |
} | |
const contract : Contract = makeDeposit(alice, 10n, | |
makeDeposit(bob, 20n, | |
makePayment(alice, bob, | |
makePayment(bob, alice, | |
Close)))); | |
return contract; |
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
Close |
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