Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add config switch add warning on genesis change #3000

Merged
merged 14 commits into from
Sep 2, 2024
24 changes: 20 additions & 4 deletions scripts/polkadotjs_endpoints_to_preconfigured.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class Endpoints(Enum):
testnets = "https://raw.githubusercontent.com/polkadot-js/apps/master/packages/apps-config/src/endpoints/testing.ts"


class BlacklistedChains(Enum):
kulupu = 'f7a99d3cb92853d00d5275c971c132c074636256583fee53b3bbe60d7b8769ba'
nftmart = 'fcf9074303d8f319ad1bf0195b145871977e7c375883b834247cb01ff22f51f9'


CHAINS_FILE_PATH_DEV = Path(os.getenv("DEV_CHAINS_JSON_PATH", 'chains/v20/chains_dev.json'))
CHAINS_FILE_PATH_PROD = Path(os.getenv("PROD_CHAINS_JSON_PATH", 'chains/v20/chains.json'))

Expand Down Expand Up @@ -194,7 +199,12 @@ def create_json_files(pjs_networks, chains_path):
is_chain_present = check_chain_id(existing_data_in_chains, chain_id)
# skip chains with wss already added to config, in case they have changed chain_id
is_node_present = check_node_is_present(existing_data_in_chains, chain.get("nodes"))
if is_chain_present or is_node_present or exclusion.casefold() in chain_name.casefold():
if is_chain_present is False and is_node_present:
print("⚠️Probably chainId is changed, check genesis for chain:" + chain_name)
if (is_chain_present
or is_node_present
or exclusion.casefold() in chain_name.casefold()
or chain_id in [c.value for c in BlacklistedChains]):
continue
add_chains_details_file(chain, chains_path)
add_chain_to_chains_file(chain, chains_path)
Expand All @@ -203,7 +213,10 @@ def create_json_files(pjs_networks, chains_path):


def add_chains_details_file(chain, chains_path):
target_path = chains_path.parent / 'preConfigured' / 'detailsDev'
if chains_path == CHAINS_FILE_PATH_DEV:
target_path = chains_path.parent / 'preConfigured' / 'detailsDev'
else:
target_path = chains_path.parent / 'preConfigured' / 'details'
file_name = chain.get("chainId") + '.json'
file_path = target_path / file_name

Expand All @@ -215,7 +228,10 @@ def add_chains_details_file(chain, chains_path):


def add_chain_to_chains_file(chain, chains_path):
target_path = chains_path.parent / 'preConfigured' / 'chains_dev.json'
if chains_path == CHAINS_FILE_PATH_DEV:
target_path = chains_path.parent / 'preConfigured' / 'chains_dev.json'
else:
target_path = chains_path.parent / 'preConfigured' / 'chains.json'
chain_data = {
"chainId": chain.get("chainId"),
"name": chain.get("name")
Expand All @@ -238,7 +254,7 @@ def main():
for endpoint in Endpoints:
get_ts_file(endpoint.value, ts_file_path)
polkadotjs_data = ts_constant_to_json(ts_file_path)
create_json_files(polkadotjs_data, CHAINS_FILE_PATH_DEV)
create_json_files(polkadotjs_data, CHAINS_FILE_PATH_PROD)


if __name__ == "__main__":
Expand Down
Loading