From 87770251a35f2afe2cc70a0eade9f6b598325791 Mon Sep 17 00:00:00 2001 From: sirpy Date: Mon, 5 Feb 2024 11:18:26 +0200 Subject: [PATCH 1/3] fix: update or create flow --- packages/app/src/abi/ERC20.json | 277 ------------------ packages/app/src/abi/ERC20.ts | 277 ++++++++++++++++++ .../app/src/components/DonateComponent.tsx | 50 ++-- .../src/hooks/useApproveSwapTokenCallback.ts | 20 +- packages/app/src/hooks/useSwapRoute.tsx | 4 +- .../src/goodcollective/goodcollective.ts | 20 +- 6 files changed, 340 insertions(+), 308 deletions(-) delete mode 100644 packages/app/src/abi/ERC20.json create mode 100644 packages/app/src/abi/ERC20.ts diff --git a/packages/app/src/abi/ERC20.json b/packages/app/src/abi/ERC20.json deleted file mode 100644 index 6898f804..00000000 --- a/packages/app/src/abi/ERC20.json +++ /dev/null @@ -1,277 +0,0 @@ -[ - { - "inputs": [], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "subtractedValue", - "type": "uint256" - } - ], - "name": "decreaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "addedValue", - "type": "uint256" - } - ], - "name": "increaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/packages/app/src/abi/ERC20.ts b/packages/app/src/abi/ERC20.ts new file mode 100644 index 00000000..4ac5d2ce --- /dev/null +++ b/packages/app/src/abi/ERC20.ts @@ -0,0 +1,277 @@ +export const ERC20 = [ + { + inputs: [], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'Approval', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'from', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'to', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'value', + type: 'uint256', + }, + ], + name: 'Transfer', + type: 'event', + }, + { + inputs: [ + { + internalType: 'address', + name: 'owner', + type: 'address', + }, + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + ], + name: 'allowance', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'approve', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + ], + name: 'balanceOf', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'decimals', + outputs: [ + { + internalType: 'uint8', + name: '', + type: 'uint8', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'subtractedValue', + type: 'uint256', + }, + ], + name: 'decreaseAllowance', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'spender', + type: 'address', + }, + { + internalType: 'uint256', + name: 'addedValue', + type: 'uint256', + }, + ], + name: 'increaseAllowance', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'name', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'symbol', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'totalSupply', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'transfer', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'from', + type: 'address', + }, + { + internalType: 'address', + name: 'to', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'transferFrom', + outputs: [ + { + internalType: 'bool', + name: '', + type: 'bool', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, +] as const; diff --git a/packages/app/src/components/DonateComponent.tsx b/packages/app/src/components/DonateComponent.tsx index 5ac9f2ce..1375ac8b 100644 --- a/packages/app/src/components/DonateComponent.tsx +++ b/packages/app/src/components/DonateComponent.tsx @@ -13,7 +13,7 @@ import { IpfsCollective } from '../models/models'; import { useGetTokenBalance } from '../hooks/useGetTokenBalance'; import { acceptablePriceImpact, Frequency, frequencyOptions, SupportedNetwork } from '../models/constants'; import { InfoIconOrange } from '../assets'; -import { useLocation } from 'react-router-native'; +import { useParams } from 'react-router-native'; import Decimal from 'decimal.js'; import { formatFiatCurrency } from '../lib/formatFiatCurrency'; import ErrorModal from './modals/ErrorModal'; @@ -35,8 +35,7 @@ function DonateComponent({ collective }: DonateComponentProps) { const [isDesktopResolution] = useMediaQuery({ minWidth: 920, }); - const location = useLocation(); - const collectiveId = location.pathname.slice('/donate/'.length); + const { id: collectiveId = '0x' } = useParams(); const { address, isConnected } = useAccount(); const { chain } = useNetwork(); @@ -77,12 +76,12 @@ function DonateComponent({ collective }: DonateComponentProps) { status: swapRouteStatus, } = useSwapRoute(currency, decimalDonationAmount, duration); - const { handleApproveToken } = useApproveSwapTokenCallback( + const { handleApproveToken, isRequireApprove } = useApproveSwapTokenCallback( currency, decimalDonationAmount, duration, (value: boolean) => setApproveSwapModalVisible(value), - collectiveId + collectiveId as `0x${string}` ); const approvalNotReady = handleApproveToken === undefined && currency !== 'G$'; @@ -106,30 +105,37 @@ function DonateComponent({ collective }: DonateComponentProps) { } else if (currency === 'G$') { return await supportFlow(); } - const txHash = await handleApproveToken?.(); - if (txHash === undefined) { - return; - } - let txReceipt: TransactionReceipt | undefined; - try { - txReceipt = await waitForTransaction({ - chainId: chain?.id, - confirmations: 1, - hash: txHash, - timeout: 1000 * 60 * 5, - }); - } catch (error) { - setErrorMessage( - 'Something went wrong: Your token approval transaction was not confirmed within the timeout period.' - ); + + let isApproveSuccess = isRequireApprove === false; + + if (isRequireApprove) { + const txHash = await handleApproveToken?.(); + if (txHash === undefined) { + return; + } + let txReceipt: TransactionReceipt | undefined; + try { + txReceipt = await waitForTransaction({ + chainId: chain?.id, + confirmations: 1, + hash: txHash, + timeout: 1000 * 60 * 5, + }); + isApproveSuccess = txReceipt?.status === 'success'; + } catch (error) { + setErrorMessage( + 'Something went wrong: Your token approval transaction was not confirmed within the timeout period.' + ); + } } - if (txReceipt?.status === 'success') { + if (isApproveSuccess) { await supportFlowWithSwap(); } }, [ chain?.id, currency, frequency, + isRequireApprove, handleApproveToken, supportFlow, supportFlowWithSwap, diff --git a/packages/app/src/hooks/useApproveSwapTokenCallback.ts b/packages/app/src/hooks/useApproveSwapTokenCallback.ts index ef81bfde..3d0a4e15 100644 --- a/packages/app/src/hooks/useApproveSwapTokenCallback.ts +++ b/packages/app/src/hooks/useApproveSwapTokenCallback.ts @@ -1,8 +1,8 @@ -import { useAccount, useContractWrite, useNetwork, usePrepareContractWrite } from 'wagmi'; +import { useAccount, useContractRead, useContractWrite, useNetwork, usePrepareContractWrite } from 'wagmi'; import { useMemo } from 'react'; import { calculateRawTotalDonation } from '../lib/calculateRawTotalDonation'; import Decimal from 'decimal.js'; -import ERC20 from '../abi/ERC20.json'; +import { ERC20 } from '../abi/ERC20'; import { useToken } from './useTokenList'; export function useApproveSwapTokenCallback( @@ -10,22 +10,31 @@ export function useApproveSwapTokenCallback( decimalAmountIn: number, duration: number, toggleApproveSwapModalVisible: (value: boolean) => void, - collectiveAddress: string + collectiveAddress: `0x${string}` ): { isLoading: boolean; isSuccess: boolean; isError: boolean; + isRequireApprove: boolean; handleApproveToken?: () => Promise<`0x${string}` | undefined>; } { - const { address } = useAccount(); + const { address = '0x' } = useAccount(); const { chain } = useNetwork(); const tokenIn = useToken(currencyIn); const rawAmountIn = useMemo( - () => calculateRawTotalDonation(decimalAmountIn, duration, tokenIn.decimals).toFixed(0, Decimal.ROUND_DOWN), + () => BigInt(calculateRawTotalDonation(decimalAmountIn, duration, tokenIn.decimals).toFixed(0, Decimal.ROUND_DOWN)), [decimalAmountIn, duration, tokenIn.decimals] ); + const { data: allowance = 0n } = useContractRead({ + chainId: chain?.id, + address: tokenIn.address as `0x${string}`, + abi: ERC20, + functionName: 'allowance', + args: [address, collectiveAddress], + }); + const { config } = usePrepareContractWrite({ chainId: chain?.id, address: tokenIn.address as `0x${string}`, @@ -51,6 +60,7 @@ export function useApproveSwapTokenCallback( }; return { + isRequireApprove: rawAmountIn > allowance, isLoading, isSuccess, isError, diff --git a/packages/app/src/hooks/useSwapRoute.tsx b/packages/app/src/hooks/useSwapRoute.tsx index 8da3c913..104f4d4d 100644 --- a/packages/app/src/hooks/useSwapRoute.tsx +++ b/packages/app/src/hooks/useSwapRoute.tsx @@ -16,11 +16,13 @@ export enum SwapRouteState { NO_ROUTE, } +const DEFAULT_SLIPPAGE_TOLERANCE = new Percent(100, 10_000); + export function useSwapRoute( currencyIn: string, decimalAmountIn: number, duration: number, - slippageTolerance: Percent = new Percent(100, 10_000) + slippageTolerance: Percent = DEFAULT_SLIPPAGE_TOLERANCE ): { path?: string; quote?: Decimal; diff --git a/packages/sdk-js/src/goodcollective/goodcollective.ts b/packages/sdk-js/src/goodcollective/goodcollective.ts index ce23c017..93d5799f 100644 --- a/packages/sdk-js/src/goodcollective/goodcollective.ts +++ b/packages/sdk-js/src/goodcollective/goodcollective.ts @@ -1,4 +1,4 @@ -import { BigNumberish, ethers } from 'ethers'; +import { BigNumberish, ContractTransaction, ethers } from 'ethers'; import GoodCollectiveContracts from '@gooddollar/goodcollective-contracts/releases/deployment.json'; import { ProvableNFT, @@ -277,14 +277,18 @@ export class GoodCollectiveSDK { const appAction = this.pool.interface.encodeFunctionData('handleSwap', [swap, signerAddress, '0x']); - const flowAction = st.createFlow({ + const hasFlow = await st.getFlow({ receiver: poolAddress, sender: signerAddress, providerOrSigner: signer }); + const flowAction = hasFlow.flowRate === '0' ? st.createFlow : st.updateFlow; + + const flowOp = flowAction({ receiver: poolAddress, sender: signerAddress, flowRate: flowRate, overrides: { ...CHAIN_OVERRIDES[this.chainId] }, }); + const swapAction = sdk.host.callAppAction(poolAddress, appAction, { ...CHAIN_OVERRIDES[this.chainId] }); - const op = sdk.batchCall([swapAction, flowAction]); + const op = sdk.batchCall([swapAction, flowOp]); return op.exec(signer); } @@ -331,4 +335,14 @@ export class GoodCollectiveSDK { const tx = await this.pool.attach(poolAddress).connect(signer).handleSwap(swap, signerAddress, '0x'); return tx; } + + async approve( + signer: ethers.Signer, + tokenAddress: string, + poolAddress: string, + amount: string + ): Promise { + const token = new ethers.Contract(tokenAddress, ['function approve(address spender, uint256 amount)'], signer); + return token.approve(poolAddress, amount, { ...CHAIN_OVERRIDES[this.chainId], gasLimit: 100000 }); + } } From a2ea0f5e270de7e2b63bb99bd39048f9c8b5b236 Mon Sep 17 00:00:00 2001 From: sirpy Date: Mon, 5 Feb 2024 11:19:28 +0200 Subject: [PATCH 2/3] fix: useParams instead of slice hack --- packages/app/package.json | 4 ++-- packages/app/src/pages/DonatePage.tsx | 5 ++--- packages/app/src/pages/ViewCollectivePage.tsx | 6 +++--- packages/app/src/pages/ViewDonorsPage.tsx | 5 ++--- packages/app/src/pages/ViewStewardsPage.tsx | 5 ++--- packages/app/src/pages/WalletProfilePage.tsx | 7 ++++--- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/packages/app/package.json b/packages/app/package.json index 997d0421..e4a300bd 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -10,7 +10,7 @@ "format:check": "prettier -c ./src", "start": "react-native start", "test": "jest", - "web": "vite -c web/vite.config.ts", + "web": "vite --port 3000 -c web/vite.config.ts", "build": "yarn build:web", "build:web": "tsc && vite build -c web/vite.config.ts", "preview:web": "vite preview -c web/vite.config.ts" @@ -108,4 +108,4 @@ "jest": { "preset": "react-native" } -} +} \ No newline at end of file diff --git a/packages/app/src/pages/DonatePage.tsx b/packages/app/src/pages/DonatePage.tsx index 16dda799..a8eac45b 100644 --- a/packages/app/src/pages/DonatePage.tsx +++ b/packages/app/src/pages/DonatePage.tsx @@ -2,12 +2,11 @@ import Layout from '../components/Layout/Layout'; import DonateComponent from '../components/DonateComponent'; import React from 'react'; import { useCollectivesMetadataById } from '../hooks'; -import { useLocation } from 'react-router-native'; +import { useParams } from 'react-router-native'; import { Text } from 'react-native'; function DonatePage() { - const location = useLocation(); - const collectiveId = location.pathname.slice('/donate/'.length); + const { id: collectiveId = '' } = useParams(); const ipfsCollectives = useCollectivesMetadataById([collectiveId]); const ipfsCollective = ipfsCollectives.length > 0 ? ipfsCollectives[0] : undefined; diff --git a/packages/app/src/pages/ViewCollectivePage.tsx b/packages/app/src/pages/ViewCollectivePage.tsx index 8a0ecd3f..4e9ccb3d 100644 --- a/packages/app/src/pages/ViewCollectivePage.tsx +++ b/packages/app/src/pages/ViewCollectivePage.tsx @@ -2,12 +2,12 @@ import ViewCollective from '../components/ViewCollective'; import Layout from '../components/Layout/Layout'; import React from 'react'; import { useCollectiveById } from '../hooks'; -import { useLocation } from 'react-router-native'; +import { useParams } from 'react-router-native'; import { Text } from 'react-native'; function ViewCollectivePage() { - const location = useLocation(); - const collectiveId = location.pathname.slice('/collective/'.length); + const { id: collectiveId = '' } = useParams(); + const collective = useCollectiveById(collectiveId); return ( diff --git a/packages/app/src/pages/ViewDonorsPage.tsx b/packages/app/src/pages/ViewDonorsPage.tsx index 5e36cf89..496924ed 100644 --- a/packages/app/src/pages/ViewDonorsPage.tsx +++ b/packages/app/src/pages/ViewDonorsPage.tsx @@ -3,7 +3,7 @@ import Layout from '../components/Layout/Layout'; import { InterSemiBold } from '../utils/webFonts'; import { Colors } from '../utils/colors'; import { DonorBlue, Ocean } from '../assets'; -import { useLocation } from 'react-router-native'; +import { useParams } from 'react-router-native'; import { useCollectiveById } from '../hooks'; import React from 'react'; import { useMediaQuery } from 'native-base'; @@ -12,8 +12,7 @@ import DonorList from '../components/DonorsList/DonorsList'; function ViewDonorsPage() { const [isDesktopResolution] = useMediaQuery({ minWidth: 612 }); - const location = useLocation(); - const collectiveId = location.pathname.slice('/collective/'.length, location.pathname.indexOf('/donors')); + const { id: collectiveId = '' } = useParams(); const collective = useCollectiveById(collectiveId); const headerImage = collective?.ipfs.headerImage ? { uri: collective.ipfs.headerImage } : Ocean; diff --git a/packages/app/src/pages/ViewStewardsPage.tsx b/packages/app/src/pages/ViewStewardsPage.tsx index 4cd4adbc..fdbd3a25 100644 --- a/packages/app/src/pages/ViewStewardsPage.tsx +++ b/packages/app/src/pages/ViewStewardsPage.tsx @@ -5,7 +5,7 @@ import Layout from '../components/Layout/Layout'; import StewardList from '../components/StewardsList/StewardsList'; import { InterSemiBold } from '../utils/webFonts'; import { Colors } from '../utils/colors'; -import { useLocation } from 'react-router-native'; +import { useParams } from 'react-router-native'; import { useCollectiveById } from '../hooks'; import React from 'react'; import { Ocean } from '../assets'; @@ -13,8 +13,7 @@ import { Ocean } from '../assets'; function ViewStewardsPage() { const [isDesktopResolution] = useMediaQuery({ minWidth: 612 }); - const location = useLocation(); - const collectiveId = location.pathname.slice('/collective/'.length, location.pathname.indexOf('/stewards')); + const { id: collectiveId = '' } = useParams(); const collective = useCollectiveById(collectiveId); const headerImage = collective?.ipfs.headerImage ? { uri: collective.ipfs.headerImage } : Ocean; diff --git a/packages/app/src/pages/WalletProfilePage.tsx b/packages/app/src/pages/WalletProfilePage.tsx index a98db814..846800fd 100644 --- a/packages/app/src/pages/WalletProfilePage.tsx +++ b/packages/app/src/pages/WalletProfilePage.tsx @@ -1,14 +1,15 @@ import React from 'react'; import Layout from '../components/Layout/Layout'; import { useDonorById, useStewardById } from '../hooks'; -import { useLocation } from 'react-router-native'; +import { useParams } from 'react-router-native'; import WalletProfile from '../components/WalletProfile'; import { useEnsName } from 'wagmi'; import { useFetchFullName } from '../hooks/useFetchFullName'; function WalletProfilePage() { - const location = useLocation(); - const profileAddress = location.pathname.slice('/profile/'.length).toLocaleLowerCase(); + const { id = '' } = useParams(); + const profileAddress = id.toLowerCase(); + const donor = useDonorById(profileAddress, 1000); const steward = useStewardById(profileAddress); From dd00bbb13f78ac8e9cfd9b3b58e420a97417cf74 Mon Sep 17 00:00:00 2001 From: LewisB Date: Tue, 6 Feb 2024 01:44:17 +0800 Subject: [PATCH 3/3] remove log --- packages/app/src/components/Header/ConnectedAccountDisplay.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/app/src/components/Header/ConnectedAccountDisplay.tsx b/packages/app/src/components/Header/ConnectedAccountDisplay.tsx index 9f65613d..22c49fd7 100644 --- a/packages/app/src/components/Header/ConnectedAccountDisplay.tsx +++ b/packages/app/src/components/Header/ConnectedAccountDisplay.tsx @@ -19,7 +19,7 @@ export const ConnectedAccountDisplay = (props: ConnectedAccountDisplayProps) => const { chain } = useNetwork(); let chainName = chain?.name.replace(/\d+|\s/g, ''); - console.log('chainName', { chainName, chain: chain }); + if (!(chainName && chainName.toUpperCase() in SupportedNetwork)) { chainName = 'Unsupported Network'; }