Skip to content

buildFromUpdateProperties

buildFromUpdateProperties(stmtUri, digest, spaceUri, creatorAddress): PartialStatementEntryAccountType

Constructs an updated IStatementEntry object using the provided properties.

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.

creatorAddress: string

The address of the statement’s creator.

PartialStatementEntryAccountType

A newly constructed IStatementEntry object reflecting the updates.

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.

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);

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

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.

statement/src/Statement.ts:179