Skip to content

Commit

Permalink
⬆️ Upgrade ACA-Py version to 0.12.1rc0 (#37)
Browse files Browse the repository at this point in the history
* ⬆️ Upgrade acapy version to 0.12

* ⬆️ Upgrade pytest dependencies

* Update version of plugin to 0.12.0

* Update lock file

* ♻️ synchronise 0.12 changes to multitenant/admin/routes

* ➕ Add acapy dependencies: askar, indy-vdr, and anoncreds

* Update lock file

* ⬆️ Use ACA-Py 0.12.1rc0

* Update lock file

* 🎨 only call wallet_record.save again if group_id was included

* ✅ synchronise our tests with latest test changes in aca-py

* ⬆️ upgrade packages to match aca-py

* Update lock file

* use 0.12.1rc0
  • Loading branch information
ff137 authored Apr 25, 2024
1 parent c5b09c3 commit 72c04be
Show file tree
Hide file tree
Showing 5 changed files with 867 additions and 514 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/hyperledger/aries-cloudagent-python:py3.9-0.11.0
FROM ghcr.io/hyperledger/aries-cloudagent-python:py3.9-0.12.1rc0

COPY acapy_wallet_groups_plugin acapy_wallet_groups_plugin
COPY config config
Expand Down
53 changes: 37 additions & 16 deletions acapy_wallet_groups_plugin/v1_0/routes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Multitenant admin routes.
This file has been copied from: https://github.com/hyperledger/aries-cloudagent-python/blob/0.11.0/aries_cloudagent/multitenant/admin/routes.py
This file has been copied from: https://github.com/hyperledger/aries-cloudagent-python/blob/0.12.0/aries_cloudagent/multitenant/admin/routes.py
We do this because we want to override two endpoints
"""
Expand Down Expand Up @@ -31,6 +31,12 @@
)
from aries_cloudagent.multitenant.base import BaseError, BaseMultitenantManager
from aries_cloudagent.storage.error import StorageError, StorageNotFoundError
from aries_cloudagent.utils.endorsement_setup import (
attempt_auto_author_with_endorser_setup,
)
from aries_cloudagent.utils.profiles import (
subwallet_type_not_same_as_base_wallet_raise_web_exception,
)
from aries_cloudagent.wallet.models.wallet_record import (
WalletRecord,
WalletRecordSchema,
Expand Down Expand Up @@ -76,8 +82,7 @@ def format_wallet_record(wallet_record: WalletRecord):
@querystring_schema(WalletListQueryStringWithGroupIdSchema())
@response_schema(WalletListSchema(), 200, description="")
async def wallets_list(request: web.BaseRequest):
"""
Request handler for listing all internal subwallets.
"""Request handler for listing all internal subwallets.
Args:
request: aiohttp request object
Expand Down Expand Up @@ -109,8 +114,7 @@ async def wallets_list(request: web.BaseRequest):
@match_info_schema(WalletIdMatchInfoSchema())
@response_schema(WalletRecordSchema(), 200, description="")
async def wallet_get(request: web.BaseRequest):
"""
Request handler for getting a single subwallet.
"""Request handler for getting a single subwallet.
Args:
request: aiohttp request object
Expand Down Expand Up @@ -140,8 +144,7 @@ async def wallet_get(request: web.BaseRequest):
@request_schema(CreateWalletRequestWithGroupIdSchema)
@response_schema(CreateWalletResponseSchema(), 200, description="")
async def wallet_create(request: web.BaseRequest):
"""
Request handler for adding a new subwallet for handling by the agent.
"""Request handler for adding a new subwallet for handling by the agent.
Args:
request: aiohttp request object
Expand All @@ -150,6 +153,13 @@ async def wallet_create(request: web.BaseRequest):
context: AdminRequestContext = request["context"]
body = await request.json()

base_wallet_type = context.profile.settings.get("wallet.type")
sub_wallet_type = body.get("wallet_type", base_wallet_type)

subwallet_type_not_same_as_base_wallet_raise_web_exception(
base_wallet_type, sub_wallet_type
)

key_management_mode = body.get("key_management_mode") or WalletRecord.MODE_MANAGED
wallet_key = body.get("wallet_key")
group_id = body.get("group_id")
Expand All @@ -161,7 +171,7 @@ async def wallet_create(request: web.BaseRequest):
wallet_dispatch_type = "base"

settings = {
"wallet.type": body.get("wallet_type") or "in_memory",
"wallet.type": sub_wallet_type,
"wallet.name": body.get("wallet_name"),
"wallet.key": wallet_key,
"wallet.webhook_urls": wallet_webhook_urls,
Expand Down Expand Up @@ -199,6 +209,11 @@ async def wallet_create(request: web.BaseRequest):
await wallet_record.save(session)

token = await multitenant_mgr.create_auth_token(wallet_record, wallet_key)

wallet_profile = await multitenant_mgr.get_wallet_profile(
context, wallet_record, extra_settings=settings
)
await attempt_auto_author_with_endorser_setup(wallet_profile)
except BaseError as err:
raise web.HTTPBadRequest(reason=err.roll_up) from err

Expand All @@ -214,8 +229,7 @@ async def wallet_create(request: web.BaseRequest):
@request_schema(UpdateWalletRequestWithGroupIdSchema)
@response_schema(WalletRecordSchema(), 200, description="")
async def wallet_update(request: web.BaseRequest):
"""
Request handler for updating a existing subwallet for handling by the agent.
"""Request handler for updating a existing subwallet for handling by the agent.
Args:
request: aiohttp request object
Expand All @@ -230,11 +244,18 @@ async def wallet_update(request: web.BaseRequest):
label = body.get("label")
image_url = body.get("image_url")
group_id = body.get("group_id")
extra_settings = body.get("extra_settings") or {}
extra_settings = body.get("extra_settings")

if all(
v is None
for v in (wallet_webhook_urls, wallet_dispatch_type, label, image_url, group_id)
for v in (
wallet_webhook_urls,
wallet_dispatch_type,
label,
image_url,
extra_settings,
group_id,
)
):
raise web.HTTPBadRequest(reason="At least one parameter is required.")

Expand All @@ -258,7 +279,7 @@ async def wallet_update(request: web.BaseRequest):
if group_id is not None:
settings["wallet.group_id"] = group_id # add group_id to wallet settings

extra_subwallet_setting = get_extra_settings_dict_per_tenant(extra_settings)
extra_subwallet_setting = get_extra_settings_dict_per_tenant(extra_settings or {})
settings.update(extra_subwallet_setting)

try:
Expand All @@ -268,9 +289,9 @@ async def wallet_update(request: web.BaseRequest):
if group_id is not None:
wallet_record.group_id = group_id

# Save the record with the new custom group_id
async with context.profile.session() as session:
await wallet_record.save(session)
# Save the record with the new custom group_id
async with context.profile.session() as session:
await wallet_record.save(session)

result = format_wallet_record(wallet_record)
except StorageNotFoundError as err:
Expand Down
Loading

0 comments on commit 72c04be

Please sign in to comment.