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

Making dapp work on GHCS #47

Merged
merged 30 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4e40c13
public-ports-fix-hostname
amessbee Jul 5, 2024
7ecdcac
Update set.hostname.sh
amessbee Jul 5, 2024
a598cc4
fix: Updating hostname script to accomodate localhost case
amessbee Jul 5, 2024
3ffdb93
fix: hostname script works on localhost
amessbee Jul 5, 2024
6725059
Add devcontainer.json with public ports
toliaqat Jul 6, 2024
fcc492c
Update App.tsx hostname placeholder
amessbee Jul 6, 2024
1f80eab
feat: nvm command in .devcontainer
amessbee Jul 7, 2024
af16635
fix: node version
amessbee Jul 7, 2024
c85bab1
fix: nvm not working in .devcontainer so remving for now
amessbee Jul 7, 2024
cbc1754
feat: Hostname Update with ENV Only - Removed script
amessbee Jul 8, 2024
611e29d
chore: make the api and rpc endpoints dynamic
rabi-siddique Jul 8, 2024
20b9b0e
chore: update dev script in package.json
rabi-siddique Jul 8, 2024
ea3e985
chore: use node version 18.20 for the dev container
rabi-siddique Jul 8, 2024
dd791bc
Update App.tsx hostname placeholder
amessbee Jul 9, 2024
f7efe5d
fix: (probably temporary) added cors header in requests
amessbee Jul 12, 2024
6eba185
fix: comment out ports visibility command in devcontainer
amessbee Jul 18, 2024
813a518
chore: use env for codespace domain instead of hardcoded string
amessbee Jul 18, 2024
b56db1f
feat: alternate solution for CORS with GH-token
amessbee Jul 18, 2024
0103bcb
fix: env variable for GH token
amessbee Jul 18, 2024
be3f772
fix: devcontainer for ports
amessbee Jul 18, 2024
de4dc06
fix: add docker to features
amessbee Jul 18, 2024
d7b10ad
fix: port opening
amessbee Jul 18, 2024
c89fb32
fix: add gh CLI to features
amessbee Jul 18, 2024
3eeb173
fix: revert to access-control in header
amessbee Jul 18, 2024
3392cca
chore: delete setup not needed anymore
amessbee Jul 18, 2024
7fd9e20
fix: export GHCS domain name
amessbee Jul 18, 2024
a467f84
chore: clean devcontainer file
amessbee Jul 18, 2024
f0749ab
chore: yarn install in postStartCommand
amessbee Jul 18, 2024
9047c52
chore: readme for ghcs
amessbee Jul 18, 2024
fdfe3e7
fix: readme links
amessbee Jul 18, 2024
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": "bash -i -c 'nvm install 18.20 && nvm alias default 18.20' && bash ./make_ports_public.sh 5173 1317 26657"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rabi-siddique @amessbee I think we need a lot of testing to sure ./make_ports_public.sh 5173 1317 26657 works every time. If there is flakyness then we should address it.

}
4 changes: 3 additions & 1 deletion contract/tools/ui-kit-goals/makeHttpClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const filterBadStatus = res => {
* @returns {import('@cosmjs/tendermint-rpc').RpcClient}
*/
export const makeHttpClient = (url, fetch) => {
const headers = {}; // XXX needed?
const headers = {'Access-Control-Allow-Origin': '*'
}; // XXX needed?

// based on cosmjs 0.30.1:
// https://github.com/cosmos/cosmjs/blob/33271bc51cdc865cadb647a1b7ab55d873637f39/packages/tendermint-rpc/src/rpcclients/http.ts#L37
Expand Down Expand Up @@ -80,6 +81,7 @@ export const makeAPI = (apiAddress, { fetch }) => {
keepalive: true,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
...options.headers,
},
};
Expand Down
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 @@ -48,7 +48,7 @@
"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:ui": "cd ui && yarn dev",
"start:ui": "export VITE_HOSTNAME=$CODESPACE_NAME && cd ui && yarn dev",
"lint": "yarn workspaces run lint",
"lint:fix": "yarn workspaces run lint:fix",
"test": "yarn workspaces run test",
Expand Down
13 changes: 11 additions & 2 deletions ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ import '@agoric/react-components/dist/style.css';

function App() {
const { themeClass } = useTheme();
let REST_HOSTNAME = 'http://localhost:1317';
let RPC_HOSTNAME = 'http://localhost:26657';

const codeSpaceHostName = import.meta.env.VITE_HOSTNAME;

if (codeSpaceHostName) {
REST_HOSTNAME = `https://${codeSpaceHostName}-1317.app.github.dev`;
RPC_HOSTNAME = `https://${codeSpaceHostName}-26657.app.github.dev`;
}

return (
<ThemeProvider>
Expand All @@ -22,8 +31,8 @@ function App() {
iconUrl: 'agoric.svg', // Optional icon for dropdown display
},
apis: {
rest: ['http://localhost:1317'],
rpc: ['http://localhost:26657'],
rest: [REST_HOSTNAME],
rpc: [RPC_HOSTNAME],
},
},
]}
Expand Down