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: sonic chain #1545

Merged
merged 4 commits into from
Jan 16, 2025
Merged

feat: sonic chain #1545

merged 4 commits into from
Jan 16, 2025

Conversation

leoslr
Copy link
Contributor

@leoslr leoslr commented Jan 15, 2025

Description of the changes

Add support for the Sonic chain.

Contracts deployed:

  1. RequestDeployer
  2. ChainlinkConversionPath
  3. ERC20Proxy
  4. ERC20FeeProxy
  5. ERC20ConversionProxy
  6. EthereumProxy
  7. EthereumFeeProxy
  8. EthConversionProxy
  9. BatchConversionPayments

All contracts have been setup ✅
All contracts have been verified ✅
Safe currently not supported on Sonic, admin isn't a multisig ❌

For reference, deployment & setup txs can be found here

Summary by CodeRabbit

  • New Features
    • Added support for the Sonic network in smart contract configurations
    • Deployed multiple contract artifacts for the Sonic network, including:
      • BatchConversionPayments
      • ChainlinkConversionPath
      • ERC20FeeProxy
      • ERC20Proxy
      • Erc20ConversionProxy
      • EthConversionProxy
      • EthereumFeeProxy
      • EthereumProxy
      • RequestDeployer
    • Introduced Sonic network configuration in the payment detection module
    • Added Sonic as a supported EVM chain and native currency in the system
    • Expanded network options with Sonic RPC and API endpoints

Copy link
Contributor

coderabbitai bot commented Jan 15, 2025

Walkthrough

This pull request introduces comprehensive support for the new "sonic" network across multiple smart contract artifacts and configurations. The changes primarily involve adding deployment entries for various contract versions in the artifacts directory, including BatchConversionPayments, ChainlinkConversionPath, ERC20FeeProxy, ERC20Proxy, Erc20ConversionProxy, EthConversionProxy, EthereumFeeProxy, EthereumProxy, and RequestDeployer. Additionally, the Hardhat configuration file is updated to include network-specific settings for sonic, such as chain ID, API keys, and deployment parameters.

Changes

File Change Summary
packages/smart-contracts/hardhat.config.ts Added sonic network configuration, Etherscan API key, custom chain details, and xdeploy network
packages/smart-contracts/.../BatchConversionPayments/index.ts Added sonic deployment with address and creation block number
packages/smart-contracts/.../ChainlinkConversionPath/index.ts Added sonic deployment for versions 0.2.0 and 0.2.1
packages/smart-contracts/.../ERC20FeeProxy/index.ts Added sonic deployment for version 0.2.0
packages/smart-contracts/.../ERC20Proxy/index.ts Added sonic deployment configuration
packages/smart-contracts/.../Erc20ConversionProxy/index.ts Added sonic deployment for versions 0.1.0 and 0.1.2
packages/smart-contracts/.../EthConversionProxy/index.ts Added sonic deployment for versions 0.2.0 and 0.2.1
packages/smart-contracts/.../EthereumFeeProxy/index.ts Added sonic deployment for version 0.2.0
packages/smart-contracts/.../EthereumProxy/index.ts Added sonic deployment for version 0.3.0
packages/smart-contracts/.../RequestDeployer/index.ts Added sonic deployment environment
packages/currency/src/chains/evm/data/sonic.ts Added chainId constant for sonic network
packages/currency/src/chains/evm/index.ts Imported SonicDefinition and added sonic entry to chains object
packages/currency/src/conversion-aggregators.ts Added sonic entry to noConversionNetworks
packages/currency/src/native.ts Added sonic currency details to nativeCurrencies
packages/payment-detection/src/eth/multichainExplorerApiProvider.ts Added sonic network entry and updated getBaseUrl method
packages/types/src/currency-types.ts Updated EvmChainName type to include sonic
packages/utils/src/providers.ts Added sonic RPC URL to networkRpcs object

Possibly related PRs

Suggested reviewers

  • aimensahnoun
  • sstefdev
  • alexandre-abrioux
  • yomarion
  • MantisClone
  • kevindavee

Finishing Touches

  • 📝 Generate Docstrings (Beta)

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

🧹 Nitpick comments (1)
packages/smart-contracts/src/lib/artifacts/ERC20FeeProxy/index.ts (1)

Line range hint 90-169: Consider documenting the deployment strategy and version compatibility.

