diff --git a/src/opengradient/client/_utils.py b/src/opengradient/client/_utils.py index 5e8d1af..d9d8436 100644 --- a/src/opengradient/client/_utils.py +++ b/src/opengradient/client/_utils.py @@ -3,8 +3,6 @@ from pathlib import Path from typing import Callable -from .exceptions import OpenGradientError - _ABI_DIR = Path(__file__).parent.parent / "abi" _BIN_DIR = Path(__file__).parent.parent / "bin" @@ -22,7 +20,8 @@ def get_abi(abi_name: str) -> dict: """Returns the ABI for the requested contract.""" abi_path = _ABI_DIR / abi_name with open(abi_path, "r") as f: - return json.load(f) + result: dict = json.load(f) + return result def get_bin(bin_name: str) -> str: @@ -50,6 +49,9 @@ def run_with_retry( """ effective_retries = max_retries if max_retries is not None else DEFAULT_MAX_RETRY + if effective_retries < 1: + raise ValueError(f"max_retries must be at least 1, got {effective_retries}") + for attempt in range(effective_retries): try: return txn_function() @@ -58,8 +60,10 @@ def run_with_retry( if any(error in error_msg for error in _NONCE_ERRORS): if attempt == effective_retries - 1: - raise OpenGradientError(f"Transaction failed after {effective_retries} attempts: {e}") + raise RuntimeError(f"Transaction failed after {effective_retries} attempts: {e}") time.sleep(retry_delay) continue raise + + raise RuntimeError(f"run_with_retry exhausted {effective_retries} attempts without returning or raising")