Skip to content

Commit

Permalink
feat: add toast message template for tx revert exception
Browse files Browse the repository at this point in the history
  • Loading branch information
gratestas authored and 0xferit committed May 19, 2023
1 parent 9aa5737 commit 11b08fd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/utils/notifyWithTost.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,21 @@ const messageTemplates = {
render({ data }) {
console.log({ data });
if (data.code === 4001) return "User denied transaction";
if (data?.error?.code === -32603) return <TxRevertMessage errorMessage={data.error.message} />;
return "Failed to execute transaction";
},
},
},
// add more message types here as needed
};

const TxRevertMessage = ({ errorMessage }) => {
const [title, reason] = errorMessage.split(":");
console.log({ title, reason });
return (
<>
<div style={{ fontSize: "20px", textTransform: "capitalize" }}>{title}</div>
<div style={{ fontSize: "16px" }}>{reason}</div>
</>
)
}

0 comments on commit 11b08fd

Please sign in to comment.