Skip to content

Commit 61128aa

Browse files
committed
Merge branch 'feature/did-method-registry' into feature/did-method-key-type-registry
2 parents 9dc2fa3 + 55ab059 commit 61128aa

35 files changed

Lines changed: 449 additions & 460 deletions

File tree

aries_cloudagent/config/default_context.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
"""Classes for configuring the default injection context."""
22

3-
from .base_context import ContextBuilder
4-
from .injection_context import InjectionContext
5-
from .provider import CachedProvider, ClassProvider
6-
73
from ..cache.base import BaseCache
84
from ..cache.in_memory import InMemoryCache
95
from ..core.event_bus import EventBus
6+
from ..core.goal_code_registry import GoalCodeRegistry
107
from ..core.plugin_registry import PluginRegistry
118
from ..core.profile import ProfileManager, ProfileManagerProvider
129
from ..core.protocol_registry import ProtocolRegistry
13-
from ..core.goal_code_registry import GoalCodeRegistry
14-
from ..resolver.did_resolver import DIDResolver
15-
from ..tails.base import BaseTailsServer
16-
1710
from ..protocols.actionmenu.v1_0.base_service import BaseMenuService
1811
from ..protocols.actionmenu.v1_0.driver_service import DriverMenuService
1912
from ..protocols.didcomm_prefix import DIDCommPrefix
2013
from ..protocols.introduction.v0_1.base_service import BaseIntroductionService
2114
from ..protocols.introduction.v0_1.demo_service import DemoIntroductionService
15+
from ..resolver.did_resolver import DIDResolver
16+
from ..tails.base import BaseTailsServer
2217
from ..transport.wire_format import BaseWireFormat
23-
from ..utils.stats import Collector
2418
from ..utils.dependencies import is_indy_sdk_module_installed
19+
from ..utils.stats import Collector
20+
from ..wallet.did_method import DIDMethods
21+
from .base_context import ContextBuilder
22+
from .injection_context import InjectionContext
23+
from .provider import CachedProvider, ClassProvider
2524

2625

2726
class DefaultContextBuilder(ContextBuilder):
@@ -51,6 +50,7 @@ async def build_context(self) -> InjectionContext:
5150

5251
# Global did resolver
5352
context.injector.bind_instance(DIDResolver, DIDResolver([]))
53+
context.injector.bind_instance(DIDMethods, DIDMethods())
5454

5555
await self.bind_providers(context)
5656
await self.load_plugins(context)

