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

fix: logs api #24

Merged
merged 12 commits into from
May 8, 2024
Merged
22 changes: 15 additions & 7 deletions src/components/Voting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@ export const Voting = () => {
try {
// Get the proof data
const { merkle_root, nullifier_hash, proof } = result;
if (address && merkle_root && nullifier_hash && proof) {
const proofStr = `merkleRoot: ${merkle_root} nullifierHash: ${nullifier_hash} proof: ${proof}`;
track('Voting proof', {
if (address && merkle_root && nullifier_hash) {
track('Voting merkle root', {
address,
proofStr,
merkle_root,
});
track('Voting nullifier hash', {
address,
nullifier_hash,
});
}
console.log('Voting proof:', result);
Expand All @@ -75,7 +78,7 @@ export const Voting = () => {
nullifier_hash as Hex,
);
const [decodedProof] = decodeAbiParameters(parseAbiParameters('uint256[8] proof'), proof as Hex);

console.log(decodedProof);
const proofData = encodePacked(
['uint256', 'uint256', 'uint256[8]'],
[decodedMerfleRoot, decodedNullifierHash, decodedProof],
Expand Down Expand Up @@ -116,9 +119,14 @@ export const Voting = () => {
setModalOpen(ModalType.ERROR);
}
} catch (error) {
const errorString = String(error);
const truncatedError = errorString.length > 255 ? errorString.substring(0, 255) : errorString;
console.error('Cast failed:', error);
if (error instanceof Error && address) {
track('Error', { message: error.message || 'Unknown error', address });
if (truncatedError && address) {
track('Error', {
address,
truncatedError,
});
agusduha marked this conversation as resolved.
Show resolved Hide resolved
}
setModalOpen(ModalType.ERROR);
}
Expand Down
Loading