The deployment pattern shows:

  1. Sequential block numbers (3973538-3974151) indicating coordinated deployment
  2. Consistent address reuse patterns across networks
  3. Multiple version compatibility scenarios

Recommendations:

  1. Document the rationale for address reuse across networks
  2. Maintain a version compatibility matrix
  3. Consider adding deployment verification tests
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dc752d9 and 935a4f0.

📒 Files selected for processing (10)
  • packages/smart-contracts/hardhat.config.ts (4 hunks)
  • packages/smart-contracts/src/lib/artifacts/BatchConversionPayments/index.ts (1 hunks)
  • packages/smart-contracts/src/lib/artifacts/ChainlinkConversionPath/index.ts (2 hunks)
  • packages/smart-contracts/src/lib/artifacts/ERC20FeeProxy/index.ts (1 hunks)
  • packages/smart-contracts/src/lib/artifacts/ERC20Proxy/index.ts (1 hunks)
  • packages/smart-contracts/src/lib/artifacts/Erc20ConversionProxy/index.ts (2 hunks)
  • packages/smart-contracts/src/lib/artifacts/EthConversionProxy/index.ts (2 hunks)
  • packages/smart-contracts/src/lib/artifacts/EthereumFeeProxy/index.ts (1 hunks)
  • packages/smart-contracts/src/lib/artifacts/EthereumProxy/index.ts (1 hunks)
  • packages/smart-contracts/src/lib/artifacts/RequestDeployer/index.ts (1 hunks)
👮 Files not reviewed due to content moderation or server errors (1)
  • packages/smart-contracts/src/lib/artifacts/Erc20ConversionProxy/index.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-and-test
🔇 Additional comments (8)
packages/smart-contracts/src/lib/artifacts/ERC20Proxy/index.ts (1)

44-47: LGTM! Verify contract verification status.

The Sonic chain deployment entry is properly structured. However, since this is a new chain deployment, ensure the contract is verified on the Sonic chain explorer.

packages/smart-contracts/src/lib/artifacts/RequestDeployer/index.ts (1)

92-95: LGTM! Deployment sequence is correct.

The RequestDeployer contract was deployed first (block 3970964) before other contracts, which is the correct deployment sequence. The address consistency across networks follows the established pattern.

packages/smart-contracts/src/lib/artifacts/BatchConversionPayments/index.ts (1)

89-92: Verify proxy dependencies for Sonic chain.

Other networks have caution comments when certain proxies are missing. Please verify that all required proxies (ETHConversion, ERC20Conversion, chainlinkConversionPath) are available on Sonic chain.

✅ Verification successful

All required proxies are deployed on Sonic chain

All necessary proxy contracts (ETHConversion, ERC20Conversion, and ChainlinkConversionPath) are properly deployed on the Sonic chain. No caution comment is needed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for the existence of required proxy contracts on Sonic chain

echo "Checking for required proxy contracts on Sonic chain..."

# Search for proxy deployment entries
rg -l "sonic.*address.*creationBlockNumber" | while read -r file; do
  echo "=== $file ==="
  rg "sonic.*address.*creationBlockNumber" "$file"
done

Length of output: 181


Script:

#!/bin/bash
# Search for Sonic chain deployments in specific contract artifacts

echo "=== Checking ETHConversion ==="
rg -A 5 "sonic" "packages/smart-contracts/src/lib/artifacts/ETHConversion/index.ts" || true

echo "=== Checking ERC20Conversion ==="
rg -A 5 "sonic" "packages/smart-contracts/src/lib/artifacts/ERC20Conversion/index.ts" || true

echo "=== Checking ChainlinkConversionPath ==="
rg -A 5 "sonic" "packages/smart-contracts/src/lib/artifacts/ChainlinkConversionPath/index.ts" || true

# Also search broadly in artifacts directory for any Sonic mentions
echo "=== All Sonic deployments in artifacts ==="
fd . "packages/smart-contracts/src/lib/artifacts" -t f -x rg -l "sonic" {} \;

Length of output: 1825


Script:

#!/bin/bash
# Check deployment data in the correct proxy files

echo "=== Checking EthConversionProxy ==="
rg -A 5 "sonic" "packages/smart-contracts/src/lib/artifacts/EthConversionProxy/index.ts"

echo "=== Checking Erc20ConversionProxy ==="
rg -A 5 "sonic" "packages/smart-contracts/src/lib/artifacts/Erc20ConversionProxy/index.ts"

