Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scoring feature to SDK and update demo-score #130

Closed
wants to merge 0 commits into from

Conversation

adi-a11y
Copy link
Contributor

@adi-a11y adi-a11y commented Oct 6, 2023

No description provided.

return rating / count
}

export function generateRootHashFromContent(journalContent: IJournalContent) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't require selective disclosure here. One hash for the content is good enough.

@@ -35,7 +35,7 @@ import * as Did from '@cord.network/did'
import { blake2AsHex } from '@polkadot/util-crypto'
import { ConfigService } from '@cord.network/config'

function getHashRoot(leaves: Uint8Array[]): Uint8Array {
export function getHashRoot(leaves: Uint8Array[]): Uint8Array {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was necessary because I had been using multiple hashes to create the identifier. However, based on your previous comment, I have now updated the code to utilize a single hash, so this is no longer necessary. I will make the change accordingly.

| Array<AnyJson>
| { [key: string]: AnyJson }

export interface scoreDetails {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate?

count: U32
}

export interface IratingInput {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be IRatingInput

return digest
}

export function getUriForScore(scoreDigest: HexString) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the SDK method to generate the identifier. Chain call is not needed.

if (encoded.isSome) {
const decoded = encoded.unwrap()
return {
rating: JSON.parse(decoded.rating.toString()),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need JSON.parse here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The output of decoded.rating looks like BN:x. To convert it into human readable from I'm using toString() method but the rating is a number hence using the JSON.parse to convert it to the right format.

@adi-a11y adi-a11y closed this Oct 6, 2023
@adi-a11y adi-a11y force-pushed the feature/score-final branch from c99d839 to 5c65744 Compare October 6, 2023 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants