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

feat: add braavos mobile #1004

Merged
merged 7 commits into from
Dec 27, 2024
Merged

feat: add braavos mobile #1004

merged 7 commits into from
Dec 27, 2024

Conversation

Marchand-Nicolas
Copy link
Collaborator

@Marchand-Nicolas Marchand-Nicolas commented Dec 26, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a new wallet configuration for "Braavos Mobile," including download links and an icon.
    • Added a new mobile wallet connector for Braavos, enhancing wallet connectivity options.
  • Bug Fixes

    • Removed obsolete wallet connector imports for improved clarity and functionality.
  • Dependencies

    • Updated and added dependencies in the project configuration to ensure compatibility with the latest features.
  • Improvements

    • Enhanced the selection process for featured quests in the QuestsProvider.
    • Improved formatting and readability in various components and test files.

@Marchand-Nicolas Marchand-Nicolas added the 🔥 Ready for review This pull request needs a review label Dec 26, 2024
Copy link

vercel bot commented Dec 26, 2024

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

Name Status Preview Comments Updated (UTC)
sepolia-starknet-quest ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 27, 2024 6:29pm
starknet-quest ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 27, 2024 6:29pm

Copy link
Contributor

coderabbitai bot commented Dec 26, 2024

Warning

Rate limit exceeded

@Marchand-Nicolas has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 10 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 787399c and efe262d.

📒 Files selected for processing (2)
  • tests/utils/braavosMobile.test.js (1 hunks)
  • utils/braavosMobile.ts (1 hunks)

Walkthrough

This pull request introduces a new Braavos Mobile wallet connector and updates several configuration files related to wallet integration. The changes involve removing some existing wallet connector imports, updating package dependencies, and adding a new BraavosMobileConnector class. Additionally, it modifies the logic for selecting the featured quest in the QuestsProvider, ensuring that if a boosted quest exists, it takes precedence over random selection. The modifications aim to enhance wallet connection capabilities and refine quest selection logic.

Changes

File Change Summary
app/provider.tsx Removed imports for InjectedConnector, WebWalletConnector, ArgentMobileConnector, and createTheme
package.json Updated get-starknet-core to v3.3.3, added get-starknet v3.3.3, updated starknetkit to v2.6.1
utils/braavosMobile.ts Added new BraavosMobileConnector class with methods for wallet connection, icon, and chain ID handling
utils/walletConfig.ts Added Braavos Mobile wallet configuration, updated getConnectors function, and modified sortConnectors function
context/QuestsProvider.tsx Updated logic for setting featuredQuest to prioritize lastBoostedQuest over random selection from notExpired
jest.config.js Updated transform property to use babel-jest with Next.js preset and added transformIgnorePatterns
tests/utils/domainService.test.js Reformatted test cases for getDomainFromAddress for consistency and readability
tests/utils/walletConfig.test.js Changed import path for walletConfig from relative to absolute path, with minor formatting adjustments

Possibly related issues

  • Modify the current featured quest logic #1011: The changes in context/QuestsProvider.tsx address the issue of modifying the featured quest logic to prioritize boosted quests, aligning with the proposed actions in the issue description.

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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: 0

🧹 Nitpick comments (3)
utils/braavosMobile.ts (2)

33-37: Consider returning meaningful connection data or error.
Currently, connect() opens a Braavos link in a new tab, but always returns null cast to Promise<ConnectorData>. This might confuse consumers expecting an actual payload or an error if the connection fails. If feasible, consider returning some signifier (e.g., a success response or a proper error) after the user completes or cancels a connection attempt.


51-55: Validate NEXT_PUBLIC_IS_TESTNET environment variable.
The chainId() function correctly switches between Sepolia and mainnet based on NEXT_PUBLIC_IS_TESTNET. However, there is no fallback or error handling if the environment variable is missing or invalid. This could lead to unexpected results in production or other environments.

utils/walletConfig.ts (1)

157-157: Consider removing or gating console logs in production.
Logging the connector to the console might be useful in dev but clutters production logs. If that’s not needed in production, consider using a debug flag or removing it altogether.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3f81544 and f6c2043.

