Skip to content

Commit 009c96a

Browse files
authored
Merge pull request #11 from opentensor/fix/nonce-management-async
Fixes nonce management & bumps version
2 parents 8fd6324 + c52e236 commit 009c96a

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

async_substrate_interface/substrate_interface.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3167,7 +3167,7 @@ async def create_signed_extrinsic(
31673167

31683168
# Retrieve nonce
31693169
if nonce is None:
3170-
nonce = await self.get_account_next_index(keypair.ss58_address) or 0
3170+
nonce = await self.get_account_nonce(keypair.ss58_address) or 0
31713171

31723172
# Process era
31733173
if era is None:
@@ -3347,7 +3347,9 @@ async def get_account_nonce(self, account_address: str) -> int:
33473347

33483348
async def get_account_next_index(self, account_address: str) -> int:
33493349
"""
3350-
Returns next index for the given account address, taking into account the transaction pool.
3350+
This method maintains a cache of nonces for each account ss58address.
3351+
Upon subsequent calls, it will return the cached nonce + 1 instead of fetching from the chain.
3352+
This allows for correct nonce management in-case of async context when gathering co-routines.
33513353
33523354
Args:
33533355
account_address: SS58 formatted address

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "async-substrate-interface"
3-
version = "1.0.0rc3"
3+
version = "1.0.0rc4"
44
description = "Asyncio library for interacting with substrate. Mostly API-compatible with py-substrate-interface"
55
readme = "README.md"
66
license = { file = "LICENSE" }

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="async-substrate-interface",
5-
version="1.0.0rc3",
5+
version="1.0.0rc4",
66
description="Asyncio library for interacting with substrate.",
77
long_description=open("README.md").read(),
88
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)