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

add monad testnet support #69

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

add monad testnet support #69

wants to merge 1 commit into from

Conversation

ManiReddyt
Copy link
Collaborator

@ManiReddyt ManiReddyt commented Jan 17, 2025

Summary by CodeRabbit

Release Notes

  • Package Updates

    • Updated version for @gardenfi/core from 2.0.3 to 2.0.4
    • Updated version for @gardenfi/orderbook from 2.0.0 to 2.0.1
    • Updated version for @gardenfi/react-hooks from 2.0.4 to 2.0.5
  • New Features

    • Added support for Monad Testnet chain
    • Updated chain configurations and mappings
  • Testing

    • Modified test cases for Quote and Garden components
    • Updated quote retrieval parameters and error handling

Copy link

coderabbitai bot commented Jan 17, 2025

Walkthrough

This pull request introduces updates across multiple packages, primarily focusing on adding support for the Monad Testnet. The changes include version bumps for several packages (@gardenfi/core, @gardenfi/orderbook, and @gardenfi/react-hooks), and modifications to support the new testnet chain. Key updates involve adding monad_testnet to chain mappings, updating asset configurations, and adjusting test configurations. The modifications appear to be preparatory work for integrating the Monad Testnet into the existing infrastructure.

Changes

File Change Summary
packages/core/package.json Version bumped from 2.0.3 to 2.0.4
packages/core/src/lib/garden/garden.spec.ts Commented out Quote-related imports and configurations
packages/core/src/lib/quote/quote.spec.ts Updated quote URL, modified test parameters, and skipped several test cases
packages/core/src/lib/switchOrAddNetwork.ts Added monadTestnet constant and updated evmToViemChainMap
packages/orderbook/package.json Version bumped from 2.0.0 to 2.0.1
packages/orderbook/src/lib/asset.ts Added monad_testnet to Chains, isMainnet, isEVM, and TimeLocks
packages/react-hooks/package.json Version bumped from 2.0.4 to 2.0.5

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant Core as Core Package
    participant Orderbook as Orderbook Package
    participant Network as Monad Testnet

    Dev->>Core: Define Monad Testnet Chain
    Core->>Orderbook: Update Chain Mappings
    Orderbook->>Network: Configure Testnet Support
    Network-->>Orderbook: Confirm Configuration
Loading

Poem

🐰 A Rabbit's Ode to Monad's Debut

In testnet's realm, a new chain springs,
With MON tokens and blockchain wings,
Commented lines, a playful dance,
Version bumps give networks a chance!

Hop, hop, technology grows! 🚀

Finishing Touches

  • 📝 Generate Docstrings (Beta)

🪧 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

@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 comments (1)
packages/core/src/lib/garden/garden.spec.ts (1)

Line range hint 46-51: Expand wallet configuration for Monad testnet.

The wallets object needs to be updated to include Monad testnet support.

 wallets = {
   [Chains.arbitrum_sepolia]: arbitrumWalletClient,
   [Chains.ethereum_sepolia]: ethereumWalletClient,
+  [Chains.monad_testnet]: createWalletClient({
+    account,
+    chain: monadTestnet,
+    transport: http(),
+  }),
   // [Chains.bitcoin_regtest]: btcWallet,
 };
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 80c54b8 and ef926db.

📒 Files selected for processing (7)
  • packages/core/package.json (1 hunks)
  • packages/core/src/lib/garden/garden.spec.ts (2 hunks)
  • packages/core/src/lib/quote/quote.spec.ts (4 hunks)
  • packages/core/src/lib/switchOrAddNetwork.ts (2 hunks)
  • packages/orderbook/package.json (1 hunks)
  • packages/orderbook/src/lib/asset.ts (4 hunks)
  • packages/react-hooks/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • packages/core/package.json
  • packages/react-hooks/package.json
  • packages/orderbook/package.json
🔇 Additional comments (7)
packages/orderbook/src/lib/asset.ts (2)

115-115: Verify the timelock duration for monad_testnet

The timelock value of 172800 (48 hours) for monad_testnet is significantly higher than other testnet chains which typically use 28800 (8 hours) or 7200 (2 hours). Please verify if this extended duration is intentional.


52-52: LGTM! Chain integration follows consistent patterns

