openwallet-foundation / credo-ts

Typescript framework for building decentralized identity and verifiable credential solutions
https://credo.js.org
Apache License 2.0
264 stars 200 forks source link

Dependency manager can't resolve Didrepository / AgentConfig #1674

Open Sshovon opened 10 months ago

Sshovon commented 10 months ago

I am trying to integrate a custom did method, but the dependency manager is encountering issues while resolving AgentConfig and DidRepository.

export class CustomModule implements Module {
    public constructor() {}
    public register(dependencyManager: DependencyManager) {
        dependencyManager.resolve(AgentConfig)
    }
    public async initialize(agentContext: AgentContext): Promise<void> { }
}

When I include the CustomModule in the agent modules, the dependency manager struggles to resolve AgentConfig. I attempted to manually register AgentConfig at runtime using dependencyManager.registerInstance, but it didn't resolve the issue. image If I include the CustomModule in the agent module, the agent encounters an error during startup.

Screenshot from 2023-12-18 15-47-40 If I omit the CustomModule, the agent starts successfully and creates a DID, but it encounters a failure while attempting to store the DID in the wallet. The issue seems to be related to resolving the DidRepository in the DID registrar, resulting in an error similar to the one seen in the last screenshot, but this time for the DidRepository instead of the agent configuration.

const didRepository = agentContext.dependencyManager.resolve(DidRepository)
await didRepository.save(agentContext, didRecord)

Possibly, the issue might be related to the runtime dependency injection.

TimoGlastra commented 10 months ago

As discussed during Aries WG call: