Skip to content

Commit

Permalink
Merge pull request #135 from input-output-hk/DOC-IMPROVE
Browse files Browse the repository at this point in the history
update ts contract demo
  • Loading branch information
nhenin committed Dec 18, 2023
2 parents b3378c5 + 9f8d4c5 commit 21ad5f2
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions packages/language/core/v1/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,36 @@
* This module exports static types (only useful in TypeScript) for the JSON schema as specified in the Appendix E of the {@link https://github.com/input-output-hk/marlowe/releases/download/v3/Marlowe.pdf | Marlowe specification}
```
import {Value, Contract} from "@marlowe/language-core-v1"
const four: Value = { add: 2n, and: 2n};
import { Contract, datetoTimeout } from "./contract.js";
import { Value } from "./value-and-observation.js";
import { lovelace } from './token.js';
import { Party } from "./participants.js";
const oneADA = 1000000n;
const tenADA: Value = { multiply: 10n, times: oneADA };
// is the same as
// const tenADA = { multiply: 10n, times: oneADA};
// these party definitions are the same, but specifying the type 'Party'
// adds static guardrails to the type, making the dev process
// more intuative
const bob: Party = { "role_token": "Bob" };
const alice = { "role_token": "Alice" };
const contract: Contract = {
"when": [
{
"then": "close",
"case": {
"party": { "role_token": "Bob" },
"of_token": { "token_name": "", "currency_symbol": "" },
"into_account": { "role_token": "Alice" },
"deposits": 1n
"party": bob,
"of_token": lovelace,
"into_account": alice,
"deposits": tenADA
}
}
],
"timeout_continuation": "close",
"timeout": 1696345114737n
"timeout": datetoTimeout(new Date("2024-05-22"))
}
```
* @packageDocumentation
Expand Down

0 comments on commit 21ad5f2

Please sign in to comment.