Skip to content

Add text input option to airdrop setup #7238

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

Merged
merged 1 commit into from
Jun 2, 2025
Merged

Add text input option to airdrop setup #7238

merged 1 commit into from
Jun 2, 2025

Conversation

pinkhoodie
Copy link
Contributor

@pinkhoodie pinkhoodie commented May 30, 2025

  • Add manual text input alternative to CSV upload for airdrop addresses

  • Support multiple input formats: space, comma, equals, and tab separated

  • Parse text input and convert to CSV format for existing validation system

  • Reuse all existing functionality: ENS resolution, address validation, duplicate removal

  • Maintain same validation flow and error handling as CSV upload

  • Change button text from 'Upload CSV' to 'Set up Airdrop' for clarity

image
image


PR-Codex overview

This PR focuses on enhancing the CSV upload functionality in the TokenAirdropSection component by adding a text input option for manually entering addresses and amounts, improving data processing, and updating UI elements for clarity.

Detailed summary

  • Added processData function in useCsvUpload to handle processed CSV data.
  • Renamed UI elements from "CSV File Uploaded" to "Airdrop List Set".
  • Updated button text from "View CSV" to "View List".
  • Changed header titles from "Airdrop CSV" to "Airdrop List".
  • Implemented parseTextInput function for parsing manual input.
  • Added text input field for entering addresses and amounts.
  • Introduced functionality to submit text input via button or keyboard.
  • Enhanced error handling for invalid CSV uploads.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features

    • Added the ability to manually enter airdrop addresses and amounts using a text area, supporting multiple input formats.
    • Users can now choose between uploading a CSV file or entering addresses and amounts directly.
  • UI Updates

    • Updated labels and button texts to reflect support for both CSV and manual list input.
    • Improved layout with a visual divider and clear instructions for manual entry.
    • Enhanced reset and validation behaviors for both input methods.
    • Adjusted CSV upload area height for better usability.

@pinkhoodie pinkhoodie requested review from a team as code owners May 30, 2025 23:50
Copy link

changeset-bot bot commented May 30, 2025

⚠️ No Changeset found

Latest commit: 2114e5f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented May 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 2, 2025 9:05pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Skipped (Inspect) Jun 2, 2025 9:05pm
login ⬜️ Skipped (Inspect) Jun 2, 2025 9:05pm
thirdweb_playground ⬜️ Skipped (Inspect) Jun 2, 2025 9:05pm
wallet-ui ⬜️ Skipped (Inspect) Jun 2, 2025 9:05pm

Copy link
Contributor

graphite-app bot commented May 30, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

Copy link
Contributor

coderabbitai bot commented May 30, 2025

Walkthrough

The changes add support for manual entry of airdrop addresses and amounts via a multiline text area, in addition to the existing CSV upload. A parser processes the text input into the required format, which is then passed to the CSV processing pipeline using a new processData method in the useCsvUpload hook. UI labels and layout are updated accordingly.

Changes

File(s) Change Summary
.../assets/create/distribution/token-airdrop.tsx Added manual text input for airdrop addresses/amounts, new parser function, updated UI labels/layout, integrated manual input with CSV processing flow.
.../hooks/useCsvUpload.ts Added new processData callback to process external data arrays through existing CSV parsing and validation logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant Parser
    participant useCsvUploadHook

    User->>UI: Upload CSV file or enter addresses in textarea
    alt User uploads CSV
        UI->>useCsvUploadHook: Parse and validate CSV
    else User enters text
        UI->>Parser: Parse text input
        Parser-->>UI: Parsed addresses/amounts
        UI->>useCsvUploadHook: processData(parsed data)
    end
    useCsvUploadHook-->>UI: Validated and normalized data
    UI-->>User: Display results or errors
Loading

Suggested reviewers

  • MananTank

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 75aa9a9 and 2114e5f.

📒 Files selected for processing (2)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/distribution/token-airdrop.tsx (11 hunks)
  • apps/dashboard/src/hooks/useCsvUpload.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/dashboard/src/hooks/useCsvUpload.ts
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/distribution/token-airdrop.tsx
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Unit Tests
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Size
  • GitHub Check: Build Packages
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the Dashboard Involves changes to the Dashboard. label May 30, 2025
Copy link

