Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from hyperledger:main #201

Merged
merged 7 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion aries_cloudagent/wallet/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
NON_SD_LIST_VALIDATE,
SD_JWT_EXAMPLE,
SD_JWT_VALIDATE,
UUID4_EXAMPLE,
UUID4_VALIDATE,
IndyDID,
StrOrDictField,
Uri,
Expand Down Expand Up @@ -172,6 +174,14 @@ class DIDEndpointWithTypeSchema(OpenAPISchema):
"example": ENDPOINT_TYPE_EXAMPLE,
},
)
mediation_id = fields.Str(
required=False,
validate=UUID4_VALIDATE,
metadata={
"description": "Medation ID to use for endpoint information.",
"example": UUID4_EXAMPLE,
},
)


class JWSCreateSchema(OpenAPISchema):
Expand Down Expand Up @@ -896,7 +906,7 @@ async def promote_wallet_public_did(
async with (
context.session() if is_ctx_admin_request else profile.session()
) as session:
wallet = session.inject_or(BaseWallet)
wallet = session.inject(BaseWallet)
did_info = await wallet.get_local_did(did)
info = await wallet.set_public_did(did_info)

Expand Down Expand Up @@ -951,6 +961,7 @@ async def wallet_set_did_endpoint(request: web.BaseRequest):
did = body["did"]
endpoint = body.get("endpoint")
endpoint_type = EndpointType.get(body.get("endpoint_type", EndpointType.ENDPOINT.w3c))
mediation_id = body.get("mediation_id")

create_transaction_for_endorser = json.loads(
request.query.get("create_transaction_for_endorser", "false")
Expand All @@ -960,6 +971,17 @@ async def wallet_set_did_endpoint(request: web.BaseRequest):
connection_id = request.query.get("conn_id")
attrib_def = None

profile = context.profile
route_manager = profile.inject(RouteManager)
mediation_record = await route_manager.mediation_record_if_id(
profile=profile, mediation_id=mediation_id, or_default=True
)
routing_keys, mediator_endpoint = await route_manager.routing_info(
profile,
mediation_record,
)
LOGGER.debug("Mediation info: %s, %s", routing_keys, mediator_endpoint)

# check if we need to endorse
if is_author_role(context.profile):
# authors cannot write to the ledger
Expand Down Expand Up @@ -1005,6 +1027,7 @@ async def wallet_set_did_endpoint(request: web.BaseRequest):
if not wallet:
raise web.HTTPForbidden(reason="No wallet available")
try:
endpoint = mediator_endpoint or endpoint
ledger = context.profile.inject_or(BaseLedger)
attrib_def = await wallet.set_did_endpoint(
did,
Expand All @@ -1013,6 +1036,7 @@ async def wallet_set_did_endpoint(request: web.BaseRequest):
endpoint_type,
write_ledger=write_ledger,
endorser_did=endorser_did,
routing_keys=routing_keys,
)
except WalletNotFoundError as err:
raise web.HTTPNotFound(reason=err.roll_up) from err
Expand Down
7 changes: 5 additions & 2 deletions aries_cloudagent/wallet/tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ class TestWalletRoutes(IsolatedAsyncioTestCase):
def setUp(self):
self.wallet = mock.create_autospec(BaseWallet)
self.session_inject = {BaseWallet: self.wallet}
self.route_mgr = mock.MagicMock()
self.route_mgr.mediation_record_if_id = mock.CoroutineMock(return_value=None)
self.route_mgr.routing_info = mock.CoroutineMock(return_value=(None, None))
self.profile = InMemoryProfile.test_profile(
settings={"admin.admin_api_key": "secret-key"}
settings={"admin.admin_api_key": "secret-key"},
bind={KeyTypes: KeyTypes(), RouteManager: self.route_mgr},
)
self.context = AdminRequestContext.test_context(self.session_inject, self.profile)
self.context.injector.bind_instance(KeyTypes, KeyTypes())
self.request_dict = {
"context": self.context,
"outbound_message_router": mock.CoroutineMock(),
Expand Down
2 changes: 1 addition & 1 deletion mkdocs-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

mkdocs-material==9.5.36
mkdocs-material==9.5.39
mike==2.1.3
40 changes: 20 additions & 20 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ didcomm-messaging = {version = "^0.1.1a0", optional = true }
[tool.poetry.group.dev.dependencies]
pre-commit = "~3.8.0"
# Sync with version in .pre-commit-config.yaml
ruff = "0.6.7"
ruff = "0.6.8"

sphinx="^5.3.0"
sphinx-rtd-theme=">=0.4.3"
Expand Down
Loading