Skip to content

Commit

Permalink
chore(ci): add gentx checker
Browse files Browse the repository at this point in the history
  • Loading branch information
albttx committed Feb 26, 2024
1 parent 508a80d commit fbb3648
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/gentx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Gentx checker

on:
pull_request: {}
push:
paths:
- govgen-1/gentx/*.json
branches:
- "ci/gentx"

env:
GOVGEND_URL: "https://atomone.fra1.digitaloceanspaces.com/govgen/bin/govgend_linux_amd64_v1/govgend"
GENESIS_URL: "https://atomone.fra1.digitaloceanspaces.com/govgen/govgen-1/genesis.json"
MUST_STAKED_AMOUNT: "1000000"

jobs:
check-gentx:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get changed files
id: files
uses: jitterbit/get-changed-files@v1
with:
format: json

- name: Check gentx values
run: |
for f in ${{ steps.files.outputs.all }}; do
if [[ "$f" == "*gentx/*.json" ]]; then
echo "checking file: $f"
COMMISSION_RATE=$(cat $f | jq -r '.body.messages[0].commission.rate')
COMMISSION_MAX_RATE=$(cat $f | jq -r '.body.messages[0].commission.max_rate')
COMMISSION_MAX_CHANGE_RATE=$(cat $f | jq -r '.body.messages[0].commission.max_change_rate')
STAKED_AMOUNT=$(cat $f | jq -r '.body.messages[0].value.amount')
# bc return 1 when success
echo "$COMMISSION_RATE == 0" | bc && echo "commission_rate must be 0" && exit 1
echo "$COMMISSION_MAX_RATE == 0" | bc && echo "commission_max_rate must be 0" && exit 1
echo "$COMMISSION_MAX_CHANGE_RATE == 0" | bc && echo "commission_max_change_rate must be 0" && exit 1
echo "$STAKED_AMOUNT == $MUST_STAKED_AMOUNT | bc" && echo "staked amount must be $MUST_STAKED_AMOUNT" && exit 1
fi
done
validate-gentx:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download govgend
runs: |
wget -O /usr/bin/govgend ${GOVGEND_URL}
chmod +x /usr/bin/govgend
- name: Collect gentxs
runs: |
govgend init github-ci --chain-id govgen-1
wget -O /root/.govgen/config/genesis.json $GENESIS_URL
for f in "govgen-1/gentx/*.json"; do
ADDR=$(cat $f | jq -r '.body.messages[0].delegator_address')
govgend add-genesis-account $ADDR 10000000ugovgen
done
govgend collect-gentx --gentx-dir ./govgen-1/gentx
- name: Validate genesis
runs: |
govgend validate-genesis

0 comments on commit fbb3648

Please sign in to comment.