Skip to content

Commit d3e87ed

Browse files
committed
fix(ci) Add script to fetch graz chains
1 parent 3584ad3 commit d3e87ed

File tree

11 files changed

+64531
-3
lines changed

11 files changed

+64531
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ First, run `npm i` to install the dependencies.
1515

1616
Then, run `npm run dev` to start the development server and visit localhost:3000.
1717

18+
If you need to fetch the latest cosmos chains, run `npm run fetch-cosmos-chains`.
19+
1820
## Deployment
1921

2022
Use the `Dockerfile` in the root of the repository to build a docker image that can be run for production deployments.

contexts/GlobalContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
osmosis,
1919
osmosistestnet,
2020
seitestnet2,
21-
} from "graz/chains";
21+
} from "../store/cosmos-chains";
2222
import PythAbi from "../abis/IPyth.json";
2323
import PythErrorsAbi from "../abis/PythErrors.json";
2424
import { ChainInfo } from "@keplr-wallet/types";

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"start": "next start",
99
"lint": "next lint",
1010
"test": "jest",
11-
"postinstall": "graz generate -g"
11+
"fetch-cosmos-chains": "bash scripts/fetchGrazChains.sh"
1212
},
1313
"dependencies": {
1414
"@amplitude/analytics-browser": "^2.8.1",

scripts/fetchGrazChains.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
4+
MAX_RETRIES=5
5+
6+
OUTPUT_DIR="store/cosmos-chains"
7+
8+
9+
command_exists() {
10+
command -v "$1" >/dev/null 2>&1
11+
}
12+
if ! command_exists graz; then
13+
echo "graz is not installed."
14+
if command_exists npm; then
15+
npm install -g graz
16+
else
17+
echo "Error: npm is not installed. Please install npm and try again."
18+
exit 1
19+
fi
20+
fi
21+
22+
mkdir -p "$OUTPUT_DIR"
23+
24+
fetch_graz_chains() {
25+
local retry_count=0
26+
27+
while [ $retry_count -lt $MAX_RETRIES ]; do
28+
echo "Attempt $((retry_count + 1)) to fetch cosmos chains..."
29+
30+
if graz generate -g; then
31+
echo "Successfully fetched cosmos chains!"
32+
33+
# Copy generated files to the output directory
34+
cp -R node_modules/graz/chains/* "$OUTPUT_DIR"
35+
echo "Copied generated files to $OUTPUT_DIR"
36+
return 0
37+
else
38+
retry_count=$((retry_count + 1))
39+
if [ $retry_count -lt $MAX_RETRIES ]; then
40+
echo "Fetch failed. Retrying in 5 seconds..."
41+
sleep 5
42+
else
43+
echo "Max retries reached. Unable to fetch cosmos chains."
44+
fi
45+
fi
46+
done
47+
48+
return 1
49+
}
50+
51+
if fetch_graz_chains; then
52+
echo "Cosmos chains have been successfully fetched and stored in $OUTPUT_DIR"
53+
else
54+
echo "Failed to fetch cosmos chains after $MAX_RETRIES attempts."
55+
exit 1
56+
fi

store/cosmos-chains/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)