Skip to content

Commit

Permalink
Merge pull request #380 from Concordium/fix-updating-schemas
Browse files Browse the repository at this point in the history
Use real URL as key for schema updates
  • Loading branch information
orhoj authored Sep 5, 2023
2 parents 2048a6d + 7fc929d commit 15a2de7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/browser-wallet/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 15a2de7

Please sign in to comment.