Skip to content

Commit

Permalink
Merge pull request #52 from Giveth/staging
Browse files Browse the repository at this point in the history
Consider recurring mini donations ( streams)
  • Loading branch information
mohammadranjbarz authored May 21, 2024
2 parents 55e97db + d1c286c commit 676d34b
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 120 deletions.
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions src/givethIoService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ export const getEligibleDonations = async (
bottomRankInRound
isReferrerGivbackEligible
referrerWallet
recurringDonation {
id
txHash
}
project {
slug
verified
Expand Down Expand Up @@ -206,7 +210,10 @@ export const getEligibleDonations = async (
projectLink: `https://giveth.io/project/${item.project.slug}`,

isReferrerGivbackEligible: item.isReferrerGivbackEligible,
referrerWallet: item.referrerWallet
referrerWallet: item.referrerWallet,

parentRecurringDonationId: item?.recurringDonation?.id,
parentRecurringDonationTxHash: item?.recurringDonation?.txHash
}
});

Expand Down Expand Up @@ -234,7 +241,10 @@ export const getEligibleDonations = async (
projectLink: `https://giveth.io/project/${item.project.slug}`,

isReferrerGivbackEligible: item.isReferrerGivbackEligible,
referrerWallet: item.referrerWallet
referrerWallet: item.referrerWallet,

parentRecurringDonationId: item?.recurringDonation?.id,
parentRecurringDonationTxHash: item?.recurringDonation?.txHash
}
});
return eligible ?
Expand Down
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ const {version} = require('../package.json');
const app = express();

swaggerDocument.info.version = version
swaggerDocument.basePath = process.env.NODE_ENV === 'staging' ? '/staging' : '/'
const swaggerPrefix = process.env.NODE_ENV === 'staging' ? '/staging' : ''

// swaggerDocument.basePath = process.env.NODE_ENV === 'staging' ? '/staging' : '/'
// const swaggerPrefix = process.env.NODE_ENV === 'staging' ? '/staging' : ''
// https://stackoverflow.com/a/58052537/4650625
app.use(`${swaggerPrefix}/api-docs`, swaggerUi.serve, swaggerUi.setup(swaggerDocument));
// app.use(`${swaggerPrefix}/api-docs`, swaggerUi.serve, swaggerUi.setup(swaggerDocument));

app.use(`/api-docs`, swaggerUi.serve, swaggerUi.setup(swaggerDocument));

app.get(`/calculate`,
async (req: Request, res: Response) => {
Expand Down
207 changes: 108 additions & 99 deletions src/types/general.ts
Original file line number Diff line number Diff line change
@@ -1,124 +1,133 @@
import moment from "moment";

export interface FormattedDonation {
amount: string,
currency: string,
createdAt: string,
valueUsd: number,
givbackFactor: number,
projectRank ?: number,
bottomRankInRound ?: number,
givbacksRound ?: number,
giverAddress: string,
txHash: string,
network: string,
source: string,
giverName: string
giverEmail?: string,
projectLink?: string,
niceTokens?: string,
info?: string,

isReferrerGivbackEligible ?:boolean,
referrerWallet ?:string
referrer ?: boolean,
referred ?: boolean
amount: string,
currency: string,
createdAt: string,
valueUsd: number,
givbackFactor: number,
projectRank?: number,
bottomRankInRound?: number,
givbacksRound?: number,
giverAddress: string,
txHash: string,
network: string,
source: string,
giverName: string
giverEmail?: string,
projectLink?: string,
niceTokens?: string,
info?: string,

isReferrerGivbackEligible?: boolean,
referrerWallet?: string
referrer?: boolean,
referred?: boolean,
parentRecurringDonationId?: string,
parentRecurringDonationTxHash?: string,


}

export interface GivethIoDonation {
amount: string,
currency: string,
createdAt: string,
valueUsd: number,
givbackFactor: number,
projectRank ?: number,
powerRound ?: number,
bottomRankInRound ?: number,
giverAddress: string,
transactionId: string,
transactionNetworkId: number,
fromWalletAddress: string,
toWalletAddress: string
chainType: string
source: string,
user: {
name: string,
email: string
}
project: {
slug: string
listed: boolean,
verified: boolean,
projectPower: {
powerRank: number
}
amount: string,
currency: string,
createdAt: string,
valueUsd: number,
givbackFactor: number,
projectRank?: number,
powerRound?: number,
bottomRankInRound?: number,
giverAddress: string,
transactionId: string,
transactionNetworkId: number,
fromWalletAddress: string,
toWalletAddress: string
chainType: string
source: string,
user: {
name: string,
email: string
}

recurringDonation ?: {
id: string,
txHash: string
}
project: {
slug: string
listed: boolean,
verified: boolean,
projectPower: {
powerRank: number
}
}

// giverName: string
// giverEmail: string,
status: string,
isProjectVerified: boolean,
isReferrerGivbackEligible ?:boolean,
referrerWallet ?:string
// giverName: string
// giverEmail: string,
status: string,
isProjectVerified: boolean,
isReferrerGivbackEligible?: boolean,
referrerWallet?: string
}

export interface DonationResponse {
giverAddress: string,
giverEmail: string,
giverName: string,
totalDonationsUsdValue?: number,
totalDonationsUsdValueAfterGivFactor: number,
givback: number,
givbackUsdValue?: string,
share: number,
niceEarned?: number

totalReferralDeductedUsdValue?: number
totalReferralDeductedUsdValueAfterGivFactor?: number

totalReferralAddedUsdValue?: number
totalReferralAddedUsdValueAfterGivFactor?: number
giverAddress: string,
giverEmail: string,
giverName: string,
totalDonationsUsdValue?: number,
totalDonationsUsdValueAfterGivFactor: number,
givback: number,
givbackUsdValue?: string,
share: number,
niceEarned?: number

totalReferralDeductedUsdValue?: number
totalReferralDeductedUsdValueAfterGivFactor?: number

totalReferralAddedUsdValue?: number
totalReferralAddedUsdValueAfterGivFactor?: number
}

export interface MinimalDonation {
giverAddress: string,
giverEmail: string,
giverName: string,
valueUsd: string,
niceTokens?: number,
share?: number,
totalDonationsUsdValue: number
totalDonationsUsdValueAfterGivFactor: number

totalReferralDeductedUsdValue?: number
totalReferralDeductedUsdValueAfterGivFactor?: number

totalReferralAddedUsdValue?: number
totalReferralAddedUsdValueAfterGivFactor?: number
giverAddress: string,
giverEmail: string,
giverName: string,
valueUsd: string,
niceTokens?: number,
share?: number,
totalDonationsUsdValue: number
totalDonationsUsdValueAfterGivFactor: number

totalReferralDeductedUsdValue?: number
totalReferralDeductedUsdValueAfterGivFactor?: number

totalReferralAddedUsdValue?: number
totalReferralAddedUsdValueAfterGivFactor?: number
}

export interface GivbackFactorParams {
topPowerRank: number;
minimumFactor: number;
maximumFactor: number;
topPowerRank: number;
minimumFactor: number;
maximumFactor: number;
}

export interface Project {
id: string,
title: string,
slug: string,
verified: boolean,
link ?: string,
projectPower: {
totalPower: number,
powerRank: number,
round: number
}
id: string,
title: string,
slug: string,
verified: boolean,
link?: string,
projectPower: {
totalPower: number,
powerRank: number,
round: number
}

}

export interface GIVbacksRound {
round: number,
start: string,
end: string
round: number,
start: string,
end: string
}

0 comments on commit 676d34b

Please sign in to comment.