buildFromRevokeRatingProperties
buildFromRevokeRatingProperties(
rating
,chainSpace
,authorUri
):Promise
<object
>
Constructs a revocation entry for a previously submitted rating on the blockchain.
This function handles the process of revoking a rating. It takes a rating revocation entry, verifies the signature of the original rating, validates required fields, and generates the necessary signatures for the revocation entry. This is essential for maintaining the integrity and trustworthiness of the rating system, especially in decentralized environments.
This function is specifically designed for use by Rating Authors or Ledger/API Providers.
Parameters
• rating: IRatingRevokeEntry
The rating revoke entry to process. This includes the original rating’s digest, signature, and other relevant details.
• chainSpace: space:cord:${string}
The identifier of the blockchain space (as a URI) where the rating is being revoked. This helps in pinpointing the exact location on the blockchain where the rating resides.
• authorUri: did:cord:3${string}
The Decentralized Identifier (DID) URI of the author who is revoking the rating. This identifier is crucial for associating the revocation with the correct author.
Returns
Promise
<object
>
- A promise that resolves to an object containing:
uri
: A unique URI for the revocation entry on the blockchain.details
: An object with the details of the revocation, ready for dispatch to the blockchain.
details
details:
IRatingDispatch
uri
uri:
RatingEntryUri
Throws
- Thrown if there is an issue with the revocation’s content, such as invalid fields or signature verification failure.
Example
// Example usage of the functionconst ratingRevokeEntry = { // ... rating revoke entry properties ...};const chainSpace = 'chainSpace123';const authorUri = 'did:example:author123';
try { const result = await buildFromRevokeRatingProperties(ratingRevokeEntry, chainSpace, authorUri, signCallback); console.log('Revocation entry URI:', result.uri); console.log('Revocation entry details:', result.details);} catch (error) { console.error('Error building revocation entry:', error);}