📒 Files selected for processing (4)
  • app/provider.tsx (1 hunks)
  • package.json (2 hunks)
  • utils/braavosMobile.ts (1 hunks)
  • utils/walletConfig.ts (4 hunks)
🔇 Additional comments (6)
app/provider.tsx (1)

11-11: Removal of unused createTheme import looks clean.
The createTheme import no longer appears to be referenced. This removal helps keep the import list concise and free of unused dependencies.

utils/braavosMobile.ts (2)

39-49: Intentional “not connected” exception design.
These methods (wallet, disconnect, account) throw exceptions since there’s no persistent connection mechanism. Ensure higher-level code handles these exceptions gracefully and informs the user that Braavos Mobile can’t be queried for account details once launched.


57-59: Confirm readiness logic.
ready() always returns true. If the user has not installed Braavos on their mobile device or if prerequisites are unmet, the function still indicates readiness. Ensure your upstream code guards against usage if Braavos Mobile is not actually ready (e.g., user not installed or not opened).

utils/walletConfig.ts (2)

93-104: Accurate “downloads” and “website” references for Braavos Mobile.
The downloads and website fields dynamically build a link using window.location.host. This is a straightforward approach, but confirm that the application is served on a domain accessible to Braavos Mobile. Additionally, ensure that the domain is correct if you have multiple environments (dev, stage, prod).


141-142: Integration of the Braavos Mobile connector.
Adding getBraavosMobile() to the connectors array properly integrates Braavos Mobile into your wallet selection. Ensure that you handle the user’s journey after they open or install Braavos from the external link triggered by the connector’s connect() method.

package.json (1)

33-34: Dependencies updated to support new wallet functionality.
The addition of "get-starknet" and the upgrade of both "get-starknet-core" and "starknetkit" suggest broader changes to wallet integrations. This aligns with using the BraavosMobileConnector. Just verify that these new versions are compatible with other parts of your codebase.

Also applies to: 55-55

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 (1)
utils/walletConfig.ts (1)

93-104: Optimize the Braavos Mobile wallet configuration

Consider these improvements for better maintainability:

  1. Use string literals instead of template literals for static URLs
  2. Extract the repeated URL into a constant to follow DRY principles
+ const BRAAVOS_DAPP_URL = "https://link.braavos.app/dapp/starknet.quest";
  {
    id: "braavosMobile",
    name: "Braavos Mobile",
    icon: braavosMobileIcon,
    downloads: {
-     chrome: `https://link.braavos.app/dapp/starknet.quest`,
-     firefox: `https://link.braavos.app/dapp/starknet.quest`,
-     edge: `https://link.braavos.app/dapp/starknet.quest`,
-     safari: `https://link.braavos.app/dapp/starknet.quest`,
+     chrome: BRAAVOS_DAPP_URL,
+     firefox: BRAAVOS_DAPP_URL,
+     edge: BRAAVOS_DAPP_URL,
+     safari: BRAAVOS_DAPP_URL,
    },
-   website: `https://link.braavos.app/dapp/starknet.quest`,
+   website: BRAAVOS_DAPP_URL,
  },
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f6c2043 and 23d898e.

📒 Files selected for processing (1)
  • utils/walletConfig.ts (4 hunks)
🔇 Additional comments (2)
utils/walletConfig.ts (2)

141-142: LGTM!

The Braavos Mobile connector is correctly added to the connectors array.


8-8: Verify the Braavos Mobile integration

Please ensure that:

  1. The getBraavosMobile function is properly exported from braavosMobile.ts
  2. There are no conflicts between the existing Braavos wallet and the new Braavos Mobile wallet implementations
✅ Verification successful

Braavos Mobile integration is properly implemented with clear separation

The verification shows that:

  1. getBraavosMobile is properly exported from braavosMobile.ts
  2. There is a clear separation between Braavos and Braavos Mobile implementations:
    • Braavos wallet uses the ID "braavos" (line 47 in walletConfig.ts)
    • Braavos Mobile uses a distinct ID "braavosMobile" (line 94 in walletConfig.ts)
    • They have separate connector configurations and installation links
    • No naming conflicts or overlapping functionality found
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the Braavos Mobile implementation and potential conflicts

