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',
})}`}
/>
-
+ {passportState !== EPassportState.NOT_SIGNED &&
+ passportScore !== null &&
+ activeQFMBDScore !== null &&
+ currentRound?.minimumUserAnalysisScore != null &&
+ activeQFMBDScore < currentRound?.minimumUserAnalysisScore && (
+
+
+ {' '}
+ {formatMessage({
+ id: 'Required Passport score to be eligible',
+ })}
+
+ {`> ${currentRound?.minimumPassportScore}`}
+
+
+
+ Your Paaaport Score
+ {passportScore}
+
+
+ )}
- {formatMessage({ id: 'It won’t take long!' })}
-
+ {actionDescription()}
+ {activeQFMBDScore == null ? (
+
+ ) : currentRound?.minimumUserAnalysisScore != null &&
+ activeQFMBDScore < currentRound?.minimumUserAnalysisScore &&
+ passportState === EPassportState.NOT_SIGNED ? (
+
+ ) : (
+ {
+ refreshScore();
+ }}
+ >
+
+
+
+ {formatMessage({ id: 'label.refresh_score' })}
+
+
+
+ )}
);
@@ -177,3 +252,57 @@ const Hr = styled.div`
background-color: ${neutralColors.gray[300]};
width: 100%;
`;
+
+const BaseButton = styled.button`
+ padding: 16px 32px;
+ background-color: ${neutralColors.gray[100]};
+ border: none;
+ border-radius: 48px;
+ box-shadow: ${Shadow.Giv[400]};
+ transition: color 0.2s ease-in-out;
+ cursor: pointer;
+`;
+
+const RefreshButton = styled(BaseButton)`
+ &:hover {
+ color: ${neutralColors.gray[800]};
+ }
+`;
+
+const PassportSection = styled.div`
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+ border: 1px solid ${neutralColors.gray[300]};
+ padding: 16px;
+ border-radius: 8px;
+`;
+
+const StyledNote = styled(P)`
+ display: flex;
+ align-items: center;
+ gap: 8px;
+`;
+
+const QFMinScore = styled(P)`
+ color: ${neutralColors.gray[900]};
+ margin-left: 10px;
+ font-weight: 700;
+`;
+
+const ScoreCard = styled(P)`
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ border-top: 1px solid ${neutralColors.gray[200]};
+ padding: 16px;
+ background-color: ${neutralColors.gray[200]};
+ border-radius: 8px;
+`;
+
+const Score = styled(P)`
+ color: ${neutralColors.gray[100]};
+ background-color: black;
+ padding: 8px 16px;
+ border-radius: 25px;
+`;
diff --git a/src/hooks/usePassport.ts b/src/hooks/usePassport.ts
index 334cb3a3f1..c3499cc425 100644
--- a/src/hooks/usePassport.ts
+++ b/src/hooks/usePassport.ts
@@ -4,7 +4,7 @@ import { getPassports } from '@/helpers/passport';
import {
connectPassport,
fetchPassportScore,
- fecthMBDScore,
+ scoreUserAddress,
} from '@/services/passport';
import { IPassportInfo, IQFRound } from '@/apollo/types/types';
import { getNowUnixMS } from '@/helpers/time';
@@ -30,12 +30,14 @@ export enum EPassportState {
export interface IPassportAndStateInfo {
passportState: EPassportState;
passportScore: number | null;
+ activeQFMBDScore: number | null;
currentRound: IQFRound | null;
}
const initialInfo = {
passportState: EPassportState.LOADING,
passportScore: null,
+ activeQFMBDScore: null,
currentRound: null,
};
@@ -52,10 +54,12 @@ export const usePassport = () => {
const updateState = useCallback(
async (refreshUserScores: IPassportInfo) => {
+ console.log('refreshUserScores ==> 🐨', refreshUserScores);
if (isSafeEnv) {
return setInfo({
passportState: EPassportState.NOT_AVAILABLE_FOR_GSAFE,
passportScore: null,
+ activeQFMBDScore: null,
currentRound: null,
});
}
@@ -63,12 +67,14 @@ export const usePassport = () => {
return setInfo({
passportState: EPassportState.ENDED,
passportScore: null,
+ activeQFMBDScore: null,
currentRound: null,
});
}
setInfo({
passportState: EPassportState.LOADING,
passportScore: null,
+ activeQFMBDScore: null,
currentRound: null,
});
try {
@@ -77,6 +83,7 @@ export const usePassport = () => {
return setInfo({
passportState: EPassportState.INVALID,
passportScore: null,
+ activeQFMBDScore: null,
currentRound: null,
});
}
@@ -84,6 +91,7 @@ export const usePassport = () => {
return setInfo({
passportState: EPassportState.NOT_ACTIVE_ROUND,
passportScore: refreshUserScores.passportScore,
+ activeQFMBDScore: null,
currentRound: null,
});
} else if (
@@ -92,6 +100,7 @@ export const usePassport = () => {
return setInfo({
passportState: EPassportState.NOT_STARTED,
passportScore: refreshUserScores.passportScore,
+ activeQFMBDScore: null,
currentRound: activeQFRound,
});
} else if (
@@ -100,24 +109,27 @@ export const usePassport = () => {
return setInfo({
passportState: EPassportState.ENDED,
passportScore: refreshUserScores.passportScore,
+ activeQFMBDScore: null,
currentRound: activeQFRound,
});
}
- if (refreshUserScores.addressMBDScore == null) {
+ if (refreshUserScores.activeQFMBDScore == null) {
return setInfo({
passportState: EPassportState.NOT_ELIGIBLE,
passportScore: null,
+ activeQFMBDScore: null,
currentRound: activeQFRound,
});
}
if (
activeQFRound.minimumUserAnalysisScore != null &&
- refreshUserScores.addressMBDScore >=
+ refreshUserScores.activeQFMBDScore >=
activeQFRound.minimumUserAnalysisScore
) {
return setInfo({
passportState: EPassportState.ELIGIBLE,
passportScore: null,
+ activeQFMBDScore: refreshUserScores.activeQFMBDScore,
currentRound: activeQFRound,
});
}
@@ -125,6 +137,7 @@ export const usePassport = () => {
return setInfo({
passportState: EPassportState.NOT_CREATED,
passportScore: null,
+ activeQFMBDScore: refreshUserScores.activeQFMBDScore,
currentRound: activeQFRound,
});
}
@@ -135,12 +148,14 @@ export const usePassport = () => {
return setInfo({
passportState: EPassportState.NOT_ELIGIBLE,
passportScore: refreshUserScores.passportScore,
+ activeQFMBDScore: refreshUserScores.activeQFMBDScore,
currentRound: activeQFRound,
});
} else {
return setInfo({
passportState: EPassportState.ELIGIBLE,
passportScore: refreshUserScores.passportScore,
+ activeQFMBDScore: refreshUserScores.activeQFMBDScore,
currentRound: activeQFRound,
});
}
@@ -148,6 +163,7 @@ export const usePassport = () => {
return setInfo({
passportState: EPassportState.ERROR,
passportScore: null,
+ activeQFMBDScore: null,
currentRound: null,
});
}
@@ -156,14 +172,18 @@ export const usePassport = () => {
);
const fetchUserMBDScore = useCallback(async () => {
+ setInfo({
+ passportState: EPassportState.LOADING,
+ passportScore: null,
+ activeQFMBDScore: null,
+ currentRound: null,
+ });
+
if (!address) return;
try {
- const { fetchUserMBDScore } = await fecthMBDScore(address);
+ const userAddressScore = await scoreUserAddress(address);
if (user) {
- await updateState({
- ...user,
- passportScore: fetchUserMBDScore,
- });
+ await updateState(userAddressScore);
}
} catch (error) {
console.log(error);
@@ -177,12 +197,14 @@ export const usePassport = () => {
return setInfo({
passportState: EPassportState.NOT_AVAILABLE_FOR_GSAFE,
passportScore: null,
+ activeQFMBDScore: null,
currentRound: null,
});
}
setInfo({
passportState: EPassportState.LOADING,
passportScore: null,
+ activeQFMBDScore: null,
currentRound: null,
});
try {
@@ -193,6 +215,7 @@ export const usePassport = () => {
setInfo({
passportState: EPassportState.ERROR,
passportScore: null,
+ activeQFMBDScore: null,
currentRound: null,
});
}
@@ -204,12 +227,14 @@ export const usePassport = () => {
return setInfo({
passportState: EPassportState.NOT_AVAILABLE_FOR_GSAFE,
passportScore: null,
+ activeQFMBDScore: null,
currentRound: null,
});
}
setInfo({
passportState: EPassportState.LOADING,
passportScore: null,
+ activeQFMBDScore: null,
currentRound: null,
});
const passports = getPassports();
@@ -223,6 +248,7 @@ export const usePassport = () => {
setInfo({
passportState: EPassportState.NOT_SIGNED,
passportScore: null,
+ activeQFMBDScore: null,
currentRound: null,
});
}
@@ -235,6 +261,7 @@ export const usePassport = () => {
return setInfo({
passportState: EPassportState.NOT_AVAILABLE_FOR_GSAFE,
passportScore: null,
+ activeQFMBDScore: null,
currentRound: null,
});
}
@@ -244,6 +271,7 @@ export const usePassport = () => {
return setInfo({
passportState: EPassportState.NOT_CONNECTED,
passportScore: null,
+ activeQFMBDScore: null,
currentRound: null,
});
}
@@ -251,18 +279,6 @@ export const usePassport = () => {
if (!isUserFullFilled) return;
console.log('******3', address, isUserFullFilled, user);
const fetchData = async () => {
- const { fetchUserMBDScore } = await fecthMBDScore(address);
- if (
- !isArchivedQF &&
- activeQFRound?.minimumUserAnalysisScore &&
- fetchUserMBDScore >= activeQFRound?.minimumUserAnalysisScore
- ) {
- return setInfo({
- passportState: EPassportState.ELIGIBLE,
- passportScore: fetchUserMBDScore,
- currentRound: activeQFRound,
- });
- }
if (
!user ||
(user.activeQFMBDScore === null && user.passportScore === null)
@@ -279,6 +295,7 @@ export const usePassport = () => {
setInfo({
passportState: EPassportState.NOT_SIGNED,
passportScore: null,
+ activeQFMBDScore: null,
currentRound: null,
});
}
diff --git a/src/services/passport.ts b/src/services/passport.ts
index 53e29b2ffd..d917bc2646 100644
--- a/src/services/passport.ts
+++ b/src/services/passport.ts
@@ -2,7 +2,6 @@ import { signMessage } from '@wagmi/core';
import { client } from '@/apollo/apolloClient';
import {
REFRESH_USER_SCORES,
- FETCH_MBD_USER_SCORE,
SCORE_ACTIVE_QF_DONOR_ADDRESS,
} from '@/apollo/gql/gqlPassport';
import config from '@/configuration';
@@ -89,24 +88,7 @@ export const scoreUserAddress = async (address: `0x${string}` | undefined) => {
fetchPolicy: 'no-cache',
});
- console.log('data', data);
- return data;
- } catch (error) {
- console.log('error', error);
- }
-};
-
-// fetch user's score stored on DB
-export const fecthMBDScore = async (address: `0x${string}` | undefined) => {
- try {
- const { data } = await client.query({
- query: FETCH_MBD_USER_SCORE,
- variables: {
- address: address?.toLowerCase(),
- },
- fetchPolicy: 'no-cache',
- });
- return data;
+ return data.scoreUserAddress;
} catch (error) {
console.log('error', error);
return null;
From 07fc2ca4c7c6851c9dddc75ac29e1d275ef0a41b Mon Sep 17 00:00:00 2001
From: Cherik
Date: Wed, 3 Jul 2024 16:03:08 +0330
Subject: [PATCH 044/156] add solanaNativeAddress
---
src/lib/constants/constants.ts | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/lib/constants/constants.ts b/src/lib/constants/constants.ts
index 4074a62dd5..01a09b637b 100644
--- a/src/lib/constants/constants.ts
+++ b/src/lib/constants/constants.ts
@@ -124,5 +124,4 @@ export const WeiPerEther = 1e18;
export const PROFILE_PHOTO_PLACEHOLDER = '/images/placeholders/profile.svg';
-// Deprecated: maximumRewards coming from backend for each qfRound
-// export const QF_MATCHING_CAP_PERCENTAGE = 4;
+export const solanaNativeAddress = '11111111111111111111111111111111';
From 9363992be5c8d6c2ba8cb31626e6b86fab10e6e3 Mon Sep 17 00:00:00 2001
From: Cherik
Date: Wed, 3 Jul 2024 16:03:40 +0330
Subject: [PATCH 045/156] return all data
---
src/hooks/useSolanaBalance.ts | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/hooks/useSolanaBalance.ts b/src/hooks/useSolanaBalance.ts
index d539a345f1..73afce4546 100644
--- a/src/hooks/useSolanaBalance.ts
+++ b/src/hooks/useSolanaBalance.ts
@@ -1,6 +1,7 @@
import { useConnection } from '@solana/wallet-adapter-react';
import { PublicKey } from '@solana/web3.js';
import { useQuery } from '@tanstack/react-query';
+import { solanaNativeAddress } from '@/lib/constants/constants';
interface ISolanaBalance {
token?: string;
@@ -27,7 +28,7 @@ export const useSolanaBalance = ({ address, token }: ISolanaBalance) => {
}
// Fetch native SOL balance if no token is provided
- if (token === '11111111111111111111111111111111') {
+ if (!token || token === solanaNativeAddress) {
const solBalance =
await solanaConnection.getBalance(ownerAddress);
console.log('*****SOL balance', solBalance);
@@ -68,14 +69,14 @@ export const useSolanaBalance = ({ address, token }: ISolanaBalance) => {
}
};
- const { data, error, isLoading } = useQuery({
+ const data = useQuery({
queryKey: ['solanaBalance', address, token],
queryFn: fetchSolanaBalance,
enabled: !!address,
});
- if (error) {
- console.error('Query error:', error);
+ if (data.error) {
+ console.error('Query error:', data.error);
}
return data;
From d3efd386ebe5bf44e55317f21aa33e1526353f83 Mon Sep 17 00:00:00 2001
From: Cherik
Date: Wed, 3 Jul 2024 16:04:57 +0330
Subject: [PATCH 046/156] remove logs
---
src/hooks/useSolanaBalance.ts | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/src/hooks/useSolanaBalance.ts b/src/hooks/useSolanaBalance.ts
index 73afce4546..d366753d5f 100644
--- a/src/hooks/useSolanaBalance.ts
+++ b/src/hooks/useSolanaBalance.ts
@@ -13,7 +13,6 @@ export const useSolanaBalance = ({ address, token }: ISolanaBalance) => {
const fetchSolanaBalance = async () => {
try {
- console.log('****fetching solana balance');
if (!address) {
console.error('No address provided');
return 0n;
@@ -31,7 +30,7 @@ export const useSolanaBalance = ({ address, token }: ISolanaBalance) => {
if (!token || token === solanaNativeAddress) {
const solBalance =
await solanaConnection.getBalance(ownerAddress);
- console.log('*****SOL balance', solBalance);
+
return solBalance;
}
@@ -44,14 +43,11 @@ export const useSolanaBalance = ({ address, token }: ISolanaBalance) => {
return 0n;
}
- console.log('*****splTokenMintAddress', splTokenMintAddress);
-
const tokenAccounts =
await solanaConnection.getParsedTokenAccountsByOwner(
ownerAddress,
{ mint: splTokenMintAddress },
);
- console.log('*****tokenAccounts', tokenAccounts);
if (tokenAccounts.value.length === 0) {
console.error('No token accounts found');
@@ -59,9 +55,7 @@ export const useSolanaBalance = ({ address, token }: ISolanaBalance) => {
}
const accountInfo = tokenAccounts.value[0].account.data;
- console.log('*****accountInfo', accountInfo);
const balance = accountInfo.parsed.info.tokenAmount.amount;
- console.log('*****balance', balance);
return balance;
} catch (error) {
console.error('Error fetching Solana balance:', error);
From 3dc713dc1439244686a3a084c7bb5172ca7600eb Mon Sep 17 00:00:00 2001
From: Cherik
Date: Wed, 3 Jul 2024 16:05:33 +0330
Subject: [PATCH 047/156] update fetching balances
---
.../donate/OnTime/OneTimeDonationCard.tsx | 107 +++++-------------
1 file changed, 26 insertions(+), 81 deletions(-)
diff --git a/src/components/views/donate/OnTime/OneTimeDonationCard.tsx b/src/components/views/donate/OnTime/OneTimeDonationCard.tsx
index 8b3758693b..5e874fd98a 100644
--- a/src/components/views/donate/OnTime/OneTimeDonationCard.tsx
+++ b/src/components/views/donate/OnTime/OneTimeDonationCard.tsx
@@ -1,5 +1,5 @@
import styled from 'styled-components';
-import React, { FC, useEffect, useRef, useState } from 'react';
+import React, { FC, useEffect, useState } from 'react';
import { useIntl } from 'react-intl';
import {
B,
@@ -15,7 +15,6 @@ import {
// @ts-ignore
import { captureException } from '@sentry/nextjs';
import { Address, Chain, formatUnits, parseUnits, zeroAddress } from 'viem';
-import { useConnection } from '@solana/wallet-adapter-react';
import { useBalance } from 'wagmi';
import { setShowWelcomeModal } from '@/features/modal/modal.slice';
import { Shadow } from '@/components/styled-components/Shadow';
@@ -66,6 +65,7 @@ import {
import { TokenIcon } from '../TokenIcon/TokenIcon';
import { SelectTokenModal } from './SelectTokenModal/SelectTokenModal';
import { Spinner } from '@/components/Spinner';
+import { useSolanaBalance } from '@/hooks/useSolanaBalance';
const CryptoDonation: FC = () => {
const {
@@ -75,7 +75,7 @@ const CryptoDonation: FC = () => {
isConnected,
balance,
} = useGeneralWallet();
- const { connection: solanaConnection } = useConnection();
+
const { formatMessage } = useIntl();
const { isSignedIn } = useAppSelector(state => state.user);
@@ -131,8 +131,8 @@ const CryptoDonation: FC = () => {
const {
data: evmBalance,
- refetch,
- isRefetching,
+ refetch: evmRefetch,
+ isRefetching: evmIsRefetching,
} = useBalance({
token:
selectedOneTimeToken?.address === zeroAddress
@@ -144,7 +144,18 @@ const CryptoDonation: FC = () => {
: undefined,
});
- const stopPolling = useRef(null);
+ const {
+ data: solanaBalance,
+ refetch: solanaRefetch,
+ isRefetching: solanaIsRefetching,
+ } = useSolanaBalance({
+ token: selectedOneTimeToken?.address,
+ address:
+ walletChainType === ChainType.SOLANA
+ ? (address as Address)
+ : undefined,
+ });
+
const tokenSymbol = selectedOneTimeToken?.symbol;
const tokenDecimals = selectedOneTimeToken?.decimals || 18;
const projectIsGivBackEligible = !!verified;
@@ -274,81 +285,15 @@ const CryptoDonation: FC = () => {
};
const selectedTokenBalance =
- (walletChainType == ChainType.EVM ? evmBalance?.value : 0n) || 0n;
-
- // const clearPoll = () => {
- // if (stopPolling.current) {
- // stopPolling.current();
- // stopPolling.current = undefined;
- // }
- // };
-
- // const pollToken = useCallback(async () => {
- // clearPoll();
-
- // if (!selectedOneTimeToken) {
- // return setSelectedTokenBalance(0n);
- // }
- // // Native token balance is provided by the Web3Provider
- // const _selectedTokenSymbol = selectedOneTimeToken.symbol.toUpperCase();
- // const nativeCurrency =
- // config.NETWORKS_CONFIG[
- // !walletChainType || walletChainType == ChainType.EVM
- // ? networkId
- // : walletChainType
- // ]?.nativeCurrency;
-
- // if (_selectedTokenSymbol === nativeCurrency?.symbol?.toUpperCase()) {
- // return setSelectedTokenBalance(
- // parseUnits(balance || '0', nativeCurrency.decimals),
- // );
- // }
- // stopPolling.current = pollEvery(
- // () => ({
- // request: async () => {
- // try {
- // if (walletChainType === ChainType.SOLANA) {
- // const splTokenMintAddress = new PublicKey(
- // selectedOneTimeToken.address,
- // );
- // const tokenAccounts =
- // await solanaConnection.getParsedTokenAccountsByOwner(
- // new PublicKey(address!),
- // { mint: splTokenMintAddress },
- // );
- // const accountInfo =
- // tokenAccounts.value[0].account.data;
- // const splBalance =
- // accountInfo.parsed.info.tokenAmount.amount;
- // return setSelectedTokenBalance(BigInt(splBalance));
- // }
-
- // const _balance = await readContract(wagmiConfig, {
- // address: selectedOneTimeToken.address! as Address,
- // abi: erc20Abi,
- // functionName: 'balanceOf',
- // args: [address as Address],
- // });
- // setSelectedTokenBalance(_balance);
- // return _balance;
- // } catch (e) {
- // captureException(e, {
- // tags: {
- // section: 'Polltoken pollEvery',
- // },
- // });
- // return setSelectedTokenBalance(0n);
- // }
- // },
- // onResult: (_balance: bigint) => {
- // if (_balance && _balance !== selectedTokenBalance) {
- // setSelectedTokenBalance(_balance);
- // }
- // },
- // }),
- // POLL_DELAY_TOKENS,
- // )();
- // }, [address, networkId, tokenSymbol, balance, walletChainType]);
+ (walletChainType == ChainType.EVM
+ ? evmBalance?.value
+ : solanaBalance) || 0n;
+ const refetch =
+ walletChainType === ChainType.EVM ? evmRefetch : solanaRefetch;
+ const isRefetching =
+ walletChainType === ChainType.EVM
+ ? evmIsRefetching
+ : solanaIsRefetching;
const handleCustomToken = (i: Address) => {
if (!supportCustomTokens) return;
From 0e0f41f74360579ab3987a5b93cde29d332c2f62 Mon Sep 17 00:00:00 2001
From: Cherik
Date: Wed, 3 Jul 2024 16:09:04 +0330
Subject: [PATCH 048/156] remove old inputbox
---
src/components/views/donate/InputBox.tsx | 114 -----------------------
1 file changed, 114 deletions(-)
delete mode 100644 src/components/views/donate/InputBox.tsx
diff --git a/src/components/views/donate/InputBox.tsx b/src/components/views/donate/InputBox.tsx
deleted file mode 100644
index 8d9e3ecec4..0000000000
--- a/src/components/views/donate/InputBox.tsx
+++ /dev/null
@@ -1,114 +0,0 @@
-import React, { FC, useEffect } from 'react';
-import {
- neutralColors,
- semanticColors,
- B,
- GLink,
-} from '@giveth/ui-design-system';
-import styled from 'styled-components';
-import { useIntl } from 'react-intl';
-import useFocus from '@/hooks/useFocus';
-
-interface IInputBox {
- value?: number;
- onChange: (e: number | undefined) => void;
- error?: boolean;
- onFocus: (i: boolean) => void;
- disabled?: boolean;
-}
-
-const InputBox: FC = ({
- value,
- onChange,
- error,
- onFocus,
- disabled,
-}) => {
- const { formatMessage } = useIntl();
- const [inputRef, setFocus] = useFocus();
-
- useEffect(() => {
- setTimeout(() => setFocus(), 1000);
- }, []);
-
- return (
-
-
- {
- const _value = e.target.value;
- const num =
- _value === '' ? undefined : Number(e.target.value);
- onChange(num);
- }}
- ref={inputRef}
- onFocus={() => onFocus(true)}
- onBlur={() => onFocus(false)}
- placeholder={formatMessage({ id: 'label.amount' })}
- disabled={disabled}
- onWheel={e => e.currentTarget.blur()}
- />
-
- {error && (
-
- {formatMessage({ id: 'label.amount_is_too_small' })}
-
- )}
-
- );
-};
-
-const Box = styled.div`
- display: flex;
- flex-direction: column;
- align-items: flex-end;
-`;
-
-const Input = styled.input`
- border-width: 0;
- height: 100%;
- font-size: 16px;
- font-weight: inherit;
- background: inherit;
- font-family: inherit;
- &:focus {
- outline: none;
- }
-
- &::placeholder {
- color: ${neutralColors.gray[500]};
- font-size: 16px;
- }
-`;
-
-const Wrapper = styled(B)`
- padding: 5px 16px;
- margin: 0 auto;
- height: 54px;
- * {
- width: 90%;
- }
-
- /* Chrome, Safari, Edge, Opera */
- input::-webkit-outer-spin-button,
- input::-webkit-inner-spin-button {
- -webkit-appearance: none;
- margin: 0;
- }
-
- /* Firefox */
- input[type='number'] {
- -moz-appearance: textfield;
- }
-`;
-
-const ErrorMsg = styled(GLink)`
- position: absolute;
- margin-top: 58px;
- color: ${semanticColors.punch[500]};
-`;
-
-export default InputBox;
From f9c1849f8345a1044db787d2a43a032c4f7396aa Mon Sep 17 00:00:00 2001
From: Cherik
Date: Wed, 3 Jul 2024 16:09:49 +0330
Subject: [PATCH 049/156] remove old token picker
---
.../views/donate/OnTime/TokenPicker.tsx | 432 ------------------
1 file changed, 432 deletions(-)
delete mode 100644 src/components/views/donate/OnTime/TokenPicker.tsx
diff --git a/src/components/views/donate/OnTime/TokenPicker.tsx b/src/components/views/donate/OnTime/TokenPicker.tsx
deleted file mode 100644
index dada253b39..0000000000
--- a/src/components/views/donate/OnTime/TokenPicker.tsx
+++ /dev/null
@@ -1,432 +0,0 @@
-import { useState } from 'react';
-import {
- neutralColors,
- P,
- brandColors,
- Caption,
- IconCheck,
- B,
- IconCaretUp,
- IconCaretDown,
- IconSearch,
- IconX,
- FlexCenter,
- IconGIVBack24,
-} from '@giveth/ui-design-system';
-import styled from 'styled-components';
-import { useIntl } from 'react-intl';
-import Select, {
- GroupBase,
- components,
- OptionProps,
- OnChangeValue,
- StylesConfig,
- MenuListProps,
- type CSSObjectWithLabel,
-} from 'react-select';
-
-import { IProjectAcceptedToken } from '@/apollo/types/gqlTypes';
-import { Shadow } from '@/components/styled-components/Shadow';
-import useDetectDevice from '@/hooks/useDetectDevice';
-import { TokenIcon } from '../TokenIcon/TokenIcon';
-
-declare module 'react-select/dist/declarations/src/Select' {
- export interface Props<
- Option,
- IsMulti extends boolean,
- Group extends GroupBase