Skip to content

Commit

Permalink
add error
Browse files Browse the repository at this point in the history
  • Loading branch information
namgold committed Oct 17, 2023
1 parent d45a0ca commit df894d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
},
})
Expand Down
2 changes: 1 addition & 1 deletion src/utils/sendTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function sendEVMTransaction({
}
chainId?: ChainId
}): Promise<TransactionResponse | undefined> {
if (!account || !library) return
if (!account || !library) throw new Error('Invalid transaction')

const estimateGasOption = {
from: account,
Expand Down

0 comments on commit df894d1

Please sign in to comment.