From 86272bf734bd7801fdbb3968f8ea1fa6faa6e621 Mon Sep 17 00:00:00 2001 From: Shaanjot Gill Date: Mon, 20 Dec 2021 11:28:48 -0800 Subject: [PATCH] DID resolve bug fix Signed-off-by: Shaanjot Gill --- aries_cloudagent/ledger/multiple_ledger/base_manager.py | 6 +++++- .../ledger/multiple_ledger/tests/test_indy_manager.py | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/aries_cloudagent/ledger/multiple_ledger/base_manager.py b/aries_cloudagent/ledger/multiple_ledger/base_manager.py index 49af0efe3c..b421119d22 100644 --- a/aries_cloudagent/ledger/multiple_ledger/base_manager.py +++ b/aries_cloudagent/ledger/multiple_ledger/base_manager.py @@ -6,6 +6,7 @@ from ...core.error import BaseError from ...core.profile import Profile from ...ledger.base import BaseLedger +from ...messaging.valid import IndyDID class MultipleLedgerManagerError(BaseError): @@ -44,4 +45,7 @@ async def lookup_did_in_configured_ledgers( def extract_did_from_identifier(self, identifier: str) -> str: """Return did from record identifier (REV_REG_ID, CRED_DEF_ID, SCHEMA_ID).""" - return identifier.split(":")[0] + if bool(IndyDID.PATTERN.match(identifier)): + return identifier.split(":")[-1] + else: + return identifier.split(":")[0] diff --git a/aries_cloudagent/ledger/multiple_ledger/tests/test_indy_manager.py b/aries_cloudagent/ledger/multiple_ledger/tests/test_indy_manager.py index 8b7d4740dc..5dac56e7ed 100644 --- a/aries_cloudagent/ledger/multiple_ledger/tests/test_indy_manager.py +++ b/aries_cloudagent/ledger/multiple_ledger/tests/test_indy_manager.py @@ -428,6 +428,14 @@ def test_extract_did_from_identifier(self): ) == "WgWxqztrNooG92RXvxSTWv" ) + assert ( + self.manager.extract_did_from_identifier("WgWxqztrNooG92RXvxSTWv") + == "WgWxqztrNooG92RXvxSTWv" + ) + assert ( + self.manager.extract_did_from_identifier("did:sov:WgWxqztrNooG92RXvxSTWv") + == "WgWxqztrNooG92RXvxSTWv" + ) async def test_get_production_ledgers(self): assert len(await self.manager.get_prod_ledgers()) == 2