From f2198a361839bc7fe52743a19549222033b9b48e Mon Sep 17 00:00:00 2001 From: Mohammad Ranjbar Z Date: Fri, 24 May 2024 11:38:59 +0330 Subject: [PATCH] "Flip" GIVbacks - most GIVbacks should go out on Optimism, only gnosis donations get GIV on gnosis related to https://github.com/Giveth/giveth-dapps-v2/issues/4181 --- src/givethIoService.ts | 4 ++-- src/index.ts | 14 +++++++------- src/swagger.json | 12 ++++++------ src/utils.ts | 8 ++++---- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/givethIoService.ts b/src/givethIoService.ts index 53b350e..3a188a5 100644 --- a/src/givethIoService.ts +++ b/src/givethIoService.ts @@ -53,7 +53,7 @@ export const getEligibleDonations = async ( eligible?: boolean, disablePurpleList?: boolean, justCountListed?: boolean, - chain?: "all-other-chains" | "optimism" + chain?: "all-other-chains" | "gnosis" }): Promise => { try { @@ -355,7 +355,7 @@ export const getDonationsReport = async (params: { niceWhitelistTokens?: string[], niceProjectSlugs?: string[], applyChainvineReferral?: boolean, - chain?: "all-other-chains" | "optimism" + chain?: "all-other-chains" | "gnosis" }): Promise => { const { beginDate, diff --git a/src/index.ts b/src/index.ts index ca89d71..071a025 100644 --- a/src/index.ts +++ b/src/index.ts @@ -118,11 +118,11 @@ app.get(`/calculate`, // chain: chain as "all-other-chains" |"optimism" // }); // - const optimismDonations = await getDonationsReport({ + const gnosisDonations = await getDonationsReport({ beginDate: startDate as string, endDate: endDate as string, applyChainvineReferral: true, - chain: "optimism" + chain: "gnosis" }); const otherChainDonations = await getDonationsReport({ beginDate: startDate as string, @@ -149,7 +149,7 @@ app.get(`/calculate`, const groupByGiverAddressForTotalDonations = _.groupBy(totalDonations, 'giverAddress') - const groupByGiverAddressForOptimismDonations = _.groupBy(optimismDonations, 'giverAddress') + const groupByGiverAddressForOptimismDonations = _.groupBy(gnosisDonations, 'giverAddress') const groupByGiverAddressForAllOtherChainsDonations = _.groupBy(otherChainDonations, 'giverAddress') @@ -305,7 +305,7 @@ const getEligibleAndNonEligibleDonations = async (req: Request, res: Response, e endDate: endDate as string, eligible, justCountListed: justCountListed === 'yes', - chain: chain as "all-other-chains" | "optimism" + chain: chain as "all-other-chains" | "gnosis" }); const donations = @@ -609,11 +609,11 @@ app.get(`/calculate-updated`, // chain: chain as "all-other-chains" |"optimism" // }); // - const optimismDonations = await getDonationsReport({ + const gnosisDonations = await getDonationsReport({ beginDate: start, endDate: end, applyChainvineReferral: true, - chain: "optimism" + chain: "gnosis" }); const otherChainDonations = await getDonationsReport({ beginDate: start, @@ -655,7 +655,7 @@ app.get(`/calculate-updated`, const groupByGiverAddressForTotalDonations = _.groupBy(totalDonations, 'giverAddress') - const groupByGiverAddressForOptimismDonations = _.groupBy(optimismDonations, 'giverAddress') + const groupByGiverAddressForOptimismDonations = _.groupBy(gnosisDonations, 'giverAddress') const groupByGiverAddressForAllOtherChainsDonations = _.groupBy(otherChainDonations, 'giverAddress') diff --git a/src/swagger.json b/src/swagger.json index 5b0fc7b..2e8d6d6 100644 --- a/src/swagger.json +++ b/src/swagger.json @@ -63,7 +63,7 @@ "type": "string", "description": "If you want to see json here set no, but if you want to download a file set yes", "default": "no", - "enum": ["no", "optimism","all-other-chains", "NICE" ], + "enum": ["no", "gnosis","all-other-chains", "NICE" ], "in": "query" } ], @@ -82,9 +82,9 @@ { "name": "chain", "type": "string", - "description": "For Optimism we need to distribute on Optimism chain so we should have different response", + "description": "For Gnosis we need to distribute on Gnosis chain so we should have different response", "default": "all-other-chains", - "enum": ["all-other-chains","optimism"], + "enum": ["all-other-chains","gnosis"], "in": "query" }, { @@ -185,9 +185,9 @@ { "name": "chain", "type": "string", - "description": "For Optimism we need to distribute on Optimism chain so we should have different response", + "description": "For Gnosis we need to distribute on Gnosis chain so we should have different response", "default": "all-other-chains", - "enum": ["all-other-chains","optimism"], + "enum": ["all-other-chains","gnosis"], "in": "query" }, { @@ -400,7 +400,7 @@ "type": "string", "description": "If you want to see json here set no, but if you want to download a file set yes", "default": "no", - "enum": ["no", "optimism","all-other-chains", "NICE" ], + "enum": ["no", "gnosis","all-other-chains", "NICE" ], "in": "query" } ], diff --git a/src/utils.ts b/src/utils.ts index 5b2cdb2..acb6a72 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -247,12 +247,12 @@ export const getNetworkNameById = (networkId: number): string => { } } -export const filterRawDonationsByChain = (gqlResult: { donations: GivethIoDonation[] }, chain ?: "all-other-chains" | "optimism"): GivethIoDonation[] => { - if (chain === 'optimism') { - return gqlResult.donations.filter(donation => donation.transactionNetworkId === 10 || donation.transactionNetworkId === 420) +export const filterRawDonationsByChain = (gqlResult: { donations: GivethIoDonation[] }, chain ?: "all-other-chains" | "gnosis"): GivethIoDonation[] => { + if (chain === 'gnosis') { + return gqlResult.donations.filter(donation => donation.transactionNetworkId === 100) } else if (chain === "all-other-chains") { // Exclude Optimism donations and return all other donations - return gqlResult.donations.filter(donation => donation.transactionNetworkId !== 10 && donation.transactionNetworkId !== 420) + return gqlResult.donations.filter(donation => donation.transactionNetworkId !== 100) } else { return gqlResult.donations }