|
1 | 1 | """Manager for multitenancy.""" |
2 | 2 |
|
| 3 | +from abc import ABC, abstractmethod |
3 | 4 | from datetime import datetime |
4 | 5 | import logging |
5 | | -from abc import abstractmethod, ABC |
| 6 | +from typing import Iterable, List, Optional, cast |
6 | 7 |
|
7 | 8 | import jwt |
8 | | -from typing import Iterable, List, Optional, cast |
9 | 9 |
|
10 | | -from ..core.profile import ( |
11 | | - Profile, |
12 | | - ProfileSession, |
13 | | -) |
14 | | -from ..messaging.responder import BaseResponder |
15 | 10 | from ..config.injection_context import InjectionContext |
16 | | -from ..wallet.models.wallet_record import WalletRecord |
17 | | -from ..wallet.base import BaseWallet |
18 | 11 | from ..core.error import BaseError |
19 | | -from ..protocols.routing.v1_0.manager import RouteNotFoundError, RoutingManager |
20 | | -from ..protocols.routing.v1_0.models.route_record import RouteRecord |
21 | | -from ..transport.wire_format import BaseWireFormat |
22 | | -from ..storage.base import BaseStorage |
23 | | -from ..storage.error import StorageNotFoundError |
| 12 | +from ..core.profile import Profile, ProfileSession |
24 | 13 | from ..protocols.coordinate_mediation.v1_0.manager import ( |
25 | 14 | MediationManager, |
26 | 15 | MediationRecord, |
27 | 16 | ) |
28 | | - |
| 17 | +from ..protocols.coordinate_mediation.v1_0.route_manager import RouteManager |
| 18 | +from ..protocols.routing.v1_0.manager import RouteNotFoundError, RoutingManager |
| 19 | +from ..protocols.routing.v1_0.models.route_record import RouteRecord |
| 20 | +from ..storage.base import BaseStorage |
| 21 | +from ..transport.wire_format import BaseWireFormat |
| 22 | +from ..wallet.base import BaseWallet |
| 23 | +from ..wallet.models.wallet_record import WalletRecord |
29 | 24 | from .error import WalletKeyMissingError |
30 | 25 |
|
31 | 26 | LOGGER = logging.getLogger(__name__) |
@@ -204,8 +199,8 @@ async def create_wallet( |
204 | 199 | public_did_info = await wallet.get_public_did() |
205 | 200 |
|
206 | 201 | if public_did_info: |
207 | | - await self.add_key( |
208 | | - wallet_record.wallet_id, public_did_info.verkey, skip_if_exists=True |
| 202 | + await profile.inject(RouteManager).route_public_did( |
| 203 | + profile, public_did_info.verkey |
209 | 204 | ) |
210 | 205 | except Exception: |
211 | 206 | await wallet_record.delete_record(session) |
@@ -285,49 +280,6 @@ async def remove_wallet_profile(self, profile: Profile): |
285 | 280 |
|
286 | 281 | """ |
287 | 282 |
|
288 | | - async def add_key( |
289 | | - self, wallet_id: str, recipient_key: str, *, skip_if_exists: bool = False |
290 | | - ): |
291 | | - """ |
292 | | - Add a wallet key to map incoming messages to specific subwallets. |
293 | | -
|
294 | | - Args: |
295 | | - wallet_id: The wallet id the key corresponds to |
296 | | - recipient_key: The recipient key belonging to the wallet |
297 | | - skip_if_exists: Whether to skip the action if the key is already registered |
298 | | - for relaying / mediation |
299 | | - """ |
300 | | - |
301 | | - LOGGER.info( |
302 | | - f"Add route record for recipient {recipient_key} to wallet {wallet_id}" |
303 | | - ) |
304 | | - routing_mgr = RoutingManager(self._profile) |
305 | | - mediation_mgr = MediationManager(self._profile) |
306 | | - mediation_record = await mediation_mgr.get_default_mediator() |
307 | | - |
308 | | - if skip_if_exists: |
309 | | - try: |
310 | | - async with self._profile.session() as session: |
311 | | - await RouteRecord.retrieve_by_recipient_key(session, recipient_key) |
312 | | - |
313 | | - # If no error is thrown, it means there is already a record |
314 | | - return |
315 | | - except (StorageNotFoundError): |
316 | | - pass |
317 | | - |
318 | | - await routing_mgr.create_route_record( |
319 | | - recipient_key=recipient_key, internal_wallet_id=wallet_id |
320 | | - ) |
321 | | - |
322 | | - # External mediation |
323 | | - if mediation_record: |
324 | | - keylist_updates = await mediation_mgr.add_key(recipient_key) |
325 | | - |
326 | | - responder = self._profile.inject(BaseResponder) |
327 | | - await responder.send( |
328 | | - keylist_updates, connection_id=mediation_record.connection_id |
329 | | - ) |
330 | | - |
331 | 283 | async def create_auth_token( |
332 | 284 | self, wallet_record: WalletRecord, wallet_key: str = None |
333 | 285 | ) -> str: |
|
0 commit comments