Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit cb5bc32f8d0462d3b7e8b8b9f57cec0aae93c6e9
Author: ff137 <[email protected]>
Date:   Tue Nov 12 13:01:19 2024 +0200

    loud_sound: Expand logging for Ledger Configuration

    Signed-off-by: ff137 <[email protected]>

commit 855fea2d19a752f63b5a15ed3965f521952238c8
Author: ff137 <[email protected]>
Date:   Tue Nov 12 11:04:16 2024 +0200

    bug: Fix registering and loading of modules

    Signed-off-by: ff137 <[email protected]>

commit 3a852195048d398c5ff63bbdb60c74c8e0ae6631
Author: ff137 <[email protected]>
Date:   Mon Nov 11 10:53:30 2024 +0200

    art: Enable trace logs for remaining modules

    Signed-off-by: ff137 <[email protected]>

commit 597aff574eacda773fb58a05f15993259f060f2b
Author: ff137 <[email protected]>
Date:   Mon Nov 11 10:22:45 2024 +0200

    art:

    Signed-off-by: ff137 <[email protected]>

commit 888f68190e3f8f24d511f5f3b727149757408402
Author: ff137 <[email protected]>
Date:   Mon Nov 11 10:22:16 2024 +0200

    loud_sound: Log a warning if resource not found, instead of passing

    Signed-off-by: ff137 <[email protected]>

commit 33a633259675acab118b08c3e6574ee097f9cba9
Author: ff137 <[email protected]>
Date:   Thu Nov 7 21:37:52 2024 +0200

    loud_sound: Expand logging for ClassLoader

    Signed-off-by: ff137 <[email protected]>

commit 0cc1cae8163187617a95534d77b99e2683d26ac5
Author: ff137 <[email protected]>
Date:   Thu Nov 7 20:58:12 2024 +0200

    bug: Handle case that load_module return type is Optional

    Signed-off-by: ff137 <[email protected]>

commit 33dc62fe6472c0d9109d347cd50747481275c651
Author: ff137 <[email protected]>
Date:   Thu Nov 7 20:15:18 2024 +0200

    art:

    Signed-off-by: ff137 <[email protected]>

commit 6ea5fe7d07ab9e575fdf9fe88ae9490f08e6794e
Author: ff137 <[email protected]>
Date:   Thu Nov 7 18:37:06 2024 +0200

    white_check_mark: Modify log assertion to be more robust

    Signed-off-by: ff137 <[email protected]>

commit 0abdad40e13cb69cb1338173f6ddabfc1937bd81
Author: ff137 <[email protected]>
Date:   Thu Nov 7 17:31:20 2024 +0200

    test_tube: Debug log assertion test failing sporadically

    Filter the logs being read by module name, and add short sleep to allow log handlers to flush

    Signed-off-by: ff137 <[email protected]>

commit 09707b891a4cd3f97e5577237a90a4070b6e1922
Author: ff137 <[email protected]>
Date:   Thu Nov 7 17:17:42 2024 +0200

    art:

    Signed-off-by: ff137 <[email protected]>

commit eca18b04bde3c7b4b069010ee589cfeb01d28c36
Author: ff137 <[email protected]>
Date:   Thu Nov 7 17:06:32 2024 +0200

    white_check_mark: Reset the logging states before and after TestLoggingUtils is run

    Signed-off-by: ff137 <[email protected]>

commit 49507fac6f7fe2de5c9ce0cb3b3f7df680e77a6b
Author: ff137 <[email protected]>
Date:   Thu Nov 7 16:03:20 2024 +0200

    white_check_mark: Add unit tests for adding trace level functionality

    Signed-off-by: ff137 <[email protected]>

commit fededd2562529089c4cb2f9a5e4b8e3a5bcc7b7b
Author: ff137 <[email protected]>
Date:   Thu Nov 7 15:22:01 2024 +0200

    loud_sound: Expand logging for Conductor start and stop

    Signed-off-by: ff137 <[email protected]>

commit ba354f46af8c52de7e4d0293f9946acbd637c44e
Author: ff137 <[email protected]>
Date:   Thu Nov 7 15:14:10 2024 +0200

    art: Update newly added logs to be trace level instead of debug

    Signed-off-by: ff137 <[email protected]>

commit 2c14ed7ffb654e23feecbb7f92e5962b3a97dfdd
Author: ff137 <[email protected]>
Date:   Thu Nov 7 15:08:53 2024 +0200

    art: Update newly added logs to be trace level instead of debug

    Signed-off-by: ff137 <[email protected]>

