Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraccaman committed Jul 24, 2024
1 parent 669f250 commit 950daa2
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion genesis/balances.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[token.NAM]
# this always needs to be present for our tooling to work
tpknam1qzvszv50azclqa05reqveehkwknpl4kh6tn3vajpt0vusa8mjpluk89ac03 = "1000000"
tpknam1qp5efx0w3sqkgngh5l4gt4hx9l07vha6vdn7twn9gd6khqvwqka9qgfpaw9 = "1230000"
tpknam1qqu944gyy0unek5vpawft46rz0aj7u4zjv5lged60pn6gg8azdg5kvusuz8 = "1230000"

tnam1q8nzq9m5v8upn6jkjsljf25mzf2n9u7qfyc8kwje = "100000"
tnam1q9t889stlm2y86vpwvglwagyqdpfe48rmcwggq2r = "100000"
Expand Down
13 changes: 12 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ python = "^3.12"
plotly = "^5.22.0"
kaleido = "0.2.1"
jinja2 = "^3.1.4"
bech32m = "^1.0.0"

[tool.poetry.group.dev.dependencies]
toml = "^0.10.2"
Expand Down
1 change: 1 addition & 0 deletions scripts/validate-merge.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import glob
import os
import subprocess
import toml

def get_all_merged_transactions():
return glob.glob("transactions/*-*.toml")
Expand Down
19 changes: 17 additions & 2 deletions scripts/validate-pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
from typing import Dict, List
import toml
import bech32m

FILE_NAME_PATTER = r"transactions/(.*)-(validator|bond|account).toml"
EMAIL_PATTERN = r"^\S+@\S+\.\S+$"
Expand Down Expand Up @@ -56,8 +57,12 @@ def check_if_account_is_valid(accounts_toml: List[Dict]):

if threshold <= 0:
return False

for public_key in public_keys:
hrp, _, _ = bech32m.bech32_decode(public_key)
if not hrp == "tnam":
return False

# TODO: check for bech32m public keys
return True

def check_if_validator_is_valid(validators_toml: List[Dict]):
Expand Down Expand Up @@ -102,6 +107,10 @@ def check_if_validator_is_valid(validators_toml: List[Dict]):

if not re.search(EMAIL_PATTERN, email):
return False

hrp, _, _ = bech32m.bech32_decode(address)
if not hrp == "tnam":
return False

return True

Expand All @@ -124,7 +133,13 @@ def check_if_bond_is_valid(bonds_toml: List[Dict], balances: Dict[str, Dict]):
if balance == 0 or not balance >= amount:
return False

# TODO: check source and validator bech32
hrp, _, _ = bech32m.bech32_decode(source)
if not hrp == "tkpnam":
return False

hrp, _, _ = bech32m.bech32_decode(validator)
if not hrp == "tnam":
return False

return True

Expand Down

0 comments on commit 950daa2

Please sign in to comment.