|
5 | 5 | import time
|
6 | 6 | from io import BytesIO
|
7 | 7 | from pathlib import Path
|
8 |
| -from typing import Any, Dict, Mapping, NoReturn, Optional, Tuple, Union |
| 8 | +from typing import Any, Dict, Mapping, NoReturn, Optional, Tuple, Union, overload |
9 | 9 |
|
10 | 10 | import aiohttp
|
11 | 11 | from aleph_message.models import (
|
|
39 | 39 | from .abstract import AuthenticatedAlephClient
|
40 | 40 | from .http import AlephHttpClient
|
41 | 41 |
|
| 42 | +try: |
| 43 | + from typing import override # type: ignore |
| 44 | +except ImportError: |
| 45 | + from typing_extensions import override # type: ignore |
| 46 | + |
| 47 | + |
42 | 48 | logger = logging.getLogger(__name__)
|
43 | 49 |
|
44 | 50 | try:
|
@@ -679,3 +685,45 @@ async def _upload_file_native(
|
679 | 685 | # nodes.
|
680 | 686 | _, status = await self._broadcast(message=message, sync=sync)
|
681 | 687 | return message, status
|
| 688 | + |
| 689 | + @overload |
| 690 | + def _resolve_address(self, address: str) -> str: ... |
| 691 | + |
| 692 | + @overload |
| 693 | + def _resolve_address(self, address: None) -> str: ... |
| 694 | + |
| 695 | + @override |
| 696 | + def _resolve_address(self, address: Optional[str] = None) -> str: |
| 697 | + """ |
| 698 | + Resolve the address to use. Prefer the provided address, fallback to account. |
| 699 | + """ |
| 700 | + if address: |
| 701 | + return address |
| 702 | + if self.account: |
| 703 | + return self.account.get_address() |
| 704 | + |
| 705 | + raise ValueError("No address provided and no account configured") |
| 706 | + |
| 707 | + @override |
| 708 | + async def get_vouchers(self, address: Optional[str] = None) -> list: |
| 709 | + """ |
| 710 | + Retrieve all vouchers for the account / specific address, across EVM and Solana chains. |
| 711 | + """ |
| 712 | + address = address or self.account.get_address() |
| 713 | + return await super().get_vouchers(address=address) |
| 714 | + |
| 715 | + @override |
| 716 | + async def get_evm_vouchers(self, address: Optional[str] = None) -> list: |
| 717 | + """ |
| 718 | + Retrieve vouchers specific to EVM chains for a specific address. |
| 719 | + """ |
| 720 | + address = address or self.account.get_address() |
| 721 | + return await super().get_evm_vouchers(address=address) |
| 722 | + |
| 723 | + @override |
| 724 | + async def get_solana_vouchers(self, address: Optional[str] = None) -> list: |
| 725 | + """ |
| 726 | + Fetch Solana vouchers for a specific address. |
| 727 | + """ |
| 728 | + address = address or self.account.get_address() |
| 729 | + return await super().get_solana_vouchers(address=address) |
0 commit comments