Skip to content

Commit

Permalink
fix (wip): frontend build error
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyas-londhe committed Oct 12, 2024
1 parent f977e37 commit d3d6b4f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 58 deletions.
77 changes: 21 additions & 56 deletions frontend/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";

import { useState, useEffect } from "react";
import { GetServerSideProps } from 'next';
import {
Box,
Card,
Expand All @@ -22,9 +21,6 @@ import {
import { CheckCircleIcon, TimeIcon, WarningIcon } from "@chakra-ui/icons";
import styled from "@emotion/styled";
import axios from "axios";
// import { generateJWTVerifierInputs } from "@zk-jwt/helpers/dist/input-generators";
// import { genAccountCode } from "@zk-email/relayer-utils";


declare global {
interface Window {
Expand Down Expand Up @@ -54,30 +50,6 @@ interface HomeProps {
data: string;
}



// Helper function to generate random BigInt
// function genAccountCode(): bigint {
// // BN254 Scalar Field fr
// const fr = BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");
// const maxBytes = 32;
// let randomBytes = new Uint8Array(maxBytes);

// // Continuously generate random numbers until we get one within the range [0, fr)
// while (true) {
// // Fill the array with random values
// window.crypto.getRandomValues(randomBytes);

// // Convert random bytes to a BigInt
// let randomValue = BigInt('0x' + Array.from(randomBytes).map(byte => byte.toString(16).padStart(2, '0')).join(''));

// // Return if the randomValue is less than max (fr in this case)
// if (randomValue < fr) {
// return randomValue;
// }
// }
// }

export default function Home() {
const [command, setCommand] = useState("");
const [jwt, setJwt] = useState("");
Expand All @@ -100,16 +72,11 @@ export default function Home() {
try {
setStepStatuses((prev) => ["success", "processing", "idle"]);

// const accountCode = await genAccountCode();
// const circuitInputs = generateJWTVerifierInputs(
// jwt,
// pubkey,
// accountCode,
// {
// maxMessageLength: 1024,
// }
// );
const response1 = await axios.post('/api/generateCircuitInputs', { jwt, pubkey, maxMessageLength: 1024 });
const response1 = await axios.post("/api/generateCircuitInputs", {
jwt,
pubkey,
maxMessageLength: 1024,
});
console.log(response1);
const { circuitInputs, accountCode } = response1.data.circuitInputs;

Expand All @@ -133,20 +100,18 @@ export default function Home() {
try {
const jwt = response.credential;
console.log("JWT:", jwt);
const decodedHeader = {}
// JSON.parse(
// Buffer.from(
// response.credential.split(".")[0],
// "base64"
// ).toString("utf-8")
// );
const decodedPayload = {}
// JSON.parse(
// Buffer.from(
// response.credential.split(".")[1],
// "base64"
// ).toString("utf-8")
// );
const decodedHeader = JSON.parse(
Buffer.from(
response.credential.split(".")[0],
"base64"
).toString("utf-8")
);
const decodedPayload = JSON.parse(
Buffer.from(
response.credential.split(".")[1],
"base64"
).toString("utf-8")
);
console.log("Decoded Header:", decodedHeader);
console.log("Decoded Payload:", decodedPayload);
setJwt(jwt);
Expand Down Expand Up @@ -213,10 +178,10 @@ export default function Home() {
stepStatuses[index] === "success"
? "green.500"
: stepStatuses[index] === "processing"
? "blue.500"
: stepStatuses[index] === "failed"
? "red.500"
: "gray.500"
? "blue.500"
: stepStatuses[index] === "failed"
? "red.500"
: "gray.500"
}
>
{stepStatuses[index] === "success" && (
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3551,7 +3551,7 @@ __metadata:

"@zk-jwt/helpers@file:../packages/helpers::locator=frontend%40workspace%3Afrontend":
version: 0.0.1
resolution: "@zk-jwt/helpers@file:../packages/helpers#../packages/helpers::hash=3eb2eb&locator=frontend%40workspace%3Afrontend"
resolution: "@zk-jwt/helpers@file:../packages/helpers#../packages/helpers::hash=559a53&locator=frontend%40workspace%3Afrontend"
dependencies:
"@zk-email/helpers": ^6.1.5
addressparser: ^1.0.1
Expand All @@ -3567,7 +3567,7 @@ __metadata:
pako: ^2.1.0
psl: ^1.9.0
snarkjs: "https://github.com/sampritipanda/snarkjs.git#fef81fc51d17a734637555c6edbd585ecda02d9e"
checksum: 55ead770c667f8fb1a0344549ef3fe1167be4d5ec9937e9c077d8c48bb06de54c4d1661d83f7e7ca94dd759ec44eb761c89b433c16a3b3b4cb8b636725b83aa2
checksum: fafe13c9a7269d689d408787221158aa8a52ee305959491a6df10f145db90d43deb47fc811cf1610c98a1f18ec8151a1de805bcf34da8ec4456ac623cb516bf3
languageName: node
linkType: hard

Expand Down

0 comments on commit d3d6b4f

Please sign in to comment.