Add nitro-rpc-client container in payments stack (#1)

* Add container for nitro-rpc-client

* Add nitro-rpc-client service

* Update nitro-rpc-client container

* Update demo.md in payments stack

---------

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
This commit is contained in:
Nabarun Gogoi 2023-10-05 11:15:18 +05:30 committed by GitHub
parent bd5a9c0ecf
commit 8d50b4172c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 25 deletions

View File

@ -34,6 +34,17 @@ services:
- "4005:4005"
- "5005:5005"
nitro-rpc-client:
image: cerc/nitro-rpc-client:local
hostname: nitro-rpc-client
restart: on-failure
depends_on:
# Wait for the go-nitro node to start
go-nitro:
condition: service_healthy
command: ["bash", "-c", "tail -f /dev/null"]
volumes:
go_nitro_data:
nitro_deployment:

View File

@ -0,0 +1,12 @@
FROM node:18.17.1-alpine3.18
RUN apk --update --no-cache add python3 alpine-sdk bash curl jq
WORKDIR /app
COPY . .
RUN echo "Installing dependencies" && \
yarn
RUN cd packages/nitro-rpc-client

View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
# Build cerc/nitro-rpc-client
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
# See: https://stackoverflow.com/a/246128/1701505
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
docker build -t cerc/nitro-rpc-client:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/go-nitro

View File

@ -21,24 +21,10 @@
export WATCHER_UPSTREAM_PAYMENT_CHANNEL=<PAYMENT_CHANNEL_ID>
```
* Generate an auth token required to query the go-nitro node's RPC endpoint:
```bash
export AUTH_TOKEN=$(curl -s -X POST -H "Content-Type: application/json" --data '{
"jsonrpc": "2.0", "id": 1,
"method": "get_auth_token",
"params": {}
}' http://127.0.0.1:4005/api/v1 | jq -r '.result')
```
* Check the payment channel status:
```bash
curl -X POST -H "Content-Type: application/json" --data "{
\"jsonrpc\": \"2.0\", \"id\": 1,
\"method\": \"get_payment_channel\",
\"params\": { \"authtoken\": \"$AUTH_TOKEN\", \"payload\": { \"Id\": \"$WATCHER_UPSTREAM_PAYMENT_CHANNEL\" } }
}" http://127.0.0.1:4005/api/v1 | jq
npm exec -c 'nitro-rpc-client get-payment-channel <WATCHER_UPSTREAM_PAYMENT_CHANNEL> -h <hostname> -p <port>'
# Expected output:
# {
@ -136,11 +122,7 @@
* Check the watcher - eth-server payment channel status after a few requests:
```bash
curl -X POST -H "Content-Type: application/json" --data "{
\"jsonrpc\": \"2.0\", \"id\": 1,
\"method\": \"get_payment_channel\",
\"params\": { \"authtoken\": \"$AUTH_TOKEN\", \"payload\": { \"Id\": \"$WATCHER_UPSTREAM_PAYMENT_CHANNEL\" } }
}" http://127.0.0.1:4005/api/v1 | jq
npm exec -c 'nitro-rpc-client get-payment-channel <WATCHER_UPSTREAM_PAYMENT_CHANNEL> -h <hostname> -p <port>'
# Expected output ('PaidSoFar' should be non zero):
# {
@ -184,11 +166,7 @@
* Check the ponder - eth-server payment channel status:
```bash
curl -X POST -H "Content-Type: application/json" --data "{
\"jsonrpc\": \"2.0\", \"id\": 1,
\"method\": \"get_payment_channel\",
\"params\": { \"authtoken\": \"$AUTH_TOKEN\", \"payload\": { \"Id\": \"$PONDER_UPSTREAM_PAYMENT_CHANNEL\" } }
}" http://127.0.0.1:4005/api/v1 | jq
npm exec -c 'nitro-rpc-client get-payment-channel <PONDER_UPSTREAM_PAYMENT_CHANNEL> -h <hostname> -p <port>'
# Expected output ('PaidSoFar' is non zero):
# {

View File

@ -31,6 +31,7 @@ containers:
- cerc/ipld-eth-server
- cerc/nitro-contracts
- cerc/go-nitro
- cerc/nitro-rpc-client
# mobymask watcher images
- cerc/watcher-ts
- cerc/watcher-mobymask-v3