diff --git a/app/data/compose/docker-compose-go-nitro.yml b/app/data/compose/docker-compose-go-nitro.yml index fc051f19..6fe831cd 100644 --- a/app/data/compose/docker-compose-go-nitro.yml +++ b/app/data/compose/docker-compose-go-nitro.yml @@ -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: diff --git a/app/data/container-build/cerc-nitro-rpc-client/Dockerfile b/app/data/container-build/cerc-nitro-rpc-client/Dockerfile new file mode 100644 index 00000000..2c0d636a --- /dev/null +++ b/app/data/container-build/cerc-nitro-rpc-client/Dockerfile @@ -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 diff --git a/app/data/container-build/cerc-nitro-rpc-client/build.sh b/app/data/container-build/cerc-nitro-rpc-client/build.sh new file mode 100755 index 00000000..1a80583b --- /dev/null +++ b/app/data/container-build/cerc-nitro-rpc-client/build.sh @@ -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 diff --git a/app/data/stacks/fixturenet-payments/demo.md b/app/data/stacks/fixturenet-payments/demo.md index 3b79047c..ed0a5799 100644 --- a/app/data/stacks/fixturenet-payments/demo.md +++ b/app/data/stacks/fixturenet-payments/demo.md @@ -21,24 +21,10 @@ export WATCHER_UPSTREAM_PAYMENT_CHANNEL= ``` -* 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 -h -p ' # 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 -h -p ' # 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 -h -p ' # Expected output ('PaidSoFar' is non zero): # { diff --git a/app/data/stacks/fixturenet-payments/stack.yml b/app/data/stacks/fixturenet-payments/stack.yml index aa7dd5dc..a16c3cb1 100644 --- a/app/data/stacks/fixturenet-payments/stack.yml +++ b/app/data/stacks/fixturenet-payments/stack.yml @@ -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