Skip to content

Conversation

IronJam11
Copy link
Contributor

@IronJam11 IronJam11 commented Aug 4, 2025

This PR solves:

  • Removes staging in uploading pictures
  • Minor refactorings
image image

Summary by CodeRabbit

  • New Features

    • Streamlined image upload process with a single "Add Photos" button, improved progress indicators, and clearer UI prompts.
    • Added confirmation dialog when removing all uploaded images.
    • Submit button is now disabled until images are uploaded.
  • Bug Fixes

    • Enhanced error handling and user feedback during image uploads.
  • Chores

    • Updated environment variable usage for network connections to improve security.
    • Removed unused counter functionality.
    • Cleaned up route comments for clarity.
  • Refactor

    • Unified image selection and upload flow for a smoother user experience.

Copy link

coderabbitai bot commented Aug 4, 2025

Walkthrough

This update refactors image upload logic in the mint NFT flow, replacing separate image picking and uploading with a unified process and improved UI feedback. It also updates contract function arguments to use dynamic values, changes RPC URL configuration to use environment variables, removes a counter provider, and deletes route path comments.

Changes

Cohort / File(s) Change Summary
Image Upload Refactor
lib/pages/mint_nft/mint_nft_images.dart
Refactored image selection and upload into a single method; replaced separate pick/upload flows; improved UI feedback and error handling; added confirmation for bulk removal; adjusted UI prompts and button logic; removed unused methods; updated state tracking and progress indicators.
Smart Contract Argument Update
lib/pages/mint_nft/submit_nft_page.dart
Updated contract call arguments to use dynamic image hash values from provider instead of hardcoded strings.
RPC URL Configuration
lib/models/wallet_chain_option.dart
Replaced hardcoded Alchemy API keys in RPC URLs with an environment variable placeholder $ALCHEMY_API_KEY for Sepolia and Ethereum mainnet.
Route Path Comment Cleanup
lib/main.dart
Removed trailing comments from nested GoRoute path declarations; no logic or routing changes.
Counter Provider Removal
lib/providers/counter_provider.dart
Deleted the CounterProvider class, including all counter management methods and state.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant UI
  participant ImagePicker
  participant Uploader

  User->>UI: Tap "Add Photos"
  UI->>ImagePicker: Pick multiple images
  ImagePicker-->>UI: Return selected images
  loop For each image
    UI->>Uploader: Upload image
    Uploader-->>UI: Upload status (success/failure)
    UI->>UI: Update upload progress and state
  end
  UI-->>User: Show uploaded images and status
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~35 minutes

Possibly related PRs

Suggested reviewers

  • ceilican

Poem

In the garden where code trees grow,
Rabbits hop where uploads flow.
With one button, photos fly—
Progress bars and snack bars nigh!
Old counters gone, new hashes in,
Paths now clean, let minting begin.
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 8d1c25a and 151d7df.

📒 Files selected for processing (5)
  • lib/main.dart (2 hunks)
  • lib/models/wallet_chain_option.dart (1 hunks)
  • lib/pages/mint_nft/mint_nft_images.dart (10 hunks)
  • lib/pages/mint_nft/submit_nft_page.dart (1 hunks)
  • lib/providers/counter_provider.dart (0 hunks)
💤 Files with no reviewable changes (1)
  • lib/providers/counter_provider.dart
🔇 Additional comments (7)
lib/models/wallet_chain_option.dart (1)

34-35: Fix string interpolation syntax for Dart

The string interpolation syntax is incorrect. In Dart, you need to use ${variable} syntax for string interpolation.

Apply this diff to fix the string interpolation:

-      'https://eth-sepolia.g.alchemy.com/v2/$ALCHEMY_API_KEY',
-  '1': 'https://eth-mainnet.g.alchemy.com/v2/$ALCHEMY_API_KEY',
+      'https://eth-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY}',
+  '1': 'https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}',

Likely an incorrect or invalid review comment.

lib/main.dart (1)

62-62: LGTM! Clean route definitions

Removing the redundant comments improves code readability. The route paths are self-explanatory.

Also applies to: 69-69, 76-76, 91-91

lib/pages/mint_nft/submit_nft_page.dart (1)

107-108: Verify non-empty string parameters before calling mintNft

In lib/pages/mint_nft/submit_nft_page.dart, the mintNft argument list currently falls back to empty strings:

mintNftProvider.getInitialPhotos().isNotEmpty
    ? mintNftProvider.getInitialPhotos()[0]
    : "",
"",

The ABI defines both imageUri and qrIpfsHash as string, but it’s unclear whether the contract allows empty values or will revert/produce invalid metadata. Because the Solidity source isn’t present here, please:

  • Confirm on-chain requirements for imageUri and qrIpfsHash (e.g., any require checks against empty strings)
  • Or add client-side checks to ensure neither value is empty before invoking writeContract
lib/pages/mint_nft/mint_nft_images.dart (4)

39-96: Excellent refactoring of image upload flow

The combined _pickAndUploadImages method significantly improves the user experience by:

  • Eliminating the two-step process
  • Providing real-time upload progress
  • Better error handling with logging
  • Clear state management

107-136: Good UX improvement with confirmation dialog

Adding a confirmation dialog before removing all images prevents accidental data loss.


187-307: Excellent visual feedback during upload

The UI improvements provide clear status indicators:

  • Currently uploading (with spinner)
  • Pending (waiting icon)
  • Completed (checkmark)
  • Progress text showing which image is being uploaded

315-316: Good validation: Submit button disabled without images

Disabling the submit button when no images are uploaded prevents invalid NFT submissions.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mintNFTPages

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.
  • 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.

Support

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

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 generate unit tests to generate unit tests for 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.

@bhavik-mangla bhavik-mangla merged commit 91a1fc2 into main Aug 5, 2025
1 check passed
@coderabbitai coderabbitai bot mentioned this pull request Aug 12, 2025
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