Skip to content

Commit

Permalink
fix(anoncreds): migration script credential id (#1849)
Browse files Browse the repository at this point in the history
Signed-off-by: Ariel Gentile <gentilester@gmail.com>
  • Loading branch information
genaris authored Apr 30, 2024
1 parent 7ea616b commit e58ec5b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ async function testMigration(
threadId: 'threadId',
credentials: [
{
credentialRecordId: anonCredsRecord.id,
credentialRecordId: anonCredsRecord.credentialId,
credentialRecordType: 'anoncreds',
},
],
Expand Down Expand Up @@ -324,7 +324,7 @@ async function testMigration(
expect(anonCredsRepo.delete).toHaveBeenCalledTimes(1)
expect(credentialExchangeRepo.findByQuery).toHaveBeenCalledTimes(1)
expect(credentialExchangeRepo.findByQuery).toHaveBeenCalledWith(agent.context, {
credentialIds: [anonCredsRecord.id],
credentialIds: [anonCredsRecord.credentialId],
})
expect(credentialExchangeRepo.update).toHaveBeenCalledTimes(1)
expect(credentialExchangeRepo.update).toHaveBeenCalledWith(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@ async function migrateLegacyToW3cCredential(agentContext: AgentContext, legacyRe
// Find the credential exchange record bound to this anoncreds credential and update it to point to the newly created w3c record
const credentialExchangeRepository = agentContext.dependencyManager.resolve(CredentialRepository)
const [relatedCredentialExchangeRecord] = await credentialExchangeRepository.findByQuery(agentContext, {
credentialIds: [legacyRecord.id],
credentialIds: [legacyRecord.credentialId],
})

if (relatedCredentialExchangeRecord) {
// Replace the related binding by the new one
const credentialBindingIndex = relatedCredentialExchangeRecord.credentials.findIndex(
(binding) => binding.credentialRecordId === legacyRecord.id
(binding) => binding.credentialRecordId === legacyRecord.credentialId
)
if (credentialBindingIndex !== -1) {
relatedCredentialExchangeRecord.credentials[credentialBindingIndex] = {
Expand Down

0 comments on commit e58ec5b

Please sign in to comment.