Skip to content

Commit

Permalink
fix: show error for reverted txs (#2302)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmanu authored Jul 25, 2023
1 parent 4afb12f commit fbd7b52
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/components/tx-flow/flows/SuccessScreen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ export const SuccessScreen = ({ txId }: { txId: string }) => {
}, [txHash])

useEffect(() => {
const unsubscribe = txSubscribe(TxEvent.FAILED, (detail) => {
if (detail.txId === txId) setError(detail.error)
})
const unsubFns: Array<() => void> = ([TxEvent.FAILED, TxEvent.REVERTED] as const).map((event) =>
txSubscribe(event, (detail) => {
if (detail.txId === txId) setError(detail.error)
}),
)

return unsubscribe
return () => unsubFns.forEach((unsubscribe) => unsubscribe())
}, [txId])

const homeLink: UrlObject = {
Expand Down

0 comments on commit fbd7b52

Please sign in to comment.