Skip to content

Commit

Permalink
feat(docs): partially document addresses (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Aug 15, 2024
1 parent 5518f7e commit 8824118
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
4 changes: 3 additions & 1 deletion eth_portfolio/_ledgers/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
logger = logging.getLogger(__name__)

class BadResponse(Exception):
pass
"""
Exception raised for errors in the response from the web3 provider.
"""


T = TypeVar('T')
Expand Down
48 changes: 48 additions & 0 deletions eth_portfolio/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,34 @@ async def describe(self, block: int) -> WalletBalances:

@stuck_coro_debugger
async def assets(self, block: Optional[Block] = None) -> TokenBalances:
"""
Retrieves the balances for every asset in the wallet at a given block.
Args:
block (optional): The block number to query. Defaults to None.
Returns:
:class:`~eth_portfolio.typing.TokenBalances`: The asset balances at `block`.
Examples:
>>> assets = await address.assets(12345678)
"""
return await self.balances(block=block, sync=False)

@stuck_coro_debugger
async def debt(self, block: Optional[Block] = None) -> RemoteTokenBalances:
"""
Retrieves all debt balances for the wallet at a given block.
Args:
block (optional): The block number. Defaults to None.
Returns:
:class:`~eth_portfolio.typing.RemoteTokenBalances`: The debt balances at `block`.
Examples:
>>> debt = await address.debt(12345678)
"""
return await protocols.lending.debt(self.address, block=block)

@stuck_coro_debugger
Expand All @@ -91,10 +115,34 @@ async def balances(self, block: Optional[Block]) -> TokenBalances:

@stuck_coro_debugger
async def eth_balance(self, block: Optional[Block]) -> Balance:
"""
Retrieves the ETH balance for the wallet at a given block.
Args:
block: The block number.
Returns:
:class:`~eth_portfolio.typing.Balance`: The ETH balance at `block`.
Examples:
>>> eth_balance = await address.eth_balance(12345678)
"""
return await balances.load_eth_balance(self.address, block)

@stuck_coro_debugger
async def token_balances(self, block) -> TokenBalances:
"""
Retrieves the balances for all tokens in the wallet at a given block.
Args:
block: The block number.
Returns:
:class:`~eth_portfolio.typing.TokenBalances`: The token balances at `block`.
Examples:
>>> token_balances = await address.token_balances(12345678)
"""
try:
data = a_sync.map(
balances.load_token_balance,
Expand Down

0 comments on commit 8824118

Please sign in to comment.