From aee6a02b44beb4da5f5957f3e2fc2ed3c94e54bd Mon Sep 17 00:00:00 2001 From: HeesungB Date: Tue, 20 Dec 2022 21:54:19 +0900 Subject: [PATCH] Add error message about insufficient gas, account not exist, verification threshold --- constants/error-message.ts | 12 ++++++++++++ pages/verification/index.tsx | 27 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/constants/error-message.ts b/constants/error-message.ts index 74d7dfb..19e633e 100644 --- a/constants/error-message.ts +++ b/constants/error-message.ts @@ -7,3 +7,15 @@ export const KEPLR_VERSION_ERROR = "You should update keplr"; export const KEPLR_NO_ACCOUNT_ERROR = "key doesn't exist"; export const KEPLR_NO_ACCOUNT_MESSAGE = "Create a wallet account to get started with ICNS!"; + +export const INSUFFICIENT_GAS_ERROR = "insufficient funds: invalid request"; +export const INSUFFICIENT_GAS_MESSAGE = + "Not enough OSMO in your account. Please add more OSMO to your account"; + +export const ACCOUNT_NOT_EXIST_ERROR = "does not exist: unknown address"; +export const ACCOUNT_NOT_EXIST_MESSAGE = + "Account has not been registered on chain. Please add some OSMO to your account and try again."; + +export const VERIFICATION_THRESHOLD_ERROR = "verfication is below threshold:"; +export const VERIFICATION_THRESHOLD_MESSAGE = + "Verifier consensus failed. Verifiers may be offline. Please try again later."; diff --git a/pages/verification/index.tsx b/pages/verification/index.tsx index a7cfde5..8311e24 100644 --- a/pages/verification/index.tsx +++ b/pages/verification/index.tsx @@ -52,8 +52,14 @@ import { verifyTwitterAccount, } from "../../queries"; import { + ACCOUNT_NOT_EXIST_ERROR, + ACCOUNT_NOT_EXIST_MESSAGE, + INSUFFICIENT_GAS_ERROR, + INSUFFICIENT_GAS_MESSAGE, KEPLR_NOT_FOUND_ERROR, TWITTER_LOGIN_ERROR, + VERIFICATION_THRESHOLD_ERROR, + VERIFICATION_THRESHOLD_MESSAGE, } from "../../constants/error-message"; import { makeClaimMessage, makeSetRecordMessage } from "../../messages"; import Axios from "axios"; @@ -428,6 +434,26 @@ export default function VerificationPage() { } } catch (error) { if (Axios.isAxiosError(error)) { + const message = (error?.response?.data as QueryError).message; + + if (message.includes(INSUFFICIENT_GAS_ERROR)) { + setErrorMessage({ message: INSUFFICIENT_GAS_MESSAGE }); + setErrorModalOpen(true); + return; + } + + if (message.includes(ACCOUNT_NOT_EXIST_ERROR)) { + setErrorMessage({ message: ACCOUNT_NOT_EXIST_MESSAGE }); + setErrorModalOpen(true); + return; + } + + if (message.includes(VERIFICATION_THRESHOLD_ERROR)) { + setErrorMessage({ message: VERIFICATION_THRESHOLD_MESSAGE }); + setErrorModalOpen(true); + return; + } + setErrorMessage({ message: (error?.response?.data as QueryError).message, }); @@ -437,6 +463,7 @@ export default function VerificationPage() { if (error instanceof Error) { console.log(error.message); + setErrorMessage({ message: error.message }); setErrorModalOpen(true); }