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

coupon system #118

Merged
merged 6 commits into from
Nov 27, 2023
Merged

coupon system #118

merged 6 commits into from
Nov 27, 2023

Conversation

rajranjan0608
Copy link
Collaborator

@rajranjan0608 rajranjan0608 commented Oct 25, 2023

This pull request includes significant changes to the CouponService and FaucetForm components, as well as adjustments to the ReCaptcha class and configuration files, to implement a coupon system for the application. The coupon system will allow users to enter a coupon ID to receive specific amounts of tokens. The system also includes regular synchronization of coupons between memory and the database, and the ability to validate, consume, and reclaim coupon amounts.

Key changes:

Coupon Service Implementation:

  • CouponService/couponService.ts: Created a new CouponService class to manage coupons. The class includes methods to validate coupon data, sync coupons with the database, update coupon usage limits, consume coupon amounts, and reclaim coupon amounts. The service uses the DynamoDBClient and DynamoDBDocumentClient from the AWS SDK for interactions with the DynamoDB database. Mutexes are used to prevent race conditions when consuming and reclaiming coupon amounts.

FaucetForm Component Modifications:

  • client/src/components/FaucetForm.tsx: Modified the FaucetForm component to include a new state variable for the coupon ID and added an input field for the coupon ID in the form. Adjusted the getChainParams function to prevent sending the erc20 parameter if it matches the chain parameter. Modified the calculateBaseUnit function to correctly calculate the base unit for token amounts. Added a updateCouponId function to update the coupon ID state variable. Modified the getCaptchaToken function to default to V2 CAPTCHA. Adjusted the resetRecaptcha function to not reset the isV2 state variable. [1] [2] [3] [4] [5] [6] [7] [8]

ReCaptcha Class Adjustments:

  • client/src/components/ReCaptcha.ts: Adjusted the getToken function in the ReCaptcha class to default to V2 CAPTCHA. Modified the resetV2Captcha function to not hide the V2 CAPTCHA container. Adjusted the loadV2Captcha function to handle the case where window.grecaptcha is undefined. [1] [2] [3]

Configuration Changes:

  • config.json: Modified the configuration file to include a new couponConfig object with IS_ENABLED and MAX_LIMIT_CAP properties. Adjusted the NATIVE_CLIENT and DEBUG properties. Modified the DRIP_AMOUNT, RATELIMIT, and COUPON_REQUIRED properties for chain configurations. [1] [2]

Server Adjustments:

  • server.ts: Adjusted the server file to import the CouponService class and create a new instance of it. Modified the getToken function to include the coupon ID in the request data. Adjusted the getBalance function to use bigint for the balance instead of BN. [1] [2] [3] [4] [5] [6] [7] [8]

Other Changes:

  • package.json: Added the @aws-sdk/lib-dynamodb and async-mutex packages to the dependencies.
  • types.ts: Added a COUPON_REQUIRED property to the ChainType type.

@ashucoder9 ashucoder9 requested a review from connorch November 6, 2023 18:07
@rajranjan0608 rajranjan0608 merged commit def053f into main Nov 27, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants