Skip to content

buildFromUpdateProperties

buildFromUpdateProperties(stmtUri, digest, spaceUri, creatorUri): PartialStatementEntry

Constructs an updated IStatementEntry object using the provided properties.

Parameters

stmtUri: stmt:cord:${string}

The existing URI of the statement that is being updated.

digest: HexString

The new hexadecimal string representing the digest of the statement.

spaceUri: space:cord:${string}

The URI of the ChainSpace associated with the statement.

creatorUri: did:cord:3${string}

The DID URI of the statement’s creator.

Returns

PartialStatementEntry

A newly constructed IStatementEntry object reflecting the updates.

Remarks

This function is used for updating an existing statement entry in the CORD blockchain system. It takes a statement URI and other identifiers to form a new statement entry, ensuring that the updated object adheres to the required data structure.

Example

const existingStmtUri = 'stmt:cord:example_uri';
const newDigest = '0x456...';
const spaceUri = 'space:cord:example_uri';
const creatorUri = 'did:cord:creator_uri';
const schemaUri = 'schema:cord:schema_uri';
const updatedStatementEntry = buildFromUpdateProperties(existingStmtUri, newDigest, spaceUri, creatorUri, schemaUri);
console.log('Updated Statement Entry:', updatedStatementEntry);

Throws

Various errors from verifyDataStructure if the created statement entry does not meet the validation criteria.

Description

The function first calls updateStatementUri to update the statement URI using the provided stmtUri and digest. It then constructs a statement entry by combining the updated statementUri, along with the digest, spaceUri, creatorUri, and optionally schemaUri, forming an object that conforms to the IStatementEntry interface. The verifyDataStructure function is then invoked to validate the integrity and structure of the newly constructed statement entry. If validation is successful, the function returns the updated IStatementEntry object.

Source

statement/src/Statement.ts:178