From cb726d394a2f1e64b96942042a250fa32f4e5395 Mon Sep 17 00:00:00 2001 From: ibraheem-latent Date: Mon, 8 Dec 2025 16:07:12 -0800 Subject: [PATCH] testing --- async_substrate_interface/sync_substrate.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/async_substrate_interface/sync_substrate.py b/async_substrate_interface/sync_substrate.py index 8ddd90b..24ab8d6 100644 --- a/async_substrate_interface/sync_substrate.py +++ b/async_substrate_interface/sync_substrate.py @@ -2,6 +2,7 @@ import logging import os import socket +from threading import Lock from hashlib import blake2b from typing import Optional, Union, Callable, Any from unittest.mock import MagicMock @@ -578,6 +579,8 @@ def __init__( self.runtime_cache = RuntimeCache() self.metadata_version_hex = "0x0f000000" # v15 self._mock = _mock + self._nonces: dict[str, int] = {} + self._nonce_lock = Lock() self.log_raw_websockets = _log_raw_websockets if not _mock: self.ws = self.connect(init=True) @@ -2678,8 +2681,13 @@ def get_account_next_index(self, account_address: str) -> int: # Unlikely to happen, this is a common RPC method raise Exception("account_nextIndex not supported") - nonce_obj = self.rpc_request("account_nextIndex", [account_address]) - return nonce_obj["result"] + with self._nonce_lock: + if self._nonces.get(account_address) is None: + nonce_obj = self.rpc_request("account_nextIndex", [account_address]) + self._nonces[account_address] = nonce_obj["result"] + else: + self._nonces[account_address] += 1 + return self._nonces[account_address] def get_metadata_constants(self, block_hash=None) -> list[dict]: """