@@ -93,28 +93,35 @@ def _load_account(
93
93
"""Load an account from a private key string or file, or from the configuration file."""
94
94
95
95
config = load_main_configuration (settings .CONFIG_FILE )
96
- chain_to_use = settings .DEFAULT_CHAIN
96
+ default_chain = settings .DEFAULT_CHAIN
97
97
98
98
if not chain :
99
99
if config and hasattr (config , "chain" ):
100
- chain_to_use = config .chain
100
+ chain = config .chain
101
101
logger .debug (
102
102
f"Detected { config .chain } account for path { settings .CONFIG_FILE } "
103
103
)
104
+ else :
105
+ chain = default_chain
106
+ logger .warning (
107
+ f"No main configuration found on path { settings .CONFIG_FILE } , defaulting to { chain } "
108
+ )
109
+ else :
110
+ chain = default_chain
104
111
105
112
# Loads configuration if no account_type is specified
106
113
if not account_type :
107
- account_type = load_chain_account_type (chain_to_use )
108
- logger .warning (
109
- f"No main configuration data found in { settings . CONFIG_FILE } , defaulting to { account_type and account_type .__name__ } "
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__ } "
110
117
)
111
118
112
119
# Loads private key from a string
113
120
if private_key_str :
114
- return account_from_hex_string (private_key_str , account_type , chain_to_use )
121
+ return account_from_hex_string (private_key_str , account_type , chain )
115
122
# Loads private key from a file
116
123
elif private_key_path and private_key_path .is_file ():
117
- return account_from_file (private_key_path , account_type , chain_to_use )
124
+ return account_from_file (private_key_path , account_type , chain )
118
125
# For ledger keys
119
126
elif settings .REMOTE_CRYPTO_HOST :
120
127
logger .debug ("Using remote account" )
@@ -129,7 +136,7 @@ def _load_account(
129
136
else :
130
137
new_private_key = get_fallback_private_key ()
131
138
account = account_from_hex_string (
132
- bytes .hex (new_private_key ), account_type , chain_to_use
139
+ bytes .hex (new_private_key ), account_type , chain
133
140
)
134
141
logger .info (
135
142
f"Generated fallback private key with address { account .get_address ()} "
0 commit comments