The monad_testnet integration follows the established patterns for chain definitions, testnet identification, and EVM chain classification.

Also applies to: 72-73, 96-97

packages/core/src/lib/switchOrAddNetwork.ts (2)

66-68: Verify block explorer URLs

The block explorer URLs use monad-devnet.devnet101.com which seems inconsistent with a testnet environment. Please verify if these are the correct URLs for the Monad testnet.


85-85: LGTM! Chain mapping is correct

The monad_testnet mapping to monadTestnet follows the established pattern in evmToViemChainMap.

packages/core/src/lib/quote/quote.spec.ts (2)

Line range hint 25-92: Address skipped tests before merging.

Multiple test cases have been skipped (exact_out, should get attested quote, test, should get strategies). These tests need to be either:

  1. Updated to support the new testnet environment
  2. Removed if no longer relevant
  3. Documented with a TODO explaining why they're skipped

This is particularly important as we're adding support for a new network.


13-23: Review the increased timeout and amount values.

The test timeout has been increased to 30 seconds and the amount to 10000000. Please verify:

  1. If these increases are necessary for the Monad testnet
  2. If they indicate potential performance issues that need addressing
✅ Verification successful

The timeout and amount values appear justified for the Arbitrum Sepolia testnet

The 30-second timeout is reasonable considering:

  • The test makes external API calls to price.garden.finance
  • It involves cross-chain operations which typically need longer timeouts
  • Another test in the same file also uses a 30s timeout

The increased amount (10M) is specific to the Arbitrum Sepolia test case, while other test cases use smaller amounts (~100K). This suggests it's an intentional adjustment for this particular testnet.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if similar timeouts exist in other test files
rg "it\(.*,.*30000" --type ts

Length of output: 31


Script:

#!/bin/bash
# Search for quote-related test files
fd "quote.*\.spec" --type f

# Search for jest timeout configurations
rg "jest.*timeout" --type ts

# Search for similar amount patterns in test files
rg "amount.*10000000|10000000.*amount" --type ts

# Search for other quote tests
rg "quote\.getQuote" --type ts

Length of output: 448


Script:

#!/bin/bash
# Get the complete quote test file
cat packages/core/src/lib/quote/quote.spec.ts

Length of output: 3440

packages/core/src/lib/garden/garden.spec.ts (1)

39-44: ⚠️ Potential issue

Add Monad testnet configuration.

The PR objective is to add Monad testnet support, but the configuration only includes Arbitrum Sepolia and Ethereum Sepolia. Please add the necessary Monad testnet configuration.

Comment on lines +59 to +61
http: [
'https://rpc.monad-testnet.category.xyz/rpc/SPa4TbSgMJxz5ywmzYvvc9O5nkAVGTgOcsi7yErG',
],
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Security: Avoid hardcoding API keys in RPC URLs

The RPC URL contains what appears to be an API key (SPa4TbSgMJxz5ywmzYvvc9O5nkAVGTgOcsi7yErG). API keys should be configured through environment variables to prevent exposure and enable key rotation.

Consider:

  1. Moving the API key to environment variables
  2. Using a configuration service to manage such sensitive values

@@ -7,20 +7,22 @@ import { Quote } from './quote';
import { describe, expect, it } from 'vitest';

describe('quote', () => {
const quoteUrl = 'http://localhost:6969';
const quoteUrl = 'https://price.garden.finance';
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid hardcoding production URLs in tests.

Using production URLs in tests can lead to flaky tests and unnecessary production load. Consider using environment variables or test configurations.

-  const quoteUrl = 'https://price.garden.finance';
+  const quoteUrl = process.env.QUOTE_URL || 'https://price.garden.finance';
📝 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
const quoteUrl = 'https://price.garden.finance';
const quoteUrl = process.env.QUOTE_URL || 'https://price.garden.finance';

Comment on lines +15 to 17
// import { Quote } from './../quote/quote';
// import { Orderbook } from 'gardenfi/orderbook';

Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove commented out code.

Instead of commenting out code, either:

  1. Remove it if it's no longer needed
  2. Add a TODO explaining why it's temporarily commented out
  3. Use feature flags if the functionality needs to be toggled

This helps maintain code clarity and prevents technical debt.

Also applies to: 36-41

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