-
Notifications
You must be signed in to change notification settings - Fork 3
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
build: rebuilt wasm tutorial with next.js #5
base: main
Are you sure you want to change the base?
build: rebuilt wasm tutorial with next.js #5
Conversation
added unit tests
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.
Looks good dude. Left you some comment of a that will make this more maintainable
<div className='App'> | ||
<GenPK | ||
files={{ | ||
model: files['model_ser_pk'], |
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.
you should be able to access this the normal way if you feel it's more readable files.model_ser_pk
id='genVkButton' | ||
onClick={async () => { | ||
if (Object.values(files).every((file) => file instanceof File)) { | ||
const result = await handleGenVkButton( |
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.
what is result
? a vk
? maybe a more descriptive name
<FileDownload | ||
fileName='vk.key' | ||
buffer={buffer} | ||
handleDownloadCompleted={function (): void { |
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.
arrow function probably cleaner here. Usually better not to add explicit return types and let TS infer it for you.
onClick={async () => { | ||
if (Object.values(files).every((file) => file instanceof File)) { | ||
const result = await handleGenVkButton( | ||
files as { [key: string]: File }, |
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.
Usually want to avoid type casting with as
<button | ||
id='genHashButton' | ||
onClick={async () => { | ||
const result = await handleGenHashButton(message as File) // 'as' cast should be safe b/c of disabled button |
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.
message: File | null
correct? instead of doing message as File
. One line above do
if (!message) {
return
}
then typescript will infer this for you and it will safe at runtime
filesNames.forEach((fileName) => { | ||
fetch(`/data/${fileName}`) | ||
.then((res) => res.blob()) | ||
.then((blob) => | ||
setFiles((prevFiles) => ({ | ||
...prevFiles, | ||
[fileName]: new File([blob], fileName), | ||
})), | ||
) | ||
}) |
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.
You're already in an async
function. Would be more readable to use await
here
}, []) | ||
|
||
useEffect(() => { | ||
if (files['test.onnx'] && files['kzg'] && files['settings.json']) { |
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.
helper function
files['test.witness.json'] && | ||
files['test.provekey'] && | ||
files['test.onnx'] && | ||
files['settings.json'] && | ||
files['kzg'] |
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.
Def could use a helper function
files['test.proof'] && | ||
files['test.key'] && | ||
files['settings.json'] && | ||
files['kzg'] |
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.
helper function
import GenPK from './GenPk' | ||
import GenVk from './GenVk' | ||
import GenProof from './GenProof' | ||
import Verify from './Verify' | ||
import Hash from './Hash' |
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.
There components should live in /components
No description provided.