Skip to content

Commit

Permalink
Kupo config (#53)
Browse files Browse the repository at this point in the history
* change kupo port

* changed configurations

* after-merge fix

* updated dists

* updated readme

---------

Co-authored-by: Olga Klimenko <oklimenko92@mail.ru>
  • Loading branch information
KateBushueva and olgaklimenko authored Aug 1, 2023
1 parent 1c79a52 commit 0385b2d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 72 deletions.
57 changes: 7 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,65 +19,22 @@ Also before starting make sure to have files with plutus scripts in the scripts/

### Running in Pre-Production testnet

1. Cardano-node with Ogmios bundle
1. The project runtime dependencies are settled in the docker-compose file, so to run Cardano node, Ogmios and Kupo just type

For simplicity you may use Cardano node with Ogmios bundle for the pre-production testnet for docker. Call the following command to download image from dockerhub and run services:
```
docker run -it -d \
--name cardano-node-ogmios \
-p 1337:1337 \
-v cardano-node-ogmios-db:/db \
cardanosolutions/cardano-node-ogmios:v5.6.0_1.35.5-preprod
```
You may call the same command with `bash ./environment/preprod/nodeWithOgmios.sh`.

2. Kupo

After building project dependencies you have built binary file for Kupo as well. You may either use the binary file from /nix/store/.. folder or build the [service](https://github.com/CardanoSolutions/kupo) by yourself.
Run the service with the following command:
```
kupo \
--ogmios-host localhost \
--ogmios-port 1337 \
--since origin \
--match "*" \
--workdir pathToKupoDb
```

Notes:
- Alternatively may run `bash ./environment/preprod/kupo.sh` from the project root to run the Kupo service for current project configuration.
- If it's the first time you run Kupo, you also better to add `--defer-db-indexes` flag to speed up the initial indexer synchronization.
- You may specify the `since` argument with different value (please see the Kupo [manual](https://cardanosolutions.github.io/kupo/))
- Instead of connecting via Ogmios you may also connect to Cardano-Node directly. In this case replace `--ogmios-host` and `--ogmios-port` arguments with

```
--node-socket some-folder/cardano-node/node.socket \
--node-config some-folder/cardano-node/config.json \
```

- To run kupo using Docker container:

```
docker pull cardanosolutions/kupo:v2.4.0
docker run --network host -d --name kupo \
cardanosolutions/kupo:v2.4.0 \
--ogmios-host 0.0.0.0 \
--ogmios-port 1337 \
--since origin \
--match "*" \
--workdir .
docker-compose up -d
```
in terminal opened from the project root

3. Create new dist for frontend:
2. Create new dist for frontend:

Run `sh build.sh` from project root

4. Run server
3. Run server

Before running the server open terminal from the project root and type `npm install` to create node modules (make sure to do it not under `nix develop`). Then run the environment in different terminals, build the project with `spago build` (under `nix develop`) and then create new dists (`sh build.sh` under `nix develop`). You may run the server on port 4008 with `npm run serve` command (under `nix develop` as well). Then go to `localhost:4008` with the Chrome browser and explore.
First make sure to run the runtime dependencies. Than open terminal from the project root and type `npm install` to create node modules (make sure to do it not under `nix develop`). Than build the project with `spago build` (under `nix develop`) and then create new dists (`sh build.sh` under `nix develop`). You may run the server on port 4008 with `npm run serve` command (under `nix develop` as well). Then go to `localhost:4008` with the Chrome browser and explore.

Note that the current offchain version functionality is available for Chrome browser with installed Nami wallet extension only. To test it with Nami wallet make sure to switch on the PreProduction testnet network (Nami -> Settings -> Network -> Preprod), you also have to lock 5 Ada as collateral (Nami -> Collateral -> Confirm).
Note that the current PreProduction testnet offchain version functionality is available for Chrome browser with installed Nami, Lode, Eternl or Flint light wallet extensions. To test it make sure to switch on the PreProduction testnet network in light wallet extension (i.e. for Nami: Nami -> Settings -> Network -> Preprod), you also have to lock 5 Ada as collateral (i.e. for Nami: Nami -> Collateral -> Confirm).

### Tests

Expand Down
2 changes: 1 addition & 1 deletion dist/131.index.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion dist/535.index.js

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions src/Shared/TestnetConfig.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Shared.TestnetConfig where
import Prelude

import Contract.Address (NetworkId(..))
import Contract.Config (defaultKupoServerConfig, defaultOgmiosWsConfig, testnetConfig)
import Contract.Config (defaultOgmiosWsConfig, testnetConfig)
import Contract.Prelude (log, (/\))
import Ctl.Internal.Contract.Monad (ContractParams)
import Ctl.Internal.Contract.QueryBackend (mkCtlBackendParams, QueryBackendParams)
Expand Down Expand Up @@ -53,6 +53,14 @@ ogmiosProdWsConfig =
, path: Nothing
}

kupoConfig :: ServerConfig
kupoConfig =
{ port: UInt.fromInt 1442
, host: "localhost"
, secure: false
, path: Nothing
}

testnetWalletConfig :: String -> Boolean -> ContractParams
testnetWalletConfig host secure = testnetConfig
{ backendParams = backParams host secure
Expand All @@ -62,7 +70,7 @@ testnetWalletConfig host secure = testnetConfig
backParams :: String -> Boolean -> QueryBackendParams
backParams host secure = mkCtlBackendParams
{ ogmiosConfig: if isProduction then ogmiosProdWsConfig else defaultOgmiosWsConfig
, kupoConfig: if isProduction then kupoProdConfig host secure else defaultKupoServerConfig
, kupoConfig: if isProduction then kupoProdConfig host secure else kupoConfig
}
where
isProduction = not $ host == "localhost"
Expand Down
9 changes: 0 additions & 9 deletions webpack.offchain.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ module.exports = (env, argv) => ({

devServer: {
port: 4008,
proxy: {
"/kupo": {
// `KUPO_HOST` env variable must be set to the base URL of the Kupo
// service, otherwise all requests to Kupo will fail.
target: process.env.KUPO_HOST || "http://localhost:1442",
changeOrigin: true,
pathRewrite: { "^/kupo": "" },
},
},
},

// we can add more entrypoints as needed
Expand Down
9 changes: 0 additions & 9 deletions webpack/webpack.ui.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ const config: Configuration = {
errors: true,
},
},
proxy: {
'/kupo': {
// KUPO_HOST env variable must be set to the base URL of the Kupo
// service, otherwise all requests to Kupo will fail.
target: process.env.KUPO_HOST ?? 'http://localhost:1442',
changeOrigin: true,
pathRewrite: { '^/kupo': '' },
},
},
},
plugins: [
new DefinePlugin({
Expand Down

0 comments on commit 0385b2d

Please sign in to comment.