Skip to content

Commit b72ac6d

Browse files
committed
feat: voucher AuthenticatedAlephHttpClient integrations
1 parent b4f9b41 commit b72ac6d

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

src/aleph/sdk/client/authenticated_http.py

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import time
66
from io import BytesIO
77
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
99

1010
import aiohttp
1111
from aleph_message.models import (
@@ -39,6 +39,12 @@
3939
from .abstract import AuthenticatedAlephClient
4040
from .http import AlephHttpClient
4141

42+
try:
43+
from typing import override # type: ignore
44+
except ImportError:
45+
from typing_extensions import override # type: ignore
46+
47+
4248
logger = logging.getLogger(__name__)
4349

4450
try:
@@ -679,3 +685,45 @@ async def _upload_file_native(
679685
# nodes.
680686
_, status = await self._broadcast(message=message, sync=sync)
681687
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

Comments
 (0)