Add a container for ERC20 contract txs in the payments stack
This commit is contained in:
parent
3262ebe4ac
commit
24a9ab3a91
@ -1,6 +1,20 @@
|
|||||||
version: '3.7'
|
version: '3.7'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
ponder-er20-contracts:
|
||||||
|
image: cerc/watcher-erc20:local
|
||||||
|
restart: on-failure
|
||||||
|
environment:
|
||||||
|
CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG}
|
||||||
|
CERC_ETH_RPC_ENDPOINT: ${CERC_ETH_RPC_ENDPOINT:-http://fixturenet-eth-geth-1:8545}
|
||||||
|
CERC_PRIVATE_KEY_DEPLOYER: ${CERC_PRIVATE_KEY_DEPLOYER:-0x888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218}
|
||||||
|
volumes:
|
||||||
|
- ../config/ponder/deploy-erc20-contract.sh:/app/deploy-erc20-contract.sh
|
||||||
|
- erc20_deployment:/app/deployment
|
||||||
|
command: ["bash", "-c", "/app/deploy-erc20-contract.sh"]
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
|
|
||||||
ponder-app-indexer:
|
ponder-app-indexer:
|
||||||
hostname: ponder-app-indexer
|
hostname: ponder-app-indexer
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@ -23,6 +37,7 @@ services:
|
|||||||
- ../config/ponder/base-rates-config.json:/app/examples/token-erc20/base-rates-config.json
|
- ../config/ponder/base-rates-config.json:/app/examples/token-erc20/base-rates-config.json
|
||||||
- peers_ids:/peers
|
- peers_ids:/peers
|
||||||
- nitro_deployment:/nitro
|
- nitro_deployment:/nitro
|
||||||
|
- erc20_deployment:/erc20
|
||||||
- ponder_indexer_nitro_data:/app/examples/token-erc20/.ponder/nitro-db
|
- ponder_indexer_nitro_data:/app/examples/token-erc20/.ponder/nitro-db
|
||||||
ports:
|
ports:
|
||||||
- "42070"
|
- "42070"
|
||||||
@ -52,6 +67,7 @@ services:
|
|||||||
- ../config/ponder/base-rates-config.json:/app/examples/token-erc20/base-rates-config.json
|
- ../config/ponder/base-rates-config.json:/app/examples/token-erc20/base-rates-config.json
|
||||||
- peers_ids:/peers
|
- peers_ids:/peers
|
||||||
- nitro_deployment:/nitro
|
- nitro_deployment:/nitro
|
||||||
|
- erc20_deployment:/erc20
|
||||||
- ponder_watcher_nitro_data:/app/examples/token-erc20/.ponder/nitro-db
|
- ponder_watcher_nitro_data:/app/examples/token-erc20/.ponder/nitro-db
|
||||||
ports:
|
ports:
|
||||||
- "42069"
|
- "42069"
|
||||||
@ -61,5 +77,6 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
peers_ids:
|
peers_ids:
|
||||||
nitro_deployment:
|
nitro_deployment:
|
||||||
|
erc20_deployment:
|
||||||
ponder_indexer_nitro_data:
|
ponder_indexer_nitro_data:
|
||||||
ponder_watcher_nitro_data:
|
ponder_watcher_nitro_data:
|
||||||
|
54
app/data/config/ponder/deploy-erc20-contract.sh
Executable file
54
app/data/config/ponder/deploy-erc20-contract.sh
Executable file
@ -0,0 +1,54 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||||
|
set -x
|
||||||
|
fi
|
||||||
|
|
||||||
|
erc20_address_file="/app/deployment/erc20-address.json"
|
||||||
|
|
||||||
|
# Check and exit if a deployment already exists (on restarts)
|
||||||
|
if [ -f ${erc20_address_file} ]; then
|
||||||
|
echo "${erc20_address_file} already exists, skipping ERC20 contract deployment"
|
||||||
|
cat ${erc20_address_file}
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
wait_for_chain_endpoint() {
|
||||||
|
# Wait till ETH RPC endpoint is available with block number > 1
|
||||||
|
retry_interval=5
|
||||||
|
while true; do
|
||||||
|
block_number_hex=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' ${CERC_ETH_RPC_ENDPOINT} | jq -r '.result')
|
||||||
|
|
||||||
|
# Check if the request call was successful
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "RPC endpoint ${CERC_ETH_RPC_ENDPOINT} not yet available, retrying in $retry_interval seconds..."
|
||||||
|
sleep $retry_interval
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Convert hex to decimal
|
||||||
|
block_number_dec=$(printf %u ${block_number_hex})
|
||||||
|
|
||||||
|
# Check if block number is > 1 to avoid failures in the deployment
|
||||||
|
if [ "$block_number_dec" -ge 1 ]; then
|
||||||
|
echo "RPC endpoint ${CERC_ETH_RPC_ENDPOINT} is up"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "RPC endpoint ${CERC_ETH_RPC_ENDPOINT} not yet available, retrying in $retry_interval seconds..."
|
||||||
|
sleep $retry_interval
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
wait_for_chain_endpoint
|
||||||
|
|
||||||
|
echo "Using CERC_PRIVATE_KEY_DEPLOYER from env"
|
||||||
|
|
||||||
|
echo ETH_RPC_URL=${CERC_ETH_RPC_ENDPOINT} > .env
|
||||||
|
echo ACCOUNT_PRIVATE_KEY=${CERC_PRIVATE_KEY_DEPLOYER} >> .env
|
||||||
|
yarn token:deploy:docker --file ${erc20_address_file}
|
||||||
|
|
||||||
|
# Keep the container running
|
||||||
|
tail -f
|
@ -31,6 +31,21 @@ else
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Read ERC20 address from a file
|
||||||
|
# Keep retrying until found
|
||||||
|
erc20_address_file="/erc20/erc20-address.json"
|
||||||
|
echo "Reading ERC20 address from ${erc20_address_file}"
|
||||||
|
retry_interval=5
|
||||||
|
while true; do
|
||||||
|
if [[ -e "$erc20_address_file" ]]; then
|
||||||
|
ERC20_CONTRACT=$(jq -r '.address' ${erc20_address_file})
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "File not yet available, retrying in $retry_interval seconds..."
|
||||||
|
sleep $retry_interval
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
echo "Using CERC_PONDER_NITRO_PK from env for Nitro account"
|
echo "Using CERC_PONDER_NITRO_PK from env for Nitro account"
|
||||||
echo "Using CERC_PONDER_NITRO_CHAIN_PK (account with funds) from env for sending Nitro txs"
|
echo "Using CERC_PONDER_NITRO_CHAIN_PK (account with funds) from env for sending Nitro txs"
|
||||||
echo "Using ${CERC_PONDER_NITRO_CHAIN_URL} as the RPC endpoint for Nitro txs"
|
echo "Using ${CERC_PONDER_NITRO_CHAIN_URL} as the RPC endpoint for Nitro txs"
|
||||||
@ -56,6 +71,7 @@ echo "UPSTREAM_NITRO_PAY_AMOUNT=\"$CERC_UPSTREAM_NITRO_PAY_AMOUNT\"" >> "$env_fi
|
|||||||
echo "INDEXER_GQL_ENDPOINT=\"$CERC_INDEXER_GQL_ENDPOINT\"" >> "$env_file"
|
echo "INDEXER_GQL_ENDPOINT=\"$CERC_INDEXER_GQL_ENDPOINT\"" >> "$env_file"
|
||||||
echo "INDEXER_NITRO_ADDRESS=\"$CERC_INDEXER_NITRO_ADDRESS\"" >> "$env_file"
|
echo "INDEXER_NITRO_ADDRESS=\"$CERC_INDEXER_NITRO_ADDRESS\"" >> "$env_file"
|
||||||
echo "INDEXER_NITRO_PAY_AMOUNT=\"$CERC_INDEXER_NITRO_PAY_AMOUNT\"" >> "$env_file"
|
echo "INDEXER_NITRO_PAY_AMOUNT=\"$CERC_INDEXER_NITRO_PAY_AMOUNT\"" >> "$env_file"
|
||||||
|
echo "ERC20_CONTRACT=\"$ERC20_CONTRACT\"" >> "$env_file"
|
||||||
|
|
||||||
cat "$env_file"
|
cat "$env_file"
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ export const config: Config = {
|
|||||||
name: "AdventureGold",
|
name: "AdventureGold",
|
||||||
network: "fixturenet",
|
network: "fixturenet",
|
||||||
abi: "./abis/AdventureGold.json",
|
abi: "./abis/AdventureGold.json",
|
||||||
address: "0x32353A6C91143bfd6C7d363B546e62a9A2489A20",
|
address: process.env.ERC20_CONTRACT,
|
||||||
startBlock: 5,
|
startBlock: 5,
|
||||||
maxBlockRange: 100,
|
maxBlockRange: 100,
|
||||||
},
|
},
|
||||||
|
@ -14,7 +14,7 @@ export const config: Config = {
|
|||||||
name: "AdventureGold",
|
name: "AdventureGold",
|
||||||
network: "fixturenet",
|
network: "fixturenet",
|
||||||
abi: "./abis/AdventureGold.json",
|
abi: "./abis/AdventureGold.json",
|
||||||
address: "0x32353A6C91143bfd6C7d363B546e62a9A2489A20",
|
address: process.env.ERC20_CONTRACT,
|
||||||
startBlock: 5,
|
startBlock: 5,
|
||||||
maxBlockRange: 100,
|
maxBlockRange: 100,
|
||||||
},
|
},
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
FROM node:16.17.1-alpine3.16
|
FROM node:16.17.1-alpine3.16
|
||||||
|
|
||||||
RUN apk --update --no-cache add git python3 alpine-sdk
|
RUN apk --update --no-cache add git python3 alpine-sdk bash curl jq
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN echo "Building watcher-ts" && \
|
RUN echo "Building erc20-watcher-ts" && \
|
||||||
git checkout v0.2.19 && \
|
|
||||||
yarn && yarn build
|
yarn && yarn build
|
||||||
|
|
||||||
WORKDIR /app/packages/erc20-watcher
|
|
||||||
|
@ -6,4 +6,4 @@ source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
|
|||||||
# See: https://stackoverflow.com/a/246128/1701505
|
# See: https://stackoverflow.com/a/246128/1701505
|
||||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||||
|
|
||||||
docker build -t cerc/watcher-erc20:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/watcher-ts
|
docker build -t cerc/watcher-erc20:local -f ${SCRIPT_DIR}/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/erc20-watcher-ts
|
||||||
|
@ -20,6 +20,7 @@ repos:
|
|||||||
- github.com/cerc-io/mobymask-ui@v0.2.2
|
- github.com/cerc-io/mobymask-ui@v0.2.2
|
||||||
# ponder repo
|
# ponder repo
|
||||||
- github.com/cerc-io/ponder@laconic-esm
|
- github.com/cerc-io/ponder@laconic-esm
|
||||||
|
- github.com/cerc-io/erc20-watcher-ts
|
||||||
containers:
|
containers:
|
||||||
# fixturenet images
|
# fixturenet images
|
||||||
- cerc/go-ethereum
|
- cerc/go-ethereum
|
||||||
@ -42,6 +43,7 @@ containers:
|
|||||||
- cerc/mobymask-ui
|
- cerc/mobymask-ui
|
||||||
# ponder image
|
# ponder image
|
||||||
- cerc/ponder
|
- cerc/ponder
|
||||||
|
- cerc/watcher-erc20
|
||||||
pods:
|
pods:
|
||||||
- fixturenet-eth
|
- fixturenet-eth
|
||||||
- ipld-eth-server-payments
|
- ipld-eth-server-payments
|
||||||
|
Loading…
Reference in New Issue
Block a user