Skip to content

Commit

Permalink
Add getValidatorInfo() method
Browse files Browse the repository at this point in the history
  • Loading branch information
platfowner committed Apr 1, 2024
1 parent fb73bb4 commit 0579ba7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
23 changes: 21 additions & 2 deletions ain/ain.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async def getBlockByHash(
"""Gets a block with the given block hash.
Args:
blockHash (str]): The block hash.
blockHash (str): The block hash.
returnTransactionObjects (bool): If `True`, returns the full transaction objects.
If `False`, returns only the transaction hashes. Default to `False`.
Expand Down Expand Up @@ -204,7 +204,7 @@ async def getBlockTransactionCountByHash(
"""Fetches block transaction count with a block hash.
Args:
blockNumber (int): The block number.
blockHash (str): The block hash.
Returns:
The block transaction count.
Expand All @@ -216,6 +216,25 @@ async def getBlockTransactionCountByHash(
},
)

async def getValidatorInfo(
self,
address: str,
) -> Any:
"""Fetches the information of the given validator address.
Args:
address (str): The block number.
Returns:
The validator information.
"""
return await self.provider.send(
"ain_getValidatorInfo",
{
"address": address,
},
)

async def getProposer(
self,
blockHashOrBlockNumber: Union[str, int],
Expand Down
8 changes: 8 additions & 0 deletions tests/test_ain.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,14 @@ async def test00GetBlockTransactionCountByHash(self):
txCount = await self.ain.getBlockTransactionCountByHash(lastBlock["hash"])
self.assertIsNotNone(txCount)

@asyncTest
async def test00GetValidatorInfo(self):
lastBlock= await self.ain.getLastBlock()
self.assertIsNotNone(lastBlock)
self.assertIsNotNone(lastBlock["proposer"])
validatorInfo = await self.ain.getValidatorInfo(lastBlock["proposer"])
self.assertIsNotNone(validatorInfo)

@asyncTest
async def test00GetProposer(self):
proposer = await self.ain.getProposer(1)
Expand Down

0 comments on commit 0579ba7

Please sign in to comment.