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

Update docs for adding Celestia network params to Leap w/ React #1830

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

karan-leapwallet
Copy link

@karan-leapwallet karan-leapwallet commented Dec 18, 2024

Overview

This PR ads a section in tutorials/wallet -> Integrating Wallets for developers Page to provide a guide on how to add celestia network parameters to Leap using React.

Summary by CodeRabbit

  • New Features
    • Updated tutorial to include integration of Celestia network parameters with the Leap wallet using React.
    • Introduced a new React component, AddNetworkLeap, for checking Leap wallet extension and suggesting network parameters.
    • Provided examples for passing Celestia network parameters for different testnets.

Copy link
Contributor

coderabbitai bot commented Dec 18, 2024

Walkthrough

The pull request introduces documentation and a React component for integrating the Celestia network with the Leap wallet. The new AddNetworkLeap component allows developers to add Celestia network parameters to the Leap wallet extension, similar to the existing Keplr wallet integration. The changes include support for mainnet, Mocha, and Arabica testnets, providing a comprehensive guide for wallet connection across different Celestia network environments.

Changes

File Change Summary
tutorials/wallets.md Added Leap wallet integration section with network parameter details
@site/src/components/AddNetworkLeap.js New component created with methods for Celestia network parameters

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant React as React Component
    participant Leap as Leap Wallet Extension
    
    Dev->>React: Import AddNetworkLeap
    Dev->>React: Pass Celestia network params
    React->>Leap: Check wallet extension
    alt Leap Extension Installed
        Leap-->>React: Wallet detected
        React->>Leap: Suggest network parameters
        Leap-->>React: Network added successfully
    else Leap Extension Not Found
        React-->>Dev: Display error message
    end
Loading

Poem

🚀 Leap into Celestia's light,
A wallet dance, a blockchain delight!
Parameters flow, networks unfurl,
React components give developers a whirl!
Connecting chains with rabbit-like might! 🌟


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 (2)
tutorials/wallets.md (2)

190-251: Consider enhancing error handling in the add function.

The current implementation could benefit from more specific error handling to help developers troubleshoot integration issues.

Consider this enhancement:

 async function add() {
     if (!window.leap) {
-        alert("Please install leap extension");
+        alert("Leap wallet extension not found. Please install it from https://www.leapwallet.io/");
     } else {
         if (window.leap.experimentalSuggestChain) {
             try {
                 await window.leap.experimentalSuggestChain({
                     // ... configuration ...
                 });
             } catch (error) {
-                alert("Failed to suggest the chain");
+                alert(`Failed to suggest the chain: ${error.message}`);
+                console.error("Chain suggestion error:", error);
             }
         }
         const chainId = params.chainId;
         try {
             await window.leap.enable(chainId);
         } catch (error) {
+            alert(`Failed to enable chain: ${error.message}`);
+            console.error("Chain enable error:", error);
         }
     }
 }

172-175: Consider varying the introductory phrases.

To improve readability and avoid repetition, consider rephrasing these introductions.

-Before we demonstrate how to export the specific parameters for
-Celestia's testnets, we need to create a ReactJS component
-that allows us to connect directly to Leap and pass it the network
-parameters.
+Let's create a ReactJS component that enables direct connection
+to Leap and handles the network parameter configuration.

-We still need to pass the Celestia network parameters to
-the `AddNetworkLeap` function:
+Next, let's configure the Celestia network parameters for
+the `AddNetworkLeap` function:

Also applies to: 267-268

🧰 Tools
🪛 LanguageTool

[style] ~173-~173: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ... parameters for Celestia's testnets, we need to create a ReactJS component that allows ...

(REP_NEED_TO_VB)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0b172e8 and d178e36.

📒 Files selected for processing (1)
  • tutorials/wallets.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
tutorials/wallets.md

[style] ~173-~173: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ... parameters for Celestia's testnets, we need to create a ReactJS component that allows ...

(REP_NEED_TO_VB)


[style] ~267-~267: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...markdownlint-enable MD013 --> We still need to pass the Celestia network parameters to...

(REP_NEED_TO_VB)

🔇 Additional comments (2)
tutorials/wallets.md (2)

170-315: LGTM! The Leap wallet integration section is well-structured.

The new section maintains consistency with the existing Keplr implementation while providing clear instructions for Leap wallet integration.

🧰 Tools
🪛 LanguageTool

[style] ~173-~173: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ... parameters for Celestia's testnets, we need to create a ReactJS component that allows ...

(REP_NEED_TO_VB)


[style] ~267-~267: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...markdownlint-enable MD013 --> We still need to pass the Celestia network parameters to...

(REP_NEED_TO_VB)


275-280: Verify the network parameters constants.

The implementation correctly uses template variables for network parameters. Let's verify that all required constants are defined.

Also applies to: 288-293, 301-306

✅ Verification successful

All required network parameters constants are properly defined

Based on the search results, I can verify that all the required constants for network parameters are properly defined in .vitepress/constants/constants.js. The file includes:

  • mainnetChainId: "celestia"
  • mainnetRpcUrl: "https://rpc.lunaroasis.net/"
  • mainnetRestUrl: "https://api.lunaroasis.net/"

These constants match exactly what's being referenced in the template variables in the code snippet under review.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if all required constants are defined in the constants file
rg -A 1 "export const .*(?:Chain|Url)" .vitepress/constants/constants.js

Length of output: 74


Script:

#!/bin/bash
# Let's try a broader search for constants file and its content
fd constants.js

# After finding the file, let's check its content
fd constants.js --exec cat {}

Length of output: 51


Script:

#!/bin/bash
# Let's try searching for any file that might contain these constants
rg -l "mainnetChainId|mainnetRpcUrl|mainnetRestUrl"

# Also search for any config or constant related files
fd -e js -e ts "config|constant"

Length of output: 209


Script:

#!/bin/bash
# Let's check the content of these files to understand how these constants are used
cat tutorials/wallets.md | grep -A 5 -B 5 "mainnet.*Url\|mainnet.*Chain"
cat how-to-guides/consensus-node.md | grep -A 5 -B 5 "mainnet.*Url\|mainnet.*Chain"
cat how-to-guides/celestia-node-troubleshooting.md | grep -A 5 -B 5 "mainnet.*Url\|mainnet.*Chain"

# Also check if there's a .vitepress directory with config
fd -H ".vitepress"

Length of output: 3550


Script:

#!/bin/bash
# Let's check the .vitepress directory for config files that might define these constants
fd . .vitepress -t f -x cat {}

Length of output: 43011

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