33import abc
44import sys
55from typing import (
6+ AbstractSet ,
67 Any ,
78 AsyncIterator ,
89 Awaitable ,
@@ -16,8 +17,12 @@ from typing import (
1617 overload ,
1718)
1819
19- from .. import Connection as _Connection , QueryStream as _QueryStream
20- from ...damlast .daml_lf_1 import TypeConName
20+ from .. import (
21+ Connection as _Connection ,
22+ PackageService as _PackageService ,
23+ QueryStream as _QueryStream ,
24+ )
25+ from ...damlast .daml_lf_1 import PackageRef , TypeConName
2126from ...prim import ContractData , ContractId
2227from ...query import Queries , Query
2328from ..api_types import (
@@ -26,15 +31,17 @@ from ..api_types import (
2631 Command ,
2732 CreateEvent ,
2833 ExerciseResponse ,
34+ PartyInfo ,
2935 SubmitResponse ,
3036)
37+ from .pkgloader import PackageLoader
3138
3239if sys .version_info >= (3 , 8 ):
3340 from typing import Protocol , runtime_checkable
3441else :
3542 from typing_extensions import Protocol , runtime_checkable
3643
37- __all__ = ["Connection" , "QueryStream" , "QueryStreamBase" ]
44+ __all__ = ["PackageService" , " Connection" , "QueryStream" , "QueryStreamBase" , "PackageLoader " ]
3845
3946Self = TypeVar ("Self" )
4047CreateFn = TypeVar ("CreateFn" , bound = Callable [[CreateEvent ], SubmitResponse ])
@@ -72,8 +79,12 @@ class ABoundaryDecorator(Protocol):
7279 @overload
7380 def __call__ (self , __fn : ABoundaryFn ) -> ABoundaryFn : ...
7481
82+ class PackageService (_PackageService , Protocol ):
83+ async def get_package (self , __package_id : PackageRef ) -> bytes : ...
84+ async def list_package_ids (self ) -> AbstractSet [PackageRef ]: ...
85+
7586@runtime_checkable
76- class Connection (_Connection , Protocol ):
87+ class Connection (_Connection , PackageService , Protocol ):
7788 async def __aenter__ (self : Self ) -> Self : ...
7889 async def __aexit__ (self , exc_type , exc_val , exc_tb ) -> None : ...
7990 async def open (self ) -> None : ...
@@ -143,6 +154,11 @@ class Connection(_Connection, Protocol):
143154 self , __template_id : str = "*" , __query : Query = None , * , offset : Optional [str ] = None
144155 ) -> QueryStream : ...
145156 def stream_many (self , * q : Queries , offset : Optional [str ] = None ) -> QueryStream : ...
157+ async def allocate_party (
158+ self , * , identifier_hint : Optional [str ] = None , display_name : Optional [str ] = None
159+ ) -> PartyInfo : ...
160+ async def list_known_parties (self ) -> Sequence [PartyInfo ]: ...
161+ async def upload_package (self , contents : bytes ) -> None : ...
146162
147163# PyCharm doesn't know what to make of these overloads with respect to the parent protocol,
148164# but mypy understands that these type signatures do not conflict with the parent base class
0 commit comments