Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quadratic funding toast on donate success page #4820

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lang/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -1352,12 +1352,12 @@
"page.donate.matching_toast.bottom_invalid_p2": "són elegibles per a l'aparellament.",
"page.donate.matching_toast.bottom_valid": "Els fons de finançament es destinaran al projecte seleccionat després que acabi la ronda. Dona a més projectes per rebre més finançament!",
"page.donate.network_not_eligible_for_qf": "Les donacions de {network} no són aptes per coincidir",
"page.donate.passport_toast.description.eligible": "La teva donació és elegible per ser emparellada! Després del",
"page.donate.passport_toast.description.eligible_2": ", totes les donacions seran revisades per a la protecció contra frau i els fons d'emparellament seran enviats als projectes. Estigues atent a les notificacions :)",
"page.donate.passport_toast.description.non_eligible": "Obtén el teu emparellament de donació amb finançament quadràtic!\nComproveu la vostra elegibilitat QF abans",
"page.donate.passport_toast.description.eligible": "Sou elegible per a QF! Sempre que les vostres donacions siguin almenys $",
"page.donate.passport_toast.description.eligible_2": ", són aptes per ser emparellats",
"page.donate.passport_toast.description.non_eligible": "Les donacions superiors a ${usd_value} són aptes per ser igualades amb finançament quadràtic.\nVerifiqueu la vostra elegibilitat de QF abans",
"page.donate.passport_toast.description.not_connected": "Obtén el teu emparellament de donació amb finançament quadràtic!\nVerifica el teu Gitcoin Passport abans de",
"page.donate.passport_toast.title.eligible": "Finançament Quadràtic",
"page.donate.passport_toast.title.non_eligible": "No et perdis l'emparellament!",
"page.donate.passport_toast.title.non_eligible": "No us ho perdeu!",
"page.donate.project_not_eligible_for_qf": "El projecte no és elegible per a la concordança QF.",
"page.donate.project_not_givbacks_eligible": "El projecte no és elegible per a GIVbacks",
"page.donate.title": "Donar",
Expand Down Expand Up @@ -1709,6 +1709,7 @@
"public-goods": "Béns públics",
"qf_donor_eligibility.banner.link.check_eligibility": "Comprovar elegibilitat",
"qf_donor_eligibility.banner.link.recheck_eligibility": "Re-comprovar elegibilitat",
"qf_donor_eligibility.banner.link.back_to_project": "Tornar als projectes",
"real-estate": "Béns immobles",
"refi": "Refi",
"registered-non-profits": "Organitzacions sense ànim de lucre",
Expand Down
9 changes: 5 additions & 4 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1352,12 +1352,12 @@
"page.donate.matching_toast.bottom_invalid_p2": "are eligible for matching.",
"page.donate.matching_toast.bottom_valid": "Matching funds will be sent to the selected project after the round ends. Donate to more projects to receive higher matching!",
"page.donate.network_not_eligible_for_qf": "{network} donations aren’t eligible for matching",
"page.donate.passport_toast.description.eligible": "Your donation is eligible to be matched! After the",
"page.donate.passport_toast.description.eligible_2": ", all donations will be reviewed for fraud protection and matching funds will be sent to the projects. Stay tuned for notifications :)",
"page.donate.passport_toast.description.non_eligible": "Get your donation matched with quadratic funding!\nCheck your QF Eligibility before",
"page.donate.passport_toast.description.eligible": "You are QF-eligible! As long as your donations are at least $",
"page.donate.passport_toast.description.eligible_2": ", they are eligible to be matched in ",
"page.donate.passport_toast.description.non_eligible": "Donations above ${usd_value} are eligible to be matched with quadratic funding.\nVerify your QF Eligibility before ",
"page.donate.passport_toast.description.not_connected": "Get your donation matched with quadratic funding!\nVerify your Gitcoin Passport before",
"page.donate.passport_toast.title.eligible": "Quadratic Funding",
"page.donate.passport_toast.title.non_eligible": "Dont miss out on matching!",
"page.donate.passport_toast.title.non_eligible": "Don't miss out!",
"page.donate.project_not_eligible_for_qf": "Project is not eligible for QF matching.",
"page.donate.project_not_givbacks_eligible": "Project is not GIVbacks eligible",
"page.donate.title": "Donate",
Expand Down Expand Up @@ -1710,6 +1710,7 @@
"public-goods": "Public Goods",
"qf_donor_eligibility.banner.link.check_eligibility": "Check Eligibility",
"qf_donor_eligibility.banner.link.recheck_eligibility": "Re-check Eligibility",
"qf_donor_eligibility.banner.link.back_to_project": "Back to projects",
"real-estate": "Real Estate",
"refi": "Refi",
"registered-non-profits": "Registered Non Profits",
Expand Down
9 changes: 5 additions & 4 deletions lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1352,12 +1352,12 @@
"page.donate.matching_toast.bottom_invalid_p2": "son subvencionables.",
"page.donate.matching_toast.bottom_valid": "Los fondos de emparejamiento se enviarán al proyecto seleccionado después de que termine la ronda. ¡Dona a más proyectos para recibir un mayor emparejamiento!",
"page.donate.network_not_eligible_for_qf": "Las donaciones de {network} no son elegibles para igualar",
"page.donate.passport_toast.description.eligible": "¡Tu donación es elegible para ser complementada! Después de la",
"page.donate.passport_toast.description.eligible_2": ", todas las donaciones serán revisadas para protección contra fraudes y los fondos de complementarios se enviarán a los proyectos. ¡Mantente atento a las notificaciones! :)",
"page.donate.passport_toast.description.non_eligible": "¡Haz que tu donación sea complementada con financiamiento cuadrático!\nCompruebe su elegibilidad QF antes de",
"page.donate.passport_toast.description.eligible": "¡Eres elegible para QF! Siempre que tus donaciones sean de al menos $",
"page.donate.passport_toast.description.eligible_2": ", son elegibles para ser emparejados en",
"page.donate.passport_toast.description.non_eligible": "Las donaciones superiores a ${usd_value} son elegibles para ser igualadas con fondos cuadráticos.\nVerifique su elegibilidad para QF antes",
"page.donate.passport_toast.description.not_connected": "¡Haz que tu donación sea complementada con financiamiento cuadrático! Verifica tu Gitcoin Passport antes de",
"page.donate.passport_toast.title.eligible": "Financiamiento Cuadrático",
"page.donate.passport_toast.title.non_eligible": "¡No te pierdas la oportunidad!",
"page.donate.passport_toast.title.non_eligible": "¡No te lo pierdas!",
"page.donate.project_not_eligible_for_qf": "El proyecto no es elegible para la financiación QF.",
"page.donate.project_not_givbacks_eligible": "El proyecto no es elegible para GIVbacks",
"page.donate.title": "Donar",
Expand Down Expand Up @@ -1710,6 +1710,7 @@
"public-goods": "Bienes públicos",
"qf_donor_eligibility.banner.link.check_eligibility": "Verificar elegibilidad",
"qf_donor_eligibility.banner.link.recheck_eligibility": "Re-verificar elegibilidad",
"qf_donor_eligibility.banner.link.back_to_project": "Volver a proyectos",
"real-estate": "Bienes Raíces",
"refi": "Refi",
"registered-non-profits": "Organizaciones sin ánimo de lucro",
Expand Down
1 change: 1 addition & 0 deletions src/apollo/gql/gqlQF.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const QF_ROUNDS_QUERY = `
allocatedFundUSDPreferred
allocatedTokenSymbol
minMBDScore
minimumValidUsdValue
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Issue Detected: Server-Side Implementation Missing

The minimumValidUsdValue field is added to the QF_ROUNDS_QUERY on the client side but does not appear to be defined in the GraphQL schema or resolvers. This discrepancy can lead to runtime errors and data inconsistencies.

Actions Needed:

  • Define minimumValidUsdValue in the GraphQL schema.
  • Implement the corresponding resolver to handle this field.
🔗 Analysis chain

LGTM. Please provide additional context.

The addition of the minimumValidUsdValue field to the QF_ROUNDS_QUERY looks good. This change appears to be related to implementing a minimum donation amount in USD for Quadratic Funding rounds.

To ensure completeness:

  1. Could you confirm if corresponding changes have been made to the GraphQL schema and resolver?
  2. How does this new field relate to the "quadratic funding toast on donate success page" mentioned in the PR title?
  3. Are there any client-side changes that utilize this new field?

Let's verify if there are any client-side changes related to this new field:


[/run_scripts]


[/run_scripts]

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for client-side usage of the new minimumValidUsdValue field

# Test: Search for minimumValidUsdValue in TypeScript and JavaScript files
rg --type-add 'frontend:*.{ts,tsx,js,jsx}' -t frontend 'minimumValidUsdValue'

Length of output: 941


Script:

#!/bin/bash
# Description: Verify the addition of `minimumValidUsdValue` in the GraphQL schema and resolvers

# Search for the definition of `minimumValidUsdValue` in GraphQL schema files
rg --type graphql 'minimumValidUsdValue'

# Search for resolver implementations related to `minimumValidUsdValue`
rg --type ts 'resolve.*minimumValidUsdValue'

Length of output: 119


Script:

#!/bin/bash
# Description: Verify the addition of `minimumValidUsdValue` in the GraphQL schema and resolvers

# Search for the definition of `minimumValidUsdValue` in GraphQL schema files with .graphql and .gql extensions
rg 'minimumValidUsdValue' --glob '*.graphql' --glob '*.gql'

# Search for resolver implementations related to `minimumValidUsdValue` in TypeScript files
rg 'resolve.*minimumValidUsdValue' --type ts

Length of output: 255

}
`;

