Skip to content

Commit

Permalink
Merge pull request #204 from multiversx/contract-verify-fix
Browse files Browse the repository at this point in the history
Error handling for contract verification
  • Loading branch information
popenta authored Jan 27, 2023
2 parents a2a0450 + 1b10d82 commit e318433
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion multiversx_sdk_cli/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "5.2.1"
__version__ = "5.2.2"
29 changes: 19 additions & 10 deletions multiversx_sdk_cli/contract_verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
from nacl.signing import SigningKey
import requests

HTTP_REQUEST_TIMEOUT = 408
HTTP_SUCCESS = 200

logger = logging.getLogger("cli.contracts.verifier")

class ContractVerificationRequest:
Expand Down Expand Up @@ -79,19 +82,25 @@ def trigger_contract_verification(
request_dictionary = contract_verification.to_dictionary()

url = f"{verifier_url}/verifier"
response = requests.post(url, json=request_dictionary).json()
response = requests.post(url, json=request_dictionary)

status = response.get("status", "")
if status:
logger.info(f"Task status: {status}")
if response.status_code == HTTP_REQUEST_TIMEOUT:
task_id = response.json().get("taskId", "")

if status == "error":
dump_out_json(response)
if task_id:
query_status_with_task_id(verifier_url, task_id)
else:
dump_out_json(response)
else:
task_id = response.get("taskId", "")
query_status_with_task_id(verifier_url, task_id)
dump_out_json(response.json())
elif response.status_code != HTTP_SUCCESS:
dump_out_json(response.json())
elif response.status_code == HTTP_SUCCESS:
status = response.json().get("status", "")
if status:
logger.info(f"Task status: {status}")
dump_out_json(response.json())
else:
task_id = response.json().get("taskId", "")
query_status_with_task_id(verifier_url, task_id)


def query_status_with_task_id(url: str, task_id: str, interval: int = 10):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import setuptools

VERSION = "5.2.1"
VERSION = "5.2.2"

try:
with open('./multiversx_sdk_cli/_version.py', 'wt') as versionfile:
Expand Down

0 comments on commit e318433

Please sign in to comment.