commit ef734ebc7dca4b975fb5718aa716a94c34a600a4
Author: ff137 <[email protected]>
Date:   Thu Nov 7 15:00:22 2024 +0200

    art: Add Logger

    Signed-off-by: ff137 <[email protected]>

commit 315da25a57b262bd60e2cf0ec8db7128a5bff99b
Author: ff137 <[email protected]>
Date:   Thu Nov 7 15:00:11 2024 +0200

    art: Ensure trace level can only be added once

    Signed-off-by: ff137 <[email protected]>

commit 64b7b55d5c8cc3f6b2c85bd3a7484c41af5eee0e
Author: ff137 <[email protected]>
Date:   Thu Nov 7 14:59:43 2024 +0200

    sparkles: Add custom trace log level

    Signed-off-by: ff137 <[email protected]>

commit 2e238e1885cffe15b9023b61684a2723764c8b67
Author: ff137 <[email protected]>
Date:   Thu Nov 7 14:17:10 2024 +0200

    art:

    Signed-off-by: ff137 <[email protected]>

commit 649b1f71da81c5c2a856fbf5ac128156aedda722
Author: ff137 <[email protected]>
Date:   Thu Nov 7 14:15:39 2024 +0200

    white_check_mark: Fix test by adding __name__ to mock object

    Signed-off-by: ff137 <[email protected]>

commit a7954d668aa288db22dd5ba0f6cfa434032870ef
Author: ff137 <[email protected]>
Date:   Thu Nov 7 13:55:19 2024 +0200

    art:

    Signed-off-by: ff137 <[email protected]>

commit 507b0a9a589b137a8206e860a3412dab53ef85d3
Author: ff137 <[email protected]>
Date:   Thu Nov 7 13:51:54 2024 +0200

    Revert ":art: Rename method and remove redundant main call"

    This reverts commit 2f6526d.

    Signed-off-by: ff137 <[email protected]>

commit 80e4d2311eec2303f55e9519c9969c753a6e7537
Author: ff137 <[email protected]>
Date:   Thu Nov 7 13:37:00 2024 +0200

    white_check_mark: Fix test by using assertLogs instead of capturing stdout

    Signed-off-by: ff137 <[email protected]>

commit 09bd5d287c54f611fb362f79479caba3a2493771
Author: ff137 <[email protected]>
Date:   Thu Nov 7 13:30:26 2024 +0200

    art: Correct to uphold previous "Module doesn't exist" log behaviour

    Signed-off-by: ff137 <[email protected]>

commit a4d51a248cc8f5192a7623848dd85681e7e84413
Author: ff137 <[email protected]>
Date:   Thu Nov 7 13:05:40 2024 +0200

    loud_sound: Expand logging for Conductor setup

    Signed-off-by: ff137 <[email protected]>

commit 21237b9f451e33293b27849b25a73a8493316dad
Author: ff137 <[email protected]>
Date:   Thu Nov 7 12:58:06 2024 +0200

    art: Replace almost all print statements with info logs

    Signed-off-by: ff137 <[email protected]>

commit 1a7ec30b895c6e898337927a842ac04524e88a12
Author: ff137 <[email protected]>
Date:   Thu Nov 7 12:38:00 2024 +0200

    art: Replace print statements with info logs

    Signed-off-by: ff137 <[email protected]>

commit fd6f669b957355321b159a7192a3b5a1433b7aa5
Author: ff137 <[email protected]>
Date:   Thu Nov 7 12:26:40 2024 +0200

    loud_sound: Add debug logging to post_process_routes

    Signed-off-by: ff137 <[email protected]>

commit 9d10b1f00fdba13de564b1d36dda34a3d59c49cd
Author: ff137 <[email protected]>
Date:   Thu Nov 7 12:26:17 2024 +0200

    loud_sound: Add debug logging to register_protocol_events

    Signed-off-by: ff137 <[email protected]>

commit 884facc0ce41ded0cf07923a6f0589a26f74bf7b
Author: ff137 <[email protected]>
Date:   Thu Nov 7 12:25:52 2024 +0200

    loud_sound: Add debug logging to register_admin_routes

    Signed-off-by: ff137 <[email protected]>

