Skip to content

Commit

Permalink
Merge pull request #10 from input-output-hk/workspaces
Browse files Browse the repository at this point in the history
Initial version of workspaces
  • Loading branch information
nhenin committed Aug 9, 2023
2 parents 9c8a09b + 63c09a4 commit 803ac6e
Show file tree
Hide file tree
Showing 157 changed files with 1,549 additions and 1,190 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/post-integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Post-integration

on:
pull_request:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: false

jobs:
deploy-docs:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v3

- name: 🧰 Setup Pages
uses: actions/configure-pages@v3

- name: 🧰 Setup nix
uses: cachix/install-nix-action@v22
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: 🔨 Build Docs
run: |
nix develop --show-trace --command bash -c "npm i && npm run build && npm run docs"
- name: 📘 Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: './docs'

- name: 📘 Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ tsconfig.tsbuildinfo
result
source
dist
test-dist

package-lock.json
yarn.lock
77 changes: 75 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,49 @@
# WIP WARNING
> The TypeScript SDK is a work in progress, it's API might change so use with caution.
# Marlowe TS-SDK
The Marlowe TypeScript SDK is a set of libraries and utilities to work with Marlowe contracts. The project uses [npm workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces) to divide itself in the following packages:

* `language/core/v1`: The `@marlowe/language-core-v1` library that contains the core Marlowe language definitions and utilities.
* `legacy-adapter`: The `@marlowe/legacy-adapter` library that contains common utilities.
* `legacy-runtime`: The `@marlowe/legacy-runtime` library that contains the initial abstraction over the Marlowe runtime

## Developer notes

### Build

In order to start develop the SDK you need to install the dependencies and build the packages.

```
$ npm i
$ npm run build
```

If you want to build a single package you can use the `-w` flag or execute the build command from the package folder.

```
# From the root folder
$ npm run build -w @marlowe/language-core-v1
# Or you can enter the package and build
$ cd packages/language/core/v1
$ npm run build
```

In order to clean the build artifacts you can use the `clean` command.

```
$ npm run clean
```

TODO
To run the unit test you can execute the `test` command.

## Testing
```
$ npm run test
```

### E2E tests

TODO: Fix the E2E tests
In order to run the E2E tests you need to create a `env/.env.test` file that points to a working version of the marlowe runtime and a working Blockfrost instance and a faucet PK

