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

Communicate better when a deposit transaction is not #217

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/neat-islands-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@reservoir0x/relay-kit-ui': patch
---

Improve tx error messaging
10 changes: 8 additions & 2 deletions packages/ui/src/components/common/ErrorWell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import type { AxiosError } from 'axios'

interface Props {
error?: Error | null | AxiosError
hasTxHashes?: boolean
}

const ErrorWell: React.FC<Props> = ({ error }) => {
const ErrorWell: React.FC<Props> = ({ error, hasTxHashes }) => {
const renderedErrorMessage = React.useMemo((): React.ReactNode => {
if (error && ((error as AxiosError).response?.data as any)?.message) {
return (error as any).response?.data?.message
Expand All @@ -17,8 +18,13 @@ const ErrorWell: React.FC<Props> = ({ error }) => {
) {
return 'Oops! Something went wrong while processing your transaction.'
}
if (!hasTxHashes) {
return 'Oops, something went wrong while initiating the bridge. Your request was not submitted. Please try again.'
} else if (error?.message?.includes('solver status check')) {
return `Oops, it seems we can't check the status of your transaction at the moment. Please visit the transaction page for more details.`
}
return error?.message
}, [error?.message])
}, [error?.message, hasTxHashes])

return (
<Text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ export const ErrorStep: FC<ErrorStepProps> = ({
</>
) : (
<>
<ErrorWell error={error} />
<ErrorWell
error={error}
hasTxHashes={allTxHashes && allTxHashes.length > 0}
/>
{allTxHashes.map(({ txHash }) => {
return (
<Anchor
Expand All @@ -92,18 +95,33 @@ export const ErrorStep: FC<ErrorStepProps> = ({
)
})}

<Button
onClick={() => {
onOpenChange(false)
}}
css={{
mt: 12,
justifyContent: 'center',
width: '100%'
}}
>
Done
</Button>
{allTxHashes && allTxHashes.length > 0 ? (
<Button
onClick={() => {
onOpenChange(false)
}}
css={{
mt: 12,
justifyContent: 'center',
width: '100%'
}}
>
Done
</Button>
) : (
<Button
onClick={() => {
onOpenChange(false)
}}
css={{
mt: 12,
justifyContent: 'center',
width: '100%'
}}
>
Retry
</Button>
)}
</>
)}
</Flex>
Expand Down