# Check if getBraavosMobile is properly exported
rg -p "export.*getBraavosMobile" 

# Check for any potential naming conflicts between Braavos implementations
rg -p "braavos" --type ts

Length of output: 1946

utils/walletConfig.ts Show resolved Hide resolved
Copy link
Contributor

@fricoben fricoben left a comment

Choose a reason for hiding this comment

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

Screenshot 2024-12-26 at 9 15 15 AM

This is available for connection on desktop, please make it only available on mobile

Copy link
Contributor

@fricoben fricoben left a comment

Choose a reason for hiding this comment

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

lgtm

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 (5)
jest.config.js (1)

24-25: Custom transform ignore patterns for specific node modules

Introducing transformIgnorePatterns ensures that certain libraries are properly transformed. Confirm that these libraries (@starknet-react and @starknetkit) specifically need to be transpiled and are otherwise causing issues. If you'd like, I can assist with further improvements or additional patterns in this list.

app/analytics/page.tsx (3)

20-20: Consider initializing quests to an empty array for clarity.

While using {} as the initial state typecasted to QuestList works, initializing to an empty array or a more explicit structure may improve readability and reduce confusion about the shape of the data.


42-48: Use a descriptive text color or variant instead of "transparent".

Setting the color prop to "transparent" might hide text if the CSS or the component does not override it later. Make sure the design intention is to rely on background or special styling.


77-77: Check if an extra parenthesis can be removed or clarified.

This closing parenthesis on line 77 concludes the mapping logic. Verify that it's aligned with the correct segment to maintain code clarity.

utils/walletConfig.ts (1)

141-144: Ensure that mobile detection meets user expectations.

Currently, window.innerWidth < 768 triggers the mobile connector. Check if a tablet user (width slightly above 768) might also need Braavos Mobile. If so, consider using a more nuanced detection approach.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 23d898e and 24016e3.

📒 Files selected for processing (6)
  • app/analytics/page.tsx (2 hunks)
  • context/QuestsProvider.tsx (0 hunks)
  • jest.config.js (2 hunks)
  • tests/utils/domainService.test.js (2 hunks)
  • tests/utils/walletConfig.test.js (3 hunks)
  • utils/walletConfig.ts (4 hunks)
💤 Files with no reviewable changes (1)
  • context/QuestsProvider.tsx
✅ Files skipped from review due to trivial changes (1)
  • tests/utils/walletConfig.test.js
🧰 Additional context used
🪛 Biome (1.9.4)
tests/utils/domainService.test.js

[error] 16-16: A global variable should not be reassigned.

Assigning to a global variable can override essential functionality.

(lint/suspicious/noGlobalAssign)


[error] 35-35: A global variable should not be reassigned.

Assigning to a global variable can override essential functionality.

(lint/suspicious/noGlobalAssign)

🔇 Additional comments (5)
jest.config.js (1)

5-5: Switching to babel-jest for comprehensive Next.js support

This update from ts-jest to the Next.js babel preset is a good change if the project heavily relies on Next.js features and transformations. Verify that you have installed all necessary Babel dependencies for this configuration, and confirm compatibility with your existing Jest test suites.

app/analytics/page.tsx (2)

25-25: Validate response structure from getQuests().

Relying on || {} is reasonable for fallback, but verifying that res meets expected interface (e.g., a known object shape vs. any fallback) would make the code more robust. Otherwise, if getQuests() returns an unexpected structure, subsequent logic might fail silently.


53-75: Ensure proper handling of empty or unexpected quest data.

When quests is an empty object or has keys pointing to non-array values, the code gracefully returns null. Confirm that you don't need to display a fallback UI or messaging instead of silently returning null.

utils/walletConfig.ts (2)

93-104: Confirm Braavos Mobile integration details.

The new wallet entry looks consistent. However, confirm that the custom link (“https://link.braavos.app/dapp/...”) is correct and that any additional required fields are present.


159-159: Remove debugging console.log statement.

This console.log appears to be debugging code and may expose sensitive connector information. Consider removing it before merging to production.

tests/utils/domainService.test.js Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔥 Ready for review This pull request needs a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants