dispatchRevokeRatingToChain
dispatchRevokeRatingToChain(
ratingEntry
,authorAccount
,authorizationUri
,signCallback
):Promise
<RatingEntryUri
>
Dispatches a request to revoke a rating entry from the blockchain.
This asynchronous function is utilized to revoke an existing rating entry from the blockchain. It first verifies the signature of the rating entry to ensure its authenticity and integrity. Then, it checks if the rating entry actually exists on the blockchain. If the entry does not exist, it throws an error. Otherwise, it proceeds to create a transaction to revoke the rating, signs the transaction, and submits it to the blockchain. This function is crucial for maintaining the accuracy and relevancy of the rating data on the blockchain, allowing for the removal of ratings when necessary.
Parameters
• ratingEntry: IRatingDispatch
The rating entry object that is to be revoked. Includes details like the entry digest and the author’s signature.
• authorAccount: CordKeyringPair
The blockchain account of the author, used for transaction signing.
• authorizationUri: auth:cord:${string}
The URI providing the authorization context for the revocation.
• signCallback: SignExtrinsicCallback
A callback function for signing the extrinsic (blockchain transaction).
Returns
Promise
<RatingEntryUri
>
- A promise that resolves to the URI of the revoked rating entry.
Throws
- Thrown if there’s an error during the dispatch process, such as a non-existent rating entry, issues with signing, or submission failures.
Example
// Example usage of the functionconst ratingEntry = { // ... properties of the rating entry to be revoked ...};const authorAccount = { /* ... author's blockchain account ... */ };const authorizationUri = 'authUri123';const signCallback = async (/* ... parameters ... */) => { /* ... signing logic ... */ };
try { const entryUri = await dispatchRevokeRatingToChain(ratingEntry, authorAccount, authorizationUri, signCallback); console.log('Revoked Rating Entry URI:', entryUri);} catch (error) { console.error('Error dispatching revocation to chain:', error);}