Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running dapp-offer-up in GH Codespaces #88

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"forwardPorts": [5173, 1317, 26657, 26656],
"portsAttributes": {
"5173": {
"label": "UI",
"onAutoForward": "openBrowser"
},
"1317": {
"label": "API",
"onAutoForward": "silent"
},
"26657": {
"label": "RPC",
"onAutoForward": "silent"
},
"26656": {
"label": "P2P",
"onAutoForward": "silent"
}
},
"postStartCommand": "/bin/bash ./make_ports_public.sh 5173 1317 26657"
}
19 changes: 19 additions & 0 deletions make_ports_public.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -x

# Function to change port visibility to public
change_port_visibility() {
local port=$1
gh codespace ports visibility $port:public -c $CODESPACE_NAME
}

# Check if at least one port is provided
if [ $# -eq 0 ]; then
echo "Usage: $0 <port1> [port2 ... portN]"
exit 1
fi

# Loop through each provided port and change its visibility to public
for port in "$@"; do
change_port_visibility $port
done
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"docker:bash": "cd contract; docker compose exec agd bash",
"docker:make": "cd contract; docker compose exec agd make -C /workspace/contract",
"make:help": "make -C contract list",
"start:contract": "cd contract && yarn start",
"start:contract": "./set.hostname.sh && cd contract && yarn start",
"start:ui": "cd ui && yarn dev",
"lint": "yarn workspaces run lint",
"test": "yarn workspaces run test",
Expand Down
28 changes: 28 additions & 0 deletions set.hostname.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Step 1: Read the environment variable CODESPACE_NAME
CODESPACE_NAME="${CODESPACE_NAME}"

# Step 2: Define the file name
FILE="ui/src/App.tsx"

# Check if the file exists
if [ ! -f "$FILE" ]; then
echo "File $FILE does not exist."
exit 1
fi

# Step 3: Check if the environment variable is set and replace accordingly
if [ -z "$CODESPACE_NAME" ]; then
echo "CODESPACE_NAME is not set. Setting host with http://localhost"
sed -i "s|https://.*-1317\.app\.github\.dev/|http://localhost:1317|g" "$FILE"
sed -i "s|https://.*-26657\.app\.github\.dev/|http://localhost:26657|g" "$FILE"
else
echo "CODESPACE_NAME is set to $CODESPACE_NAME. Setting host with https://${CODESPACE_NAME}-1317.app.github.dev/"
sed -i "s|https://.*-1317\.app\.github\.dev/|https://${CODESPACE_NAME}-1317.app.github.dev/|g" "$FILE"
echo "CODESPACE_NAME is set to $CODESPACE_NAME. Setting host with https://${CODESPACE_NAME}-26675.app.github.dev/"
sed -i "s|https://.*-26657\.app\.github\.dev/|https://${CODESPACE_NAME}-26657.app.github.dev/|g" "$FILE"
fi

# Step 4: Notify the user of completion
echo "Replacement complete in $FILE"
28 changes: 28 additions & 0 deletions ui/set.hostname.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Step 1: Read the environment variable CODESPACE_NAME
CODESPACE_NAME="${CODESPACE_NAME}"

# Step 2: Define the file name
FILE="src/App.tsx"

# Check if the file exists
if [ ! -f "$FILE" ]; then
echo "File $FILE does not exist."
exit 1
fi

# Step 3: Check if the environment variable is set and replace accordingly
if [ -z "$CODESPACE_NAME" ]; then
echo "CODESPACE_NAME is not set. Setting host with http://localhost"
sed -i "s|https://.*-1317\.app\.github\.dev/|http://localhost:1317|g" "$FILE"
sed -i "s|https://.*-26657\.app\.github\.dev/|http://localhost:26657|g" "$FILE"
else
echo "CODESPACE_NAME is set to $CODESPACE_NAME. Setting host with https://${CODESPACE_NAME}-1317.app.github.dev/"
sed -i "s|https://.*-1317\.app\.github\.dev/|https://${CODESPACE_NAME}-1317.app.github.dev/|g" "$FILE"
echo "CODESPACE_NAME is set to $CODESPACE_NAME. Setting host with https://${CODESPACE_NAME}-26675.app.github.dev/"
sed -i "s|https://.*-26657\.app\.github\.dev/|https://${CODESPACE_NAME}-26657.app.github.dev/|g" "$FILE"
fi

# Step 4: Notify the user of completion
echo "Replacement complete in $FILE"
4 changes: 2 additions & 2 deletions ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const { entries, fromEntries } = Object;
type Wallet = Awaited<ReturnType<typeof makeAgoricWalletConnection>>;

const ENDPOINTS = {
RPC: 'http://localhost:26657',
API: 'http://localhost:1317',
RPC: 'https://hostname-26657.app.github.dev/',
API: 'https://hostname-1317.app.github.dev/',
};

const watcher = makeAgoricChainStorageWatcher(ENDPOINTS.API, 'agoriclocal');
Expand Down
Loading