diff --git a/packages/browser-wallet/CHANGELOG.md b/packages/browser-wallet/CHANGELOG.md index 931543dd..10e793bc 100644 --- a/packages/browser-wallet/CHANGELOG.md +++ b/packages/browser-wallet/CHANGELOG.md @@ -10,6 +10,7 @@ - Verifiable credentials are now validated according to the schema when being added. This will e.g. block setting an attribute as an integer if the schema defines it as a string. - Refreshed the schema for credential schemas so that attribute types are now restricted as expected (`string`, `integer` and the special types are allowed). +- An issue where credential schemas were not updated with the correct key. ## 1.1.5 diff --git a/packages/browser-wallet/src/shared/utils/verifiable-credential-helpers.ts b/packages/browser-wallet/src/shared/utils/verifiable-credential-helpers.ts index 3d2989dc..571129b2 100644 --- a/packages/browser-wallet/src/shared/utils/verifiable-credential-helpers.ts +++ b/packages/browser-wallet/src/shared/utils/verifiable-credential-helpers.ts @@ -932,7 +932,7 @@ export async function getCredentialSchemas( abortControllers: AbortController[], client: ConcordiumGRPCClient ) { - const onChainSchemas: VerifiableCredentialSchema[] = []; + const onChainSchemas: { schema: VerifiableCredentialSchema; url: string }[] = []; const allContractAddresses = credentials.map((vc) => getCredentialRegistryContractAddress(vc.id)); const issuerContractAddresses = new Set(allContractAddresses); @@ -953,7 +953,7 @@ export async function getCredentialSchemas( registryMetadata.credentialSchema.schema, controller ); - onChainSchemas.push(credentialSchema); + onChainSchemas.push({ schema: credentialSchema, url: registryMetadata.credentialSchema.schema.url }); } catch (e) { // Ignore errors that occur because we aborted, as that is expected to happen. if (!controller.signal.aborted) { @@ -1060,12 +1060,12 @@ export async function getChangesToCredentialSchemas( for (const updatedSchema of upToDateSchemas) { if (Object.keys(updatedSchemasInStorage).length === 0) { updatedSchemasInStorage = { - [updatedSchema.$id]: updatedSchema, + [updatedSchema.url]: updatedSchema.schema, }; updateReceived = true; } else { - updatedSchemasInStorage[updatedSchema.$id] = updatedSchema; - if (JSON.stringify(storedSchemas[updatedSchema.$id]) !== JSON.stringify(updatedSchema)) { + updatedSchemasInStorage[updatedSchema.url] = updatedSchema.schema; + if (JSON.stringify(storedSchemas[updatedSchema.url]) !== JSON.stringify(updatedSchema)) { updateReceived = true; } }