TODO: explain how to get the Faucet PK
Expand All @@ -15,3 +55,36 @@ BLOCKFROST_URL="https://cardano-preprod.blockfrost.io/api/v0"
NETWORK_ID=Preprod
BANK_PK_HEX='<pk>'
```

### Documentation

> ⚠ You need to [build the packages](#build) before you can compile the documentation!
To compile all documentation

```
$ npm run docs
```

Documentation is built with [TypeDoc](https://typedoc.org), published through [GitHub Pages](https://pages.github.com), and hosted at https://input-output-hk.github.io/marlowe-ts-sdk

Each sub project needs a `typedoc.json` file in the sub project root directory as specified in the `workspaces` field in `./packages.json`. For example, there's some project "some-project" specified:

```json
// ./packages.json
{
...,
"workspaces": ["./path/to/some-project"]
}
```

There needs to be a `typedoc.json` in `./path/to/some-project` and it needs properties along the lines of this example:

```json
// ./path/to/some-project/typedoc.json
{
"entryPointStrategy": "expand",
"entryPoints": ["./src"],
"tsconfig": "./tsconfig.json"
}
```
11 changes: 0 additions & 11 deletions fixup

This file was deleted.

1 change: 0 additions & 1 deletion jest.config.console.js

This file was deleted.

47 changes: 2 additions & 45 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,6 @@
module.exports = {

testEnvironment: "node",
projects: [
{
displayName: "e2e test",
testMatch: ["./**/*.spec.e2e.ts"],
runner: "jest-serial-runner",
extensionsToTreatAsEsm: ['.ts'],
preset: 'ts-jest/presets/default-esm',
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1'
},
globalSetup: "./dotenv/dotenv-test.js",
setupFilesAfterEnv: ["./jest.config.console.js"],
transform: {
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.m?[tj]sx?$': [
'ts-jest',
{
useESM: true,
},
],
},
},
{
displayName: "unit test",
testMatch: ["./**/*.spec.ts"],
extensionsToTreatAsEsm: ['.ts'],
preset: 'ts-jest/presets/default-esm',
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1'
},
globalSetup: "./dotenv/dotenv-test.js",
setupFilesAfterEnv: ["./jest.config.console.js"],
transform: {
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.m?[tj]sx?$': [
'ts-jest',
{
useESM: true,
},
],
},
}
'<rootDir>/packages/language/core/v1/test/jest.unit.config.mjs'
]
};

72 changes: 24 additions & 48 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "marlowe-ts-sdk",
"version": "0.0.37-beta",
"description": "Marlowe Runtime SDK for building Marlowe Contracts",
"version": "0.1.0-beta",
"description": "Marlowe Runtime SDK for building and managing Marlowe Contracts",
"engines": {
"node": ">=14.20.1"
},
Expand All @@ -10,69 +10,45 @@
"access": "public"
},
"contributors": [
"Nicolas Henin <nicolas.henin@iohk.io> (https://iohk.io)"
"Nicolas Henin <nicolas.henin@iohk.io> (https://iohk.io)",
"Hernan Rajchert <hernan.rajchert@iohk.io> (https://iohk.io)",
"Bjorn Kihlberg <bjorn.kihlberg@iohk.io> (https://iohk.io)"
],
"license": "Apache-2.0",
"scripts": {
"build:esm": "tsc -p src/tsconfig.json --outDir ./dist/esm --module es2020",
"build:cjs": "tsc --build src",
"build": "rm -fr dist/* && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && ./fixup",
"circular-deps:check": "madge --circular dist",
"tscNoEmit": "shx echo typescript --noEmit command not implemented yet",
"cleanup:dist": "shx rm -rf dist",
"cleanup:nm": "shx rm -rf node_modules",
"cleanup": "run-s cleanup:dist cleanup:nm",
"lint": "eslint -c ../../complete.eslintrc.js \"src/**/*.ts\" \"test/**/*.ts\"",
"lint:fix": "yarn lint --fix",
"test": "yarn node --experimental-vm-modules $(yarn bin jest -c ./jest.config.js)",
"test:build:verify": "tsc --build ./test",
"test:e2e": "shx echo 'test:e2e' command not implemented yet",
"coverage": "shx echo No coverage report for this package",
"prepack": "yarn build"
"build": "tsc --build && rollup --config rollup/legacy-runtime-esm.config.mjs",
"clean": "npm run clean --workspaces && shx rm -rf dist",
"test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest",
"docs": "typedoc ."
},
"workspaces": [
"packages/legacy-adapter",
"packages/language/core/v1",
"packages/legacy-runtime"
],
"devDependencies": {
"@relmify/jest-fp-ts": "^2.0.2",
"@rollup/plugin-commonjs": "^25.0.3",
"@rollup/plugin-node-resolve": "^15.1.0",
"@types/axios-curlirize": "^1.3.2",
"@types/deep-equal": "1.0.1",
"@types/jest": "^26.0.24",
"@types/json-bigint": "^1.0.1",
"@types/node": "^18.14.2",

"eslint": "^7.32.0",
"jest": "^29.4",
"jest-serial-runner": "^1.2.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.3.2",
"rollup": "^3.27.2",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-output-size": "^1.2.2",
"shx": "^0.3.3",
"ts-jest": "^29.0.5",
"jest-serial-runner": "^1.2.1",
"@relmify/jest-fp-ts": "^2.0.2",
"ts-node": "^10.9.1"
},
"dependencies": {
"@blockfrost/blockfrost-js": "5.2.0",
"@blockfrost/openapi": "0.1.54",
"@emurgo/cardano-serialization-lib-browser":"11.4.0",
"@types/deep-equal": "1.0.1",
"@types/qs" : "6.9.7",
"qs" : "6.11.1" ,
"axios": "^1.3.3",
"axios-curlirize": "^2.0.0",
"date-fns": "2.29.3",
"deep-equal": "1.0.1",
"dotenv": "^16.0.3",
"fp-ts": "^2.13.1",
"json-bigint": "^1.0.0",
"lucid-cardano": "0.9.4",
"ts-adt": "^2.0.2",
"ts-pattern": "^4.2.0",
"retry-ts":"0.1.4",
"newtype-ts":"0.3.5",
"monocle-ts":"2.3.13",
"io-ts":"2.2.20",
"io-ts-types":"0.5.19",
"io-ts-bigint":"2.0.1",
"jsonbigint-io-ts-reporters":"2.0.1",
"ts-node": "^10.9.1",
"typedoc": "^0.24.8",
"typescript": "^4.9.5",
"typescript-language-server": "^3.1.0"
},
"packageManager": "yarn@3.2.1"
"packageManager": "npm@9.3.1"
}
2 changes: 2 additions & 0 deletions packages/language/core/v1/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# @marlowe/language-core-v1
TODO
54 changes: 54 additions & 0 deletions packages/language/core/v1/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "@marlowe/language-core-v1",
"version": "0.1.0-beta",
"description": "Library to manipulate Marlowe Core contracts",
"repository": "https://github.com/input-output-hk/marlowe-ts-sdk",
"publishConfig": {
"access": "public"
},
"contributors": [
"Nicolas Henin <nicolas.henin@iohk.io> (https://iohk.io)",
"Hernan Rajchert <hernan.rajchert@iohk.io> (https://iohk.io)",
"Bjorn Kihlberg <bjorn.kihlberg@iohk.io> (https://iohk.io)"
],
"license": "Apache-2.0",
"scripts": {
"build": "tsc --build src",
"clean": "tsc --build --clean src ",
"test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest --config test/jest.unit.config.mjs"
},
"type": "module",
"exports": {
".": "./dist/semantics/contract/index.js",
"./examples": "./dist/examples/index.js",
"./next": "./dist/semantics/next/index.js",
"./environment": "./dist/semantics/environment.js",
"./state": "./dist/semantics/state.js"
},

"dependencies": {
"@blockfrost/blockfrost-js": "5.2.0",
"@blockfrost/openapi": "0.1.54",
"@emurgo/cardano-serialization-lib-browser":"11.4.0",
"@types/deep-equal": "1.0.1",
"@types/qs" : "6.9.7",
"qs" : "6.11.1" ,
"axios": "^1.3.3",
"axios-curlirize": "^2.0.0",
"date-fns": "2.29.3",
"deep-equal": "1.0.1",
"dotenv": "^16.0.3",
"fp-ts": "^2.16.0",
"json-bigint": "^1.0.0",
"lucid-cardano": "0.9.4",
"ts-adt": "^2.0.2",
"ts-pattern": "^4.2.0",
"retry-ts":"0.1.4",
"newtype-ts":"0.3.5",
"monocle-ts":"2.3.13",
"io-ts":"2.2.20",
"io-ts-types":"0.5.19",
"io-ts-bigint":"2.0.1",
"jsonbigint-io-ts-reporters":"2.0.1"
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/* eslint-disable sort-keys-fix/sort-keys-fix */

import { Contract } from "../semantics/contract";
import { close } from "../semantics/contract/close";
import { Timeout } from "../semantics/contract/when";
import { Contract } from "../semantics/contract/index.js";
import { close } from "../semantics/contract/close.js";
import { Timeout } from "../semantics/contract/when/index.js";


/**
* Marlowe Example : A contract with One Step (one true notify)
*/

export const oneNotifyTrue : (notifyTimeout:Timeout) => Contract
= (notifyTimeout) =>
export const oneNotifyTrue : (notifyTimeout:Timeout) => Contract
= (notifyTimeout) =>
({ when :[{ case :{ notify_if: true }
, then : close}]
, timeout : notifyTimeout
, timeout_continuation : close})


0 comments on commit 803ac6e

Please sign in to comment.