Expand Down
5 changes: 1 addition & 4 deletions src/components/views/donate/DonateIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,7 @@ const DonateIndex: FC = () => {

if (!transactionId) return;
const includeInQF =
activeStartedRound &&
!!getDonationById.valueUsd &&
getDonationById.valueUsd >=
(activeStartedRound?.minimumValidUsdValue || 0);
activeStartedRound && !!getDonationById.valueUsd;
setSuccessDonation({
Comment on lines +160 to 161
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Potential Issue: Inclusion Criteria for Quadratic Funding Eligibility May Have Changed

The updated condition for includeInQF now only checks for the existence of getDonationById.valueUsd:

const includeInQF =
    activeStartedRound && !!getDonationById.valueUsd;

Previously, the condition might have included a check against a minimum donation amount to qualify for Quadratic Funding (QF). By only verifying the presence of valueUsd, donations with minimal amounts could unintentionally become eligible for QF, which may not be desired.

If the intention is to include only donations above a certain minimum value, consider updating the condition accordingly. For example:

const includeInQF =
    activeStartedRound && !!getDonationById.valueUsd
+   && getDonationById.valueUsd >= GIVBACKS_DONATION_QUALIFICATION_VALUE_USD;

This ensures that only donations meeting the minimum USD value qualify for QF inclusion.

txHash: [
{
Expand Down
5 changes: 1 addition & 4 deletions src/components/views/donate/OneTime/DonateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,7 @@ const DonateModal: FC<IDonateModalProps> = props => {
formatUnits(amount, token.decimals),
token.decimals,
) || 0);
const includeInQF =
activeStartedRound &&
isOnEligibleNetworks &&
donationUsdValue >= (activeStartedRound.minimumValidUsdValue || 0);
const includeInQF = activeStartedRound && isOnEligibleNetworks;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Simplified QF inclusion logic - Please clarify the criteria

The condition for including a donation in the Quadratic Funding (QF) round has been simplified, which improves code readability. However, this change raises a few points:

  1. The removal of the donationUsdValue check means that all donations on eligible networks will be included in QF, regardless of their USD value. Is this intentional?
  2. If there's a minimum threshold for QF inclusion, it should be implemented to avoid including very small donations.

Consider adding a comment explaining the criteria for including donations in QF. If a minimum threshold is needed, you could modify the line as follows:

const includeInQF = activeStartedRound && isOnEligibleNetworks && donationUsdValue >= MINIMUM_QF_THRESHOLD;

Where MINIMUM_QF_THRESHOLD is a constant defined elsewhere in the codebase.

const chainvineReferred = getWithExpiry(StorageLabel.CHAINVINEREFERRED);
const { title, addresses } = project || {};

Expand Down
38 changes: 27 additions & 11 deletions src/components/views/donate/QFToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
FlexCenter,
} from '@giveth/ui-design-system';
import { useIntl } from 'react-intl';
import { useRouter } from 'next/router';
import { EQFElegibilityState, usePassport } from '@/hooks/usePassport';
import PassportModal from '@/components/modals/PassportModal';

Expand All @@ -19,6 +20,7 @@ const QFToast = () => {
usePassport();
const { qfEligibilityState, passportState, passportScore, currentRound } =
info;
const router = useRouter();
const [showModal, setShowModal] = useState<boolean>(false);

const isEligible = qfEligibilityState === EQFElegibilityState.ELIGIBLE;
Expand Down Expand Up @@ -46,23 +48,25 @@ const QFToast = () => {
formatMessage({
id: 'page.donate.passport_toast.description.eligible',
}) +
' ' +
currentRound?.name +
currentRound?.minimumValidUsdValue +
' ' +
formatMessage({
id: 'label.ends_on',
id: 'page.donate.passport_toast.description.eligible_2',
}) +
' ' +
endDate +
formatMessage({
id: 'page.donate.passport_toast.description.eligible_2',
});
currentRound?.name +
'.';
} else {
description = (
<>
{formatMessage({
id: 'page.donate.passport_toast.description.non_eligible',
})}{' '}
{formatMessage(
{
id: 'page.donate.passport_toast.description.non_eligible',
},
{
usd_value: currentRound?.minimumValidUsdValue,
},
)}{' '}
<span>{endDate}</span>
</>
);
Expand All @@ -75,7 +79,19 @@ const QFToast = () => {
{title}
</Title>
<Description>{description}</Description>
{!isEligible && (
{isEligible ? (
<FlexCenter>
<Button
label={formatMessage({
id: 'qf_donor_eligibility.banner.link.back_to_project',
})}
buttonType='primary'
size='small'
icon={<IconExternalLink16 />}
onClick={() => router.push('/qf')}
/>
</FlexCenter>
) : (
<FlexCenter>
<Button
label={formatMessage({
Expand Down
Loading