commit ec1c69012b5a0577816343ec7e9f87aac2b9fc47
Author: ff137 <[email protected]>
Date:   Thu Nov 7 12:25:30 2024 +0200

    loud_sound: Add debug logging to load_protocols

    Signed-off-by: ff137 <[email protected]>

commit 526c2e7825770c4aad054df34b2050ff93a5bc94
Author: ff137 <[email protected]>
Date:   Thu Nov 7 12:24:10 2024 +0200

    loud_sound: Add debug logging to load_protocol_version

    Signed-off-by: ff137 <[email protected]>

commit b4fe36e16e92230527415ededd70191d0b49c4ef
Author: ff137 <[email protected]>
Date:   Thu Nov 7 12:23:58 2024 +0200

    loud_sound: Add debug logging to init_context

    Signed-off-by: ff137 <[email protected]>

commit d04bf3f2140730c9258c98010649500360f95eec
Author: ff137 <[email protected]>
Date:   Thu Nov 7 11:45:36 2024 +0200

    art:

    Signed-off-by: ff137 <[email protected]>

commit 6630df8bfb5e9f58459f09c7b16fb7c52c6a4eee
Author: ff137 <[email protected]>
Date:   Thu Nov 7 11:42:34 2024 +0200

    art: Deduplicate registering list of plugins

    Signed-off-by: ff137 <[email protected]>

commit 5c236509ee1153841c9fc086761e045ff95e6611
Author: ff137 <[email protected]>
Date:   Thu Nov 7 11:42:14 2024 +0200

    loud_sound: Add debug logging to Context Builder

    Signed-off-by: ff137 <[email protected]>

commit 26e272a4c8d4cf8f065fd8cff3ef85ca1d3ed283
Author: ff137 <[email protected]>
Date:   Wed Nov 6 21:08:48 2024 +0200

    art:

    Signed-off-by: ff137 <[email protected]>

commit 3f151399486ba9c99ba3d15e47eb1dd7583159f4
Author: ff137 <[email protected]>
Date:   Wed Nov 6 21:07:22 2024 +0200

    art: Rename method and remove redundant main call

    Signed-off-by: ff137 <[email protected]>

commit b728f948b2780b837f2bde6fd90107dc3311e4ff
Author: ff137 <[email protected]>
Date:   Wed Nov 6 20:36:43 2024 +0200

    art: improve logging in register_package

    Signed-off-by: ff137 <[email protected]>

commit facff607c2daac0b9f075f2fa8388fd54c248cd4
Author: ff137 <[email protected]>
Date:   Wed Nov 6 20:27:33 2024 +0200

    art: Refactor `register_plugin` steps for maintainability

    Signed-off-by: ff137 <[email protected]>

