Skip to content

Commit

Permalink
Fix types in web3_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaStebaev committed Apr 16, 2024
1 parent 9eee659 commit a4823fa
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions skale/utils/web3_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def outdated_client_file_msg(method, latest_block_number, saved_number, state_pa


def make_client_checking_middleware(allowed_ts_diff: int,
state_path: str = None):
state_path: str | None = None):
def eth_client_checking_middleware(make_request, web3):
def middleware(method, params):
if method in ('eth_block_number', 'eth_getBlockByNumber'):
Expand Down Expand Up @@ -139,23 +139,23 @@ def middleware(method, params):

def init_web3(endpoint: str,
provider_timeout: int = DEFAULT_HTTP_TIMEOUT,
middlewares: Iterable = None,
state_path: str = None, ts_diff: int = None):
middlewares: Iterable | None = None,
state_path: str | None = None, ts_diff: int | None = None):
if not middlewares:
ts_diff = ts_diff or config.ALLOWED_TS_DIFF
state_path = state_path or config.LAST_BLOCK_FILE
if not ts_diff == config.NO_SYNC_TS_DIFF:
sync_middleware = make_client_checking_middleware(ts_diff, state_path)
middewares = (
middewares = [
http_retry_request_middleware,
sync_middleware,
attrdict_middleware
)
]
else:
middewares = (
middewares = [
http_retry_request_middleware,
attrdict_middleware
)
]

provider = get_provider(endpoint, timeout=provider_timeout)
web3 = Web3(provider)
Expand Down

0 comments on commit a4823fa

Please sign in to comment.