From df894d1dc8aded3a4550d7ee84fc7891d8fdfdde Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Tue, 17 Oct 2023 10:03:52 +0700 Subject: [PATCH] add error --- src/hooks/index.ts | 7 +++++-- src/utils/sendTransaction.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/hooks/index.ts b/src/hooks/index.ts index 207904c8c3..da3621acb3 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -125,10 +125,13 @@ type Web3React = { active: boolean } -const wrapProvider = (provider: Web3Provider, blackjackData: BlackjackCheck): Web3Provider => +const wrapProvider = (provider: Web3Provider, blackjackData: BlackjackCheck | undefined): Web3Provider => new Proxy(provider, { get(target, prop) { - if (prop === 'send' && blackjackData.blacklisted) throw new Error('There was an error with your transaction') + if (prop === 'send') { + if (!blackjackData) throw new Error('There was an error with your transaction') + if (blackjackData.blacklisted) throw new Error('There was an error with your transaction.') + } return target[prop as keyof Web3Provider] }, }) diff --git a/src/utils/sendTransaction.ts b/src/utils/sendTransaction.ts index df864c118b..dd4d8a9a6d 100644 --- a/src/utils/sendTransaction.ts +++ b/src/utils/sendTransaction.ts @@ -33,7 +33,7 @@ export async function sendEVMTransaction({ } chainId?: ChainId }): Promise { - if (!account || !library) return + if (!account || !library) throw new Error('Invalid transaction') const estimateGasOption = { from: account,