Skip to content

Commit

Permalink
Update PR title and minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
falvaradorodriguez authored and Uxio0 committed Apr 12, 2024
1 parent 7d203f5 commit e17cbda
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 39 deletions.
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/add_safe_address_new_chain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ body:
id: block_explorer_url_master_copy
attributes:
label: Block explorer URL (Master copy)
description: Detail of contract address in the chain block explorer or deployment log.
description: Detail of contract address in the chain block explorer or deployment log. (Optional)
placeholder: ex. https://etherscan.io/address/0x69f4d1788e39c87893c980c06edf4b7f686e2938
- type: input
id: address_master_copy_l2
Expand All @@ -104,13 +104,13 @@ body:
id: tx_hash_master_copy_l2
attributes:
label: Deployment Tx hash (Master copy L2)
description: Contract deployment Tx hash.
description: Contract L2 deployment Tx hash.
placeholder: ex. 0x25b182f34baa23c122b081b249fb9da27f032e663e0a0ab3833be1c1c9266c3e
- type: textarea
id: block_explorer_url_master_copy_l2
attributes:
label: Block explorer URL (Master copy L2)
description: Detail of contract address in the chain block explorer or deployment log.
description: Detail of contract address L2 in the chain block explorer or deployment log. (Optional)
placeholder: ex. https://etherscan.io/address/0x69f4d1788e39c87893c980c06edf4b7f686e2938
- type: markdown
attributes:
Expand All @@ -133,5 +133,5 @@ body:
id: block_explorer_url_proxy
attributes:
label: Block explorer URL (Proxy factory)
description: Detail of contract address in the chain block explorer or deployment log.
description: Detail of contract address in the chain block explorer or deployment log. (Optional)
placeholder: ex. https://etherscan.io/address/0x69f4d1788e39c87893c980c06edf4b7f686e2938
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ def create_issue_branch(repo: Repository, chain_id: int, version: str) -> str:
def create_pr(
repo: Repository,
branch_name: str,
chain_id: int,
chain_enum_name: str,
version: str,
issue_number: int,
) -> None:
try:
repo.create_pull(
title=f"Add new chain {chain_enum_name}",
body=f"Automatic PR to add new address to {chain_enum_name} {chain_id} chain\n Closes #{issue_number}",
title=f"Add addresses {version} for chain {chain_enum_name}",
body=f"Automatic PR to add new address {version} to {chain_enum_name} chain\n Closes #{issue_number}",
head=branch_name,
base="main",
)
Expand Down Expand Up @@ -457,7 +457,7 @@ def execute_issue_changes() -> None:
repo, branch_name, chain_enum_name, address_proxy, tx_block, version
)

create_pr(repo, branch_name, chain_id, chain_enum_name, issue_number)
create_pr(repo, branch_name, chain_enum_name, version, issue_number)


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import re
import uuid
from typing import Any, Dict, Optional
from typing import Any, Dict, List, Optional
from urllib.parse import urlparse

import requests
Expand Down Expand Up @@ -37,7 +37,7 @@ def get_chain_enum_name(chain_id: int) -> Optional[str]:
if response.status_code == 200:
return convert_chain_name(response.json().get("name"))
return None
except IOError as e:
except (IOError, ConnectionError) as e:
print(f"Error getting chain name: {e}")
return None

Expand All @@ -52,25 +52,29 @@ def get_chain_id_from_rpc_url(rpc_url: str) -> Optional[int]:
if response.status_code == 200:
return int(response.json().get("result"), 16)
return None
except IOError as e:
except (IOError, ConnectionError) as e:
print(f"Error validating RPC url: {e}")
return None


def get_contract_address_and_block_from_tx_hash(
rpc_url: str, tx_hash: str
) -> Optional[Dict[str, Any]]:
ethereum_client = EthereumClient(rpc_url)
tx = ethereum_client.get_transaction(tx_hash)
if not tx:
print(f"Transaction not found: {tx_hash}")
try:
ethereum_client = EthereumClient(rpc_url)
tx = ethereum_client.get_transaction(tx_hash)
if not tx:
print(f"Transaction not found: {tx_hash}")
return None
return {
"block": tx.get("blockNumber"),
"address": mk_contract_address_2(
tx.get("to"), tx.get("input")[:32], tx.get("input")[32:]
),
}
except (IOError, ConnectionError) as e:
print(f"Error info from tx hash: {e}")
return None
return {
"block": tx.get("blockNumber"),
"address": mk_contract_address_2(
tx.get("to"), tx.get("input")[:32], tx.get("input")[32:]
),
}


