Skip to content

Conversation

@Pana
Copy link
Contributor

@Pana Pana commented May 9, 2025

Summary by CodeRabbit

  • New Features
    • Added support for the Conflux network, including NFT collection and item display, asset handling, and activity tracking.
  • Enhancements
    • Expanded network and platform lists to include Conflux for improved compatibility.
  • Bug Fixes
    • None.
  • Documentation
    • None.
  • Style
    • Minor formatting adjustments for improved code readability (not user-facing).

@coderabbitai
Copy link

coderabbitai bot commented May 9, 2025

Walkthrough

Support for the Conflux eSpace network has been added across multiple modules. This includes new network configuration, NFT handler logic, type definitions, asset handler support, and integration with existing network registries and enums. The changes enable recognition, querying, and processing of Conflux NFTs and assets within the application.

Changes

File(s) Change Summary
packages/extension/src/libs/nft-handlers/conflux.ts Added a new module to fetch and process NFT collections and items for the Conflux network, including a main async function and an internal helper for collection item retrieval.
packages/extension/src/libs/nft-handlers/types/conflux.ts Introduced TypeScript interfaces for Conflux NFT data structures and API responses, extending existing NFT item types with description fields.
packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts Added Conflux network endpoint to the NetworkEndpoints mapping.
packages/extension/src/providers/ethereum/libs/assets-handlers/assetinfo-mew.ts Added Conflux network to the supportedNetworks mapping for asset info handling; minor formatting adjustment.
packages/extension/src/providers/ethereum/libs/assets-handlers/types/tokenbalance-mew.ts Included NetworkNames.Conflux in the SupportedNetworkNames type alias.
packages/extension/src/providers/ethereum/networks/conflux.ts Added a new module defining the Conflux eSpace EVM network configuration, including metadata, handlers, and an icon.
packages/extension/src/providers/ethereum/networks/index.ts Imported and registered the new conflux network node in the exported networks object.
packages/types/src/networks.ts Extended the NetworkNames and CoingeckoPlatform enums to include Conflux.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant ConfluxAPI

    User->>App: Requests NFT collections for Conflux network
    App->>ConfluxAPI: Fetch collections owned by address
    ConfluxAPI-->>App: Returns collection list
    loop For each collection
        App->>ConfluxAPI: Fetch NFT items for collection/address
        ConfluxAPI-->>App: Returns NFT items
    end
    App-->>User: Returns aggregated NFT collections and items
Loading

Suggested reviewers

  • SemajaM8
  • kvhnuke

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

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

🧹 Nitpick comments (6)
packages/extension/src/libs/nft-handlers/types/conflux.ts (3)

3-13: Refine ConfluxNFTItem property types for better type safety.

  • Replace the generic rawData: object with a more specific type or unknown/Record<string, unknown> to avoid object pitfalls.
  • Consider using the existing NFTType (or a union) instead of type: string to enforce valid NFT types.

15-24: Improve nullability and reuse existing types in NFTBalanceItem.

  • website and iconUrl are nullable—consider using a URL type or custom MaybeURL alias.
  • For type: string, reuse NFTType if applicable.

26-29: Make ListResponse generic.

Current list: object[] is too coarse. You can introduce a type parameter:

export interface ListResponse<T> {
  total: number;
  list: T[];
}

This will enable strong typing of API results.

packages/extension/src/providers/ethereum/libs/assets-handlers/assetinfo-mew.ts (1)

279-289: Code formatting improvement while maintaining logic.

The code reformatting maintains the original logic while improving readability. It correctly:

  1. Filters out the native token address from contracts
  2. Uses the appropriate Coingecko platform for the specified network

However, there is a performance issue flagged by static analysis:

-      : tokens.reduce(
-          (obj, cur) => ({ ...obj, [cur.contract]: null }),
-          {} as Record<string, CoinGeckoTokenMarket | null>,
-        );
+      : tokens.reduce(
+          (obj, cur) => {
+            obj[cur.contract] = null;
+            return obj;
+          },
+          {} as Record<string, CoinGeckoTokenMarket | null>,
+        );

This avoids using spread syntax on accumulators, which can lead to O(n²) time complexity.

🧰 Tools
🪛 Biome (1.9.4)

[error] 287-287: Avoid the use of spread (...) syntax on accumulators.

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

(lint/performance/noAccumulatingSpread)

packages/extension/src/libs/nft-handlers/conflux.ts (2)

36-37: Type casting could be improved.

The double casting pattern as unknown as NFTBalanceItem[] suggests potential type mismatch. Consider revising the type definitions to more accurately match the API response structure.

If the type definitions can't be changed, at least add a comment explaining why this casting approach is necessary.

Also applies to: 72-73


58-84: Helper function looks good but has room for improvement.

The collection item retrieval function is well implemented with:

  • Proper error handling
  • Correct mapping to standardized NFT item format
  • Good use of caching

Consider adding:

  1. Logging for specific API errors to aid debugging
  2. Handling for API rate limiting if Conflux API enforces it
  3. Pagination support for collections with more than 100 items

Also, the URL construction:

-    url: `https://evm.confluxscan.org/nft/${item.contract}/${item.tokenId}`,
+    url: `https://evm.confluxscan.org/nft/${item.contract}/${encodeURIComponent(item.tokenId)}`,

