Skip to content

dispatchReviseRatingToChain

dispatchReviseRatingToChain(ratingEntry, authorAccount, authorizationUri, signCallback): Promise<RatingEntryUri>

Dispatches a request to revise an existing rating entry on the blockchain.

This asynchronous function handles the process of revising a rating entry that is already stored on the blockchain. It first checks whether the specified rating entry exists on the blockchain. If it does, the function simply returns the existing entry’s URI. If the rating entry is not stored, it proceeds to dispatch a revised version of the rating to the blockchain. This involves creating and signing a transaction for the revised rating, and then submitting this transaction to the blockchain. This function is essential for ensuring that ratings on the blockchain can be updated to maintain their accuracy and relevance over time.

Parameters

ratingEntry: IRatingDispatch

The revised rating entry object to be dispatched. It includes the entry’s details and its unique URI.

authorAccount: CordKeyringPair

The blockchain account of the author, used for signing the transaction.

authorizationUri: auth:cord:${string}

The URI that provides authorization context for the rating revision dispatch.

signCallback: SignExtrinsicCallback

A callback function for signing the extrinsic (blockchain transaction).

Returns

Promise<RatingEntryUri>

  • A promise that resolves to the URI of the revised rating entry. If the entry was already on the chain, it returns the existing URI.

Throws

  • Thrown if there’s an error during the dispatch process, such as issues with signing, transaction creation, or submission.

Example

// Example usage of the function
const revisedRatingEntry = {
// ... revised rating entry properties ...
};
const authorAccount = { /* ... author's blockchain account ... */ };
const authorizationUri = 'authUri123';
const signCallback = async (/* ... parameters ... */) => { /* ... signing logic ... */ };
try {
const entryUri = await dispatchReviseRatingToChain(revisedRatingEntry, authorAccount, authorizationUri, signCallback);
console.log('Revised Rating Entry URI:', entryUri);
} catch (error) {
console.error('Error dispatching revised rating to chain:', error);
}

Source

network-score/src/Scoring.chain.ts:304