commit 3c7dee8
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Wed Nov 20 16:42:10 2024 +0000

    chore(deps): Bump aiohttp (openwallet-foundation#3342)

    Bumps the pip group with 1 update in the /scenarios directory: [aiohttp](https://github.com/aio-libs/aiohttp).

    Updates `aiohttp` from 3.10.5 to 3.10.11
    - [Release notes](https://github.com/aio-libs/aiohttp/releases)
    - [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst)
    - [Commits](aio-libs/aiohttp@v3.10.5...v3.10.11)

    ---
    updated-dependencies:
    - dependency-name: aiohttp
      dependency-type: indirect
      dependency-group: pip
    ...

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: jamshale <[email protected]>

commit f5c49b0
Author: jamshale <[email protected]>
Date:   Mon Nov 18 14:40:31 2024 -0800

    did:tdw resolver (openwallet-foundation#3237)

    * did:tdw resolver

    Signed-off-by: jamshale <[email protected]>

    * Update unit tests

    Signed-off-by: jamshale <[email protected]>

    * Update poetry.lock

    Signed-off-by: jamshale <[email protected]>

    ---------

    Signed-off-by: jamshale <[email protected]>

commit c18f6d1
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Nov 18 09:05:59 2024 -0800

    chore(deps): Bump pyjwt from 2.9.0 to 2.10.0 (openwallet-foundation#3339)

    Bumps [pyjwt](https://github.com/jpadilla/pyjwt) from 2.9.0 to 2.10.0.
    - [Release notes](https://github.com/jpadilla/pyjwt/releases)
    - [Changelog](https://github.com/jpadilla/pyjwt/blob/master/CHANGELOG.rst)
    - [Commits](jpadilla/pyjwt@2.9.0...2.10.0)

    ---
    updated-dependencies:
    - dependency-name: pyjwt
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 2522877
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Nov 18 08:38:07 2024 -0800

    chore(deps): Bump aiohttp from 3.11.0 to 3.11.2 (openwallet-foundation#3340)

    Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.11.0 to 3.11.2.
    - [Release notes](https://github.com/aio-libs/aiohttp/releases)
    - [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst)
    - [Commits](aio-libs/aiohttp@v3.11.0...v3.11.2)

    ---
    updated-dependencies:
    - dependency-name: aiohttp
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 1d07ede
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Nov 18 08:28:57 2024 -0800

    chore(deps-dev): Bump ruff from 0.7.3 to 0.7.4 (openwallet-foundation#3341)

    Bumps [ruff](https://github.com/astral-sh/ruff) from 0.7.3 to 0.7.4.
    - [Release notes](https://github.com/astral-sh/ruff/releases)
    - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)
    - [Commits](astral-sh/ruff@0.7.3...0.7.4)

    ---
    updated-dependencies:
    - dependency-name: ruff
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit a41b4fb
Merge: b7d27fa d84a384
Author: Daniel Bluhm <[email protected]>
Date:   Thu Nov 14 15:19:46 2024 -0600

    Merge pull request openwallet-foundation#3338 from didx-xyz/fix-deprecations

    🎨 Fix current test warnings

commit d84a384
Author: ff137 <[email protected]>
Date:   Thu Nov 14 13:23:00 2024 +0200

    :art: Remove unnecessary asyncio pytest markers

    Resolves unclosed event loop warnings.

    Signed-off-by: ff137 <[email protected]>

commit c65f6ce
Author: ff137 <[email protected]>
Date:   Thu Nov 14 13:04:38 2024 +0200

    :arrow_up: Upgrade aiohttp to latest release and update lock file

    Signed-off-by: ff137 <[email protected]>

commit 6f967c6
Author: ff137 <[email protected]>
Date:   Thu Nov 14 13:02:35 2024 +0200

    :art: Filter Pydantic UserWarning in test

    Signed-off-by: ff137 <[email protected]>

commit 70364a4
Author: ff137 <[email protected]>
Date:   Thu Nov 14 12:59:48 2024 +0200

    :art: Filter Aries RFC 0160 DeprecationWarning in tests

    Signed-off-by: ff137 <[email protected]>

commit 573c208
Author: ff137 <[email protected]>
Date:   Thu Nov 14 12:51:51 2024 +0200

    :art: Replace deprecated `scope` keyword with `loop_scope`

    Signed-off-by: ff137 <[email protected]>

commit 36e47ce
Author: ff137 <[email protected]>
Date:   Thu Nov 14 11:25:23 2024 +0200

    :art: Replace deprecated `open_binary` method with `files`

    Signed-off-by: ff137 <[email protected]>

commit d8632ee
Author: ff137 <[email protected]>
Date:   Thu Nov 14 11:14:27 2024 +0200

    :art: Rename class to resolve PytestCollectionWarning

    Signed-off-by: ff137 <[email protected]>

commit 02019c3
Author: ff137 <[email protected]>
Date:   Thu Nov 14 11:10:57 2024 +0200

    :arrow_up: Upgrade python-dateutil

    Resolves calling deprecated `datetime.utcfromtimestamp` method

    Signed-off-by: ff137 <[email protected]>
  • Loading branch information
ff137 committed Nov 21, 2024
1 parent 765e281 commit 008fc18
Show file tree
Hide file tree
Showing 27 changed files with 1,749 additions and 774 deletions.
13 changes: 9 additions & 4 deletions acapy_agent/__main__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
"""acapy_agent package entry point."""

import logging
import os
import sys

LOGGER = logging.getLogger(__name__)


def init_debug(args):
"""Initialize debugging environment."""
Expand All @@ -26,16 +29,18 @@ def init_debug(args):
import debugpy

debugpy.listen((DAP_HOST, DAP_PORT))
print(f"=== Waiting for debugger to attach to {DAP_HOST}:{DAP_PORT} ===")
LOGGER.info(
f"=== Waiting for debugger to attach to {DAP_HOST}:{DAP_PORT} ==="
)
debugpy.wait_for_client()
except ImportError:
print("debugpy library was not found")
LOGGER.error("debugpy library was not found")

if ENABLE_PYDEVD_PYCHARM or "--debug-pycharm" in args:
try:
import pydevd_pycharm

print(
LOGGER.info(
"aca-py remote debugging to "
f"{PYDEVD_PYCHARM_HOST}:{PYDEVD_PYCHARM_AGENT_PORT}"
)
Expand All @@ -47,7 +52,7 @@ def init_debug(args):
suspend=False,
)
except ImportError:
print("pydevd_pycharm library was not found")
LOGGER.error("pydevd_pycharm library was not found")


def run(args):
Expand Down
7 changes: 5 additions & 2 deletions acapy_agent/commands/provision.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Provision command for setting up agent settings before starting."""

import asyncio
import logging
from typing import Sequence

from configargparse import ArgumentParser
Expand All @@ -22,6 +23,8 @@
from ..storage.base import BaseStorage
from . import PROG

LOGGER = logging.getLogger(__name__)


class ProvisionError(BaseError):
"""Base exception for provisioning errors."""
Expand Down Expand Up @@ -58,9 +61,9 @@ async def provision(settings: dict):
)

if await ledger_config(root_profile, public_did and public_did.did, True):
print("Ledger configured")
LOGGER.info("Ledger configured")
else:
print("Ledger not configured")
LOGGER.warning("Ledger not configured")

await root_profile.close()
except BaseError as e:
Expand Down
4 changes: 2 additions & 2 deletions acapy_agent/commands/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async def start_app(conductor: Conductor):

async def shutdown_app(conductor: Conductor):
"""Shut down."""
print("\nShutting down")
LOGGER.info("Shutting down")
await conductor.stop()


Expand Down Expand Up @@ -59,7 +59,7 @@ def execute(argv: Sequence[str] = None):
# Run the application
if uvloop:
uvloop.install()
print("uvloop installed")
LOGGER.info("uvloop installed")
run_loop(start_app(conductor), shutdown_app(conductor))


Expand Down
2 changes: 1 addition & 1 deletion acapy_agent/config/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def get_registered(cls, category: Optional[str] = None):


def create_argument_parser(*, prog: Optional[str] = None):
"""Create am instance of an arg parser, force yaml format for external config."""
"""Create an instance of an arg parser, force yaml format for external config."""
return ArgumentParser(config_file_parser_class=YAMLConfigFileParser, prog=prog)


Expand Down
73 changes: 43 additions & 30 deletions acapy_agent/config/default_context.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
"""Classes for configuring the default injection context."""

import logging

from ..anoncreds.registry import AnonCredsRegistry
from ..cache.base import BaseCache
from ..cache.in_memory import InMemoryCache
from ..config.logging.utils import add_trace_level
from ..core.event_bus import EventBus
from ..core.goal_code_registry import GoalCodeRegistry
from ..core.plugin_registry import PluginRegistry
Expand All @@ -26,17 +29,23 @@
from .injection_context import InjectionContext
from .provider import CachedProvider, ClassProvider

LOGGER = logging.getLogger(__name__)
add_trace_level() # Allow trace logs from this module


class DefaultContextBuilder(ContextBuilder):
"""Default context builder."""

async def build_context(self) -> InjectionContext:
"""Build the base injection context; set DIDComm prefix to emit."""
LOGGER.trace("Building new injection context with settings: %s", self.settings)

context = InjectionContext(settings=self.settings)
context.settings.set_default("default_label", "Aries Cloud Agent")

if context.settings.get("timing.enabled"):
timing_log = context.settings.get("timing.log_file")
LOGGER.trace("Enabling timing collector with log file: %s", timing_log)
collector = Collector(log_path=timing_log)
context.injector.bind_instance(Collector, collector)

Expand All @@ -63,11 +72,8 @@ async def build_context(self) -> InjectionContext:

# DIDComm Messaging
if context.settings.get("experiment.didcomm_v2"):
from didcomm_messaging import (
CryptoService,
PackagingService,
RoutingService,
)
LOGGER.info("DIDComm v2 experimental mode enabled")
from didcomm_messaging import CryptoService, PackagingService, RoutingService
from didcomm_messaging.crypto.backend.askar import AskarCryptoService

context.injector.bind_instance(CryptoService, AskarCryptoService())
Expand All @@ -81,18 +87,21 @@ async def build_context(self) -> InjectionContext:

async def bind_providers(self, context: InjectionContext):
"""Bind various class providers."""
LOGGER.trace("Begin binding providers to context")

context.injector.bind_provider(ProfileManager, ProfileManagerProvider())

wallet_type = self.settings.get("wallet.type")
if wallet_type == "askar-anoncreds":
LOGGER.trace("Using AnonCreds tails server")
context.injector.bind_provider(
BaseTailsServer,
ClassProvider(
"acapy_agent.tails.anoncreds_tails_server.AnonCredsTailsServer",
),
)
else:
LOGGER.trace("Using Indy tails server")
context.injector.bind_provider(
BaseTailsServer,
ClassProvider(
Expand All @@ -104,12 +113,7 @@ async def bind_providers(self, context: InjectionContext):
context.injector.bind_provider(
BaseWireFormat,
CachedProvider(
# StatsProvider(
ClassProvider("acapy_agent.transport.pack_format.PackWireFormat"),
# (
# "encode_message", "parse_message"
# ),
# )
),
)

Expand All @@ -120,6 +124,7 @@ async def bind_providers(self, context: InjectionContext):
async def load_plugins(self, context: InjectionContext):
"""Set up plugin registry and load plugins."""

LOGGER.trace("Initializing plugin registry")
plugin_registry = PluginRegistry(
blocklist=self.settings.get("blocked_plugins", [])
)
Expand All @@ -130,18 +135,18 @@ async def load_plugins(self, context: InjectionContext):
if not self.settings.get("transport.disabled"):
plugin_registry.register_package("acapy_agent.protocols")

# Currently providing admin routes only
plugin_registry.register_plugin("acapy_agent.holder")

plugin_registry.register_plugin("acapy_agent.ledger")

plugin_registry.register_plugin("acapy_agent.messaging.jsonld")
plugin_registry.register_plugin("acapy_agent.resolver")
plugin_registry.register_plugin("acapy_agent.settings")
plugin_registry.register_plugin("acapy_agent.vc")
plugin_registry.register_plugin("acapy_agent.vc.data_integrity")
plugin_registry.register_plugin("acapy_agent.wallet")
plugin_registry.register_plugin("acapy_agent.wallet.keys")
# Define plugin groups
default_plugins = [
"acapy_agent.holder",
"acapy_agent.ledger",
"acapy_agent.messaging.jsonld",
"acapy_agent.resolver",
"acapy_agent.settings",
"acapy_agent.vc",
"acapy_agent.vc.data_integrity",
"acapy_agent.wallet",
"acapy_agent.wallet.keys",
]

anoncreds_plugins = [
"acapy_agent.anoncreds",
Expand All @@ -157,26 +162,34 @@ async def load_plugins(self, context: InjectionContext):
"acapy_agent.revocation",
]

def register_askar_plugins():
for plugin in askar_plugins:
def register_plugins(plugins: list[str], plugin_type: str):
"""Register a group of plugins with logging."""
LOGGER.trace("Registering %s plugins", plugin_type)
for plugin in plugins:
plugin_registry.register_plugin(plugin)

def register_askar_plugins():
register_plugins(askar_plugins, "askar")

def register_anoncreds_plugins():
for plugin in anoncreds_plugins:
plugin_registry.register_plugin(plugin)
register_plugins(anoncreds_plugins, "anoncreds")

if wallet_type == "askar-anoncreds":
register_anoncreds_plugins()
else:
register_askar_plugins()
register_plugins(default_plugins, "default")

if context.settings.get("multitenant.admin_enabled"):
LOGGER.trace("Multitenant admin enabled - registering additional plugins")
plugin_registry.register_plugin("acapy_agent.multitenant.admin")
register_askar_plugins()
register_anoncreds_plugins()
else:
if wallet_type == "askar-anoncreds":
register_anoncreds_plugins()
else:
register_askar_plugins()

# Register external plugins
for plugin_path in self.settings.get("external_plugins", []):
LOGGER.trace("Registering external plugin: %s", plugin_path)
plugin_registry.register_plugin(plugin_path)

# Register message protocols
Expand Down
30 changes: 29 additions & 1 deletion acapy_agent/config/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@ async def fetch_genesis_transactions(genesis_url: str) -> str:
# https://github.com/openwallet-foundation/acapy/issues/1745
return await fetch(genesis_url, headers=headers, max_attempts=20)
except FetchError as e:
LOGGER.error("Error retrieving genesis transactions from %s: %s", genesis_url, e)
raise ConfigError("Error retrieving ledger genesis transactions") from e


async def get_genesis_transactions(settings: Settings) -> str:
"""Fetch genesis transactions if necessary."""

LOGGER.debug("Getting genesis transactions from settings")
txns = settings.get("ledger.genesis_transactions")
LOGGER.debug("Genesis transactions from settings: %s", "found" if txns else "absent")
if not txns:
LOGGER.debug("No genesis transactions found in settings")
if settings.get("ledger.genesis_url"):
txns = await fetch_genesis_transactions(settings["ledger.genesis_url"])
elif settings.get("ledger.genesis_file"):
Expand All @@ -51,8 +55,10 @@ async def get_genesis_transactions(settings: Settings) -> str:
with open(genesis_path, "r") as genesis_file:
txns = genesis_file.read()
except IOError as e:
LOGGER.error("Failed to read genesis file: %s", str(e))
raise ConfigError("Error reading ledger genesis transactions") from e
if txns:
LOGGER.debug("Storing genesis transactions in settings")
settings["ledger.genesis_transactions"] = txns
return txns

Expand All @@ -63,6 +69,8 @@ async def load_multiple_genesis_transactions_from_config(settings: Settings):
ledger_config_list = settings.get("ledger.ledger_config_list")
ledger_txns_list = []
write_ledger_set = False
LOGGER.debug("Processing %d ledger configs", len(ledger_config_list))

for config in ledger_config_list:
txns = None
if "genesis_transactions" in config:
Expand All @@ -74,11 +82,12 @@ async def load_multiple_genesis_transactions_from_config(settings: Settings):
try:
genesis_path = config.get("genesis_file")
LOGGER.info(
"Reading ledger genesis transactions from: %s", genesis_path
"Reading ledger genesis transactions from file: %s", genesis_path
)
with open(genesis_path, "r") as genesis_file:
txns = genesis_file.read()
except IOError as e:
LOGGER.error("Failed to read genesis file: %s", str(e))
raise ConfigError("Error reading ledger genesis transactions") from e
is_write_ledger = (
False if config.get("is_write") is None else config.get("is_write")
Expand Down Expand Up @@ -119,13 +128,18 @@ async def load_multiple_genesis_transactions_from_config(settings: Settings):
" genesis_file and genesis_transactions provided."
)
settings["ledger.ledger_config_list"] = ledger_txns_list
LOGGER.debug("Processed %d ledger configs successfully", len(ledger_txns_list))


async def ledger_config(
profile: Profile, public_did: str, provision: bool = False
) -> bool:
"""Perform Indy ledger configuration."""

LOGGER.debug(
"Configuring ledger for profile %s and public_did %s", profile.name, public_did
)

session = await profile.session()

ledger = session.inject_or(BaseLedger)
Expand All @@ -136,32 +150,46 @@ async def ledger_config(
async with ledger:
# Check transaction author agreement acceptance
if not ledger.read_only:
LOGGER.debug("Checking transaction author agreement")
taa_info = await ledger.get_txn_author_agreement()
if taa_info["taa_required"] and public_did:
LOGGER.debug("TAA acceptance required")
taa_accepted = await ledger.get_latest_txn_author_acceptance()
if (
not taa_accepted
or taa_info["taa_record"]["digest"] != taa_accepted["digest"]
):
LOGGER.info("TAA acceptance needed - performing acceptance")
if not await accept_taa(ledger, profile, taa_info, provision):
LOGGER.warning("TAA acceptance failed")
return False
LOGGER.info("TAA acceptance completed")

# Publish endpoints if necessary - skipped if TAA is required but not accepted
endpoint = session.settings.get("default_endpoint")
if public_did:
wallet = session.inject(BaseWallet)
try:
LOGGER.debug("Setting DID endpoint to: %s", endpoint)
await wallet.set_did_endpoint(public_did, endpoint, ledger)
except LedgerError as x_ledger:
LOGGER.error("Error setting DID endpoint: %s", x_ledger.message)
raise ConfigError(x_ledger.message) from x_ledger # e.g., read-only

# Publish profile endpoint if ledger is NOT read-only
profile_endpoint = session.settings.get("profile_endpoint")
if profile_endpoint and not ledger.read_only:
LOGGER.debug(
"Publishing profile endpoint: %s for DID: %s",
profile_endpoint,
public_did,
)
await ledger.update_endpoint_for_did(
public_did, profile_endpoint, EndpointType.PROFILE
)
LOGGER.info("Profile endpoint published successfully")

LOGGER.info("Ledger configuration complete")
return True


Expand Down
Loading

0 comments on commit 008fc18

Please sign in to comment.