-
Notifications
You must be signed in to change notification settings - Fork 49
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
Conversation
return rating / count | ||
} | ||
|
||
export function generateRootHashFromContent(journalContent: IJournalContent) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
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.
packages/types/src/Score.ts
Outdated
| Array<AnyJson> | ||
| { [key: string]: AnyJson } | ||
|
||
export interface scoreDetails { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate?
packages/types/src/Score.ts
Outdated
count: U32 | ||
} | ||
|
||
export interface IratingInput { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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()), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
c99d839
to
5c65744
Compare
No description provided.