From 11b08fd0a802dded6ef338543693aaa5991003cc Mon Sep 17 00:00:00 2001 From: gratestas Date: Fri, 19 May 2023 19:38:45 +0300 Subject: [PATCH] feat: add toast message template for tx revert exception --- src/utils/notifyWithTost.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/utils/notifyWithTost.js b/src/utils/notifyWithTost.js index b2df20fb..4c340bdc 100644 --- a/src/utils/notifyWithTost.js +++ b/src/utils/notifyWithTost.js @@ -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 ; 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 ( + <> +
{title}
+
{reason}
+ + ) +} \ No newline at end of file