Length of output: 943

packages/smart-contracts/src/lib/artifacts/EthConversionProxy/index.ts (1)

111-114: LGTM! Version compatibility is maintained.

The deployment entries for both versions 0.2.0 and 0.2.1 are consistent with the pattern used in other networks. The same address is correctly used as only administrative functions differ between versions.

Also applies to: 133-136

packages/smart-contracts/src/lib/artifacts/EthereumProxy/index.ts (1)

207-210: LGTM! Consistent with CREATE2 deployment pattern.

The sonic network entry follows the established pattern of deterministic deployment using CREATE2, reusing the same contract address across multiple networks. This is a good practice as it ensures contract address consistency.

Let's verify this deployment pattern across other contract artifacts:

✅ Verification successful

Verified: CREATE2 deployment pattern confirmed

The sonic network deployment (0x171Ee0881407d4c0C11eA1a2FB7D5b4cdED71e6e) shares the same deterministic address with several other networks (goerli, optimism, moonbeam, mantle, core, sepolia), confirming the use of CREATE2 for consistent cross-chain deployments.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify CREATE2 deployment pattern for sonic network
# Expected: Same address pattern across multiple contracts

# Search for sonic network entries in all contract artifacts
rg -A 2 'sonic: \{' packages/smart-contracts/src/lib/artifacts/

Length of output: 4106


Script:

#!/bin/bash
# Description: Check if contract addresses are consistent across networks
# Expected: Same addresses for each contract across different networks

# Search for network entries in all contract artifacts
rg -B 1 -A 2 'address:.*' packages/smart-contracts/src/lib/artifacts/EthereumProxy/index.ts

Length of output: 6455

packages/smart-contracts/hardhat.config.ts (1)

207-211: LGTM! Verify API endpoints accessibility.

The sonic network configuration is comprehensive and follows the established patterns across all sections (networks, etherscan, and xdeploy).

Let's verify the API endpoints are accessible:

Also applies to: 251-251, 294-301, 334-334

✅ Verification successful

✓ API endpoints are accessible and properly configured

Both the API endpoint (api.sonicscan.org) and browser interface (sonicscan.org) are operational and return successful responses with appropriate security configurations.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify sonic network API endpoints
# Expected: HTTP 200 OK response

# Test the API endpoint
curl -I https://api.sonicscan.org/api

# Test the browser endpoint
curl -I https://sonicscan.org/

Length of output: 2680

packages/smart-contracts/src/lib/artifacts/EthereumFeeProxy/index.ts (1)

153-156: Review version mismatch between ABI and deployment.

Version 0.2.0 is using ABI_0_1_0. While this might be intentional, please verify that:

  1. The 0.1.0 ABI is compatible with 0.2.0 functionality
  2. No new features from 0.2.0 are missing from the 0.1.0 ABI
✅ Verification successful

Version mismatch is intentional and safe

The contract implementation shows that v0.2.0 maintains the same interface as v0.1.0 with no breaking changes or new features. Using ABI_0_1_0 for the Sonic chain deployment is correct and won't cause any compatibility issues.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for version compatibility and missing features

# Search for version-specific features or functions
ast-grep --pattern 'contract EthereumFeeProxy {
  $$$
  function $FUNC($$$) {
    $$$
  }
  $$$
}'

Length of output: 100


Script:

#!/bin/bash
# Find contract source files
fd -e sol "EthereumFeeProxy"

# Find ABI definitions and version references
rg -l "ABI_0_1_0|ABI_0_2_0" --type ts

# Check deployment configurations
rg -A 5 "sonic.*address.*0x4989F941D62bEEb3548Bf55d0D5291Ec335429f0"

Length of output: 1679


Script:

#!/bin/bash
# Check contract content
cat packages/smart-contracts/src/contracts/EthereumFeeProxy.sol

# Check ABI definitions in artifacts
rg -A 10 "ABI_0_1_0|ABI_0_2_0" packages/smart-contracts/src/lib/artifacts/EthereumFeeProxy/index.ts

Length of output: 3409

packages/smart-contracts/src/lib/artifacts/ERC20FeeProxy/index.ts (1)

166-169: LGTM! Deployment follows established patterns.

