Skip to content

Commit

Permalink
Updating README.
Browse files Browse the repository at this point in the history
  • Loading branch information
merivale committed Jul 28, 2021
1 parent be3cafc commit b5b19b3
Showing 1 changed file with 17 additions and 41 deletions.
58 changes: 17 additions & 41 deletions marlowe-dashboard-client/README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,24 @@
The Marlowe Dashboard is an online simulator for Marlowe Applications.
Marlowe Run (formerly called the Marlowe Dashboard) is an online simulator for Marlowe Applications.

## Getting started

The Marlowe Dashboard is written in [PureScript](https://www.purescript.org/) and uses npm and [spago](https://github.com/purescript/spago) for managing dependencies. It talks to the [marlowe-dashboard-server](https://github.com/input-output-hk/plutus/tree/master/marlowe-dashboard-server) which also needs to be up and running during development. The client build also depends on purescript files that are generated by the backend service using [purescript-bridge](https://github.com/eskimor/purescript-bridge).
Marlowe Run is written in [PureScript](https://www.purescript.org/) and uses npm and [spago](https://github.com/purescript/spago) for managing dependencies. It talks to the [marlowe-pab](https://github.com/input-output-hk/plutus/tree/master/marlowe/pab) which also needs to be up and running during development. The client build also depends on PureScript files that are generated by the backend service using [purescript-bridge](https://github.com/eskimor/purescript-bridge).

The [marlowe-pab](https://github.com/input-output-hk/plutus/tree/master/marlowe/pab) is a version of the [plutus-pab](https://github.com/input-output-hk/plutus/tree/master/plutus-pab) with the Marlowe Plutus contracts built in.

**Note**: _The workflow described here relies heavily on Nix. This means you should either be working inside a nix-shell environment or use tools such as [lorri](https://github.com/target/lorri) or [nix-direnv](https://github.com/nix-community/nix-direnv) or similar to provide a suitable environment._

### Starting the backend server

The Marlowe Dashboard requires a running instance of the PAB to work. First you need to set up the database:

```bash
$ plutus-pab-migrate
```

Next, setup the Marlowe contracts:

```bash
$ npm run setup-contracts
```

This installs the necessary Marlowe contracts on the PAB, and creates a `contracts/contracts.json` file with links to their nix store paths. This is needed by the frontend application to start instances of these contracts.

Finally, start all the PAB servers:
Marlowe Run requires a running instance of the Marlowe PAB to work:

```bash
$ plutus-pab-all-servers
$ marlowe-pab-server
```

The `plutus-pab-migrate` and `plutus-pab-all-servers` scripts are provided by the global [shell.nix](../shell.nix). The npm `setup-contracts` script also relies on local scripts provided by [default.nix](default.nix). If these commands are not available, make sure you are in a nix-shell session or that lorri is ready. For additional information on invoking the PAB please refer to its [README.md](../plutus-pab/README.md).

### Starting the frontend server

With the contracts installed and the PAB server running, you can get started using the `npm start` script:
With the Marlowe PAB server running, you can get the client started using the `npm start` script:

```bash
$ npm run start
Expand All @@ -49,7 +35,7 @@ Once the `start` script completes you can access the frontend via [http://localh

## Development Workflow

The following outlines some essentials for actually working on the marlowe dashboard code.
The following outlines some essentials for actually working on the Marlowe Run code.

### NPM Scripts

Expand All @@ -65,26 +51,21 @@ Please refer to [package.json](./package.json) for the full set of provided scri

### Generating PureScript Code

The PureScript build depends on the presence of a `./generated` folder with bridge code generated by the backend. This code can
be generated by running `marlowe-dashboard-generate-purs` which is provided by the nix-shell environment.
The PureScript build depends on the presence of a `./generated` folder with bridge code generated by the backend. This code can be generated by running `marlowe-pab-generate-purs` which is provided by the nix-shell environment.

### Managing Dependencies

There are two relevant sources of dependencies that have to be handled and integrated with Nix separately: _Javascript(/npm)_ dependencies and _PureScript_ dependencies.

#### Managing NPM Dependencies

The Javascript dependencies are handled by npm in [package.json](./package.json) (and [package-lock.json](./package-lock.json) which
is updated by npm automatically).
The Javascript dependencies are handled by npm in [package.json](./package.json) (and [package-lock.json](./package-lock.json) which is updated by npm automatically).

The npm dependencies are integrated with Nix via [npmlock2nix](https://github.com/tweag/npmlock2nix) almost completely transparently. Any changes to the lockfile will be picked up npmlock2nix automatically during the nix build. No
additional files have to be generated or maintained.
The npm dependencies are integrated with Nix via [npmlock2nix](https://github.com/tweag/npmlock2nix) almost completely transparently. Any changes to the lockfile will be picked up npmlock2nix automatically during the nix build. No additional files have to be generated or maintained.

##### NodeJS GitHub dependencies

In general, npm dependencies are handled by npmlock2nix automatically and transparently. The one exception to this rule are
GitHub dependencies. In order for these to work in restricted evaluation mode (which is what hydra uses) you have to specify
the sha256 of the dependency you want to use in your `buildNodeModules`. For example:
In general, npm dependencies are handled by npmlock2nix automatically and transparently. The one exception to this rule are GitHub dependencies. In order for these to work in restricted evaluation mode (which is what hydra uses) you have to specify the sha256 of the dependency you want to use in your `buildNodeModules`. For example:

```
buildNodeModules {
Expand All @@ -97,38 +78,33 @@ buildNodeModules {
}
```

You can add new dependencies with the sha256 set to `"0000000000000000000000000000000000000000000000000000"`. This will yield an error
message during the build with the actual hash value.
You can add new dependencies with the sha256 set to `"0000000000000000000000000000000000000000000000000000"`. This will yield an error message during the build with the actual hash value.

#### Managing PureScript Dependencies

The PureScript dependencies are handled by [spago](https://github.com/purescript/spago) in [packages.dhall](./packages.dhall).

The Nix integration is done using [spago2nix](https://github.com/justinwoo/spago2nix). Any changes to the PureScript dependencies
require an update of the Nix code generated by spago2nix:
The Nix integration is done using [spago2nix](https://github.com/justinwoo/spago2nix). Any changes to the PureScript dependencies require an update of the Nix code generated by spago2nix:

```
$ spago2nix generate
```

This will parse the spago configuration and will generate an updated `.nix` file.

**Note**: If the `spago2nix` command is not available make sure you are inside a nix-shell environment or that your lorri session
is up and running.

**Note**: If the `spago2nix` command is not available make sure you are inside a nix-shell environment or that your lorri session is up and running.

### Nix

#### Building The Client With Nix

You can run the following command (from the repository root) to build the client and the
backend server with Nix:
You can run the following command (from the repository root) to build the client and the backend server with Nix:

```sh
$ nix-build \
--option trusted-public-keys "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" \
--option substituters https://hydra.iohk.io \
-A marlowe-dashboard.client -A marlowe-dashboard.server-invoker
-A marlowe-dashboard.client -A marlowe-dashboard.marlowe-invoker
```

**Note**: When building the client make sure that the generated directory is removed completely or you will get _Duplicate module_ errors.

0 comments on commit b5b19b3

Please sign in to comment.