Skip to content

Commit

Permalink
Merge branch 'main' into 177-upgrade-pydantic-version
Browse files Browse the repository at this point in the history
  • Loading branch information
philogicae authored Dec 4, 2024
2 parents afe055d + abdb760 commit 4132ea0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/aleph/sdk/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ def account_from_hex_string(
private_key_str = private_key_str[2:]

if not chain:
if not account_type:
account_type = load_chain_account_type(Chain.ETH) # type: ignore
return account_type(bytes.fromhex(private_key_str)) # type: ignore
chain = settings.DEFAULT_CHAIN
if not account_type:
account_type = load_chain_account_type(chain) # type: ignore
account = account_type(
bytes.fromhex(private_key_str),
**({"chain": chain} if type(account_type) in [ETHAccount, EVMAccount] else {}),
) # type: ignore

account_type = load_chain_account_type(chain)
account = account_type(bytes.fromhex(private_key_str), chain)
if chain in get_chains_with_super_token():
account.switch_chain(chain)
return account # type: ignore
Expand All @@ -73,12 +75,14 @@ def account_from_file(
private_key = private_key_path.read_bytes()

if not chain:
if not account_type:
account_type = load_chain_account_type(Chain.ETH) # type: ignore
return account_type(private_key) # type: ignore
chain = settings.DEFAULT_CHAIN
if not account_type:
account_type = load_chain_account_type(chain) # type: ignore
account = account_type(
private_key,
**({"chain": chain} if type(account_type) in [ETHAccount, EVMAccount] else {}),
) # type: ignore

account_type = load_chain_account_type(chain)
account = account_type(private_key, chain)
if chain in get_chains_with_super_token():
account.switch_chain(chain)
return account
Expand Down Expand Up @@ -106,8 +110,6 @@ def _load_account(
logger.warning(
f"No main configuration found on path {settings.CONFIG_FILE}, defaulting to {chain}"
)
else:
chain = default_chain

# Loads configuration if no account_type is specified
if not account_type:
Expand Down
2 changes: 2 additions & 0 deletions src/aleph/sdk/client/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,3 +467,5 @@ async def get_message_status(self, item_hash: str) -> MessageStatus:
if resp.status == HTTPNotFound.status_code:
raise MessageNotFoundError(f"No such hash {item_hash}")
resp.raise_for_status()
result = await resp.json()
return MessageStatus(result["status"])
27 changes: 27 additions & 0 deletions src/aleph/sdk/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,38 @@ class Settings(BaseSettings):
CHAINS_AVAX_ACTIVE: Optional[bool] = None
CHAINS_BASE_ACTIVE: Optional[bool] = None
CHAINS_BSC_ACTIVE: Optional[bool] = None
CHAINS_ARBITRUM_ACTIVE: Optional[bool] = None
CHAINS_BLAST_ACTIVE: Optional[bool] = None
CHAINS_BOB_ACTIVE: Optional[bool] = None
CHAINS_CYBER_ACTIVE: Optional[bool] = None
CHAINS_FRAXTAL_ACTIVE: Optional[bool] = None
CHAINS_LINEA_ACTIVE: Optional[bool] = None
CHAINS_LISK_ACTIVE: Optional[bool] = None
CHAINS_METIS_ACTIVE: Optional[bool] = None
CHAINS_MODE_ACTIVE: Optional[bool] = None
CHAINS_OPTIMISM_ACTIVE: Optional[bool] = None
CHAINS_POL_ACTIVE: Optional[bool] = None
CHAINS_WORLDCHAIN_ACTIVE: Optional[bool] = None
CHAINS_ZORA_ACTIVE: Optional[bool] = None

CHAINS_SEPOLIA_RPC: Optional[str] = None
CHAINS_ETH_RPC: Optional[str] = None
CHAINS_AVAX_RPC: Optional[str] = None
CHAINS_BASE_RPC: Optional[str] = None
CHAINS_BSC_RPC: Optional[str] = None
CHAINS_ARBITRUM_RPC: Optional[str] = None
CHAINS_BLAST_RPC: Optional[str] = None
CHAINS_BOB_RPC: Optional[str] = None
CHAINS_CYBER_RPC: Optional[str] = None
CHAINS_FRAXTAL_RPC: Optional[str] = None
CHAINS_LINEA_RPC: Optional[str] = None
CHAINS_LISK_RPC: Optional[str] = None
CHAINS_METIS_RPC: Optional[str] = None
CHAINS_MODE_RPC: Optional[str] = None
CHAINS_OPTIMISM_RPC: Optional[str] = None
CHAINS_POL_RPC: Optional[str] = None
CHAINS_WORLDCHAIN_RPC: Optional[str] = None
CHAINS_ZORA_RPC: Optional[str] = None

DEFAULT_CHAIN: Chain = Chain.ETH

Expand Down

0 comments on commit 4132ea0

Please sign in to comment.