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

docs: Add wallet app tutorial #421

Merged
merged 5 commits into from
Dec 1, 2024
Merged

docs: Add wallet app tutorial #421

merged 5 commits into from
Dec 1, 2024

Conversation

lesnitsky
Copy link
Contributor

@lesnitsky lesnitsky commented Dec 1, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a comprehensive tutorial for building a mobile wallet app using Flutter and Starknet.
    • Added support for environment variable configuration with a new .env file.
    • Updated the application structure to include a WalletApp widget and a HomeScreen.
  • Bug Fixes

    • Updated the Kotlin version for the Android wallet application.
  • Chores

    • Removed obsolete project files and dependencies to streamline the application.
  • Documentation

    • Enhanced tutorial content to clarify installation steps and prerequisites.
    • Updated the .gitignore to track the .env file for version control.

Copy link

docs-page bot commented Dec 1, 2024

To view this pull requests documentation preview, visit the following URL:

docs.page/focustree/starknet.dart~421

Documentation is deployed and generated using docs.page.

Copy link
Contributor

coderabbitai bot commented Dec 1, 2024

Walkthrough

This pull request introduces a comprehensive tutorial for building a mobile wallet application using Flutter and Starknet. Key updates include enhanced installation steps, the addition of environment variable management, and modifications to the main application structure. Notably, Kotlin and dependency versions are updated, and files related to project metadata are removed. The tutorial culminates in the creation of a WalletApp widget with a HomeScreen, which integrates wallet functionalities. Changes also include updates to the iOS application entry point and the overall dependency management in the pubspec.yaml.

Changes

File Path Change Summary
docs/examples/mobile-wallet.mdx Added comprehensive tutorial for building a mobile wallet app, including prerequisites and installation steps. Updated main.dart for environment variable loading and initializing WalletKit and Hive. Added HomeScreen in home_screen.dart.
examples/wallet_app/android/build.gradle Updated Kotlin version from 1.7.10 to 2.0.21.
examples/wallet_app/contracts Removed subproject commit reference file for wallet app contracts.
examples/wallet_app/devnet/pyproject.toml Removed pyproject.toml file defining project metadata and dependencies for the Python application.
examples/wallet_app/ios/Runner/AppDelegate.swift Changed entry point annotation from @UIApplicationMain to @main.
examples/wallet_app/lib/main.dart Updated main function to be asynchronous, added environment variable loading, and moved UI settings.
examples/wallet_app/pubspec.yaml Updated dependencies, added flutter_dotenv, removed several dependencies, and included .env in assets.
examples/wallet_app/.env Added new environment variables ACCOUNT_CLASS_HASH and RPC.
examples/wallet_app/.gitignore Updated to allow tracking of the .env file in version control.

Possibly related PRs

Suggested reviewers

  • ptisserand

Poem

🐇 In the meadow where wallets bloom,
A Flutter app dispels the gloom.
With Kotlin bright and dependencies neat,
Our mobile wallet is now complete!
Environment variables, a breeze to find,
Hopping forward, leaving worries behind! 🌼

Warning

Rate limit exceeded

@lesnitsky has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 8 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 496ee3e and 0687a68.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 496ee3e and 0687a68.

