-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve: add error handler for transaction (#103)
* disable stake button when unstaked balance is zero Signed-off-by: ryanwolhuter <[email protected]> * add ethers error codes list Signed-off-by: ryanwolhuter <[email protected]> * add ethers error link component Signed-off-by: ryanwolhuter <[email protected]> * open error link in new tab Signed-off-by: ryanwolhuter <[email protected]> * undo comment out Signed-off-by: ryanwolhuter <[email protected]> Signed-off-by: ryanwolhuter <[email protected]>
- Loading branch information
1 parent
a9d03dd
commit 752eb75
Showing
8 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { ethersErrorCodes } from "constant"; | ||
import NextLink from "next/link"; | ||
import styled from "styled-components"; | ||
|
||
export function EthersErrorLink({ errorMessage }: { errorMessage: string }) { | ||
if (!ethersErrorCodes.some((code) => errorMessage.includes(code))) { | ||
return <span>{errorMessage}</span>; | ||
} | ||
|
||
const [firstPart, secondPart] = errorMessage.split("["); | ||
|
||
const link = secondPart.replace("See:", "").replace("]", "").trim(); | ||
|
||
return ( | ||
<span> | ||
{firstPart}.{" "} | ||
<Link href={link} target="_blank"> | ||
Learn more. | ||
</Link> | ||
</span> | ||
); | ||
} | ||
|
||
const Link = styled(NextLink)` | ||
font: inherit; | ||
color: inherit; | ||
text-decoration: underline; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export const ethersErrorCodes = [ | ||
"CALL_EXCEPTION", | ||
"INSUFFICIENT_FUNDS", | ||
"MISSING_NEW", | ||
"NONCE_EXPIRED", | ||
"NUMERIC_FAULT", | ||
"REPLACEMENT_UNDERPRICED", | ||
"TRANSACTION_REPLACED", | ||
"UNPREDICTABLE_GAS_LIMIT", | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
752eb75
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.
Successfully deployed to the following URLs:
voter-dapp-v2 – ./
goerli.vote.v2.umaproject.org
voter-dapp-v2-uma.vercel.app
voter-dapp-v2-git-master-uma.vercel.app
voter-dapp-v2.vercel.app