Skip to content

Commit

Permalink
Merge pull request #1249 from KomodoPlatform/fix-scan-logic
Browse files Browse the repository at this point in the history
add scan results as obj param
  • Loading branch information
smk762 authored Jan 13, 2025
2 parents 9dd0424 + ed4cac5 commit 4e081d9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
1 change: 1 addition & 0 deletions utils/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
__pycache__/
.env
.venv
23 changes: 12 additions & 11 deletions utils/generate_app_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@
"UAH",
]



with open(f"{script_path}/electrum_scan_report.json", "r") as f:
electrum_scan_report = json.load(f)

with open(f"{repo_path}/explorers/explorer_paths.json", "r") as f:
explorer_paths = json.load(f)

Expand Down Expand Up @@ -133,8 +128,9 @@ def colorize(string, color):


class CoinConfig:
def __init__(self, coin_data: dict):
def __init__(self, coin_data: dict, electrum_scan_report: dict):
self.coin_data = coin_data
self.electrum_scan_report = electrum_scan_report
self.data = {}
self.is_testnet = self.is_testnet_network()
self.ticker = self.coin_data["coin"].replace("-TEST", "")
Expand Down Expand Up @@ -528,15 +524,16 @@ def get_explorers(self):
self.data[self.ticker].update({i[0]: i[1]})


def parse_coins_repo():
def parse_coins_repo(electrum_scan_report):
ensure_chainids()
errors = []
coins_config = {}
with open(f"{repo_path}/coins", "r") as f:
coins_data = json.load(f)

for item in coins_data:
if item["mm2"] == 1:
config = CoinConfig(item)
config = CoinConfig(item, electrum_scan_report)
config.get_generics()
config.get_protocol_info()
config.clean_name()
Expand Down Expand Up @@ -770,9 +767,13 @@ def sort_dicts_list(data, sort_key):
if sys.argv[1] == "no-scan":
skip_scan = True
if skip_scan is False:
get_electrums_report()
ensure_chainids()
coins_config, nodata = parse_coins_repo()
electrum_scan_report = get_electrums_report()
else:
# Use existing scan data
with open(f"{script_path}/electrum_scan_report.json", "r") as f:
electrum_scan_report = json.load(f)

coins_config, nodata = parse_coins_repo(electrum_scan_report)
# Includes failing servers
with open(f"{script_path}/coins_config_unfiltered.json", "w+") as f:
json.dump(coins_config, f, indent=4)
Expand Down
7 changes: 2 additions & 5 deletions utils/scan_electrums.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,6 @@ def get_repo_electrums():
return repo_electrums






def get_existing_report():
if os.path.exists("electrum_scan_report.json"):
with open(f"{script_path}/electrum_scan_report.json", "r") as f:
Expand Down Expand Up @@ -549,8 +545,9 @@ def get_electrums_report():

with open(f"{script_path}/electrum_scan_report.json", "w+") as f:
f.write(json.dumps(results, indent=4))

# print(json.dumps(results, indent=4))
return results

if __name__ == '__main__':
get_electrums_report()

0 comments on commit 4e081d9

Please sign in to comment.