From 747df4c7683560d909d1369bae942d2ec9f854a0 Mon Sep 17 00:00:00 2001 From: Lovel George Date: Fri, 14 Jun 2024 14:13:55 -0400 Subject: [PATCH 001/156] change console.log to console.error in try catch blocks and removed logs to show up in production --- pages/_app.tsx | 3 +++ pages/donate/[slug].tsx | 2 +- pages/success/[slug].tsx | 2 +- pages/verification/[slug]/index.tsx | 2 +- scripts/generate-robots-txt.js | 2 +- src/apollo/apolloClient.ts | 4 ++-- src/components/USDInput.tsx | 2 +- src/components/cards/MintCard.tsx | 4 ++-- src/components/menu/NotificationButtonWithMenu.tsx | 2 +- src/components/modals/EditUserModal.tsx | 2 +- src/components/modals/Mint/MintModal.tsx | 4 ++-- src/components/modals/SearchModal.tsx | 2 +- .../modals/StakeLock/TotalGIVpowerBox.tsx | 2 +- .../deactivateProject/DeactivateProjectIndex.tsx | 2 +- src/components/views/EditIndex.tsx | 2 +- .../create/AlloProtocol/AlloProtocolModal.tsx | 2 +- src/components/views/donate/DonateModal.tsx | 2 +- .../donate/ModifySuperToken/DepositSuperToken.tsx | 4 ++-- .../donate/ModifySuperToken/WithDrawSuperToken.tsx | 2 +- .../RecurringDonationModal.tsx | 2 +- src/components/views/homepage/HomeFromBlog.tsx | 2 +- .../views/nft/overview/CheckEligibility.tsx | 4 ++-- .../views/project/projectUpdates/index.tsx | 2 +- .../userProfile/boostedTab/ProfileBoostedTab.tsx | 4 ++-- .../donationsTab/recurringTab/EndStreamModal.tsx | 2 +- .../ModifyStreamModal/UpdateStreamInnerModal.tsx | 2 +- src/components/views/verification/PersonalInfo.tsx | 2 +- src/context/profile.context.tsx | 2 +- src/context/project.context.tsx | 2 +- src/features/user/user.thunks.ts | 10 +++++----- src/helpers/network.ts | 2 +- src/hooks/useCreateEvmDonation.tsx | 6 +++--- src/hooks/useCreateSolanaDonation.tsx | 2 +- src/hooks/usePassport.ts | 2 +- src/hooks/useStakingPool.ts | 2 +- src/lib/authentication.ts | 2 +- src/lib/contracts.ts | 2 +- src/lib/helpers.ts | 4 ++-- src/lib/metamask/index.ts | 2 +- src/lib/safe/index.ts | 2 +- src/lib/stakingPool.ts | 14 +++++++------- src/lib/transaction.ts | 4 ++-- src/lib/wallet.ts | 2 +- src/services/donation.ts | 12 ++++++------ src/services/passport.ts | 4 ++-- src/services/token.ts | 2 +- 46 files changed, 74 insertions(+), 71 deletions(-) diff --git a/pages/_app.tsx b/pages/_app.tsx index e1c298b711..fe496dc64a 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -78,6 +78,9 @@ function renderSnippet() { if (process.env.NEXT_PUBLIC_ENV === 'development') { return snippet.max(opts); } + if (process.env.NEXT_PUBLIC_ENV === "production") { + console.log = function () {}; + } return snippet.min(opts); } diff --git a/pages/donate/[slug].tsx b/pages/donate/[slug].tsx index efcb9d7bc8..d70ebf51c3 100644 --- a/pages/donate/[slug].tsx +++ b/pages/donate/[slug].tsx @@ -53,7 +53,7 @@ export const getServerSideProps: GetServerSideProps = async props => { }, }; } catch (error: any) { - console.log({ error }); + console.error({ error }); captureException(error, { tags: { section: 'Donate SSR', diff --git a/pages/success/[slug].tsx b/pages/success/[slug].tsx index 1bfd2610b8..24bd6338a1 100644 --- a/pages/success/[slug].tsx +++ b/pages/success/[slug].tsx @@ -26,7 +26,7 @@ const SuccessRoute = () => { setProject(data.projectBySlug); setIsLoading(false); } catch (error) { - console.log('fetchProjectBySlug error: ', error); + console.error('fetchProjectBySlug error: ', error); setIsLoading(false); captureException(error, { tags: { diff --git a/pages/verification/[slug]/index.tsx b/pages/verification/[slug]/index.tsx index 4a409ebbf1..5ce5ca2c12 100644 --- a/pages/verification/[slug]/index.tsx +++ b/pages/verification/[slug]/index.tsx @@ -68,7 +68,7 @@ const VerificationRoute = () => { setIsProjectLoading(false); }) .catch((error: unknown) => { - console.log('fetchProjectBySlug error: ', error); + console.error('fetchProjectBySlug error: ', error); captureException(error, { tags: { section: 'verificationFetchProjectBySlug', diff --git a/scripts/generate-robots-txt.js b/scripts/generate-robots-txt.js index 6ad80c3899..eb3bb8763f 100644 --- a/scripts/generate-robots-txt.js +++ b/scripts/generate-robots-txt.js @@ -21,7 +21,7 @@ function generateRobotsTxt() { } public/robots.txt`, ); } catch (error) { - console.log(`Cannot Generate a public/robots.txt`, error); + console.error(`Cannot Generate a public/robots.txt`, error); } } diff --git a/src/apollo/apolloClient.ts b/src/apollo/apolloClient.ts index d89253265c..47d177f49e 100644 --- a/src/apollo/apolloClient.ts +++ b/src/apollo/apolloClient.ts @@ -122,7 +122,7 @@ function createApolloClient() { if (graphQLErrors) { console.log('operation', operation); graphQLErrors.forEach(err => { - console.log('err', JSON.stringify(err)); + console.error('err', JSON.stringify(err)); const { message, locations, path } = err; if (message.toLowerCase().includes('authentication required')) { console.log(Date.now(), 'sign out from graphQL'); @@ -134,7 +134,7 @@ function createApolloClient() { } }); } - if (networkError) console.log(`[Network error]: ${networkError}`); + if (networkError) console.error(`[Network error]: ${networkError}`); const { response } = operation.getContext(); if ( diff --git a/src/components/USDInput.tsx b/src/components/USDInput.tsx index eff9ec13a4..5870545984 100644 --- a/src/components/USDInput.tsx +++ b/src/components/USDInput.tsx @@ -42,7 +42,7 @@ export const USDInput: FC = ({ try { temp = parseUnits(value || '0', 6).toString(); } catch (error) { - console.log('number is not acceptable'); + console.error('number is not acceptable'); captureException(error, { tags: { section: 'USDInput', diff --git a/src/components/cards/MintCard.tsx b/src/components/cards/MintCard.tsx index 910432237a..fffc16a7bb 100644 --- a/src/components/cards/MintCard.tsx +++ b/src/components/cards/MintCard.tsx @@ -106,7 +106,7 @@ export const MintCard = () => { maxSupply: _maxSupply || 0, }); } catch (error) { - console.log('failed to fetch GIversPFP data'); + console.error('failed to fetch GIversPFP data'); } } fetchData(); @@ -125,7 +125,7 @@ export const MintCard = () => { }); setBalance(Number(_balanceOf || '0')); } catch (error) { - console.log('failed to fetch user balance data'); + console.error('failed to fetch user balance data'); } } fetchData(); diff --git a/src/components/menu/NotificationButtonWithMenu.tsx b/src/components/menu/NotificationButtonWithMenu.tsx index afd32358b6..f8ca7b13dc 100644 --- a/src/components/menu/NotificationButtonWithMenu.tsx +++ b/src/components/menu/NotificationButtonWithMenu.tsx @@ -64,7 +64,7 @@ export const NotificationButtonWithMenu: FC = ({ const res = await fetchNotificationsData({ limit: 4 }); if (res?.notifications) setNotifications(res.notifications); } catch (e) { - console.log('fetchNotificationsAndSetState error: ', e); + console.error('fetchNotificationsAndSetState error: ', e); } }; if (NOTIFICATION_ENABLED) { diff --git a/src/components/modals/EditUserModal.tsx b/src/components/modals/EditUserModal.tsx index 461fe0f9f7..341d6bdcad 100644 --- a/src/components/modals/EditUserModal.tsx +++ b/src/components/modals/EditUserModal.tsx @@ -79,7 +79,7 @@ const EditUserModal = ({ type: ToastType.DANGER, title: error.message, }); - console.log(error); + console.error(error); captureException(error, { tags: { section: 'onSaveAvatar', diff --git a/src/components/modals/Mint/MintModal.tsx b/src/components/modals/Mint/MintModal.tsx index d6ea0d3e65..52dd4131eb 100644 --- a/src/components/modals/Mint/MintModal.tsx +++ b/src/components/modals/Mint/MintModal.tsx @@ -75,7 +75,7 @@ export const MintModal: FC = ({ } } catch (error) { setStep(MintStep.APPROVE); - console.log('error on approve dai', error); + console.error('error on approve dai', error); } } @@ -115,7 +115,7 @@ export const MintModal: FC = ({ } } catch (error) { setMintStep(EPFPMinSteps.FAILURE); - console.log('error on mint', error); + console.error('error on mint', error); } } diff --git a/src/components/modals/SearchModal.tsx b/src/components/modals/SearchModal.tsx index 753f36430a..ed70801dd9 100644 --- a/src/components/modals/SearchModal.tsx +++ b/src/components/modals/SearchModal.tsx @@ -124,7 +124,7 @@ export const SearchModal: FC = ({ setShowModal }) => { const campaign: ICampaign = data.findCampaignBySlug; setProjects(campaign.relatedProjects); } catch (error) { - console.log('error', error); + console.error('error', error); } } fetchFeaturedCampaign(); diff --git a/src/components/modals/StakeLock/TotalGIVpowerBox.tsx b/src/components/modals/StakeLock/TotalGIVpowerBox.tsx index 024a0f1250..80bcebfe83 100644 --- a/src/components/modals/StakeLock/TotalGIVpowerBox.tsx +++ b/src/components/modals/StakeLock/TotalGIVpowerBox.tsx @@ -40,7 +40,7 @@ const TotalGIVpowerBox = () => { return setTotalGIVpower(total); } } catch (err) { - console.log('Error on getGIVpowerOnChain', { err }); + console.error('Error on getGIVpowerOnChain', { err }); } // if we can't get the GIVpower from the contract, we calculate it from the subgraph const { total } = getTotalGIVpower(values); diff --git a/src/components/modals/deactivateProject/DeactivateProjectIndex.tsx b/src/components/modals/deactivateProject/DeactivateProjectIndex.tsx index eb9fc90bc8..e424799f4a 100644 --- a/src/components/modals/deactivateProject/DeactivateProjectIndex.tsx +++ b/src/components/modals/deactivateProject/DeactivateProjectIndex.tsx @@ -94,7 +94,7 @@ const DeactivateProjectModal: FC = ({ setIsLoading(false); } catch (error) { setIsLoading(false); - console.log('deactivation error', { error }); + console.error('deactivation error', { error }); } }; diff --git a/src/components/views/EditIndex.tsx b/src/components/views/EditIndex.tsx index 385d3e7cfe..24bdae5894 100644 --- a/src/components/views/EditIndex.tsx +++ b/src/components/views/EditIndex.tsx @@ -81,7 +81,7 @@ const EditIndex = () => { }) .catch((error: unknown) => { setIsLoadingProject(false); - console.log(error); + console.error(error); captureException(error, { tags: { section: 'EditIndex', diff --git a/src/components/views/create/AlloProtocol/AlloProtocolModal.tsx b/src/components/views/create/AlloProtocol/AlloProtocolModal.tsx index afac34799d..f5a30fa2ad 100644 --- a/src/components/views/create/AlloProtocol/AlloProtocolModal.tsx +++ b/src/components/views/create/AlloProtocol/AlloProtocolModal.tsx @@ -120,7 +120,7 @@ const AlloProtocolModal: FC = ({ } setShowModal(false); // Close the modal } catch (error) { - console.log('Error Contract', error); + console.error('Error Contract', error); } finally { setIsLoading(false); } diff --git a/src/components/views/donate/DonateModal.tsx b/src/components/views/donate/DonateModal.tsx index 3e028157f3..6522b0b958 100644 --- a/src/components/views/donate/DonateModal.tsx +++ b/src/components/views/donate/DonateModal.tsx @@ -107,7 +107,7 @@ const DonateModal: FC = props => { } catch (e) { setIsLoadingGivethAddress(false); showToastError('Failed to fetch Giveth wallet address'); - console.log('Failed to fetch Giveth wallet address', e); + console.error('Failed to fetch Giveth wallet address', e); closeModal(); } }; diff --git a/src/components/views/donate/ModifySuperToken/DepositSuperToken.tsx b/src/components/views/donate/ModifySuperToken/DepositSuperToken.tsx index bdb8f8abb3..75a4220755 100644 --- a/src/components/views/donate/ModifySuperToken/DepositSuperToken.tsx +++ b/src/components/views/donate/ModifySuperToken/DepositSuperToken.tsx @@ -91,7 +91,7 @@ export const DepositSuperToken: FC = ({ setStep(EModifySuperTokenSteps.APPROVE); } } catch (error) { - console.log('error', error); + console.error('error', error); setStep(EModifySuperTokenSteps.APPROVE); } }; @@ -150,7 +150,7 @@ export const DepositSuperToken: FC = ({ showToastError(error); setStep(EModifySuperTokenSteps.DEPOSIT); } - console.log('error', error); + console.error('error', error); } }; diff --git a/src/components/views/donate/ModifySuperToken/WithDrawSuperToken.tsx b/src/components/views/donate/ModifySuperToken/WithDrawSuperToken.tsx index cab0a5266a..4c9e2dbe3d 100644 --- a/src/components/views/donate/ModifySuperToken/WithDrawSuperToken.tsx +++ b/src/components/views/donate/ModifySuperToken/WithDrawSuperToken.tsx @@ -111,7 +111,7 @@ export const WithDrawSuperToken: FC = ({ showToastError(error); setStep(EModifySuperTokenSteps.WITHDRAW); } - console.log('error', error); + console.error('error', error); } }; diff --git a/src/components/views/donate/RecurringDonationModal/RecurringDonationModal.tsx b/src/components/views/donate/RecurringDonationModal/RecurringDonationModal.tsx index bdc5bf62d6..fd03a70b42 100644 --- a/src/components/views/donate/RecurringDonationModal/RecurringDonationModal.tsx +++ b/src/components/views/donate/RecurringDonationModal/RecurringDonationModal.tsx @@ -470,7 +470,7 @@ const RecurringDonationInnerModal: FC = ({ if (error?.code !== 'ACTION_REJECTED') { showToastError(error); } - console.log('Error on recurring donation', { error }); + console.error('Error on recurring donation', { error }); } }; diff --git a/src/components/views/homepage/HomeFromBlog.tsx b/src/components/views/homepage/HomeFromBlog.tsx index f3d1c267e5..164c540cb6 100644 --- a/src/components/views/homepage/HomeFromBlog.tsx +++ b/src/components/views/homepage/HomeFromBlog.tsx @@ -40,7 +40,7 @@ const HomeFromBlog = () => { }); setMediumPosts(modifiedPosts); } catch (error) { - console.log('error', error); + console.error('error', error); } }; getPosts(); diff --git a/src/components/views/nft/overview/CheckEligibility.tsx b/src/components/views/nft/overview/CheckEligibility.tsx index 01677a6755..8ec0072d59 100644 --- a/src/components/views/nft/overview/CheckEligibility.tsx +++ b/src/components/views/nft/overview/CheckEligibility.tsx @@ -45,7 +45,7 @@ const CheckEligibility = () => { setShowModal(true); } catch (error) { setError('Cannot get data'); - console.log('ErrorRRR', error); + console.error('ErrorRRR', error); } }; @@ -73,7 +73,7 @@ const CheckEligibility = () => { } } catch (error) { setError('Please connect your wallet'); - console.log('Error', error); + console.error('Error', error); } }; diff --git a/src/components/views/project/projectUpdates/index.tsx b/src/components/views/project/projectUpdates/index.tsx index 9f1b933b69..469f242a4b 100644 --- a/src/components/views/project/projectUpdates/index.tsx +++ b/src/components/views/project/projectUpdates/index.tsx @@ -96,7 +96,7 @@ const ProjectUpdates = () => { }); return true; } catch (error: any) { - console.log({ error }); + console.error({ error }); captureException(error, { tags: { section: 'editProjectUpdate', diff --git a/src/components/views/userProfile/boostedTab/ProfileBoostedTab.tsx b/src/components/views/userProfile/boostedTab/ProfileBoostedTab.tsx index 9c00a56731..3a1153d966 100644 --- a/src/components/views/userProfile/boostedTab/ProfileBoostedTab.tsx +++ b/src/components/views/userProfile/boostedTab/ProfileBoostedTab.tsx @@ -83,7 +83,7 @@ export const ProfileBoostedTab: FC = () => { setLoading(false); return false; } catch (error) { - console.log({ error }); + console.error({ error }); captureException(error, { tags: { section: 'Save manage power boosting', @@ -122,7 +122,7 @@ export const ProfileBoostedTab: FC = () => { setLoading(false); return false; } catch (error) { - console.log({ error }); + console.error({ error }); captureException(error, { tags: { section: 'Save manage power boosting', diff --git a/src/components/views/userProfile/donationsTab/recurringTab/EndStreamModal.tsx b/src/components/views/userProfile/donationsTab/recurringTab/EndStreamModal.tsx index c61306984a..2fd8130af4 100644 --- a/src/components/views/userProfile/donationsTab/recurringTab/EndStreamModal.tsx +++ b/src/components/views/userProfile/donationsTab/recurringTab/EndStreamModal.tsx @@ -139,7 +139,7 @@ const EndStreamInnerModal: FC = ({ if (error?.code !== 'ACTION_REJECTED') { showToastError(error); } - console.log('Error on recurring donation', { error }); + console.error('Error on recurring donation', { error }); } }; diff --git a/src/components/views/userProfile/donationsTab/recurringTab/ModifyStreamModal/UpdateStreamInnerModal.tsx b/src/components/views/userProfile/donationsTab/recurringTab/ModifyStreamModal/UpdateStreamInnerModal.tsx index 30bce4219e..d4ac8ac327 100644 --- a/src/components/views/userProfile/donationsTab/recurringTab/ModifyStreamModal/UpdateStreamInnerModal.tsx +++ b/src/components/views/userProfile/donationsTab/recurringTab/ModifyStreamModal/UpdateStreamInnerModal.tsx @@ -170,7 +170,7 @@ export const UpdateStreamInnerModal: FC = ({ if (error?.code !== 'ACTION_REJECTED') { showToastError(error); } - console.log('Error on recurring donation', { error }); + console.error('Error on recurring donation', { error }); } }; diff --git a/src/components/views/verification/PersonalInfo.tsx b/src/components/views/verification/PersonalInfo.tsx index e7674ec3a9..3aa34604b4 100644 --- a/src/components/views/verification/PersonalInfo.tsx +++ b/src/components/views/verification/PersonalInfo.tsx @@ -97,7 +97,7 @@ const PersonalInfo = () => { await sendEmail(); setResetMail(false); } catch (error) { - console.log('SubmitError', error); + console.error('SubmitError', error); } finally { setIsSentMailLoading(false); } diff --git a/src/context/profile.context.tsx b/src/context/profile.context.tsx index cd86d4001a..14518c684b 100644 --- a/src/context/profile.context.tsx +++ b/src/context/profile.context.tsx @@ -38,7 +38,7 @@ export const ProfileProvider = (props: { ]); setBalance(res[user.walletAddress!]); } catch (error) { - console.log('error on getGIVpowerBalanceByAddress', { error }); + console.error('error on getGIVpowerBalanceByAddress', { error }); } }; if (!myAccount) fetchTotal(); diff --git a/src/context/project.context.tsx b/src/context/project.context.tsx index 6124f09249..dfc42d7c21 100644 --- a/src/context/project.context.tsx +++ b/src/context/project.context.tsx @@ -129,7 +129,7 @@ export const ProjectProvider = ({ setIsLoading(false); }) .catch((error: unknown) => { - console.log('fetchProjectBySlug error: ', error); + console.error('fetchProjectBySlug error: ', error); captureException(error, { tags: { section: 'fetchProject', diff --git a/src/features/user/user.thunks.ts b/src/features/user/user.thunks.ts index a119a2df16..d639ad685d 100644 --- a/src/features/user/user.thunks.ts +++ b/src/features/user/user.thunks.ts @@ -129,7 +129,7 @@ export const signToGetToken = createAsyncThunk( sessionPending = true; } } catch (error) { - console.log({ error }); + console.error({ error }); } console.log({ activeSafeToken, @@ -165,7 +165,7 @@ export const signToGetToken = createAsyncThunk( }); } catch (error) { // user will close the transaction but it will create anyway - console.log({ error }); + console.error({ error }); } // calls the backend to create gnosis safe token console.log({ @@ -203,7 +203,7 @@ export const signToGetToken = createAsyncThunk( return Promise.reject('Signing failed'); } } catch (error) { - console.log({ error }); + console.error({ error }); return Promise.reject('Signing failed'); } }, @@ -234,7 +234,7 @@ export const startChainvineReferral = createAsyncThunk( dispatch(fetchUserByAddress(address)); return res?.payload; } catch (error) { - console.log({ error }); + console.error({ error }); return Promise.reject('Referral start failed'); } }, @@ -250,7 +250,7 @@ export const countReferralClick = createAsyncThunk( ); return response?.payload; } catch (error) { - console.log({ error }); + console.error({ error }); return Promise.reject('Referral start failed'); } }, diff --git a/src/helpers/network.ts b/src/helpers/network.ts index f0242bee2e..16fa7ad6e5 100644 --- a/src/helpers/network.ts +++ b/src/helpers/network.ts @@ -10,7 +10,7 @@ export const ensureCorrectNetwork = async (targetChainId: number) => { }); return chain.id === targetChainId; } catch (error) { - console.log('error', error); + console.error('error', error); return false; } }; diff --git a/src/hooks/useCreateEvmDonation.tsx b/src/hooks/useCreateEvmDonation.tsx index 2b3761a621..d8113d9b72 100644 --- a/src/hooks/useCreateEvmDonation.tsx +++ b/src/hooks/useCreateEvmDonation.tsx @@ -146,7 +146,7 @@ export const useCreateEvmDonation = () => { setFailedModalType(EDonationFailedType.NOT_SAVED); } } catch (error) { - console.log('Error sending transaction', { error }); + console.error('Error sending transaction', { error }); } }; @@ -155,14 +155,14 @@ export const useCreateEvmDonation = () => { donationId: number, setFailedModalType: (type: EDonationFailedType) => void, ) => { - console.log('name', error.name); + console.error('name', error.name); const localTxHash = error.replacement?.hash || error.transactionHash; setTxHash(localTxHash); if (error.name === 'TransactionExecutionError') { setFailedModalType(EDonationFailedType.FAILED); } else { - console.log('Rejected1', error); + console.error('Rejected1', error); setFailedModalType(EDonationFailedType.REJECTED); } diff --git a/src/hooks/useCreateSolanaDonation.tsx b/src/hooks/useCreateSolanaDonation.tsx index aca487aa91..04eba2d00f 100644 --- a/src/hooks/useCreateSolanaDonation.tsx +++ b/src/hooks/useCreateSolanaDonation.tsx @@ -105,7 +105,7 @@ export const useCreateSolanaDonation = () => { setFailedModalType(EDonationFailedType.NOT_SAVED); } } catch (error) { - console.log('Error sending transaction', { error }); + console.error('Error sending transaction', { error }); } }; diff --git a/src/hooks/usePassport.ts b/src/hooks/usePassport.ts index 46df0a5515..6835155d33 100644 --- a/src/hooks/usePassport.ts +++ b/src/hooks/usePassport.ts @@ -151,7 +151,7 @@ export const usePassport = () => { const { refreshUserScores } = await fetchPassportScore(address); await updateState(refreshUserScores); } catch (error) { - console.log(error); + console.error(error); setInfo({ passportState: EPassportState.ERROR, passportScore: null, diff --git a/src/hooks/useStakingPool.ts b/src/hooks/useStakingPool.ts index 95a2476a6b..f753ee6c38 100644 --- a/src/hooks/useStakingPool.ts +++ b/src/hooks/useStakingPool.ts @@ -48,7 +48,7 @@ export const useStakingPool = ( ? getGivStakingAPR(network, currentValues, network) : getLPStakingAPR(poolStakingConfig, currentValues); promise.then(setApr).catch(e => { - console.log('Error Calculating APR', e); + console.error('Error Calculating APR', e); setApr({ effectiveAPR: Zero }); }); } else { diff --git a/src/lib/authentication.ts b/src/lib/authentication.ts index a6a74cfec8..8db97989fd 100644 --- a/src/lib/authentication.ts +++ b/src/lib/authentication.ts @@ -39,7 +39,7 @@ export const createSiweMessage = async ( nonce, }; } catch (error) { - console.log({ error }); + console.error({ error }); return false; } }; diff --git a/src/lib/contracts.ts b/src/lib/contracts.ts index df3e85b556..a55d56c554 100644 --- a/src/lib/contracts.ts +++ b/src/lib/contracts.ts @@ -46,7 +46,7 @@ export async function getERC20Info({ contractAddress, networkId }: IERC20Info) { return ERC20Info; } catch (error) { - console.log({ error }); + console.error({ error }); captureException(error, { tags: { section: 'getERC20Info', diff --git a/src/lib/helpers.ts b/src/lib/helpers.ts index 849dabd661..77ae46c798 100644 --- a/src/lib/helpers.ts +++ b/src/lib/helpers.ts @@ -504,7 +504,7 @@ export const showToastError = (err: any) => { type: ToastType.DANGER, position: 'top-center', }); - console.log({ err }); + console.error({ err }); }; export const calcBiggestUnitDifferenceTime = (_time: string) => { @@ -607,7 +607,7 @@ export const getUserIPInfo = async () => { return fetch('https://api.db-ip.com/v2/free/self') .then(res => res.json()) .catch(err => { - console.log('getUserIp error: ', { err }); + console.error('getUserIp error: ', { err }); throw err; }); }; diff --git a/src/lib/metamask/index.ts b/src/lib/metamask/index.ts index b0424eb93d..b5002356ce 100644 --- a/src/lib/metamask/index.ts +++ b/src/lib/metamask/index.ts @@ -157,7 +157,7 @@ export async function addToken_old( console.log('Your loss!'); } } catch (error) { - console.log(error); + console.error(error); captureException(error, { tags: { section: 'addToken', diff --git a/src/lib/safe/index.ts b/src/lib/safe/index.ts index 0a15ee7c61..2ca05557ef 100644 --- a/src/lib/safe/index.ts +++ b/src/lib/safe/index.ts @@ -14,7 +14,7 @@ export const getTxFromSafeTxId = async ( const tx = await safeService.getTransaction(safeTxHash); return tx; } catch (error) { - console.log("Couldn't get tx from safe tx hash", error); + console.error("Couldn't get tx from safe tx hash", error); return null; } }; diff --git a/src/lib/stakingPool.ts b/src/lib/stakingPool.ts index 4257cbc37f..a1cf82306b 100644 --- a/src/lib/stakingPool.ts +++ b/src/lib/stakingPool.ts @@ -75,7 +75,7 @@ const getUnipoolInfo = async ( totalSupply = _totalSupply as bigint; rewardRate = _rewardRate as bigint; } catch (error) { - console.log('Error on fetching totalSupply,rewardRate :', error); + console.error('Error on fetching totalSupply,rewardRate :', error); captureException(error, { tags: { section: 'getUnipoolInfo', @@ -537,7 +537,7 @@ export const approveERC20tokenTransfer = async ( return false; } } catch (error) { - console.log('Error on Approve', error); + console.error('Error on Approve', error); return false; } }; @@ -558,7 +558,7 @@ export const wrapToken = async ( value: 0n, }); } catch (error) { - console.log('Error on wrapping token:', error); + console.error('Error on wrapping token:', error); captureException(error, { tags: { section: 'wrapToken', @@ -583,7 +583,7 @@ export const stakeGIV = async ( value: 0n, }); } catch (error) { - console.log('Error on stake token:', error); + console.error('Error on stake token:', error); captureException(error, { tags: { section: 'stakeToken', @@ -609,7 +609,7 @@ export const unwrapToken = async ( value: 0n, }); } catch (error) { - console.log('Error on unwrapping token:', error); + console.error('Error on unwrapping token:', error); captureException(error, { tags: { section: 'unwrapToken', @@ -728,7 +728,7 @@ export const lockToken = async ( value: 0n, }); } catch (error) { - console.log('Error on locking token:', error); + console.error('Error on locking token:', error); captureException(error, { tags: { section: 'lockToken', @@ -760,7 +760,7 @@ export const getGIVpowerOnChain = async ( args: [account], })) as bigint; } catch (error) { - console.log('Error on get total GIVpower:', error); + console.error('Error on get total GIVpower:', error); captureException(error, { tags: { section: 'getTotalGIVpower', diff --git a/src/lib/transaction.ts b/src/lib/transaction.ts index 8bb1013df9..54bda2b6fe 100644 --- a/src/lib/transaction.ts +++ b/src/lib/transaction.ts @@ -59,7 +59,7 @@ export const retryFetchEVMTransaction = async ( const transaction = await getTransaction(wagmiConfig, { hash: txHash, }).catch(error => { - console.log( + console.error( 'Attempt', i, 'Fetching Transaction Error:', @@ -88,7 +88,7 @@ export const retryFetchSolanaTransaction = async ( solanaConnection, txHash, ).catch(error => { - console.log( + console.error( 'Attempt', i, 'Fetching Transaction Error:', diff --git a/src/lib/wallet.ts b/src/lib/wallet.ts index b8880996ee..a47befe514 100644 --- a/src/lib/wallet.ts +++ b/src/lib/wallet.ts @@ -18,7 +18,7 @@ export function isSolanaAddress(address: string) { const isOnCurve = PublicKey.isOnCurve(publicKey); return typeof isOnCurve === 'boolean'; } catch (e) { - console.log(e); + console.error(e); return false; } } diff --git a/src/services/donation.ts b/src/services/donation.ts index 383cfeb882..65a63c24fc 100644 --- a/src/services/donation.ts +++ b/src/services/donation.ts @@ -100,7 +100,7 @@ const createDonation = async (props: IOnTxHash) => { section: SENTRY_URGENT, }, }); - console.log('createDonation error: ', error); + console.error('createDonation error: ', error); throw error; } @@ -174,7 +174,7 @@ export const createDraftRecurringDonation = async ({ section: SENTRY_URGENT, }, }); - console.log('createDraftRecurringDonation error: ', error); + console.error('createDraftRecurringDonation error: ', error); throw error; } }; @@ -216,7 +216,7 @@ export const createRecurringDonation = async ({ section: SENTRY_URGENT, }, }); - console.log('createRecurringDonation error: ', error); + console.error('createRecurringDonation error: ', error); throw error; } }; @@ -272,7 +272,7 @@ export const updateRecurringDonation = async ( section: SENTRY_URGENT, }, }); - console.log('updateRecurringDonation error: ', error); + console.error('updateRecurringDonation error: ', error); throw error; } }; @@ -313,7 +313,7 @@ export const endRecurringDonation = async ({ section: SENTRY_URGENT, }, }); - console.log('endRecurringDonation error: ', error); + console.error('endRecurringDonation error: ', error); throw error; } }; @@ -337,7 +337,7 @@ export const updateRecurringDonationStatus = async ( section: SENTRY_URGENT, }, }); - console.log('updateRecurringDonationStatus error: ', error); + console.error('updateRecurringDonationStatus error: ', error); throw error; } }; diff --git a/src/services/passport.ts b/src/services/passport.ts index d04b05b9d9..f073ebd4ce 100644 --- a/src/services/passport.ts +++ b/src/services/passport.ts @@ -19,7 +19,7 @@ export const fetchPassportScore = async (account: string) => { }); return data; } catch (error) { - console.log('error', error); + console.error('error', error); //remove user's info from local storage const passports = getPassports(); delete passports[account.toLowerCase()]; @@ -64,7 +64,7 @@ export const connectPassport = async (account: string, singin: boolean) => { } return true; } catch (error: any) { - console.log('error', error); + console.error('error', error); if (error.code === 'ACTION_REJECTED') { showToastError('Rejected By User'); } else { diff --git a/src/services/token.ts b/src/services/token.ts index b578e9d1fb..f7ca779e7a 100644 --- a/src/services/token.ts +++ b/src/services/token.ts @@ -45,7 +45,7 @@ export const fetchBalance = async ( }); } } catch (error) { - console.log('error on fetchBalance', { error }); + console.error('error on fetchBalance', { error }); return; } }; From 120c8ef4736ef0b0fad63cdee732ada0ca21e3f0 Mon Sep 17 00:00:00 2001 From: Lovel George Date: Mon, 17 Jun 2024 09:06:39 -0400 Subject: [PATCH 002/156] fixed lint --- pages/_app.tsx | 2 +- src/context/profile.context.tsx | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pages/_app.tsx b/pages/_app.tsx index fe496dc64a..459c3fe8e8 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -78,7 +78,7 @@ function renderSnippet() { if (process.env.NEXT_PUBLIC_ENV === 'development') { return snippet.max(opts); } - if (process.env.NEXT_PUBLIC_ENV === "production") { + if (process.env.NEXT_PUBLIC_ENV === 'production') { console.log = function () {}; } diff --git a/src/context/profile.context.tsx b/src/context/profile.context.tsx index 14518c684b..8c946979c2 100644 --- a/src/context/profile.context.tsx +++ b/src/context/profile.context.tsx @@ -38,7 +38,9 @@ export const ProfileProvider = (props: { ]); setBalance(res[user.walletAddress!]); } catch (error) { - console.error('error on getGIVpowerBalanceByAddress', { error }); + console.error('error on getGIVpowerBalanceByAddress', { + error, + }); } }; if (!myAccount) fetchTotal(); From 2e3990ff4255971f572c1829ee5ce3946a8d051e Mon Sep 17 00:00:00 2001 From: kkatusic Date: Mon, 17 Jun 2024 16:12:19 +0200 Subject: [PATCH 003/156] added validation for steps --- lang/ca.json | 1 + lang/en.json | 1 + lang/es.json | 1 + src/apollo/types/types.ts | 9 +++ .../views/verification/PersonalInfo.tsx | 14 ++-- .../views/verification/TermsAndConditions.tsx | 79 ++++++++++++++++--- .../views/verification/WarningCircle.tsx | 25 ++++++ .../views/verification/menu/DesktopMenu.tsx | 25 ++++-- .../views/verification/menu/menuList.ts | 29 ++++--- src/helpers/projects.ts | 57 +++++++++++++ 10 files changed, 206 insertions(+), 35 deletions(-) create mode 100644 src/components/views/verification/WarningCircle.tsx diff --git a/lang/ca.json b/lang/ca.json index 44d213efe1..6dc4042a06 100644 --- a/lang/ca.json +++ b/lang/ca.json @@ -835,6 +835,7 @@ "label.save_changes": "Desa els canvis", "label.save_on_gas_fees": "Estalvia en taxes de gas, canvia de xarxa.", "label.say_hello_to": "Saluda a...", + "label.some_section_missing": "Algunes seccions no tenen informació.", "label.sdg_impact_fund": "Fons d'impacte SDG", "label.search": "Cerca", "label.search_for_a_project_or_a_cause": "Cerca un projecte o una causa a totes les categories", diff --git a/lang/en.json b/lang/en.json index cf1f606cd1..bc29b5a26e 100644 --- a/lang/en.json +++ b/lang/en.json @@ -835,6 +835,7 @@ "label.save_changes": "Save Changes", "label.save_on_gas_fees": "Save on gas fees, switch network.", "label.say_hello_to": "Say Hello to...", + "label.some_section_missing": "Some Sections are Missing Information", "label.sdg_impact_fund": "SDG impact fund", "label.search": "Search", "label.search_for_a_project_or_a_cause": "Search for a project or a cause on all of the categories", diff --git a/lang/es.json b/lang/es.json index c6abdd276f..e4bc3bc22d 100644 --- a/lang/es.json +++ b/lang/es.json @@ -835,6 +835,7 @@ "label.save_changes": "Guardar cambios", "label.save_on_gas_fees": "Ahorra en tarifas de gas, cambia de red.", "label.say_hello_to": "Dile hola a...", + "label.some_section_missing": "Algunas secciones no tienen información.", "label.sdg_impact_fund": "Fondo de impacto SDG", "label.search": "Buscar", "label.search_for_a_project_or_a_cause": "Busca un proyecto o una causa en todas las categorias", diff --git a/src/apollo/types/types.ts b/src/apollo/types/types.ts index a67360f0ee..5e01ebe3d9 100644 --- a/src/apollo/types/types.ts +++ b/src/apollo/types/types.ts @@ -378,6 +378,12 @@ export interface ISocialProfile { name: string; } +export interface IPersonalInfo { + email: string; + walletAddress: string; + fullName: string; +} + export interface IProjectVerification { id: string; isTermAndConditionsAccepted: boolean; @@ -397,6 +403,7 @@ export interface IProjectVerification { socialProfiles?: ISocialProfile[]; status: EVerificationStatus; lastStep: EVerificationSteps; + personalInfo?: IPersonalInfo; } export enum EVerificationStatus { @@ -417,7 +424,9 @@ export interface IProjectVerificationUpdateInput { } export enum EVerificationSteps { + BEFORE_START = 'beforeStart', PERSONAL_INFO = 'personalInfo', + SOCIAL_PROFILES = 'socialProfiles', PROJECT_REGISTRY = 'projectRegistry', PROJECT_CONTACTS = 'projectContacts', MANAGING_FUNDS = 'managingFunds', diff --git a/src/components/views/verification/PersonalInfo.tsx b/src/components/views/verification/PersonalInfo.tsx index e7674ec3a9..558f52e6b0 100644 --- a/src/components/views/verification/PersonalInfo.tsx +++ b/src/components/views/verification/PersonalInfo.tsx @@ -103,13 +103,13 @@ const PersonalInfo = () => { } }; function handleNext() { - if (!verificationData?.emailConfirmed) { - showToastError( - formatMessage({ id: 'label.please_confirm_your_email' }), - ); - } else { - setStep(2); - } + // if (!verificationData?.emailConfirmed) { + showToastError( + formatMessage({ id: 'label.please_confirm_your_email' }), + ); + // } else { + setStep(2); + // } } useEffect(() => { diff --git a/src/components/views/verification/TermsAndConditions.tsx b/src/components/views/verification/TermsAndConditions.tsx index 794d6bf07f..f5c0e5c350 100644 --- a/src/components/views/verification/TermsAndConditions.tsx +++ b/src/components/views/verification/TermsAndConditions.tsx @@ -6,7 +6,7 @@ import { semanticColors, FlexCenter, } from '@giveth/ui-design-system'; -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import styled from 'styled-components'; import CheckBox from '@/components/Checkbox'; import { Relative } from '@/components/styled-components/Position'; @@ -16,9 +16,12 @@ import { client } from '@/apollo/apolloClient'; import { UPDATE_PROJECT_VERIFICATION } from '@/apollo/gql/gqlVerification'; import { EVerificationStatus, EVerificationSteps } from '@/apollo/types/types'; import { showToastError } from '@/lib/helpers'; +import menuList from './menu/menuList'; +import { checkVerificationStep } from '@/helpers/projects'; export default function TermsAndConditions() { const [loading, setLoading] = useState(false); + const [allChecked, setAllChecked] = useState(false); const { verificationData, setVerificationData, setStep, isDraft } = useVerificationData(); @@ -36,7 +39,11 @@ export default function TermsAndConditions() { } : undefined, ); - setStep(8); + }; + + const handleAccepted = () => { + setAccepted(prevState => !prevState); + updateVerificationState(); }; const handleNext = async () => { @@ -60,6 +67,29 @@ export default function TermsAndConditions() { } }; + const handleFinish = () => { + if (accepted) { + handleNext(); + setStep(8); + } + }; + + /** + * Check have user submited all data needed for verification + */ + useEffect(() => { + const checkedArray = menuList.map((item, index) => { + if (index !== 8) { + return checkVerificationStep(item.slug, verificationData); + } + return true; + }); + + // Check if all elements are true + const allChecked = checkedArray.every(Boolean); + setAllChecked(allChecked); + }, [verificationData]); + return ( <> @@ -97,7 +127,7 @@ export default function TermsAndConditions() { id: 'label.i_accept_all_giveth_tos', })} checked={accepted} - onChange={setAccepted} + onChange={handleAccepted} /> )} @@ -110,14 +140,24 @@ export default function TermsAndConditions() { id: 'label.prev', })}`} /> -