📒 Files selected for processing (2)
  • examples/wallet_app/.env (1 hunks)
  • examples/wallet_app/.gitignore (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • examples/wallet_app/.env
  • examples/wallet_app/.gitignore

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

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: 3

🧹 Outside diff range and nitpick comments (2)
docs/examples/mobile-wallet.mdx (2)

3-3: Fix grammatical and formatting issues

Several minor issues in the tutorial text:

  1. Line 3: Add a comma after "In this tutorial"
  2. Line 44: Add "the" before "flutter_dotenv package"
  3. Line 79: "setup" should be "set up" (verb form)
  4. Line 99: Add a comma after "Finally"

Also applies to: 44-44, 79-79, 99-99

🧰 Tools
🪛 LanguageTool

[typographical] ~3-~3: It appears that a comma is missing.
Context: ...d a mobile wallet for Starknet In this tutorial we will build a mobile wallet app. ## ...

(DURING_THAT_TIME_COMMA)


25-30: Add security note about environment variables

Consider adding a security note about not committing the .env file and providing a .env.example template instead.

Add this section after the .env file example:

> Note: Never commit your .env file to version control. Create a .env.example file with placeholder values instead.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 9ad0b07 and 496ee3e.

⛔ Files ignored due to path filters (2)
  • examples/wallet_app/devnet/poetry.lock is excluded by !**/*.lock
  • examples/wallet_app/ios/Podfile.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • docs/examples/mobile-wallet.mdx (2 hunks)
  • examples/wallet_app/android/build.gradle (1 hunks)
  • examples/wallet_app/contracts (0 hunks)
  • examples/wallet_app/devnet/pyproject.toml (0 hunks)
  • examples/wallet_app/ios/Runner/AppDelegate.swift (1 hunks)
  • examples/wallet_app/lib/main.dart (1 hunks)
  • examples/wallet_app/pubspec.yaml (2 hunks)
💤 Files with no reviewable changes (2)
  • examples/wallet_app/contracts
  • examples/wallet_app/devnet/pyproject.toml
🧰 Additional context used
🪛 LanguageTool
docs/examples/mobile-wallet.mdx

[typographical] ~3-~3: It appears that a comma is missing.
Context: ...d a mobile wallet for Starknet In this tutorial we will build a mobile wallet app. ## ...

(DURING_THAT_TIME_COMMA)


[uncategorized] ~44-~44: You might be missing the article “the” here.
Context: ...to load our environment variables using flutter_dotenv package ```dart import ...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)


[grammar] ~79-~79: The word “setup” is a noun. The verb is spelled with a space.
Context: ...t Hive.initFlutter(); } ``` Let's also setup device orientation and system ui overla...

(NOUN_VERB_CONFUSION)


[typographical] ~99-~99: Consider adding a comma after ‘Finally’ for more clarity.
Context: ...Brightness: Brightness.dark, )); ``` Finally we can create an App widget and run our...

(RB_LY_COMMA)

🔇 Additional comments (5)
examples/wallet_app/ios/Runner/AppDelegate.swift (2)

4-4: LGTM! Good modernization of the Swift entry point.

The change from @UIApplicationMain to @main follows modern Swift conventions. This is a safe update that maintains full compatibility while adopting the more concise syntax introduced in Swift 5.3.


Line range hint 5-13: LGTM! Standard Flutter iOS integration.

The implementation follows Flutter's recommended pattern for iOS integration with proper plugin registration.

examples/wallet_app/pubspec.yaml (2)

47-48: ⚠️ Potential issue

Ensure .env file is properly gitignored

Since the .env file typically contains sensitive configuration, ensure it's added to .gitignore to prevent accidental commits of sensitive data.

✅ Verification successful

.env file is properly secured in version control

The .gitignore file already includes proper rules for environment files:

  • .env - blocks the main env file
  • .env.* - blocks all env file variants
  • With explicit exceptions for example files (.env.example, .env.mainnet.example, etc.)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if .env is properly gitignored
if ! grep -q "^\.env$" .gitignore; then
  echo "Warning: .env is not in .gitignore"
fi

Length of output: 30


Script:

#!/bin/bash
# Let's first check if .gitignore exists and show its contents
if [ -f .gitignore ]; then
    echo "Content of .gitignore:"
    cat .gitignore
else
    echo ".gitignore file not found"
fi

# Also check if .env file exists in the repository
echo -e "\nChecking for .env files:"
fd -H ".env$"

Length of output: 720


21-21: Verify impact of major flutter_lints version update

The update from flutter_lints 2.0.0 to 5.0.0 is a major version jump that might introduce breaking changes in linting rules.

✅ Verification successful

Review flutter_lints version update in wallet_app

The analysis shows that the wallet_app and several other packages use the default flutter_lints configuration without any custom rule overrides. Since flutter_lints follows semantic versioning and maintains a stable set of recommended rules, the update from 2.0.0 to 5.0.0 should be safe as it primarily introduces new lint rules rather than breaking existing ones.

  • The analysis_options.yaml in wallet_app uses the default include without modifications
  • Other packages using flutter_lints also use the default configuration
  • No custom rules are enabled that could be impacted by the version change
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any existing lint configurations that might need updates
fd -e yaml "analysis_options"

Length of output: 331


Script:

#!/bin/bash
# Check the content of analysis_options.yaml files to see their linting configurations
for file in $(fd -e yaml "analysis_options"); do
  echo "=== $file ==="
  cat "$file"
  echo -e "\n"
done

Length of output: 6450

examples/wallet_app/lib/main.dart (1)

31-37: Consider platform-specific UI configurations

The system UI configuration might need adjustments for different platforms (iOS vs Android).

@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.7.10'
ext.kotlin_version = '2.0.21'
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Kotlin 2.0.21 is incompatible with Android Gradle Plugin 7.3.0

The verification confirms that the Android Gradle Plugin version 7.3.0 is being used in the project. Kotlin 2.0.x is not compatible with this AGP version, as it requires a more recent version of the Android Gradle Plugin. Additionally, other examples in the codebase are using Kotlin 1.7.10, which indicates this is the established version across the project.

Recommendations:

  • Either downgrade Kotlin to 1.9.x (preferably 1.9.22) for compatibility with AGP 7.3.0
  • Or upgrade both AGP and Kotlin versions together following the official compatibility matrix
🔗 Analysis chain

Consider using a more stable Kotlin version for the tutorial

The update to Kotlin 2.0.21 introduces potential risks:

  1. Kotlin 2.0 is a very recent major release that might have compatibility issues with existing Android tooling
  2. For a tutorial, using such a new version might cause problems for users following along

Consider using the latest stable 1.x version (e.g., 1.9.22) which is more widely tested with Android tooling.

Let's verify the compatibility with Android Gradle Plugin:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check Kotlin versions recommended for Android Gradle Plugin 7.3.0

# Search for any Kotlin version recommendations in the Android documentation
rg --type md "Kotlin.*version.*7\.3\.0" 

# Look for any version constraints in build files
rg "kotlin.*version.*7\.3\.0"

Length of output: 73


Script:

#!/bin/bash
# Let's check the current Android Gradle Plugin version and other dependencies

# Check build.gradle files for Android Gradle Plugin version
rg "com\.android\.tools\.build:gradle" -A 2

# Check other Kotlin-related dependencies
rg "org\.jetbrains\.kotlin" -A 2

# Look for any other build configuration that might give context
rg "compileSdk|minSdk|targetSdk|buildToolsVersion" 

Length of output: 4246

Comment on lines +15 to +18
await WalletKit().init(
accountClassHash: dotenv.env['ACCOUNT_CLASS_HASH'] as String,
rpc: dotenv.env['RPC'] as String,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add validation for environment variables

Direct casting of environment variables to String without validation could lead to runtime errors if variables are missing.

Consider adding validation:

  await WalletKit().init(
-    accountClassHash: dotenv.env['ACCOUNT_CLASS_HASH'] as String,
-    rpc: dotenv.env['RPC'] as String,
+    accountClassHash: dotenv.env['ACCOUNT_CLASS_HASH'] ?? 
+      throw Exception('ACCOUNT_CLASS_HASH environment variable is required'),
+    rpc: dotenv.env['RPC'] ?? 
+      throw Exception('RPC environment variable is required'),
  );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await WalletKit().init(
accountClassHash: dotenv.env['ACCOUNT_CLASS_HASH'] as String,
rpc: dotenv.env['RPC'] as String,
);
await WalletKit().init(
accountClassHash: dotenv.env['ACCOUNT_CLASS_HASH'] ??
throw Exception('ACCOUNT_CLASS_HASH environment variable is required'),
rpc: dotenv.env['RPC'] ??
throw Exception('RPC environment variable is required'),
);

Comment on lines +117 to +120
WalletKit().init(
accountClassHash: dotenv.env['ACCOUNT_CLASS_HASH'] as String,
rpc: dotenv.env['RPC'] as String,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add await to WalletKit initialization

The WalletKit initialization in the tutorial is missing the await keyword, unlike the actual implementation in main.dart.

-  WalletKit().init(
+  await WalletKit().init(
     accountClassHash: dotenv.env['ACCOUNT_CLASS_HASH'] as String,
     rpc: dotenv.env['RPC'] as String,
   );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
WalletKit().init(
accountClassHash: dotenv.env['ACCOUNT_CLASS_HASH'] as String,
rpc: dotenv.env['RPC'] as String,
);
await WalletKit().init(
accountClassHash: dotenv.env['ACCOUNT_CLASS_HASH'] as String,
rpc: dotenv.env['RPC'] as String,
);

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.

1 participant