codecov bot commented May 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.55%. Comparing base (ca08417) to head (2114e5f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7238   +/-   ##
=======================================
  Coverage   55.55%   55.55%           
=======================================
  Files         908      908           
  Lines       58571    58571           
  Branches     4131     4131           
=======================================
  Hits        32540    32540           
  Misses      25927    25927           
  Partials      104      104           
Flag Coverage Δ
packages 55.55% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/distribution/token-airdrop.tsx (2)

197-234: Review the text parsing logic for robustness.

The parseTextInput function handles multiple input formats well, but there are some potential edge cases and improvements to consider:

  1. Empty quantity handling: Line 222 defaults to "1" when no quantity is provided, which is good.
  2. Separator precedence: The function checks separators in a specific order (=, comma, tab, space), which could lead to unexpected results if an address contains these characters.
  3. No input validation: The function doesn't validate addresses or quantities, but this is handled downstream.

Consider these improvements:

 const parseTextInput = (text: string): AirdropAddressInput[] => {
   const lines = text
     .split("\n")
     .map((line) => line.trim())
     .filter((line) => line !== "");
   const result: AirdropAddressInput[] = [];
 
   for (const line of lines) {
     let parts: string[] = [];
 
+    // More robust parsing with better separator detection
     if (line.includes("=")) {
-      parts = line.split("=");
+      parts = line.split("=").slice(0, 2); // Only take first two parts
     } else if (line.includes(",")) {
-      parts = line.split(",");
+      parts = line.split(",").slice(0, 2);
     } else if (line.includes("\t")) {
-      parts = line.split("\t");
+      parts = line.split("\t").slice(0, 2);
     } else {
       parts = line.split(/\s+/);
     }
 
     parts = parts.map((part) => part.trim()).filter((part) => part !== "");
 
     if (parts.length >= 1) {
       const address = parts[0];
-      const quantity = parts[1] || "1";
+      const quantity = parts[1] || "1";
 
       if (address) {
         result.push({
           address: address.trim(),
           quantity: quantity.trim(),
         });
       }
     }
   }
 
   return result;
 };

359-466: Well-structured dual input UI.

The new UI layout effectively presents both upload and manual input options:

  1. Clear separation: The divider with "Or enter manually" text provides good visual separation.
  2. Helpful examples: The placeholder text shows multiple input format examples.
  3. Good UX: Ctrl+Enter keyboard shortcut and disabled state management enhance user experience.
  4. Consistent styling: The manual input section follows the same design patterns as the upload section.

Minor suggestion for the placeholder text:

- placeholder={`0x314ab97b76e39d63c78d5c86c2daf8eaa306b182 3.141592
- thirdweb.eth,2.7182
- 0x141ca95b6177615fb1417cf70e930e102bf8f384=1.41421`}
+ placeholder={`0x314ab97b76e39d63c78d5c86c2daf8eaa306b182 3.141592
+ thirdweb.eth,2.7182
+ 0x141ca95b6177615fb1417cf70e930e102bf8f384=1.41421
+ 0x456...def (defaults to 1 token)`}

This would clarify that quantity is optional.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3678054 and 13307e5.

📒 Files selected for processing (1)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/distribution/token-airdrop.tsx (11 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Unit Tests
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Lint Packages
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (11)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/distribution/token-airdrop.tsx (11)

26-26: LGTM - Clean import addition.

The Textarea component import is properly added and will be used for the manual text input functionality.


96-96: Good UI copy improvements.

The text changes from "CSV" specific terminology to more generic terms like "Airdrop List Set", "View List", and "Airdrop List" better reflect the new dual input approach.

Also applies to: 113-113, 120-120


156-161: Clear and descriptive UI copy.

The updated sheet title and description accurately communicate the new functionality, mentioning both CSV upload and manual entry options.


180-180: Consistent button text update.

The button text "Set up Airdrop" aligns well with the sheet title and provides a clearer call-to-action than the previous "Upload CSV".


241-241: Good state management addition.

The textInput state is properly initialized and will be used to track the manual input content.


252-261: Inline CSV parser is well-structured.

The inline parser function properly handles the address and quantity mapping with appropriate defaults and filtering.


296-302: Good loading state condition.

The condition properly checks for the loading state when raw data exists but normalization hasn't completed yet.


304-315: Improved continue handler logic.

The updated condition only checks for normalizeData existence, which is more appropriate than the previous logic that also checked rawData.length.


317-320: Comprehensive reset functionality.

The handleReset function properly clears both CSV data and text input, maintaining consistency between the two input methods.


324-326: Good condition update for showing results.

The condition correctly checks for both normalized data and raw data to determine when to show the results table.


338-338: Proper handler integration.

Both the reset button and continue button now use the updated handlers that account for the dual input approach.

Also applies to: 352-352

Copy link
Contributor

github-actions bot commented May 30, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 62.21 KB (0%) 1.3 s (0%) 266 ms (+35.99% 🔺) 1.6 s
thirdweb (cjs) 345.12 KB (0%) 7 s (0%) 1.5 s (-2.87% 🔽) 8.4 s
thirdweb (minimal + tree-shaking) 5.7 KB (0%) 114 ms (0%) 57 ms (+324.07% 🔺) 171 ms
thirdweb/chains (tree-shaking) 531 B (0%) 11 ms (0%) 36 ms (+305.19% 🔺) 46 ms
thirdweb/react (minimal + tree-shaking) 19.54 KB (0%) 391 ms (0%) 100 ms (+198.91% 🔺) 491 ms

@vercel vercel bot temporarily deployed to Preview – docs-v2 May 31, 2025 00:04 Inactive
@vercel vercel bot temporarily deployed to Preview – login May 31, 2025 00:04 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui May 31, 2025 00:04 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground May 31, 2025 00:04 Inactive
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/dashboard/src/hooks/useCsvUpload.ts (1)

165-176: LGTM! Consider extracting shared validation logic.

The processData function correctly enables external components to feed pre-parsed data into the existing CSV processing pipeline, which aligns perfectly with the manual text input feature.

However, there's code duplication between this function and the onDrop function (lines 123-126). Consider extracting the shared validation logic:

+  const validateAndSetData = useCallback(
+    (processedData: T[]) => {
+      if (!processedData[0]?.address) {
+        setNoCsv(true);
+        return false;
+      }
+      setRawData(processedData);
+      return true;
+    },
+    [],
+  );

  const processData = useCallback(
    (data: T[]) => {
      setNoCsv(false);
      const processedData = props.csvParser(data);
-      if (!processedData[0]?.address) {
-        setNoCsv(true);
-        return;
-      }
-      setRawData(processedData);
+      validateAndSetData(processedData);
    },
    [props.csvParser],
  );

And update the onDrop function similarly to reuse the validation logic.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 13307e5 and 75aa9a9.

📒 Files selected for processing (2)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/distribution/token-airdrop.tsx (11 hunks)
  • apps/dashboard/src/hooks/useCsvUpload.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/distribution/token-airdrop.tsx
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Unit Tests
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Build Packages
  • GitHub Check: Size
  • GitHub Check: Lint Packages
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
apps/dashboard/src/hooks/useCsvUpload.ts (1)

187-187: Function correctly exposed in hook interface.

The processData function is properly added to the hook's return object, making it available for external components to use.

@MananTank
Copy link
Member

Nice!

@MananTank MananTank added the merge-queue Adds the pull request to Graphite's merge queue. label Jun 2, 2025
Copy link
Member

MananTank commented Jun 2, 2025

Merge activity

- Add manual text input alternative to CSV upload for airdrop addresses

- Support multiple input formats: space, comma, equals, and tab separated

- Parse text input and convert to CSV format for existing validation system

- Reuse all existing functionality: ENS resolution, address validation, duplicate removal

- Maintain same validation flow and error handling as CSV upload

- Change button text from 'Upload CSV' to 'Set up Airdrop' for clarity

![image](https://github.com/user-attachments/assets/e43afdd8-eed8-491a-ac93-9f02eb6ee703)
![image](https://github.com/user-attachments/assets/42522fa1-3886-4d68-a113-079d58b3da96)

<!--

## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes"

If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000):

## Notes for the reviewer

Anything important to call out? Be sure to also clarify these in your comments.

## How to test

Unit tests, playground, etc.

-->

<!-- start pr-codex -->

---

## PR-Codex overview
This PR enhances the CSV upload functionality in the `TokenAirdropSection` component. It introduces a new method for processing CSV data, allows manual entry of addresses and amounts, and updates UI labels to reflect the new functionality.

### Detailed summary
- Added `processData` function in `useCsvUpload` for processing parsed CSV data.
- Updated `TokenAirdropSection` UI labels from "CSV File Uploaded" to "Airdrop List Set".
- Changed button text from "View CSV" to "View List".
- Introduced `parseTextInput` function for manual input parsing.
- Added text input for entering addresses and amounts.
- Implemented handling for text input submission.
- Updated the layout to separate CSV upload and manual entry sections.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Added the ability to manually enter airdrop addresses and amounts using a text area, supporting multiple input formats.
  - Users can now choose between uploading a CSV file or entering addresses and amounts directly.

- **UI Updates**
  - Updated labels and button texts to reflect support for both CSV and manual list input.
  - Improved layout with a visual divider and clear instructions for manual entry.
  - Enhanced reset and validation behaviors for both input methods.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@vercel vercel bot temporarily deployed to Preview – wallet-ui June 2, 2025 20:57 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground June 2, 2025 20:57 Inactive
@vercel vercel bot temporarily deployed to Preview – login June 2, 2025 20:57 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 June 2, 2025 20:57 Inactive
@graphite-app graphite-app bot merged commit 2114e5f into main Jun 2, 2025
24 checks passed
@graphite-app graphite-app bot deleted the nk/csvairdrop branch June 2, 2025 21:05
@graphite-app graphite-app bot removed the merge-queue Adds the pull request to Graphite's merge queue. label Jun 2, 2025
@vercel vercel bot temporarily deployed to Production – login June 2, 2025 21:05 Inactive
@vercel vercel bot temporarily deployed to Production – wallet-ui June 2, 2025 21:05 Inactive
@vercel vercel bot temporarily deployed to Production – docs-v2 June 2, 2025 21:05 Inactive
@vercel vercel bot temporarily deployed to Production – thirdweb_playground June 2, 2025 21:05 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dashboard Involves changes to the Dashboard.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants