Enable NFT tab on Rootstock#791
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughAdds a Blockscout-based NFT handler for Rootstock that fetches ERC-721 collections from Blockscout, maps results to NFTCollection/NFTItem shapes, resolves contractURI metadata via a Rootstock RPC node, and includes new TypeScript types for Blockscout responses; integrates the handler into the Rootstock network config. Changes
Sequence DiagramsequenceDiagram
participant Client
participant NFTHandler as NFT Handler<br/>(Blockscout)
participant BlockscoutAPI as Blockscout API
participant RootstockRPC as Rootstock RPC
Client->>NFTHandler: request NFTs(network, address)
NFTHandler->>NFTHandler: validate network == Rootstock
NFTHandler->>BlockscoutAPI: fetch ERC-721 collections (cached)
BlockscoutAPI-->>NFTHandler: return items[]
alt items present
loop each collection
NFTHandler->>RootstockRPC: call contractURI(contract)
RootstockRPC-->>NFTHandler: return URI (maybe ipfs://)
NFTHandler->>NFTHandler: convert ipfs to gateway URL
NFTHandler->>NFTHandler: fetch collection metadata JSON
NFTHandler->>NFTHandler: extract description -> collection.description
end
end
NFTHandler-->>Client: return NFTCollection[]
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
packages/extension/src/libs/nft-handlers/blockscout.ts (1)
7-7: Avoid hardcoding the metadata RPC endpoint.Using
ROOTSTOCK_RPC_NODEdirectly bypasses network configuration and makes this handler harder to evolve (e.g., environment-specific RPC routing). Prefer passing/deriving the RPC endpoint from network config with an explicit fallback.Also applies to: 27-27
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/extension/src/libs/nft-handlers/blockscout.ts` at line 7, The constant ROOTSTOCK_RPC_NODE is hardcoded; change the handler to obtain the RPC endpoint from the network/config input with a fallback to the current 'https://public-node.rsk.co'. Update the symbol ROOTSTOCK_RPC_NODE usage so the handler reads an endpoint option from the network config or function parameters (e.g., a passed-in rpcUrl or network.rpcUrl) and only uses the hardcoded URL as the default; ensure all places referencing ROOTSTOCK_RPC_NODE (including the other occurrence around the symbol on line ~27) are switched to use the derived/configured endpoint.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/extension/src/libs/nft-handlers/blockscout.ts`:
- Around line 29-33: The code awaits contract.contractURI() and fetch(httpUrl)
with no timeouts, which can hang; wrap both calls with bounded timeouts and
return null on timeout. For contract.contractURI(), use a Promise.race that
rejects or resolves to null after X ms (e.g., 5s) and handle that case in the
same way as the existing error path; for fetch(httpUrl) use an AbortController
with the same timeout to abort the request and treat aborted/timeout as null.
Update the block that calls contract.contractURI() and getAssetURL/ fetch to use
these timeout helpers and ensure the catch path still returns null on timeout or
error.
- Around line 41-44: The exported default async NFT handler currently declares
its first parameter as network: NodeType but must match the
EvmNetworkOptions.NFTHandler contract which expects network: BaseNetwork; update
the function signature (the default exported async function that returns
Promise<NFTCollection[]>) to accept network: BaseNetwork instead of NodeType so
the types align with EvmNetworkOptions and downstream callers.
---
Nitpick comments:
In `@packages/extension/src/libs/nft-handlers/blockscout.ts`:
- Line 7: The constant ROOTSTOCK_RPC_NODE is hardcoded; change the handler to
obtain the RPC endpoint from the network/config input with a fallback to the
current 'https://public-node.rsk.co'. Update the symbol ROOTSTOCK_RPC_NODE usage
so the handler reads an endpoint option from the network config or function
parameters (e.g., a passed-in rpcUrl or network.rpcUrl) and only uses the
hardcoded URL as the default; ensure all places referencing ROOTSTOCK_RPC_NODE
(including the other occurrence around the symbol on line ~27) are switched to
use the derived/configured endpoint.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 19ec784f-1891-4405-8013-c1eeec9219e2
📒 Files selected for processing (3)
packages/extension/src/libs/nft-handlers/blockscout.tspackages/extension/src/libs/nft-handlers/types/blockscout.tspackages/extension/src/providers/ethereum/networks/rsk.ts
0c34b2a to
7f1cf13
Compare
Description
This pull request enables NFT tab on Rootstock network.
Demo
rootstock-nft.mp4
How to test
Summary by CodeRabbit