19
19
from safe_eth .eth .utils import mk_contract_address_2
20
20
21
21
ERRORS = []
22
+ WARNINGS = []
22
23
23
24
24
25
def convert_chain_name (name : str ) -> str :
@@ -164,26 +165,21 @@ def validate_blockscout_client_url(
164
165
]
165
166
166
167
if client_url_domain not in chain_explorers_urls_domains :
167
- ERRORS .append (
168
+ WARNINGS .append (
168
169
f"Blockscout Client URL ({ url } ) not contained in the list of explorers urls in the chain."
169
170
)
170
- return None
171
171
try :
172
- body = { "query" : '{transaction(hash: "%s ") {status}}' % tx_hash }
173
- response = requests .post ( url , json = body , verify = False )
172
+ request_url = url . rstrip ( "/ " ) + f"/transactions/ { tx_hash } "
173
+ response = requests .get ( request_url , verify = False )
174
174
if response .status_code == 200 :
175
- tx_status = (
176
- response .json ()
177
- .get ("data" , {})
178
- .get ("transaction" , {})
179
- .get ("status" , {})
180
- )
181
- if tx_status .lower () == "ok" :
175
+ tx_status = response .json ().get ("status" , "" ).lower ()
176
+ if tx_status == "ok" :
182
177
return None
183
- except (IOError , ConnectionError ) as e :
178
+ except (IOError , ConnectionError , AttributeError ) as e :
184
179
print (f"Error validating Blockscout Client URL: { e } " )
185
180
186
181
ERRORS .append (f"Blockscout Client URL ({ url } ) not valid." )
182
+ return None
187
183
188
184
189
185
def validate_etherscan_client_urls (
@@ -204,10 +200,9 @@ def validate_etherscan_client_urls(
204
200
f"{ extract (base_url ).domain } .{ extract (base_url ).suffix } "
205
201
)
206
202
if client_base_url_domain not in chain_explorers_urls_domains :
207
- ERRORS .append (
203
+ WARNINGS .append (
208
204
f"Etherscan Client URL ({ base_url } ) not contained in the list of explorers urls in the chain"
209
205
)
210
- return None
211
206
212
207
if api_url :
213
208
parsed_api_url = urlparse (api_url )
@@ -218,23 +213,30 @@ def validate_etherscan_client_urls(
218
213
return None
219
214
client_api_url_domain = f"{ extract (api_url ).domain } .{ extract (api_url ).suffix } "
220
215
if client_api_url_domain not in chain_explorers_urls_domains :
221
- ERRORS .append (
216
+ WARNINGS .append (
222
217
f"Etherscan Client URL API ({ api_url } ) not contained in the list of explorers urls in the chain"
223
218
)
224
- return None
225
219
226
220
try :
227
221
url = f"{ api_url } /api?module=transaction&action=gettxreceiptstatus&txhash={ tx_hash } "
228
222
response = requests .get (url , verify = False )
229
223
230
224
if response .status_code == 200 :
225
+ request_status = response .json ().get ("status" , "" )
226
+ if request_status == "0" :
227
+ request_failure_message = response .json ().get ("result" , "" )
228
+ ERRORS .append (
229
+ f"Error validating Etherscan Client API URL: { request_failure_message } "
230
+ )
231
+ return None
231
232
tx_status = response .json ().get ("result" , {}).get ("status" , "" )
232
233
if tx_status == "1" :
233
234
return None
234
- except (IOError , ConnectionError ) as e :
235
+ except (IOError , ConnectionError , AttributeError ) as e :
235
236
print (f"Error validating Etherscan Client API URL: { e } " )
236
237
237
238
ERRORS .append (f"Etherscan Client API URL ({ api_url } ) not valid." )
239
+ return None
238
240
239
241
240
242
def validate_version (version : str ) -> None :
@@ -363,8 +365,8 @@ def validate_issue_inputs() -> None:
363
365
print ("Inputs to validate:" )
364
366
print (f"Chain ID: { chain_id_input } " )
365
367
print (f"RPC URL: { rpc_url } " )
366
- print (f"Blockscout Client URL: { blockscout_client_url } " )
367
- print (f"Etherscan Client URL: { etherscan_client_url } " )
368
+ print (f"Blockscout Client V1 URL: { blockscout_client_url } " )
369
+ print (f"Etherscan Client V1 URL: { etherscan_client_url } " )
368
370
print (f"Etherscan Client API URL: { etherscan_client_api_url } " )
369
371
print (f"Version: { version } " )
370
372
print (f"Address (Master copy): { address_master_copy } " )
@@ -424,28 +426,40 @@ def validate_issue_inputs() -> None:
424
426
"Proxy factory" , address_proxy , tx_hash_proxy , rpc_url
425
427
)
426
428
429
+ result_comments = []
430
+
431
+ if len (WARNINGS ) > 0 :
432
+ warnings_comment = "\n - " .join (WARNINGS )
433
+ result_comments .append (
434
+ "⚠️ Validation has detected the following warnings:"
435
+ + f"\n - { warnings_comment } "
436
+ + "\n \n "
437
+ )
438
+
427
439
if len (ERRORS ) > 0 :
428
440
errors_comment = "\n - " .join (ERRORS )
429
- add_message_to_env (
430
- "Validation has failed with the following errors:"
441
+ result_comments . append (
442
+ "❌ Validation has failed with the following errors:"
431
443
+ f"\n - { errors_comment } "
432
- + "\n \n Validation failed!❌ "
444
+ + "\n \n Validation failed!"
433
445
)
446
+ add_message_to_env ("\n " .join (result_comments ))
434
447
return None
448
+
435
449
chain_name_comment = chain_name if chain_name else "N/A"
436
450
tx_master_block_comment = tx_master_info .get ("block" ) if tx_master_info else "N/A"
437
451
tx_master_l2_block_comment = (
438
452
tx_master_l2_info .get ("block" ) if tx_master_l2_info else "N/A"
439
453
)
440
454
tx_proxy_block_comment = tx_proxy_info .get ("block" ) if tx_proxy_info else "N/A"
441
- add_message_to_env (
442
- "All elements have been validated and are correct:"
455
+ result_comments . append (
456
+ "✅ All elements have been validated and are correct:"
443
457
+ f"\n - Chain ID: { chain_id } "
444
458
+ f"\n - Chain Name: { chain_name_comment } "
445
459
+ f"\n - RPC URL: { rpc_url } "
446
460
+ f"\n - Blockscout Client URL: { blockscout_client_url } "
447
- + f"\n - Etherscan Client URL: { etherscan_client_url } "
448
- + f"\n - Etherscan Client API URL: { etherscan_client_api_url } "
461
+ + f"\n - Etherscan Client V1 URL: { etherscan_client_url } "
462
+ + f"\n - Etherscan Client V1 API URL: { etherscan_client_api_url } "
449
463
+ f"\n - Version: { version } "
450
464
+ f"\n - Address Master Copy: { address_master_copy } "
451
465
+ f"\n - Tx Hash Master Copy: { tx_hash_master_copy } "
@@ -456,8 +470,9 @@ def validate_issue_inputs() -> None:
456
470
+ f"\n - Address Proxy: { address_proxy } "
457
471
+ f"\n - Tx Hash Proxy: { tx_hash_proxy } "
458
472
+ f"\n - Tx Block Proxy: { tx_proxy_block_comment } "
459
- + "\n \n Validation successful!✅ "
473
+ + "\n \n Validation successful!"
460
474
)
475
+ add_message_to_env ("\n " .join (result_comments ))
461
476
462
477
463
478
if __name__ == "__main__" :
0 commit comments