Skip to content

Commit 3bacf00

Browse files
rach-idadlerjohn
andauthored
ci: add contracts upgradability check (#188)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. --> ## Overview Closes #187 ## Checklist <!-- Please complete the checklist to ensure that the PR is ready to be reviewed. IMPORTANT: PRs should be left in Draft until the below checklist is completed. --> - [ ] New and updated code has appropriate documentation - [ ] New and updated code has new and/or updated testing - [ ] Required CI checks are passing - [ ] Visual proof for any user facing features like CLI or documentation updates - [ ] Linked issues closed with keywords --------- Co-authored-by: John Adler <[email protected]>
1 parent 42bb4d8 commit 3bacf00

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Check Contract Inheritance
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
check_inheritance:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v2
19+
with:
20+
node-version: 16
21+
22+
- name: Install Surya
23+
run: |
24+
npm install -g surya
25+
26+
- name: Run Surya Inheritance Check
27+
run: |
28+
./scripts/upgradability_check.sh

scripts/upgradability_check.sh

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
# this script will check if the QGB contract is inheriting the correct upgradability contracts.
4+
5+
out=$(surya inheritance src/QuantumGravityBridge.sol | grep -i "\"QuantumGravityBridge\" ->" | cut -d ">" -f 2 | sed 's/[";]//g')
6+
7+
required_contracts=("Initializable" "UUPSUpgradeable" "OwnableUpgradeable")
8+
missing_contracts=()
9+
10+
for field in "${required_contracts[@]}"; do
11+
if ! grep -q "\<$field\>" <<< "$out"; then
12+
missing_contracts+=("$field")
13+
fi
14+
done
15+
16+
if [ ${#missing_contracts[@]} -eq 0 ]; then
17+
echo "The QuantumGravityBridge contract is inheriting the right contracts. Exiting."
18+
exit 0
19+
else
20+
echo "The QuantumGravityBridge contract is missing the necessary inherited contracts: ${missing_contracts[*]}"
21+
exit 1
22+
fi

0 commit comments

Comments
 (0)