Skip to content

Commit

Permalink
Merge pull request #57 from Giveth/staging
Browse files Browse the repository at this point in the history
Release flip givbacks from gnosis to OP
  • Loading branch information
mohammadranjbarz authored Jul 3, 2024
2 parents aaeba1d + 8c59fe6 commit 19fce93
Show file tree
Hide file tree
Showing 6 changed files with 723 additions and 23 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions funding.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"opRetro": {
"projectId": "0xe434930e189c807b137ff0d8e2fa6a95eaa57dde574143a02ca0d7fb31a40bea"
}
}
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
41 changes: 31 additions & 10 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 @@ -484,6 +484,10 @@ app.get('/givPrice', async (req: Request, res: Response) => {
givPriceInUsd
})
} catch (e: any) {
console.log('/givPrice error', {
error: e,
req,
})
res.status(400).send({errorMessage: e.message})
}
})
Expand All @@ -494,6 +498,10 @@ app.get('/purpleList', async (req: Request, res: Response) => {

res.json({purpleList: await getPurpleList()})
} catch (e: any) {
console.log('/purpleList error', {
error: e,
req,
})
res.status(400).send({errorMessage: e.message})
}
})
Expand All @@ -507,6 +515,10 @@ app.get('/givDumpers', async (req: Request, res: Response) => {
})
)
} catch (e: any) {
console.log('/givDumpers error', {
error: e,
req,
})
res.status(400).send({errorMessage: e.message})
}
})
Expand All @@ -522,7 +534,10 @@ app.get('/token_distro_assign_histories', async (req: Request, res: Response) =>
})
)
} catch (e: any) {
console.log('error happened', e)
console.log('/token_distro_assign_histories error', {
error: e,
req,
})
res.status(400).send({errorMessage: e.message})
}
})
Expand Down Expand Up @@ -609,11 +624,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 +670,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 Expand Up @@ -794,7 +809,10 @@ app.get(`/calculate-updated`,
res.send(response)
}
} catch (e: any) {
console.log("error happened", e)
console.log('/calculate-updated error', {
error: e,
req,
})
res.status(400).send({
message: e.message
})
Expand All @@ -805,7 +823,10 @@ app.get(`/current-round`, async (req: Request, res: Response) => {
try {
const result = await getCurrentGIVbacksRound()
res.send(result)
} catch (e: any) {
} catch (e: any) {console.log('/current-round error', {
error: e,
req,
})
res.status(400).send({errorMessage: e.message})
}
}
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
10 changes: 5 additions & 5 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export const createSmartContractCallAddBatchParams = async (params: {
hashParams
};
} catch (e) {
console.log('createSmartContractCallAddBatchParams', e)
console.log('createSmartContractCallAddBatchParams error', e)
throw e
}
}
Expand Down 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 19fce93

Please sign in to comment.