This ensures tokenIds with special characters are properly encoded in URLs.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c6d81f2 and 9b7a6cd.

⛔ Files ignored due to path filters (1)
  • packages/extension/src/providers/ethereum/networks/icons/conflux.png is excluded by !**/*.png
📒 Files selected for processing (8)
  • packages/extension/src/libs/nft-handlers/conflux.ts (1 hunks)
  • packages/extension/src/libs/nft-handlers/types/conflux.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 (2 hunks)
  • packages/extension/src/providers/ethereum/libs/assets-handlers/types/tokenbalance-mew.ts (1 hunks)
  • packages/extension/src/providers/ethereum/networks/conflux.ts (1 hunks)
  • packages/extension/src/providers/ethereum/networks/index.ts (2 hunks)
  • packages/types/src/networks.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
packages/extension/src/providers/ethereum/libs/assets-handlers/assetinfo-mew.ts (2)
packages/swap/src/configs.ts (1)
  • NATIVE_TOKEN_ADDRESS (123-123)
packages/extension/src/libs/market-data/types.ts (1)
  • CoinGeckoTokenMarket (23-37)
packages/extension/src/providers/ethereum/networks/conflux.ts (2)
packages/extension/src/providers/ethereum/types/evm-network.ts (2)
  • EvmNetworkOptions (25-56)
  • EvmNetwork (58-293)
packages/extension/src/providers/ethereum/libs/activity-handlers/index.ts (1)
  • EtherscanActivity (10-10)
packages/extension/src/libs/nft-handlers/types/conflux.ts (1)
packages/extension/src/types/nft.ts (1)
  • NFTItem (9-16)
🪛 Biome (1.9.4)
packages/extension/src/providers/ethereum/libs/assets-handlers/assetinfo-mew.ts

[error] 287-287: Avoid the use of spread (...) syntax on accumulators.

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

(lint/performance/noAccumulatingSpread)

🔇 Additional comments (11)
packages/extension/src/libs/nft-handlers/types/conflux.ts (2)

31-35: ConfluxResponse shape looks correct.

No further changes needed here; the interface aligns with the other handlers.


37-39: Extending NFTItem to include description is appropriate.

This ensures downstream code treats descriptions uniformly across networks.

packages/extension/src/providers/ethereum/libs/activity-handlers/providers/etherscan/configs.ts (1)

74-74: Confirm the ConfluxScan EVM API endpoint.

The URL https://evmapi.confluxscan.org/ matches the Etherscan-compatible pattern. Please verify it supports the same query parameters as other Etherscan endpoints (module, action, etc.).

packages/extension/src/providers/ethereum/networks/index.ts (2)

74-74: Import Conflux network configuration.

The new import aligns with the file structure and makes the Conflux config available for registration.


158-159: Register conflux in the network exports.

Including conflux: conflux ensures the Conflux network is part of the default export and can be selected like other networks.

packages/extension/src/providers/ethereum/libs/assets-handlers/types/tokenbalance-mew.ts (1)

76-77: Include Conflux in supported network names.

Adding | NetworkNames.Conflux extends token balance handling to Conflux. Ensure assetinfo-mew.ts also configures Conflux under supportedNetworks.

packages/types/src/networks.ts (2)

108-110: Add Conflux to NetworkNames enum.

The new entry Conflux = "Conflux" aligns with other network identifiers. Ensure any consumers of NetworkNames handle this new key.


174-176: Add Conflux to CoingeckoPlatform enum.

The platform ID conflux matches the lowercase convention. Consider verifying on CoinGecko that the slug conflux is correct.

packages/extension/src/providers/ethereum/libs/assets-handlers/assetinfo-mew.ts (1)

220-223: LGTM! Conflux network support added properly.

The Conflux network integration follows the established pattern for adding network support, with appropriate token balance API name (tbName: 'cfx') and Coingecko platform identifier.

packages/extension/src/providers/ethereum/networks/conflux.ts (2)

9-25: Network configuration looks good and follows established patterns.

The Conflux eSpace network configuration is properly defined with:

  • Correct chain ID (0x406 = 1030 in decimal)
  • Appropriate explorer URLs
  • Proper currency names
  • Integration with relevant handlers (NFT, assets, activity)

The configuration properties follow the expected structure for an EVM network.


27-29: Network instantiation and export follows project conventions.

The instantiation of the EvmNetwork with the defined configuration and its default export matches the pattern used for other networks in the project.

@Pana Pana changed the title add conflux network feat: add conflux network May 9, 2025
@kvhnuke kvhnuke changed the base branch from main to devop/packeupdates-0512 May 12, 2025 19:53
@kvhnuke kvhnuke merged commit e0ea928 into enkryptcom:devop/packeupdates-0512 May 12, 2025
2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request May 14, 2025
@coderabbitai coderabbitai bot mentioned this pull request Jun 17, 2025
@coderabbitai coderabbitai bot mentioned this pull request Jul 24, 2025
@coderabbitai coderabbitai bot mentioned this pull request Aug 18, 2025
@coderabbitai coderabbitai bot mentioned this pull request Sep 25, 2025
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