-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat: show more informative rpc error #216
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,62 @@ | ||||||
import { useEffect, useState } from 'react'; | ||||||
import { appStore, chainStorageWatcherAtom, rpcNodeAtom } from 'store/app'; | ||||||
import { useAtomValue } from 'jotai'; | ||||||
import ActionsDialog from './ActionsDialog'; | ||||||
import { useStore } from 'zustand'; | ||||||
|
||||||
const ChainConnectionErrorDialog = () => { | ||||||
const { chainConnectionError } = useStore(appStore); | ||||||
const chainStorageWatcher = useAtomValue(chainStorageWatcherAtom); | ||||||
const rpcNode = useAtomValue(rpcNodeAtom); | ||||||
const [isShowing, setIsShowing] = useState(false); | ||||||
|
||||||
useEffect(() => { | ||||||
if (chainConnectionError) { | ||||||
setIsShowing(true); | ||||||
} | ||||||
}, [chainConnectionError]); | ||||||
|
||||||
const body = ( | ||||||
<div className="mt-2 p-1 max-h-96 overflow-y-auto"> | ||||||
<p className="mb-2"> | ||||||
There was an issue connecting to the chain - likely due to RPC node | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
issues. We are working to resolve it with our RPC providers. Please | ||||||
check back in a couple of hours. | ||||||
</p> | ||||||
{chainStorageWatcher && ( | ||||||
<p> | ||||||
API Endpoint:{' '} | ||||||
<span className="text-blue-500">{chainStorageWatcher?.apiAddr}</span> | ||||||
</p> | ||||||
)} | ||||||
{rpcNode && ( | ||||||
<p> | ||||||
RPC Endpoint: <span className="text-blue-500">{rpcNode}</span> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: a blue URL looks like a hyperlink. It might be best to choose a different color and/or replace the <span> with <input readonly>. |
||||||
</p> | ||||||
)} | ||||||
<p> | ||||||
Error:{' '} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can avoid repeating "error".
Suggested change
Also, is |
||||||
<span className="text-alert">{chainConnectionError?.toString()}</span> | ||||||
</p> | ||||||
</div> | ||||||
); | ||||||
|
||||||
return ( | ||||||
<ActionsDialog | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not requesting a change, but I guess this is no longer an actions dialog. |
||||||
title="Chain Connection Error" | ||||||
body={body} | ||||||
isOpen={isShowing} | ||||||
secondaryAction={{ | ||||||
action: () => { | ||||||
setIsShowing(false); | ||||||
}, | ||||||
label: 'Dismiss', | ||||||
}} | ||||||
onClose={() => { | ||||||
setIsShowing(false); | ||||||
}} | ||||||
/> | ||||||
); | ||||||
}; | ||||||
|
||||||
export default ChainConnectionErrorDialog; |
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.
question:
Why is this using
while just above it's only
Is it because we know
makeAgoricChainStorageWatcher
is giving us an instance ofError
but we don't know if thecatch
is?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's probably value in introducing a helper for use in both places; something like