Catch the TypeError which occours when contractCode is undefined (#2314)

This commit is contained in:
Joel Raju 2021-05-21 14:19:16 +05:30 committed by GitHub
parent 08953e36c0
commit 24069ca5bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -62,7 +62,7 @@ const isHardwareWallet = (walletName: string) =>
const isSmartContractWallet = async (web3Provider: Web3, account: string): Promise<boolean> => { const isSmartContractWallet = async (web3Provider: Web3, account: string): Promise<boolean> => {
const contractCode = await web3Provider.eth.getCode(account) const contractCode = await web3Provider.eth.getCode(account)
return contractCode.replace(EMPTY_DATA, '').replace(/0/g, '') !== '' return !!contractCode && contractCode.replace(EMPTY_DATA, '').replace(/0/g, '') !== ''
} }
export const getProviderInfo = async (web3Instance: Web3, providerName = 'Wallet'): Promise<ProviderProps> => { export const getProviderInfo = async (web3Instance: Web3, providerName = 'Wallet'): Promise<ProviderProps> => {