-
Notifications
You must be signed in to change notification settings - Fork 300
(feat) add hyperlink api reference #1855
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
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.
LGTM, minor stylistic nits but not really that important and you can disregard if you prefer
<div> | ||
<h3 className="mb-2 text-lg font-bold">Results</h3> | ||
<Code language="json">{stringifyResponse(status.data)}</Code> | ||
{props.type === EvmApiType.Write && status.data && typeof status.data === 'object' && 'hash' in status.data && typeof status.data.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.
For these kinds of cases I suggest you use zod for this kind of thing and it's much easier to write and also easier to read and understand, e.g. make a Result
component and use it here, something like this:
import { z } from "zod";
...
const Results = ({ data }) => {
const parsed = hashSchema.safeParse(data);
return parsed.success ? (
<>
<Code language="json">Tx Hash: {parsed.data.hash}</Code>
...
</>
) : (
<Code language="json">{stringifyResponse(status.data)}</Code>
)
}
const hashSchema = z.strictObject({ hash: z.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.
This looks much cleaner. I will keep it mind to use it now.
No description provided.