Skip to content

Commit

Permalink
update ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraccaman committed Aug 21, 2024
1 parent 4043eee commit d2c0e0a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions scripts/validate-pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,36 +188,40 @@ def check_if_bond_is_valid(bonds_toml: List[Dict], balances: Dict[str, Dict]):
return True


def validate_toml(file, can_apply_for_validators, can_apply_for_bonds, can_apply_for_accounts):
def validate_toml(file, can_apply_for_validators, can_apply_for_bonds, can_apply_for_accounts) -> bool:
balances = toml.load(open("genesis/balances.toml", "r"))
nam_balances = balances['token']['NAM']

if '-account.toml' in file and can_apply_for_accounts:
accounts_toml = read_unsafe_toml(file)
if accounts_toml is None:
print("{} is NOT valid.".format(file))
return False
is_valid = check_if_account_is_valid(accounts_toml)
if not is_valid:
print("{} is NOT valid.".format(file))
return False
elif '-validator.toml' in file and can_apply_for_validators:
validators_toml = read_unsafe_toml(file)
if validators_toml is None:
print("{} is NOT valid.".format(file))
return False
is_valid = check_if_validator_is_valid(validators_toml)
if not is_valid:
print("{} is NOT valid.".format(file))
return False
elif '-bond.toml' in file and can_apply_for_bonds:
bonds_toml = read_unsafe_toml(file)
if not bonds_toml:
print("{} is NOT valid.".format(file))
return False
is_valid = check_if_bond_is_valid(bonds_toml, nam_balances)
if not is_valid:
print("{} is NOT valid.".format(file))
return False
else:
return False

print("{} is valid.".format(file))

def main():
alias = get_alias_from_env()
check_deleted_and_modified_files(alias)
Expand All @@ -240,7 +244,12 @@ def main():

print("{} is allowed, checking if its valid...".format(file))

validate_toml(file, can_apply_for_validators, can_apply_for_bonds, can_apply_for_accounts)
res = validate_toml(file, can_apply_for_validators, can_apply_for_bonds, can_apply_for_accounts)
if res:
print("{} is valid.".format(file))
else:
print("{} is NOT valid".format(file))
exit(1)


if __name__ == "__main__":
Expand Down

0 comments on commit d2c0e0a

Please sign in to comment.