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

Used donation time in validating the donations #112

Merged
merged 2 commits into from
Oct 28, 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
2 changes: 2 additions & 0 deletions src/resolvers/donationResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ export class DonationResolver {
useDonationBox?: boolean,
@Arg('relevantDonationTxHash', { nullable: true })
relevantDonationTxHash?: string,
donateTime = new Date(),
): Promise<number> {
const logData = {
amount,
Expand Down Expand Up @@ -778,6 +779,7 @@ export class DonationResolver {
tokenSymbol: token,
userAddress: donorUser.walletAddress!,
amount,
donateTime,
});

const tokenInDb = await Token.findOne({
Expand Down
1 change: 1 addition & 0 deletions src/resolvers/draftDonationResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class DraftDonationResolver {
tokenSymbol: token,
userAddress: donorUser.walletAddress!,
amount,
donateTime: new Date(),
});

const draftDonationId = await DraftDonation.createQueryBuilder(
Expand Down
9 changes: 7 additions & 2 deletions src/services/chains/evm/draftDonationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,17 @@ async function submitMatchedDraftDonation(
currency,
projectId,
+tx.nonce,
'',
'', // transakId
{
req: { user: { userId: draftDonation.userId }, auth: {} },
} as ApolloContext,
referrerId,
'',
'', // safeTransactionId
undefined, // draft donation id
undefined, // use donationBox
undefined, // relevant donation tx hash

new Date(+tx.timeStamp * 1000),
);

await Donation.update(Number(donationId), {
Expand Down
4 changes: 3 additions & 1 deletion src/utils/qacc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ const validateDonation = async (params: {
networkId: number;
tokenSymbol: string;
amount: number;
donateTime: Date;
}): Promise<void> => {
const { projectId, userAddress, tokenSymbol, networkId } = params;
const { projectId, userAddress, tokenSymbol, networkId, donateTime } = params;

let user = await findUserByWalletAddress(userAddress)!;
if (!user) {
Expand All @@ -32,6 +33,7 @@ const validateDonation = async (params: {
const cap = await qAccService.getQAccDonationCap({
userId: user.id,
projectId,
donateTime,
});

if (cap < params.amount) {
Expand Down
Loading