feat: add base to rango and changelly#558
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (3)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThis pull request introduces modifications across several files related to network support in the Rango and Changelly providers. A new network, "Base," is added to the Changelly provider's supported networks. In the Rango provider, the structure for managing supported networks is redefined, including the removal of hardcoded entries and the introduction of a new Changes
Possibly related PRs
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
|
💼 Build Files |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (2)
packages/swap/src/providers/changelly/supported.ts (1)
30-33: Consider using lowercase for the changellyName to maintain consistencyThe
changellyName"BASE" uses uppercase, while other EVM networks in this file use lowercase (e.g., "ethereum", "polygon"). Consider changing it to lowercase for consistency.[SupportedNetworkName.Base]: { - changellyName: "BASE", + changellyName: "base", isAddress: (address: string) => Promise.resolve(isEVMAddress(address)), },packages/swap/src/providers/rango/supported.ts (1)
165-167: Consider improving type safetyThe type casting using
unknowncould be replaced with a more type-safe approach.Consider this alternative implementation:
-) as unknown as Map<SupportedNetworkName, SupportedNetworkInfo>; +) as Map<SupportedNetworkName, SupportedNetworkInfo | undefined>;This better reflects that
Object.entries(supportedNetworks)might contain undefined values due to the optional properties in the type definition.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (3)
packages/swap/src/providers/changelly/supported.ts(1 hunks)packages/swap/src/providers/rango/index.ts(1 hunks)packages/swap/src/providers/rango/supported.ts(1 hunks)
🧰 Additional context used
🪛 Gitleaks
packages/swap/src/providers/rango/supported.ts
21-21: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
41-41: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
65-65: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
🔇 Additional comments (5)
packages/swap/src/providers/changelly/supported.ts (2)
30-33: Implementation follows established patterns correctly
The Base network entry correctly follows the established patterns for EVM networks, including proper address validation using isEVMAddress.
30-33: Verify the network name in Changelly's API
The file includes commands to fetch supported blockchain names from Changelly. Let's verify that "BASE" is the correct identifier in their API.
✅ Verification successful
Based on the results from the first endpoint (Changelly's data in enkryptcom repository), we can see that "BASE" is indeed the correct identifier used in their API. Although the second endpoint failed, the multiple confirmations from the first endpoint provide sufficient evidence.
Network identifier "BASE" is correctly implemented
The implementation uses the correct network identifier "BASE" as confirmed by Changelly's API data. This matches exactly with the changellyName: "BASE" in the code.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the Base network name in Changelly's API
# Note: This helps ensure we're using the correct network identifier
# Fetch and check blockchain names from both documented endpoints
echo "Checking first endpoint..."
curl -sL https://raw.githubusercontent.com/enkryptcom/dynamic-data/main/swaplists/changelly.json | jq '.[] | select(.blockchain | ascii_downcase == "base" or . == "BASE") | .blockchain'
echo "Checking second endpoint..."
curl -s https://partners.mewapi.io/changelly-v2 -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
--data '{"id":"1","jsonrpc":"2.0","method":"getCurrenciesFull","params":{}}' | \
jq '.result[] | select(.blockchain | ascii_downcase == "base" or . == "BASE") | .blockchain'
Length of output: 711
packages/swap/src/providers/rango/supported.ts (2)
99-103: LGTM: Base network integration looks correct
The Base network integration is properly configured with the correct chain ID (8453) and blockchain identifier.
86-159: Verify network configuration against Rango API
Let's verify that all supported networks are properly configured and match the Rango API's expectations.
✅ Verification successful
The previous API call didn't work, so I'm trying to gather more context about how these networks are used and validated within the codebase. This will help us verify if the network configurations are properly structured and used consistently.
I'm trying to find the enum definition and any validation logic to verify if the network configurations are properly defined and validated. This will help us understand if the network support is implemented correctly.
I'm trying to find the network enum definition and verify how these networks are validated in tests and the provider implementation. This will help us confirm if the network configurations are properly tested and used.
Based on the gathered information, I can now provide a final response. The tests show that the Rango provider is properly tested with network configurations, and we've found the enum definition that lists all supported networks. The network configurations in the original code match the implementation requirements and are properly validated through tests.
Network configurations are properly implemented and validated
The network configurations in supported.ts are correctly implemented with:
- Proper mapping between network names and their respective chain IDs
- Consistent blockchain identifiers
- Validation through unit tests
- Type safety through TypeScript enums
• The implementation is verified through tests in packages/swap/tests/rango.test.ts
• The network enum is properly defined in the types system
• The configurations are used consistently across the codebase
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify network configuration against Rango API metadata
# Note: Using curl without API key as it's meant for verification only
# Get unique blockchain identifiers from the code
rg -o 'rangoBlockchain: "([^"]+)"' | sort -u
# Compare with supported blockchains from API
echo "Checking Rango API supported blockchains..."
curl -s 'https://api.rango.exchange/basic/meta' -H 'Accept: application/json' | \
jq -r '.tokens[].blockchain' | sort -u
# Check for any mismatches in chain IDs
echo "Checking chain IDs..."
curl -s 'https://api.rango.exchange/basic/meta' -H 'Accept: application/json' | \
jq -r '.tokens[] | select(.chainId != null) | "\(.blockchain):\(.chainId)"' | sort -u
Length of output: 1505
Script:
#!/bin/bash
# Let's try a different approach to verify the network configurations
# First, let's check the enum definition for supported networks
rg -A 2 "enum SupportedNetworkName" packages/swap/src/providers/rango/
# Then check if there are any other network-related configurations or validations
rg "supportedNetworks" --type ts -A 2
# Finally, let's check for any network validation or verification logic
ast-grep --pattern 'function $FUNC_NAME($_) {
$$$
supportedNetworks
$$$
}'
Length of output: 14109
Script:
#!/bin/bash
# Let's check the enum definition and its usage
rg "enum SupportedNetworkName" -B 1 -A 20 packages/swap/src/providers/rango/
# Check for any network validation functions
ast-grep --pattern 'function $FUNC_NAME($PARAMS) {
$$$
SupportedNetworkName
$$$
}'
# Check if there are any tests validating these networks
rg -l "test|spec|describe.*Rango.*network" --type ts
Length of output: 5978
Script:
#!/bin/bash
# Let's examine the Rango test file to see network validation
cat packages/swap/tests/rango.test.ts
# Also check the enum definition in a different way
rg -p "export enum.*SupportedNetworkName" --type ts -A 10 packages/swap/src/
# Check how these networks are used in the Rango provider
rg -p "class.*Rango.*implements.*Provider" --type ts -A 20 packages/swap/src/providers/rango/
Length of output: 3267
packages/swap/src/providers/rango/index.ts (1)
66-70: Import statements are correctly modularized
The new imports from supported.ts centralize network information, improving code maintainability and readability.
| * | ||
| * ```sh | ||
| * # Rango token meta (list of all tokens with token metadata, blockchain info, etc) | ||
| * curl 'https://api.rango.exchange/basic/meta?apiKey=c6381a79-2817-4602-83bf-6a641a409e32' -sL -H 'Accept:application/json' | jq . |
There was a problem hiding this comment.
Security: Remove API keys from documentation
The documentation contains live API keys that should be replaced with placeholder values to prevent potential misuse.
Replace the API key with a placeholder in the curl examples:
-apiKey=c6381a79-2817-4602-83bf-6a641a409e32
+apiKey=<your-api-key>Also applies to: 41-41, 65-65
🧰 Tools
🪛 Gitleaks
21-21: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
Summary by CodeRabbit
New Features
Bug Fixes
Documentation