uriToStatementIdAndDigest
uriToStatementIdAndDigest(
statementUri):object
Extracts the statement identifier and digest from a given statement URI.
Parameters
Section titled “Parameters”• statementUri: `stmt:cord:${string}`
The statement URI to be parsed. Expected format: ‘stmt:cord:
Returns
Section titled “Returns”object
An object containing the extracted identifier and digest from the statement URI.
digest
Section titled “digest”digest:
StatementDigest
identifier
Section titled “identifier”identifier:
string
Remarks
Section titled “Remarks”This function parses a statement URI and separates it into its constituent identifier and digest components. It expects the URI to conform to a specific format and structure.
Example
Section titled “Example”const statementUri = 'stmt:cord:1234:abcd';const { identifier, digest } = uriToStatementIdAndDigest(statementUri);console.log('Identifier:', identifier, 'Digest:', digest);Throws
Section titled “Throws”If the statementUri does not follow the expected format.
Description
Section titled “Description”The function splits the statementUri string by the colon (:) delimiter and checks if it conforms to the expected format.
If the format is valid, it extracts the identifier and suffix (digest) parts. The digest is then prefixed with ‘0x’ to form
the correct statement digest. The function returns an object containing both the identifier and the formatted digest.