The Sonic chain deployment:

  1. Uses a consistent address pattern seen in other networks (goerli, optimism, moonbeam)
  2. Has a creation block number (3974138) that aligns chronologically with other contract deployments in this PR

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)
packages/payment-detection/src/eth/multichainExplorerApiProvider.ts (1)

Line range hint 37-84: Consider refactoring the getBaseUrl method for better maintainability.

The method is growing large with the addition of new networks. Consider refactoring to use a map or configuration object:

-  // eslint-disable-next-line complexity
-  getBaseUrl(): string {
-    switch (this.network.name) {
-      case 'sonic':
-        return 'https://api.sonicscan.org/api';
-      // ... other cases
-    }
-  }
+  private static readonly BASE_URLS: Record<string, string> = {
+    sonic: 'https://api.sonicscan.org/api',
+    base: 'https://api.basescan.org/api',
+    // ... other mappings
+  };
+
+  getBaseUrl(): string {
+    return MultichainExplorerApiProvider.BASE_URLS[this.network.name] || super.getBaseUrl();
+  }
packages/utils/src/providers.ts (1)

56-56: Consider making the RPC URL configurable via environment variable.

While the hardcoded RPC URL works, following the pattern used for other networks, consider documenting that it can be overridden using the environment variable RN_WEB3_RPC_URL_SONIC for production deployments.

Add a comment above the networkRpcs object:

/**
 * Default RPC URLs for networks. Can be overridden using RN_WEB3_RPC_URL_[NETWORK] environment variables.
 * Example: RN_WEB3_RPC_URL_SONIC for the Sonic network.
 */
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 935a4f0 and 121f360.

📒 Files selected for processing (7)
  • packages/currency/src/chains/evm/data/sonic.ts (1 hunks)
  • packages/currency/src/chains/evm/index.ts (2 hunks)
  • packages/currency/src/conversion-aggregators.ts (1 hunks)
  • packages/currency/src/native.ts (1 hunks)
  • packages/payment-detection/src/eth/multichainExplorerApiProvider.ts (3 hunks)
  • packages/types/src/currency-types.ts (1 hunks)
  • packages/utils/src/providers.ts (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • packages/currency/src/chains/evm/data/sonic.ts
  • packages/currency/src/conversion-aggregators.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build-and-test
🔇 Additional comments (5)
packages/currency/src/chains/evm/index.ts (1)

31-31: LGTM! The Sonic chain integration follows the established pattern.

The changes correctly integrate the Sonic chain definition into the EVM chains configuration.

Also applies to: 66-66

packages/payment-detection/src/eth/multichainExplorerApiProvider.ts (1)

20-20: LGTM! The Sonic network configuration is correctly defined.

The chain ID and network name are properly configured.

packages/currency/src/native.ts (1)

175-180: LGTM! The Sonic native currency is properly configured.

The native currency configuration follows the standard pattern with correct decimal precision and network reference.

Let's verify that the symbol is unique across all native currencies:

✅ Verification successful

Symbol '$S' is unique across all native currencies

The native currency configuration for Sonic network with symbol '$S' is unique and doesn't conflict with any other native currency symbols in the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for duplicate native currency symbols
rg -B 1 -A 1 "symbol: '\$S'" packages/currency/src/native.ts

Length of output: 67


Script:

#!/bin/bash
# Search for native currency configurations using ripgrep
rg -A 3 "symbol: .*," packages/currency/src/native.ts

# Alternative search using ast-grep to find object literals with symbol property
ast-grep --pattern '{
  symbol: $_,
  $$$
}'

Length of output: 20773

packages/types/src/currency-types.ts (1)

29-29: LGTM! The Sonic chain type is properly defined.

The addition to EvmChainName type maintains alphabetical order and consistency.

packages/utils/src/providers.ts (1)

56-56: Verify the RPC endpoint's reliability and rate limits.

Since this RPC will be used for contract interactions mentioned in the PR (RequestDeployer, ERC20Proxy, etc.), ensure that:

  1. The RPC endpoint is stable and production-ready
  2. It has sufficient rate limits for your use case
  3. It supports all required JSON-RPC methods needed by the contracts

@leoslr leoslr requested a review from kevindavee January 16, 2025 08:13
@leoslr leoslr merged commit 9ab9b25 into master Jan 16, 2025
10 checks passed
@leoslr leoslr deleted the feat/sonic-chain branch January 16, 2025 08:51
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.

3 participants