Normalize QuickNode arb/optimism network mapping#940
Conversation
Co-authored-by: hyacinthus <488292+hyacinthus@users.noreply.github.com>
Co-authored-by: hyacinthus <488292+hyacinthus@users.noreply.github.com>
Co-authored-by: hyacinthus <488292+hyacinthus@users.noreply.github.com>
Co-authored-by: hyacinthus <488292+hyacinthus@users.noreply.github.com>
Co-authored-by: hyacinthus <488292+hyacinthus@users.noreply.github.com>
Co-authored-by: hyacinthus <488292+hyacinthus@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes QuickNode network mapping issues by adding alias support for non-standard chain and network identifiers returned by QuickNode's API. The implementation normalizes QuickNode's short-form identifiers (arb, optimism) to match the existing enum values used throughout the codebase.
Changes:
- Added alias mappings for QuickNode chain identifier
arb→arbitrumand network identifieroptimism→optimism-mainnet - Updated
init_chain_configsto apply alias normalization before enum construction - Added test coverage for alias mapping functionality
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| intentkit/utils/chain.py | Added QUICKNODE_CHAIN_ALIASES and QUICKNODE_NETWORK_ALIASES dictionaries; updated init_chain_configs to normalize identifiers using these aliases before creating Chain and QuickNodeNetwork enums |
| tests/utils/test_chain.py | Added test helper classes (DummyResponse, DummyClient) and test_quicknode_chain_provider_alias_mapping test case to verify alias mapping functionality |
| def test_quicknode_chain_provider_alias_mapping(monkeypatch: pytest.MonkeyPatch): | ||
| # QuickNode can return chain "arb" with network "optimism"; both should map. | ||
| payload = { | ||
| "data": [ | ||
| { | ||
| "chain": "arb", | ||
| "network": "optimism", | ||
| "http_url": "https://quicknode", | ||
| "ens_url": "https://ens", | ||
| "wss_url": "wss://quicknode", | ||
| } | ||
| ] | ||
| } | ||
|
|
||
| monkeypatch.setattr( | ||
| chain_utils.httpx, | ||
| "Client", | ||
| lambda *_, **__: DummyClient(payload), | ||
| ) | ||
|
|
||
| provider = QuicknodeChainProvider("test-key") | ||
| provider.init_chain_configs() | ||
|
|
||
| config = provider.chain_configs[QuickNodeNetwork.OptimismMainnet] | ||
| assert config.chain is Chain.Arbitrum | ||
| assert config.network is QuickNodeNetwork.OptimismMainnet |
There was a problem hiding this comment.
The test uses an unrealistic combination of QuickNode identifiers. According to the PR description, QuickNode returns:
- chain='arb', network='arbitrum-mainnet' for Arbitrum endpoints
- chain='optimism', network='optimism' for Optimism endpoints
This test combines chain='arb' with network='optimism', which doesn't represent an actual QuickNode response. While the test technically validates that both aliases work, it doesn't test the real-world scenarios that were causing the startup errors. Consider adding separate test cases for each actual QuickNode response pattern.
|
|
||
|
|
||
| def test_quicknode_chain_provider_alias_mapping(monkeypatch: pytest.MonkeyPatch): | ||
| # QuickNode can return chain "arb" with network "optimism"; both should map. |
There was a problem hiding this comment.
The comment states "QuickNode can return chain 'arb' with network 'optimism'" but this is misleading. According to the PR description, QuickNode returns chain='arb' with network='arbitrum-mainnet' for Arbitrum, and chain='optimism' with network='optimism' for Optimism. The comment should accurately describe what the test is validating.
| # QuickNode can return chain "arb" with network "optimism"; both should map. | |
| # Simulate QuickNode returning chain "arb" with network "optimism" and verify both aliases map correctly. |
QuickNode returns
arbandoptimismidentifiers for Arbitrum/Optimism networks, but the current mapping expectsarbitrumandoptimism-mainnet, causing startup to skip those endpoints. This change aligns QuickNode inputs with the internal network-id mapping so enabled Arbitrum/Optimism endpoints are recognized.arb/optimismaliases and map them to the existing Arbitrum/Optimism network identifiers.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.