forked from sei-protocol/testnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
confirm-gen-txs.py
executable file
·48 lines (38 loc) · 1.62 KB
/
confirm-gen-txs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import argparse
import os
import json
"""
Script to generate a CSV file of $wallet_address,$validator_address,$moniker
Assumes that the file structure of the gentx files is: $chain_id/gentx/...
"""
def main(chain_id):
# get all files within the gentx folder
gentx_files = os.listdir(chain_id + "/gentx")
invalids = ""
with open('gentx-output.csv', 'w') as outfile:
outfile.write("") # clean file
for file in gentx_files:
print(f'Extracting info from {file}')
f = open(chain_id + '/gentx/' + file, 'r')
data = json.load(f)
validatorData = data['body']['messages'][0]
moniker = validatorData['description']['moniker']
rate = float(validatorData['commission']['rate']) * 100
delegator_addr = validatorData['delegator_address']
validator_addr = validatorData['validator_address']
exp = validatorData['value']
### Basic validation ###
if exp['denom'] != 'usei':
invalids += f'[!] Invalid denomination for validator: {moniker} {exp["denom"]} \n'
if int(exp['amount'] ) / 10000000 < 1.0:
invalids += f'[!] Invalid amount for validator: {moniker} {int(exp["amount"] ) /10000000}\n'
with open('gentx-output.csv', 'a') as outfile:
outfile.write(f"{delegator_addr},{validator_addr},{moniker}\n")
with open('gentx-output.csv', 'a') as outfile:
outfile.write(invalids)
print('Written to file gentx-output.csv')
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--chain-id', type=str)
args = parser.parse_args()
main(args.chain_id)