Skip to content

updateRegistryEntryUri

updateRegistryEntryUri(registryEntryUri, digest): EntryUri

Updates the digest component of a given registry entry URI with a new digest.

Parameters

registryEntryUri: `entry:cord:${string}`

The original registry entry URI to be updated. Format: ‘entry:cord::‘.

digest: HexString

The new hexadecimal string digest to be inserted into the URI. Must start with ‘0x’.

Returns

EntryUri

The updated registry entry URI with the new digest.

Remarks

This function modifies an existing registry entry URI by replacing its digest with a new provided digest. It ensures that the URI retains its original structure and prefix, while only the digest part is updated.

Example

const originalUri = 'entry:cord:1234:abcd';
const newDigest = '0x5678...';
const updatedUri = updateRegistryEntryUri(originalUri, newDigest);
console.log('Updated Registry Entry URI:', updatedUri);

Throws

If the registryEntryUri does not follow the expected format.

Throws

If the new digest does not start with ‘0x’.

Description

The function splits the registryEntryUri and validates its structure. If valid, it replaces the digest with the new one. The updated URI is constructed with the new digest (without ‘0x’ prefix) and returned.

Source

identifier/src/Identifier.ts:857