7
7
8
8
from aleph .sdk .chains .common import get_fallback_private_key
9
9
from aleph .sdk .chains .ethereum import ETHAccount
10
+ from aleph .sdk .chains .evm import EVMAccount
10
11
from aleph .sdk .chains .remote import RemoteAccount
11
12
from aleph .sdk .chains .solana import SOLAccount
13
+ from aleph .sdk .chains .substrate import DOTAccount
12
14
from aleph .sdk .conf import load_main_configuration , settings
13
15
from aleph .sdk .evm_utils import get_chains_with_super_token
14
16
from aleph .sdk .types import AccountFromPrivateKey
18
20
T = TypeVar ("T" , bound = AccountFromPrivateKey )
19
21
20
22
chain_account_map : Dict [Chain , Type [T ]] = { # type: ignore
21
- Chain .ETH : ETHAccount ,
23
+ Chain .ARBITRUM : EVMAccount ,
22
24
Chain .AVAX : ETHAccount ,
23
25
Chain .BASE : ETHAccount ,
26
+ Chain .BLAST : EVMAccount ,
27
+ Chain .BOB : EVMAccount ,
28
+ Chain .CYBER : EVMAccount ,
29
+ Chain .DOT : DOTAccount ,
30
+ Chain .ETH : ETHAccount ,
31
+ Chain .FRAXTAL : EVMAccount ,
32
+ Chain .LINEA : EVMAccount ,
33
+ Chain .LISK : EVMAccount ,
34
+ Chain .METIS : EVMAccount ,
35
+ Chain .MODE : EVMAccount ,
36
+ Chain .OPTIMISM : EVMAccount ,
37
+ Chain .POL : EVMAccount ,
24
38
Chain .SOL : SOLAccount ,
39
+ Chain .WORLDCHAIN : EVMAccount ,
40
+ Chain .ZORA : EVMAccount ,
25
41
}
26
42
27
43
@@ -43,7 +59,7 @@ def account_from_hex_string(
43
59
return account_type (bytes .fromhex (private_key_str )) # type: ignore
44
60
45
61
account_type = load_chain_account_type (chain )
46
- account = account_type (bytes .fromhex (private_key_str ))
62
+ account = account_type (bytes .fromhex (private_key_str ), chain )
47
63
if chain in get_chains_with_super_token ():
48
64
account .switch_chain (chain )
49
65
return account # type: ignore
@@ -62,7 +78,7 @@ def account_from_file(
62
78
return account_type (private_key ) # type: ignore
63
79
64
80
account_type = load_chain_account_type (chain )
65
- account = account_type (private_key )
81
+ account = account_type (private_key , chain )
66
82
if chain in get_chains_with_super_token ():
67
83
account .switch_chain (chain )
68
84
return account
@@ -76,21 +92,29 @@ def _load_account(
76
92
) -> AccountFromPrivateKey :
77
93
"""Load an account from a private key string or file, or from the configuration file."""
78
94
79
- # Loads configuration if no account_type is specified
80
- if not account_type :
81
- config = load_main_configuration (settings .CONFIG_FILE )
95
+ config = load_main_configuration (settings .CONFIG_FILE )
96
+ default_chain = settings .DEFAULT_CHAIN
97
+
98
+ if not chain :
82
99
if config and hasattr (config , "chain" ):
83
- account_type = load_chain_account_type ( config .chain )
100
+ chain = config .chain
84
101
logger .debug (
85
102
f"Detected { config .chain } account for path { settings .CONFIG_FILE } "
86
103
)
87
104
else :
88
- account_type = account_type = load_chain_account_type (
89
- Chain .ETH
90
- ) # Defaults to ETHAccount
105
+ chain = default_chain
91
106
logger .warning (
92
- f"No main configuration data found in { settings .CONFIG_FILE } , defaulting to { account_type and account_type . __name__ } "
107
+ f"No main configuration found on path { settings .CONFIG_FILE } , defaulting to { chain } "
93
108
)
109
+ else :
110
+ chain = default_chain
111
+
112
+ # Loads configuration if no account_type is specified
113
+ if not account_type :
114
+ account_type = load_chain_account_type (chain )
115
+ logger .debug (
116
+ f"No account type specified defaulting to { account_type and account_type .__name__ } "
117
+ )
94
118
95
119
# Loads private key from a string
96
120
if private_key_str :
0 commit comments