-
Notifications
You must be signed in to change notification settings - Fork 1
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
fix: merkle root format #29
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
src/utils/misc.ts
Outdated
export function formatProofData({ merkle_root, nullifier_hash, proof }: ISuccessResult) { | ||
// Format merkle root to bytes32 | ||
const merkle_root_bytes32 = to32Bytes(merkle_root); | ||
|
||
const [decodedMerkleRoot] = decodeAbiParameters( | ||
parseAbiParameters('uint256 merkle_root'), | ||
merkle_root_bytes32 as Hex, | ||
); | ||
const [decodedNullifierHash] = decodeAbiParameters( | ||
parseAbiParameters('uint256 nullifier_hash'), | ||
nullifier_hash as Hex, | ||
); | ||
const [decodedProof] = decodeAbiParameters(parseAbiParameters('uint256[8] proof'), proof as Hex); | ||
const proofData = encodePacked( | ||
['uint256', 'uint256', 'uint256[8]'], | ||
[decodedMerkleRoot, decodedNullifierHash, decodedProof], | ||
); | ||
return proofData; | ||
} |
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 not using camel case for variables 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.
snake case*
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.
https://docs.worldcoin.org/reference/idkit#types due to how it comes from sdk
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.
src/utils/misc.ts
Outdated
export function formatProofData({ merkle_root, nullifier_hash, proof }: ISuccessResult) { | ||
// Format merkle root to bytes32 | ||
const merkle_root_bytes32 = to32Bytes(merkle_root); | ||
|
||
const [decodedMerkleRoot] = decodeAbiParameters( | ||
parseAbiParameters('uint256 merkle_root'), | ||
merkle_root_bytes32 as Hex, | ||
); | ||
const [decodedNullifierHash] = decodeAbiParameters( | ||
parseAbiParameters('uint256 nullifier_hash'), | ||
nullifier_hash as Hex, | ||
); | ||
const [decodedProof] = decodeAbiParameters(parseAbiParameters('uint256[8] proof'), proof as Hex); | ||
const proofData = encodePacked( | ||
['uint256', 'uint256', 'uint256[8]'], | ||
[decodedMerkleRoot, decodedNullifierHash, decodedProof], | ||
); | ||
return proofData; | ||
} |
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.
snake case*
@@ -0,0 +1,10 @@ | |||
export interface ISuccessResult { | |||
merkle_root: string; | |||
nullifier_hash: string; |
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 use snake case?
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.
No description provided.