Skip to content

Commit 2bfc485

Browse files
Eliminate mainnet/testnet code duplication, add shellcheck CI, fix typo and inconsistencies
Co-authored-by: numbers-official <181934381+numbers-official@users.noreply.github.com>
1 parent 13eab94 commit 2bfc485

24 files changed

+182
-197
lines changed

.github/workflows/shellcheck.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Shell Linting
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
shellcheck:
9+
name: ShellCheck
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Run ShellCheck
17+
run: find . -name "*.sh" -not -path "./.git/*" | xargs shellcheck --severity=error -x

api/env.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
# shellcheck shell=bash
12
URL="127.0.0.1:9650"

api/health.health.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/bash
22

3+
# shellcheck source=env.sh
4+
source env.sh
5+
36
curl -X POST --data '{
47
"jsonrpc":"2.0",
58
"id" :1,
69
"method" :"health.health"
7-
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/health
10+
}' -H 'content-type:application/json;' "${URL}/ext/health"

api/info.getNetworkID.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/bin/bash
22

3+
# shellcheck source=env.sh
34
source env.sh
45

56
curl -X POST --data '{
67
"jsonrpc":"2.0",
78
"id" :1,
89
"method" :"info.getNetworkID"
9-
}' -H 'content-type:application/json;' ${URL}/ext/info
10+
}' -H 'content-type:application/json;' "${URL}/ext/info"

api/info.getNetworkName.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/bin/bash
22

3+
# shellcheck source=env.sh
34
source env.sh
45

56
curl -X POST --data '{
67
"jsonrpc":"2.0",
78
"id" :1,
89
"method" :"info.getNetworkName"
9-
}' -H 'content-type:application/json;' ${URL}/ext/info
10+
}' -H 'content-type:application/json;' "${URL}/ext/info"

api/info.getNodeID.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
# Expected Output
66
# {"jsonrpc":"2.0","result":{"nodeID":"NodeID-JRhJd4Qn4WTjP28RUFDQa2NC59deo7tT6"},"id":1}
77

8-
URL="127.0.0.1:9650"
8+
# shellcheck source=env.sh
9+
source env.sh
910

1011
curl -X POST --data '{
1112
"jsonrpc":"2.0",
1213
"id" :1,
1314
"method" :"info.getNodeID"
14-
}' -H 'content-type:application/json;' ${URL}/ext/info
15+
}' -H 'content-type:application/json;' "${URL}/ext/info"

api/info.getVMs.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/bin/bash
22

3+
# shellcheck source=env.sh
34
source env.sh
45

56
curl -X POST --data '{
67
"jsonrpc":"2.0",
78
"id" :1,
89
"method" :"info.getVMs",
910
"params" :{}
10-
}' -H 'content-type:application/json;' ${URL}/ext/info
11+
}' -H 'content-type:application/json;' "${URL}/ext/info"

api/info.isBootstrapped.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
# Note: The bootstrapping process takes approximately 50–100 hours and requires 100 GB of space.
44
# https://chainstack.com/avalanche-subnet-tutorial-series-running-a-local-avalanche-node-on-fuji-testnet/
55

6-
URL="127.0.0.1:9650"
6+
# shellcheck source=env.sh
7+
source env.sh
78
CHAIN_ID="$1"
89

910
curl -X POST --data "{
@@ -13,4 +14,4 @@ curl -X POST --data "{
1314
\"chain\":\"${CHAIN_ID}\"
1415
},
1516
\"id\": 1
16-
}" -H 'content-type:application/json;' ${URL}/ext/info
17+
}" -H 'content-type:application/json;' "${URL}/ext/info"

api/info.peers.sh

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
11
#!/bin/bash
22

3+
# shellcheck source=peers.conf
4+
source peers.conf
5+
36
# Snow
47
echo "========== Snow nodes information =========="
5-
curl -X POST --data '{
6-
"jsonrpc":"2.0",
7-
"id" :1,
8-
"method" :"info.peers",
9-
"params": {
10-
"nodeIDs": [
11-
"NodeID-7TwAjiRpTbNcqUx6F9EoyXRBLAfeoQXRq",
12-
"NodeID-JbeonHKqomERomXgCiXr9oC9vfynkBupj",
13-
"NodeID-BffXkmzM8EwrBZgpqFp9pwgE9DbDgYKG2",
14-
"NodeID-24WK7qiKXAumya1kKEktwj2ubBbRyq5UW",
15-
"NodeID-A2Z8m7egVLhKf1Qj14uvXadhExM5zrB7p"
16-
]
8+
curl -X POST --data "{
9+
\"jsonrpc\":\"2.0\",
10+
\"id\":1,
11+
\"method\":\"info.peers\",
12+
\"params\": {
13+
\"nodeIDs\": ${SNOW_NODE_IDS}
1714
}
18-
}' -H 'content-type:application/json;' https://api.avax-test.network/ext/info | jq .
15+
}" -H 'content-type:application/json;' https://api.avax-test.network/ext/info | jq .
1916

2017
# Jade
2118
echo "========== Jade nodes information =========="
22-
curl -X POST --data '{
23-
"jsonrpc":"2.0",
24-
"id" :1,
25-
"method" :"info.peers",
26-
"params": {
27-
"nodeIDs": [
28-
"NodeID-BXTBUqX8gitUDtVam4fhRWGD1SfeHGoBx"
29-
]
19+
curl -X POST --data "{
20+
\"jsonrpc\":\"2.0\",
21+
\"id\":1,
22+
\"method\":\"info.peers\",
23+
\"params\": {
24+
\"nodeIDs\": ${JADE_NODE_IDS}
3025
}
31-
}' -H 'content-type:application/json;' https://api.avax.network/ext/info | jq .
26+
}" -H 'content-type:application/json;' https://api.avax.network/ext/info | jq .
3227

api/metrics.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
#!/bin/bash
22

3-
curl -X POST 127.0.0.1:9650/ext/metrics
3+
# shellcheck source=env.sh
4+
source env.sh
5+
6+
curl -X POST "${URL}/ext/metrics"

0 commit comments

Comments
 (0)