Conversation
Signed-off-by: dung5ire <dung@5ire.org>
feat: add 5ireChain
Update Syscoin and Rollux integration
devop: new networks
WalkthroughThis pull request introduces significant updates to the Enkrypt extension, focusing on network configuration and support. The changes involve adding new networks like 5ire and Syscoin NEVM, updating network configurations, modifying token balance retrieval mechanisms, and adjusting network-related imports and exports. The modifications span multiple files across the extension's providers, types, and UI components, reflecting a comprehensive update to the network support infrastructure. Changes
Sequence DiagramsequenceDiagram
participant User
participant Extension
participant BlockscoutAPI
participant CoinGecko
User->>Extension: Request token balances
Extension->>BlockscoutAPI: Fetch native and ERC-20 token balances
BlockscoutAPI-->>Extension: Return token balance data
Extension->>CoinGecko: Fetch additional token information
CoinGecko-->>Extension: Return token details
Extension->>User: Display token balances
Possibly related PRs
Suggested reviewers
✨ Finishing Touches
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: 0
🧹 Nitpick comments (4)
packages/extension/src/providers/ethereum/libs/assets-handlers/blockscout.ts (2)
26-88: LGTM! Robust implementation of Blockscout balance fetching.The implementation is well-structured with proper:
- Error handling
- Input validation
- Response data validation
- Parallel request optimization
However, consider adding rate limiting to prevent API abuse:
+const RATE_LIMIT_MS = 1000; // 1 request per second +let lastRequestTime = 0; + const getBlockscoutBalances = ( chain: SupportedNetworkNames, address: string, ): Promise<TokenBalance[]> => { + const now = Date.now(); + if (now - lastRequestTime < RATE_LIMIT_MS) { + return Promise.reject('Rate limit exceeded'); + } + lastRequestTime = now; + const encodedAddress = encodeURIComponent(address);
79-87: Consider adding retry logic for failed requests.The current error handling returns a zero balance on failure. Consider implementing retry logic for transient failures.
+const MAX_RETRIES = 3; +const RETRY_DELAY_MS = 1000; + +const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)); + +const fetchWithRetry = async (url: string, retries = MAX_RETRIES): Promise<any> => { + try { + const response = await fetch(url); + return await response.json(); + } catch (error) { + if (retries > 0) { + await sleep(RETRY_DELAY_MS); + return fetchWithRetry(url, retries - 1); + } + throw error; + } +};packages/types/src/networks.ts (1)
100-100: Consider standardizing the network value format.The value "5ire" for Fire network deviates from the typical uppercase format used by other networks (e.g., "SYS", "TSYS", "Form").
Consider using an uppercase format:
- Fire = "5ire", + Fire = "FIRE",packages/extension/src/providers/ethereum/networks/index.ts (1)
65-65: Consider renaming the import to follow naming conventions.The import name
_5ireNodeuses an underscore prefix to avoid JavaScript identifier restrictions. Consider organizing the file structure to allow a more standard naming pattern.-import _5ireNode from './5ire'; +import fireNode from './fire';
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
packages/extension/src/providers/ethereum/networks/icons/5ire.svgis excluded by!**/*.svg
📒 Files selected for processing (22)
README.md(2 hunks)packages/extension/package.json(1 hunks)packages/extension/src/providers/common/libs/new-features.ts(1 hunks)packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts(1 hunks)packages/extension/src/providers/ethereum/libs/assets-handlers/assetinfo-mew.ts(3 hunks)packages/extension/src/providers/ethereum/libs/assets-handlers/blockscout.ts(1 hunks)packages/extension/src/providers/ethereum/libs/assets-handlers/token-lists.ts(1 hunks)packages/extension/src/providers/ethereum/libs/assets-handlers/types/tokenbalance-mew.ts(2 hunks)packages/extension/src/providers/ethereum/libs/transaction/index.ts(1 hunks)packages/extension/src/providers/ethereum/networks/5ire.ts(1 hunks)packages/extension/src/providers/ethereum/networks/bsc.ts(0 hunks)packages/extension/src/providers/ethereum/networks/form.ts(1 hunks)packages/extension/src/providers/ethereum/networks/index.ts(4 hunks)packages/extension/src/providers/ethereum/networks/sys.ts(0 hunks)packages/extension/src/providers/ethereum/networks/syscoin/nevm-testnet.ts(1 hunks)packages/extension/src/providers/ethereum/networks/syscoin/nevm.ts(1 hunks)packages/extension/src/providers/ethereum/networks/syscoin/rollux-testnet.ts(2 hunks)packages/extension/src/providers/ethereum/networks/syscoin/rollux.ts(2 hunks)packages/extension/src/providers/ethereum/networks/tsys.ts(0 hunks)packages/extension/src/providers/ethereum/types/evm-network.ts(2 hunks)packages/extension/src/ui/action/App.vue(1 hunks)packages/types/src/networks.ts(2 hunks)
💤 Files with no reviewable changes (3)
- packages/extension/src/providers/ethereum/networks/tsys.ts
- packages/extension/src/providers/ethereum/networks/sys.ts
- packages/extension/src/providers/ethereum/networks/bsc.ts
✅ Files skipped from review due to trivial changes (1)
- packages/extension/package.json
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: buildAll
- GitHub Check: test
🔇 Additional comments (30)
packages/extension/src/providers/common/libs/new-features.ts (1)
3-8: LGTM! Network additions are properly configured.The newNetworks array correctly includes the newly supported networks: Form, Rollux, SyscoinNEVM, and Fire.
packages/extension/src/providers/ethereum/networks/5ire.ts (2)
19-19: Implement proper activity handling.The current activity handler always returns an empty array, which means no transaction history will be shown to users. Consider implementing proper activity tracking.
Would you like me to provide an example implementation using the EtherscanActivity handler?
6-20: 🛠️ Refactor suggestionAdd essential security configurations.
The network configuration is missing important security parameters:
networkVersionfor EIP-1193 complianceenforceChainIdflag to prevent chain ID spoofingconst fireOptions: EvmNetworkOptions = { name: NetworkNames.Fire, name_long: '5ire Chain', homePage: 'https://www.5ire.org', blockExplorerTX: 'https://5irescan.io/tx/[[txHash]]', blockExplorerAddr: 'https://5irescan.io/address/[[address]]', chainID: '0x3e3', isTestNetwork: false, currencyName: '5IRE', currencyNameLong: '5ire', node: 'https://rpc.5ire.network', icon, coingeckoID: '5ire', + networkVersion: '995', + enforceChainId: true, activityHandler: wrapActivityHandler(() => Promise.resolve([])), };packages/extension/src/providers/ethereum/networks/form.ts (2)
7-20: 🛠️ Refactor suggestionAdd essential security configurations.
The network configuration is missing important security parameters:
networkVersionfor EIP-1193 complianceenforceChainIdflag to prevent chain ID spoofingconst formOptions: EvmNetworkOptions = { name: NetworkNames.Form, name_long: 'Form Mainnet', homePage: 'https://docs.form.network', blockExplorerTX: 'https://explorer.form.network/tx/[[txHash]]', blockExplorerAddr: 'https://explorer.form.network/address/[[address]]', chainID: '0x1de', isTestNetwork: false, currencyName: 'ETH', currencyNameLong: 'Ethereum', node: 'wss://rpc.form.network/ws', icon, + networkVersion: '478', + enforceChainId: true, activityHandler: wrapActivityHandler(EtherscanActivity), };
15-16: Verify if using 'ETH' as currency name is correct.Using 'ETH' and 'Ethereum' as currency names for Form network might be misleading to users. Please verify if these are the official currency names for this network.
✅ Verification successful
Currency names 'ETH' and 'Ethereum' are correct for Form network
The use of 'ETH' and 'Ethereum' as currency names is appropriate as Form is an EVM-compatible network that follows standard Ethereum conventions for maximum compatibility with existing tools and dApps.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Search for Form network's currency name in documentation curl -s https://docs.form.network | grep -i "currency\|token"Length of output: 63
Script:
#!/bin/bash # Search for Form network related configurations and documentation echo "=== Searching for Form network configurations ===" rg -A 5 -B 5 "Form.*network" --type ts echo -e "\n=== Searching for network type definitions ===" ast-grep --pattern 'interface $_ { $$$ currencyName: $_ $$$ }' echo -e "\n=== Looking for Form network documentation ===" fd README -t f -X cat {}Length of output: 44787
Script:
#!/bin/bash # Search for Form network's complete configuration echo "=== Searching for Form network configuration ===" rg -A 20 "NetworkNames.Form.*=" --type ts echo -e "\n=== Looking for Form network imports ===" rg "from.*form" --type tsLength of output: 2025
Script:
#!/bin/bash # View Form network configuration files echo "=== Form Network Configuration ===" cat packages/extension/src/providers/ethereum/networks/form.ts echo -e "\n=== Form Testnet Configuration ===" cat packages/extension/src/providers/ethereum/networks/form-testnet.tsLength of output: 2063
packages/extension/src/providers/ethereum/networks/syscoin/nevm-testnet.ts (2)
7-21: LGTM! Well-structured testnet configuration.The configuration includes all necessary components for a testnet:
- Proper test network flag
- Faucet link for obtaining test tokens
- Activity tracking implementation
7-21: 🛠️ Refactor suggestionAdd essential security configurations.
The network configuration is missing important security parameters:
networkVersionfor EIP-1193 complianceenforceChainIdflag to prevent chain ID spoofingconst syscoinNEVMTestOptions: EvmNetworkOptions = { name: NetworkNames.SyscoinNEVMTest, name_long: 'Syscoin NEVM Testnet', homePage: 'https://www.syscoin.org/', blockExplorerTX: 'https://explorer.tanenbaum.io/tx/[[txHash]]', blockExplorerAddr: 'https://explorer.tanenbaum.io/address/[[address]]', chainID: '0x1644', isTestNetwork: true, currencyName: 'TSYS', currencyNameLong: 'Test Syscoin', node: 'wss://rpc.tanenbaum.io/wss', icon, buyLink: 'https://faucet.syscoin.org', + networkVersion: '5700', + enforceChainId: true, activityHandler: wrapActivityHandler(EtherscanActivity), };packages/extension/src/providers/ethereum/networks/syscoin/rollux.ts (2)
1-1: LGTM! Import paths have been updated correctly.The import paths have been restructured to maintain consistency with the new directory structure.
Also applies to: 3-5
23-23: Verify the Coinify trade URL functionality.The
buyLinkURL includes multiple cryptocurrency options. Please ensure that:
- The URL is accessible and functional
- The default cryptocurrency selection works as expected
- All listed cryptocurrencies (SYSROLLUX, SYSEVM, SYS) are available on the platform
packages/extension/src/providers/ethereum/networks/syscoin/nevm.ts (2)
8-25: LGTM! Network configuration is well-structured.The Syscoin NEVM network configuration includes all necessary properties and follows security best practices:
- Uses secure WebSocket (wss://) for node communication
- Includes proper block explorer URLs
- Chain ID is correctly formatted as hex
23-23: Verify the Coinify trade URL functionality.Similar to Rollux, please verify:
- URL accessibility
- Default cryptocurrency selection (SYSEVM)
- Available cryptocurrencies (SYSROLLUX, SYSEVM, SYS)
packages/extension/src/providers/ethereum/libs/assets-handlers/types/tokenbalance-mew.ts (2)
Line range hint
54-67: LGTM! Network types have been expanded.The
SupportedNetworkNamestype has been correctly updated to include new networks like SyscoinNEVM, Rollux, etc.
8-8: Verify the impact of makingtbNameoptional.The change to make
tbNameoptional (?) is a breaking change. Please ensure that all existing code handles the case wheretbNameis undefined.Also applies to: 10-10
packages/types/src/networks.ts (1)
69-69: LGTM: Network name updates look good.The rebranding of Syscoin to Syscoin NEVM and addition of Form network maintain consistent naming patterns.
Also applies to: 72-73
packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts (1)
52-52: LGTM: Explorer endpoints are correctly configured.The explorer endpoints for Form and Syscoin NEVM networks are properly configured and consistent with their respective network changes.
Also applies to: 55-56
packages/extension/src/providers/ethereum/networks/index.ts (2)
36-36: LGTM: Network node imports are properly organized.The imports for Form and Syscoin NEVM networks are correctly structured and organized in separate files.
Also applies to: 38-41
112-112: Verify network node configurations.The network node mappings are consistent with the enum changes. However, ensure that the node configurations in the imported files are properly set up.
Also applies to: 114-115, 141-141
✅ Verification successful
Network configurations are properly structured and complete
All network configurations follow the correct pattern using
EvmNetworkOptionsinterface and contain all required fields including chainID, RPC endpoints, and block explorer URLs. The configurations are consistent with the codebase standards.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify network node configurations exist and are properly structured # Check for network configuration files echo "Checking network configuration files..." for file in "form" "syscoin/nevm-testnet" "syscoin/nevm" "5ire"; do if [ -f "packages/extension/src/providers/ethereum/networks/${file}.ts" ]; then echo "Found ${file}.ts" # Check for required exports rg -l "export default" "packages/extension/src/providers/ethereum/networks/${file}.ts" else echo "Missing ${file}.ts" fi doneLength of output: 1480
Script:
#!/bin/bash # Check the structure of network configurations echo "Analyzing network configuration structure..." # Check for essential network properties using ast-grep echo "Checking network configuration properties..." ast-grep --pattern 'export default { $$$ chainId: $_, $$$ rpcUrls: $_, $$$ }' # Get more details about the configuration objects echo -e "\nConfiguration details:" for file in form.ts "syscoin/nevm-testnet.ts" "syscoin/nevm.ts" "5ire.ts"; do echo -e "\n=== $file ===" rg "export default" -A 10 "packages/extension/src/providers/ethereum/networks/$file" doneLength of output: 1362
Script:
#!/bin/bash # Get the full network configurations echo "Analyzing network configuration variables..." # Look for variable declarations and their structure for file in form.ts "syscoin/nevm-testnet.ts" "syscoin/nevm.ts" "5ire.ts"; do echo -e "\n=== $file ===" echo "Variable declaration and structure:" rg "^(const|let|var) \w+ = {" -A 15 "packages/extension/src/providers/ethereum/networks/$file" done # Also check for any imports that might define the network type echo -e "\nChecking network type definitions..." rg "import.*Network" "packages/extension/src/providers/ethereum/networks/"Length of output: 20248
Script:
#!/bin/bash # Get the full network configurations with fixed regex echo "Analyzing network configuration variables..." for file in form.ts "syscoin/nevm-testnet.ts" "syscoin/nevm.ts" "5ire.ts"; do echo -e "\n=== $file ===" echo "Variable declaration and structure:" rg "^const.*=" -A 15 "packages/extension/src/providers/ethereum/networks/$file" doneLength of output: 3814
packages/extension/src/providers/ethereum/libs/assets-handlers/token-lists.ts (1)
6-7: LGTM: Token list configurations are properly set up.The token list URLs for SyscoinNEVM and Rollux networks are correctly configured using their respective Coingecko platform IDs.
packages/extension/src/providers/ethereum/types/evm-network.ts (2)
37-37: LGTM! The newbuyLinkproperty is properly typed.The optional property is correctly defined with appropriate type annotations.
102-102: LGTM! Options are properly stored for later access.The assignment of options to
this.optionsenables access to network-specific configurations likebuyLink.packages/extension/src/providers/ethereum/libs/transaction/index.ts (1)
95-96: LGTM! Enhanced fee market network detection.The additional check for non-empty
baseFeePerGasarray prevents false positives when fee history is unavailable, making the detection more reliable.packages/extension/src/providers/ethereum/libs/assets-handlers/assetinfo-mew.ts (3)
23-23: LGTM! Added Blockscout balance retrieval support.The import is properly added to support the new balance retrieval mechanism.
124-127: LGTM! Network configurations properly updated.The network configurations for SyscoinNEVM and Rollux are correctly set up with Blockscout support.
Also applies to: 130-130
199-200: LGTM! Blockscout balance retrieval properly integrated.The conditional branch correctly handles balance retrieval for networks with Blockscout support.
packages/extension/src/ui/action/App.vue (1)
365-384: LGTM! Well-structured buy link handling.The refactored implementation:
- Uses a clear switch statement for better maintainability
- Properly handles network-specific buy links
- Correctly includes addresses where needed
packages/extension/src/providers/ethereum/networks/syscoin/rollux-testnet.ts (2)
19-19: LGTM! Appropriate faucet link for testnet.The addition of the
buyLinkpointing to the Rollux faucet is appropriate for a testnet configuration.
1-1: Verify the updated import paths.The import paths have been updated to use parent directory traversal. Please verify that these new paths are correct and that the imported files exist at the specified locations.
Also applies to: 3-4
✅ Verification successful
Import paths are correctly updated
All import paths in rollux-testnet.ts have been verified to correctly point to their respective files:
- '../icons/tsys_rollux.svg' → icon file
- '../../types/evm-network' → network type definitions
- '../../libs/activity-handlers' → activity handlers
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the imported files exist at the specified locations # Check if the icon file exists fd -t f "tsys_rollux.svg" -x echo "Icon file found at: {}" # Check if the type definitions exist fd -t f "evm-network.(ts|d.ts)" -x echo "Network types found at: {}" # Check if the activity handlers exist fd -t f "activity-handlers.(ts|d.ts)" -x echo "Activity handlers found at: {}"Length of output: 490
Script:
#!/bin/bash # Search for activity handlers directory or files fd -t f "activity" -x echo "Found: {}"Length of output: 744
Script:
#!/bin/bash # Search for EtherscanActivity in the codebase rg -l "EtherscanActivity" --type ts # Show the context of files containing EtherscanActivity rg "EtherscanActivity" --type ts -C 2Length of output: 54065
README.md (3)
102-102: LGTM! Network name update is more specific.The update from "Syscoin" to "Syscoin NEVM" provides better clarity about the network type.
111-111: LGTM! New network addition.The addition of "5ireChain" to the supported chains list is properly placed in alphabetical order.
102-102: Verify network name consistency across the codebase.Please ensure that the network names "Syscoin NEVM" and "5ireChain" are consistently used across the codebase, including configuration files, type definitions, and UI components.
Also applies to: 111-111
✅ Verification successful
Network names are consistently used across the codebase
The verification confirms that both "Syscoin NEVM" (as
NetworkNames.SyscoinNEVM) and "5ireChain" (asNetworkNames.Fire) are consistently used across configuration files, type definitions, and UI components.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for network name consistency across the codebase # Search for network name variations echo "Checking for network name variations..." rg -i "syscoin|5ire" --type ts --type vue # Search for network configurations echo "Checking network configurations..." ast-grep --pattern 'NetworkNames.$_'Length of output: 58514
Summary by CodeRabbit
New Features
Network Updates
Version Bump