Skip to content

Commit

Permalink
chore: deprecate injectionContainer on agent (#1241)
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra authored Jan 26, 2023
1 parent 0f6d231 commit b6ae948
Show file tree
Hide file tree
Showing 22 changed files with 43 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describeSkipNode17And18('credentials, BBS+ signature', () => {
'Faber Agent Credentials LD BBS+',
'Alice Agent Credentials LD BBS+'
))
wallet = faberAgent.injectionContainer.resolve<Wallet>(InjectionSymbols.Wallet)
wallet = faberAgent.dependencyManager.resolve<Wallet>(InjectionSymbols.Wallet)
await wallet.createKey({ keyType: KeyType.Ed25519, seed })
const key = await wallet.createKey({ keyType: KeyType.Bls12381g2, seed })

Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/agent/BaseAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ export abstract class BaseAgent<AgentModules extends ModulesMap = EmptyModuleMap
})
}

/**
* @deprecated The injectionContainer property has been deprecated in favour of the dependencyManager property.
*/
public get injectionContainer() {
return this.dependencyManager.container
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('credentials', () => {
aliceAgent.events
.observable<CredentialStateChangedEvent>(CredentialEventTypes.CredentialStateChanged)
.subscribe(aliceReplay)
wallet = faberAgent.injectionContainer.resolve<Wallet>(InjectionSymbols.Wallet)
wallet = faberAgent.dependencyManager.resolve<Wallet>(InjectionSymbols.Wallet)

await wallet.createKey({ seed, keyType: KeyType.Ed25519 })

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('credentials', () => {
AutoAcceptCredential.Always
))

wallet = faberAgent.injectionContainer.resolve<Wallet>(InjectionSymbols.Wallet)
wallet = faberAgent.dependencyManager.resolve<Wallet>(InjectionSymbols.Wallet)
await wallet.createKey({ seed, keyType: KeyType.Ed25519 })
signCredentialOptions = {
credential: TEST_LD_DOCUMENT,
Expand Down Expand Up @@ -142,7 +142,7 @@ describe('credentials', () => {
'alice agent: content-approved v2 jsonld',
AutoAcceptCredential.ContentApproved
))
wallet = faberAgent.injectionContainer.resolve<Wallet>(InjectionSymbols.Wallet)
wallet = faberAgent.dependencyManager.resolve<Wallet>(InjectionSymbols.Wallet)
await wallet.createKey({ seed, keyType: KeyType.Ed25519 })
signCredentialOptions = {
credential: TEST_LD_DOCUMENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('credentials', () => {
'Faber Agent Credentials LD',
'Alice Agent Credentials LD'
))
wallet = faberAgent.injectionContainer.resolve<Wallet>(InjectionSymbols.Wallet)
wallet = faberAgent.dependencyManager.resolve<Wallet>(InjectionSymbols.Wallet)
await wallet.createKey({ seed, keyType: KeyType.Ed25519 })
signCredentialOptions = {
credential: inputDocAsJson,
Expand Down Expand Up @@ -312,7 +312,6 @@ describe('credentials', () => {
threadId: faberCredentialRecord.threadId,
state: CredentialState.OfferReceived,
})
// didCommMessageRepository = faberAgent.injectionContainer.resolve(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve(DidCommMessageRepository)

const offerMessage = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ describe('dids', () => {
const ed25519PublicKeyBase58 = TypedArrayEncoder.toBase58(publicKeyEd25519)
const indyDid = indyDidFromPublicKeyBase58(ed25519PublicKeyBase58)

const wallet = agent.injectionContainer.resolve<Wallet>(InjectionSymbols.Wallet)
const wallet = agent.dependencyManager.resolve<Wallet>(InjectionSymbols.Wallet)
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain, @typescript-eslint/no-non-null-assertion
const submitterDid = `did:sov:${wallet.publicDid?.did!}`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for presentation from Alice')
faberProofExchangeRecord = await faberProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

let proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -159,7 +159,7 @@ describe('Present Proof', () => {
testLogger.test('Alice waits for proof request from Faber')
aliceProofExchangeRecord = await aliceProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

let request = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -212,7 +212,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for presentation from Alice')
faberProofExchangeRecord = await faberProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -266,7 +266,7 @@ describe('Present Proof', () => {
testLogger.test('Alice waits for proof request from Faber')
aliceProofExchangeRecord = await aliceProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

request = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Present Proof', () => {

faberProofExchangeRecord = await faberProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -118,7 +118,7 @@ describe('Present Proof', () => {
testLogger.test('Alice waits for proof request from Faber')
aliceProofExchangeRecord = await aliceProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const request = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for presentation from Alice')
faberProofExchangeRecord = await faberProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for presentation from Alice')
faberProofExchangeRecord = await faberProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('Present Proof', () => {
testLogger.test('Alice waits for proof request from Faber')
aliceProofExchangeRecord = await aliceProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const request = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for presentation from Alice')
faberProofExchangeRecord = await faberProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

let proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -188,7 +188,7 @@ describe('Present Proof', () => {
testLogger.test('Alice waits for proof request from Faber')
aliceProofExchangeRecord = await aliceProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

let request = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -241,7 +241,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for presentation from Alice')
faberProofExchangeRecord = await faberProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -319,7 +319,7 @@ describe('Present Proof', () => {
testLogger.test('Alice waits for proof request from Faber')
aliceProofExchangeRecord = await aliceProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

request = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for presentation from Alice')
faberProofExchangeRecord = await faberPresentationRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -118,7 +118,7 @@ describe('Present Proof', () => {
testLogger.test('Alice waits for proof request from Faber')
aliceProofExchangeRecord = await alicePresentationRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const request = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for presentation from Alice')
faberPresentationRecord = await faberPresentationRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberPresentationRecord.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for presentation from Alice')
faberProofExchangeRecord = await faberPresentationRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('Present Proof', () => {
testLogger.test('Alice waits for proof request from Faber')
aliceProofExchangeRecord = await alicePresentationRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const request = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/storage/migration/__tests__/0.1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('UpdateAssistant | v0.1 - v0.2', () => {
dependencyManager
)

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)

const updateAssistant = new UpdateAssistant(agent, {
v0_1ToV0_2: {
Expand Down Expand Up @@ -110,7 +110,7 @@ describe('UpdateAssistant | v0.1 - v0.2', () => {
dependencyManager
)

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)

const updateAssistant = new UpdateAssistant(agent, {
v0_1ToV0_2: {
Expand Down Expand Up @@ -174,7 +174,7 @@ describe('UpdateAssistant | v0.1 - v0.2', () => {
dependencyManager
)

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)

const updateAssistant = new UpdateAssistant(agent, {
v0_1ToV0_2: {
Expand Down Expand Up @@ -242,7 +242,7 @@ describe('UpdateAssistant | v0.1 - v0.2', () => {
dependencyManager
)

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)

const updateAssistant = new UpdateAssistant(agent, {
v0_1ToV0_2: {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/storage/migration/__tests__/0.2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('UpdateAssistant | v0.2 - v0.3.1', () => {
dependencyManager
)

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)

const updateAssistant = new UpdateAssistant(agent, {
v0_1ToV0_2: {
Expand Down Expand Up @@ -119,7 +119,7 @@ describe('UpdateAssistant | v0.2 - v0.3.1', () => {
dependencyManager
)

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)

// We need to manually initialize the wallet as we're using the in memory wallet service
// When we call agent.initialize() it will create the wallet and store the current framework
Expand Down Expand Up @@ -170,7 +170,7 @@ describe('UpdateAssistant | v0.2 - v0.3.1', () => {
dependencyManager
)

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)

// We need to manually initialize the wallet as we're using the in memory wallet service
// When we call agent.initialize() it will create the wallet and store the current framework
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/storage/migration/__tests__/0.3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('UpdateAssistant | v0.3 - v0.3.1', () => {
dependencyManager
)

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)

const updateAssistant = new UpdateAssistant(agent, {
v0_1ToV0_2: {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/storage/migration/__tests__/backup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('UpdateAssistant | Backup', () => {
// Expect an update is needed
expect(await updateAssistant.isUpToDate()).toBe(false)

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)
// Backup should not exist before update
expect(await fileSystem.exists(backupPath)).toBe(false)

Expand Down Expand Up @@ -128,7 +128,7 @@ describe('UpdateAssistant | Backup', () => {
},
])

const fileSystem = agent.injectionContainer.resolve<FileSystem>(InjectionSymbols.FileSystem)
const fileSystem = agent.dependencyManager.resolve<FileSystem>(InjectionSymbols.FileSystem)
// Backup should not exist before update
expect(await fileSystem.exists(backupPath)).toBe(false)

Expand Down
6 changes: 3 additions & 3 deletions packages/core/tests/v1-indy-proofs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for a presentation proposal from Alice')
faberProofExchangeRecord = await faberProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -390,7 +390,7 @@ describe('Present Proof', () => {
testLogger.test('Alice waits for presentation request from Faber')
aliceProofExchangeRecord = await aliceProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const request = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down Expand Up @@ -615,7 +615,7 @@ describe('Present Proof', () => {
testLogger.test('Alice waits for presentation request from Faber')
aliceProofExchangeRecord = await aliceProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const request = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/v2-indy-proofs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('Present Proof', () => {
testLogger.test('Faber waits for a presentation proposal from Alice')
faberProofExchangeRecord = await faberProofExchangeRecordPromise

didCommMessageRepository = faberAgent.injectionContainer.resolve<DidCommMessageRepository>(DidCommMessageRepository)
didCommMessageRepository = faberAgent.dependencyManager.resolve<DidCommMessageRepository>(DidCommMessageRepository)

const proposal = await didCommMessageRepository.findAgentMessage(faberAgent.context, {
associatedRecordId: faberProofExchangeRecord.id,
Expand Down
Loading

0 comments on commit b6ae948

Please sign in to comment.