Skip to content

Commit

Permalink
"Flip" GIVbacks - most GIVbacks should go out on Optimism, only gnosi…
Browse files Browse the repository at this point in the history
…s donations get GIV on gnosis

related to Giveth/giveth-dapps-v2#4181
  • Loading branch information
mohammadranjbarz committed May 24, 2024
1 parent 676d34b commit f2198a3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/givethIoService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<FormattedDonation[]> => {
try {
Expand Down Expand Up @@ -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<MinimalDonation[]> => {
const {
beginDate,
Expand Down
14 changes: 7 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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')


Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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')


Expand Down
12 changes: 6 additions & 6 deletions src/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
],
Expand All @@ -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"
},
{
Expand Down Expand Up @@ -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"
},
{
Expand Down Expand Up @@ -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"
}
],
Expand Down
8 changes: 4 additions & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit f2198a3

Please sign in to comment.