aries_cloudagent/config/wallet.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from ..wallet.base import BaseWallet
1212
from ..wallet.crypto import seed_to_did
1313
from ..wallet.did_info import DIDInfo
14-
from ..wallet.did_method import DIDMethod
14+
from ..wallet.did_method import SOV
1515
from ..wallet.key_type import KeyType
1616
from .base import ConfigError
1717
from .injection_context import InjectionContext
@@ -79,7 +79,7 @@ async def wallet_config(
7979
if wallet_seed and seed_to_did(wallet_seed) != public_did:
8080
if context.settings.get("wallet.replace_public_did"):
8181
replace_did_info = await wallet.create_local_did(
82-
method=DIDMethod.SOV, key_type=KeyType.ED25519, seed=wallet_seed
82+
method=SOV, key_type=KeyType.ED25519, seed=wallet_seed
8383
)
8484
public_did = replace_did_info.did
8585
await wallet.set_public_did(public_did)
@@ -99,7 +99,7 @@ async def wallet_config(
9999
metadata = {"endpoint": endpoint} if endpoint else None
100100

101101
local_did_info = await wallet.create_local_did(
102-
method=DIDMethod.SOV,
102+
method=SOV,
103103
key_type=KeyType.ED25519,
104104
seed=wallet_seed,
105105
metadata=metadata,
@@ -110,7 +110,7 @@ async def wallet_config(
110110
print(f"Verkey: {local_did_info.verkey}")
111111
else:
112112
public_did_info = await wallet.create_public_did(
113-
method=DIDMethod.SOV, key_type=KeyType.ED25519, seed=wallet_seed
113+
method=SOV, key_type=KeyType.ED25519, seed=wallet_seed
114114
)
115115
public_did = public_did_info.did
116116
if provision:
@@ -128,7 +128,7 @@ async def wallet_config(
128128
test_seed = "testseed000000000000000000000001"
129129
if test_seed:
130130
await wallet.create_local_did(
131-
method=DIDMethod.SOV,
131+
method=SOV,
132132
key_type=KeyType.ED25519,
133133
seed=test_seed,
134134
metadata={"endpoint": "1.2.3.4:8021"},

aries_cloudagent/core/tests/test_conductor.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from ...version import __version__
4242
from ...wallet.base import BaseWallet
4343
from ...wallet.key_type import KeyType
44-
from ...wallet.did_method import DIDMethod
44+
from ...wallet.did_method import SOV
4545

4646
from .. import conductor as test_module
4747

@@ -131,7 +131,7 @@ async def test_startup(self):
131131

132132
wallet = session.inject(BaseWallet)
133133
await wallet.create_public_did(
134-
DIDMethod.SOV,
134+
SOV,
135135
KeyType.ED25519,
136136
)
137137

@@ -600,7 +600,7 @@ async def test_admin(self):
600600
session = await conductor.root_profile.session()
601601
wallet = session.inject(BaseWallet)
602602
await wallet.create_public_did(
603-
DIDMethod.SOV,
603+
SOV,
604604
KeyType.ED25519,
605605
)
606606

@@ -644,7 +644,7 @@ async def test_admin_startx(self):
644644
session = await conductor.root_profile.session()
645645
wallet = session.inject(BaseWallet)
646646
await wallet.create_public_did(
647-
DIDMethod.SOV,
647+
SOV,
648648
KeyType.ED25519,
649649
)
650650

@@ -716,7 +716,7 @@ async def test_start_static(self):
716716
session = await conductor.root_profile.session()
717717
wallet = session.inject(BaseWallet)
718718
await wallet.create_public_did(
719-
DIDMethod.SOV,
719+
SOV,
720720
KeyType.ED25519,
721721
)
722722

@@ -886,7 +886,7 @@ async def test_print_invite_connection(self):
886886
session = await conductor.root_profile.session()
887887
wallet = session.inject(BaseWallet)
888888
await wallet.create_public_did(
889-
DIDMethod.SOV,
889+
SOV,
890890
KeyType.ED25519,
891891
)
892892

@@ -1389,7 +1389,7 @@ async def test_startup_x_version_mismatch(self):
13891389

13901390
wallet = session.inject(BaseWallet)
13911391
await wallet.create_public_did(
1392-
DIDMethod.SOV,
1392+
SOV,
13931393
KeyType.ED25519,
13941394
)
13951395

@@ -1426,7 +1426,7 @@ async def test_startup_x_no_storage_version(self):
14261426

14271427
wallet = session.inject(BaseWallet)
14281428
await wallet.create_public_did(
1429-
DIDMethod.SOV,
1429+
SOV,
14301430
KeyType.ED25519,
14311431
)
14321432

aries_cloudagent/ledger/tests/test_indy.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from ...wallet.error import WalletNotFoundError
2121
from ...wallet.indy import IndyOpenWallet, IndySdkWallet
2222
from ...wallet.key_type import KeyType
23-
from ...wallet.did_method import DIDMethod
23+
from ...wallet.did_method import SOV
2424

2525
from ..endpoint_type import EndpointType
2626
from ..indy import (
@@ -70,7 +70,7 @@ async def setUp(self):
7070
did=self.test_did,
7171
verkey="3Dn1SJNPaCXcvvJvSbsFWP2xaCjMom3can8CQNhWrTRx",
7272
metadata={"test": "test"},
73-
method=DIDMethod.SOV,
73+
method=SOV,
7474
key_type=KeyType.ED25519,
7575
)
7676
self.test_verkey = "3Dn1SJNPaCXcvvJvSbsFWP2xaCjMom3can8CQNhWrTRx"
@@ -1219,7 +1219,7 @@ async def test_send_credential_definition(
12191219
did=self.test_did,
12201220
verkey=self.test_verkey,
12211221
metadata=None,
1222-
method=DIDMethod.SOV,
1222+
method=SOV,
12231223
key_type=KeyType.ED25519,
12241224
)
12251225
mock_did = mock_wallet_get_public_did.return_value
@@ -1299,7 +1299,7 @@ async def test_send_credential_definition_endorse_only(
12991299
self.test_did,
13001300
self.test_verkey,
13011301
None,
1302-
DIDMethod.SOV,
1302+
SOV,
13031303
KeyType.ED25519,
13041304
)
13051305
async with ledger:
@@ -1382,7 +1382,7 @@ async def test_send_credential_definition_exists_in_ledger_and_wallet(
13821382
did=self.test_did,
13831383
verkey=self.test_verkey,
13841384
metadata=None,
1385-
method=DIDMethod.SOV,
1385+
method=SOV,
13861386
key_type=KeyType.ED25519,
13871387
)
13881388

@@ -1794,7 +1794,7 @@ async def test_send_credential_definition_on_ledger_in_wallet(
17941794
did=self.test_did,
17951795
verkey=self.test_verkey,
17961796
metadata=None,
1797-
method=DIDMethod.SOV,
1797+
method=SOV,
17981798
key_type=KeyType.ED25519,
17991799
)
18001800
mock_did = mock_wallet_get_public_did.return_value
@@ -1868,7 +1868,7 @@ async def test_send_credential_definition_create_cred_def_exception(
18681868
did=self.test_did,
18691869
verkey=self.test_verkey,
18701870
metadata=None,
1871-
method=DIDMethod.SOV,
1871+
method=SOV,
18721872
key_type=KeyType.ED25519,
18731873
)
18741874
async with ledger:

aries_cloudagent/ledger/tests/test_indy_vdr.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from ...indy.issuer import IndyIssuer
1111
from ...wallet.base import BaseWallet
1212
from ...wallet.key_type import KeyType
13-
from ...wallet.did_method import DIDMethod
13+
from ...wallet.did_method import SOV, DIDMethods
1414
from ...wallet.did_info import DIDInfo
1515

1616
from ..endpoint_type import EndpointType
@@ -67,7 +67,7 @@ async def test_submit_signed(
6767
ledger: IndyVdrLedger,
6868
):
6969
wallet = (await ledger.profile.session()).wallet
70-
test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519)
70+
test_did = await wallet.create_public_did(SOV, KeyType.ED25519)
7171
test_msg = indy_vdr.ledger.build_get_txn_request(test_did.did, 1, 1)
7272

7373
async with ledger:
@@ -120,7 +120,7 @@ async def test_submit_signed_taa_accept(
120120
ledger: IndyVdrLedger,
121121
):
122122
wallet = (await ledger.profile.session()).wallet
123-
test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519)
123+
test_did = await wallet.create_public_did(SOV, KeyType.ED25519)
124124

125125
async with ledger:
126126
test_msg = indy_vdr.ledger.build_get_txn_request(test_did.did, 1, 1)
@@ -188,7 +188,7 @@ async def test_txn_endorse(
188188
with pytest.raises(BadLedgerRequestError):
189189
await ledger.txn_endorse(request_json=test_msg.body)
190190

191-
test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519)
191+
test_did = await wallet.create_public_did(SOV, KeyType.ED25519)
192192
test_msg.set_endorser(test_did.did)
193193

194194
endorsed_json = await ledger.txn_endorse(request_json=test_msg.body)
@@ -201,7 +201,7 @@ async def test_send_schema(
201201
ledger: IndyVdrLedger,
202202
):
203203
wallet = (await ledger.profile.session()).wallet
204-
test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519)
204+
test_did = await wallet.create_public_did(SOV, KeyType.ED25519)
205205
issuer = async_mock.MagicMock(IndyIssuer)
206206
issuer.create_schema.return_value = (
207207
"schema_issuer_did:schema_name:9.1",
@@ -262,7 +262,7 @@ async def test_send_schema_already_exists(
262262
ledger: IndyVdrLedger,
263263
):
264264
wallet = (await ledger.profile.session()).wallet
265-
test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519)
265+
test_did = await wallet.create_public_did(SOV, KeyType.ED25519)
266266
issuer = async_mock.MagicMock(IndyIssuer)
267267
issuer.create_schema.return_value = (
268268
"schema_issuer_did:schema_name:9.1",
@@ -292,7 +292,7 @@ async def test_send_schema_ledger_read_only(
292292
ledger: IndyVdrLedger,
293293
):
294294
wallet = (await ledger.profile.session()).wallet
295-
test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519)
295+
test_did = await wallet.create_public_did(SOV, KeyType.ED25519)
296296
issuer = async_mock.MagicMock(IndyIssuer)
297297
issuer.create_schema.return_value = (
298298
"schema_issuer_did:schema_name:9.1",
@@ -321,7 +321,7 @@ async def test_send_schema_ledger_transaction_error(
321321
ledger: IndyVdrLedger,
322322
):
323323
wallet = (await ledger.profile.session()).wallet
324-
test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519)
324+
test_did = await wallet.create_public_did(SOV, KeyType.ED25519)
325325
issuer = async_mock.MagicMock(IndyIssuer)
326326
issuer.create_schema.return_value = (
327327
"schema_issuer_did:schema_name:9.1",
@@ -383,7 +383,7 @@ async def test_send_credential_definition(
383383
ledger: IndyVdrLedger,
384384
):
385385
wallet = (await ledger.profile.session()).wallet
386-
test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519)
386+
test_did = await wallet.create_public_did(SOV, KeyType.ED25519)
387387
schema_id = "55GkHamhTU1ZbTbV2ab9DE:2:schema_name:9.1"
388388
cred_def_id = "55GkHamhTU1ZbTbV2ab9DE:3:CL:99:tag"
389389
cred_def = {
@@ -598,7 +598,7 @@ async def test_update_endpoint_for_did(
598598
ledger: IndyVdrLedger,
599599
):
600600
wallet = (await ledger.profile.session()).wallet
601-
test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519)
601+
test_did = await wallet.create_public_did(SOV, KeyType.ED25519)
602602
async with ledger:
603603
ledger.pool_handle.submit_request.side_effect = (
604604
{"data": None},
@@ -675,7 +675,7 @@ async def test_construct_attr_json(
675675
async def test_update_endpoint_for_did_calls_attr_json(self, ledger: IndyVdrLedger):
676676
routing_keys = ["3YJCx3TqotDWFGv7JMR5erEvrmgu5y4FDqjR7sKWxgXn"]
677677
wallet = (await ledger.profile.session()).wallet
678-
test_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519)
678+
test_did = await wallet.create_public_did(SOV, KeyType.ED25519)
679679

680680
async with ledger:
681681
with async_mock.patch.object(
@@ -742,8 +742,8 @@ async def test_register_nym_local(
742742
ledger: IndyVdrLedger,
743743
):
744744
wallet: BaseWallet = (await ledger.profile.session()).wallet
745-
public_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519)
746-
post_did = await wallet.create_local_did(DIDMethod.SOV, KeyType.ED25519)
745+
public_did = await wallet.create_public_did(SOV, KeyType.ED25519)
746+
post_did = await wallet.create_local_did(SOV, KeyType.ED25519)
747747
async with ledger:
748748
await ledger.register_nym(post_did.did, post_did.verkey)
749749
did = await wallet.get_local_did(post_did.did)
@@ -755,7 +755,7 @@ async def test_register_nym_non_local(
755755
ledger: IndyVdrLedger,
756756
):
757757
wallet: BaseWallet = (await ledger.profile.session()).wallet
758-
public_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519)
758+
public_did = await wallet.create_public_did(SOV, KeyType.ED25519)
759759
async with ledger:
760760
await ledger.register_nym("55GkHamhTU1ZbTbV2ab9DE", "verkey")
761761

@@ -898,7 +898,7 @@ async def test_send_revoc_reg_def(
898898
ledger: IndyVdrLedger,
899899
):
900900
wallet: BaseWallet = (await ledger.profile.session()).wallet
901-
public_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519)
901+
public_did = await wallet.create_public_did(SOV, KeyType.ED25519)
902902
async with ledger:
903903
reg_id = (
904904
"55GkHamhTU1ZbTbV2ab9DE:4:55GkHamhTU1ZbTbV2ab9DE:3:CL:99:tag:CL_ACCUM:0"
@@ -927,7 +927,7 @@ async def test_send_revoc_reg_entry(
927927
ledger: IndyVdrLedger,
928928
):
929929
wallet: BaseWallet = (await ledger.profile.session()).wallet
930-
public_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519)
930+
public_did = await wallet.create_public_did(SOV, KeyType.ED25519)
931931
async with ledger:
932932
reg_id = (
933933
"55GkHamhTU1ZbTbV2ab9DE:4:55GkHamhTU1ZbTbV2ab9DE:3:CL:99:tag:CL_ACCUM:0"
@@ -966,7 +966,7 @@ async def test_credential_definition_id2schema_id(self, ledger: IndyVdrLedger):
966966
@pytest.mark.asyncio
967967
async def test_rotate_did_keypair(self, ledger: IndyVdrLedger):
968968
wallet = (await ledger.profile.session()).wallet
969-
public_did = await wallet.create_public_did(DIDMethod.SOV, KeyType.ED25519)
969+
public_did = await wallet.create_public_did(SOV, KeyType.ED25519)
970970

971971
async with ledger:
972972
with async_mock.patch.object(
@@ -980,4 +980,5 @@ async def test_rotate_did_keypair(self, ledger: IndyVdrLedger):
980980
]
981981
),
982982
):
983+
ledger.profile.context.injector.bind_instance(DIDMethods, DIDMethods())
983984
await ledger.rotate_public_did_keypair()

0 commit comments

Comments
 (0)