def validate_chain(chain_id_input: str) -> Optional[Dict[str, Any]]:
Expand Down Expand Up @@ -135,27 +139,28 @@ def validate_etherscan_client_required_urls(base_url: str, api_url: str) -> None
return None


def get_chain_explorers_urls(chain_id: int) -> [str]:
def get_chain_explorers_urls(chain_id: int) -> List[str]:
try:
url = f"https://raw.githubusercontent.com/ethereum-lists/chains/master/_data/chains/eip155-{chain_id}.json"
response = requests.get(url)

if response.status_code == 200:
explorers = response.json().get("explorers")
return [explorer.get("url") for explorer in explorers]
except IOError as e:
except (IOError, ConnectionError) as e:
print(f"Error getting chain explorers urls: {e}")
return []


def validate_blockscout_client_url(
url: str, chain_explorers_urls: [str], tx_hash: str
url: str, chain_explorers_urls: List[str], tx_hash: str
) -> None:
if url:
parsed_url = urlparse(url)
if parsed_url.netloc not in [
chain_explorers_urls_netloc = [
urlparse(explorer_url).netloc for explorer_url in chain_explorers_urls
]:
]
if parsed_url.netloc not in chain_explorers_urls_netloc:
ERRORS.append(
f"Blockscout Client URL ({url}) not contained in the list of explorers urls in the chain."
)
Expand All @@ -172,14 +177,14 @@ def validate_blockscout_client_url(
)
if tx_status.lower() == "ok":
return None
except IOError as e:
except (IOError, ConnectionError) as e:
print(f"Error validating Blockscout Client URL: {e}")

ERRORS.append(f"Blockscout Client URL ({url}) not valid.")


def validate_etherscan_client_urls(
base_url: str, api_url: str, chain_explorers_urls: [str], tx_hash: str
base_url: str, api_url: str, chain_explorers_urls: List[str], tx_hash: str
) -> None:
if base_url:
parsed_base_url = urlparse(base_url)
Expand All @@ -188,10 +193,10 @@ def validate_etherscan_client_urls(
f"Etherscan Client URL ({base_url}) provided is not valid. The url path should be empty."
)
return None

if parsed_base_url.netloc not in [
chain_explorers_urls_netloc = [
urlparse(explorer_url).netloc for explorer_url in chain_explorers_urls
]:
]
if parsed_base_url.netloc not in chain_explorers_urls_netloc:
ERRORS.append(
f"Etherscan Client URL ({base_url}) not contained in the list of explorers urls in the chain"
)
Expand All @@ -201,16 +206,16 @@ def validate_etherscan_client_urls(
parsed_api_url = urlparse(api_url)
if parsed_api_url.path != "":
ERRORS.append(
f"Etherscan Client URL ({api_url}) provided is not valid. The url path should be empty."
f"Etherscan Client API URL ({api_url}) provided is not valid. The url path should be empty."
)
return None

if not any(
api_url_ends_by_any_chain_explorer_netloc = any(
parsed_api_url.netloc.endswith(urlparse(explorer_url).netloc)
for explorer_url in chain_explorers_urls
):
)
if not api_url_ends_by_any_chain_explorer_netloc:
ERRORS.append(
f"Etherscan Client URL ({api_url}) not contained in the list of explorers urls in the chain"
f"Etherscan Client URL API ({api_url}) not contained in the list of explorers urls in the chain"
)
return None

Expand All @@ -222,10 +227,10 @@ def validate_etherscan_client_urls(
tx_status = response.json().get("result", {}).get("status", "")
if tx_status == "1":
return None
except IOError as e:
print(f"Error validating Blockscout Client URL: {e}")
except (IOError, ConnectionError) as e:
print(f"Error validating Etherscan Client API URL: {e}")

ERRORS.append(f"Etherscan Client URL ({api_url}) not valid.")
ERRORS.append(f"Etherscan Client API URL ({api_url}) not valid.")


def validate_version(version: str) -> None:
Expand Down

0 comments on commit e17cbda

Please sign in to comment.