Skip to content

Commit

Permalink
Merge pull request #517 from Kodylow/gateway-uis-for-all-gateways
Browse files Browse the repository at this point in the history
  • Loading branch information
Kodylow authored Sep 9, 2024
2 parents 1990658 + 143ff89 commit 1387909
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
17 changes: 16 additions & 1 deletion mprocs-nix-gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,27 @@ procs:
shell: tail -n +0 -F $FM_LOGS_DIR/bitcoind.log
devimint:
shell: tail -n +0 -F $FM_LOGS_DIR/devimint.log
gateway-ui:
gateway-ui-cln:
shell: bash --init-file scripts/mprocs-nix-gateway.sh
stop: SIGKILL
env:
PORT: '3004'
BROWSER: none
GATEWAY_TYPE: cln
gateway-ui-lnd:
shell: bash --init-file scripts/mprocs-nix-gateway.sh
stop: SIGKILL
env:
PORT: '3005'
BROWSER: none
GATEWAY_TYPE: lnd
gateway-ui-ldk:
shell: bash --init-file scripts/mprocs-nix-gateway.sh
stop: SIGKILL
env:
PORT: '3006'
BROWSER: none
GATEWAY_TYPE: ldk
guardian-ui-1:
shell: bash --init-file scripts/mprocs-nix-guardian-manual.sh
stop: SIGKILL
Expand Down
26 changes: 25 additions & 1 deletion scripts/mprocs-nix-gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,32 @@ if [ "$STATUS" = "ERROR" ]; then
exit 1
fi

# Check if argument is provided
if [ -z "$GATEWAY_TYPE" ]; then
echo "Error: GATEWAY_TYPE is required for gateway-ui dev. Use 'cln', 'lnd', or 'ldk'."
exit 1
fi

# Configure UI env from devimint env
export REACT_APP_FM_GATEWAY_API=$FM_GATEWAY_API_ADDR
LOCAL_GATEWAY_API_ADDR=$FM_GATEWAY_API_ADDR

# Handle which gateway to connect to
if [ "$GATEWAY_TYPE" = "cln" ]; then
LOCAL_GATEWAY_API_ADDR="$FM_GATEWAY_API_ADDR"
elif [ "$GATEWAY_TYPE" = "lnd" ]; then
LOCAL_GATEWAY_API_ADDR=$(echo "$FM_GATEWAY_API_ADDR" | sed -E 's/:([0-9]+)$/:'"$(($(echo "$FM_GATEWAY_API_ADDR" | sed -E 's/.*:([0-9]+)$/\1/') + 1))"'/')
elif [ "$GATEWAY_TYPE" = "ldk" ]; then
LOCAL_GATEWAY_API_ADDR=$(echo "$FM_GATEWAY_API_ADDR" | sed -E 's/:([0-9]+)$/:'"$(($(echo "$FM_GATEWAY_API_ADDR" | sed -E 's/.*:([0-9]+)$/\1/') + 2))"'/')
else
echo "Error: Invalid gateway type. Use 'cln', 'lnd', or 'ldk'."
exit 1
fi

echo "Starting gateway-ui on $LOCAL_GATEWAY_API_ADDR"
echo "Gateway type: $GATEWAY_TYPE"
echo "Local gateway api addr: $LOCAL_GATEWAY_API_ADDR"

export REACT_APP_FM_GATEWAY_API=$LOCAL_GATEWAY_API_ADDR
export REACT_APP_FM_GATEWAY_PASSWORD=$FM_GATEWAY_PASSWORD

yarn dev:gateway-ui

0 comments on commit 1387909

Please sign in to comment.