feat: adapter alias#509
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe changes extend the vault address resolution system by adding support for vault adapter aliases. The Changes
Sequence DiagramsequenceDiagram
participant Component as Chart Component
participant Context as VaultRegistryContext
participant MonarchAPI as Monarch API
participant Cache as Computed Maps<br/>(chainId:address)
Component->>Context: getAddressLabel(address, chainId)
alt chainId provided
Context->>Cache: lookup in precomputed map
Cache-->>Context: AddressLabel or undefined
else no chainId
Context->>Cache: search across all addresses
Cache-->>Context: AddressLabel or undefined
end
Context-->>Component: AddressLabel with displayName
Component->>Component: render displayName or fallback
Note over Context,MonarchAPI: On context load:
Context->>MonarchAPI: fetchMonarchVaults()
Context->>MonarchAPI: fetchMonarchVaultAdapterAliases()
MonarchAPI-->>Context: vaults[], adapters[]
Context->>Cache: build chainId:address lookup maps
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/data-sources/monarch-api/vaults.ts`:
- Around line 362-399: The catch in fetchMonarchVaultAdapterAliases currently
swallows failures by returning [] — instead log the error (keep the
console.warn) and then rethrow a normalized/typed error so callers (e.g., React
Query) can surface the failure; specifically, replace the "return []" in
fetchMonarchVaultAdapterAliases's catch with throwing a new application-level
error (wrapping the original error from monarchGraphqlFetcher) or rethrowing the
original after normalization, ensuring the thrown error includes context like
"Failed fetching Monarch adapter aliases" and the original error details.
🪄 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: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 4aa5f985-7ca5-473f-92fb-7ff9baed366a
📒 Files selected for processing (8)
src/contexts/VaultRegistryContext.tsxsrc/data-sources/monarch-api/index.tssrc/data-sources/monarch-api/vaults.tssrc/features/market-detail/components/charts/borrowers-pie-chart.tsxsrc/features/market-detail/components/charts/supplier-positions-chart.tsxsrc/features/market-detail/components/charts/suppliers-pie-chart.tsxsrc/hooks/queries/useVaultAdapterAliasesQuery.tssrc/hooks/useAddressLabel.ts
| export const fetchMonarchVaultAdapterAliases = async (): Promise<VaultAdapterAlias[]> => { | ||
| try { | ||
| const aliases: VaultAdapterAlias[] = []; | ||
| const seenKeys = new Set<string>(); | ||
|
|
||
| for (let page = 0; page < MONARCH_ADAPTER_ALIAS_MAX_PAGES; page++) { | ||
| const response = await monarchGraphqlFetcher<MonarchAdapterAliasesResponse>(adapterAliasesQuery, { | ||
| adapterTypes: MORPHO_MARKET_ADAPTER_TYPES, | ||
| limit: MONARCH_ADAPTER_ALIAS_PAGE_SIZE, | ||
| offset: page * MONARCH_ADAPTER_ALIAS_PAGE_SIZE, | ||
| }); | ||
|
|
||
| const records = response.data?.Adapter ?? []; | ||
| for (const record of records) { | ||
| const alias = transformAdapterAliasRecord(record); | ||
| if (!alias) { | ||
| continue; | ||
| } | ||
|
|
||
| const key = `${alias.chainId}:${alias.address}`; | ||
| if (seenKeys.has(key)) { | ||
| continue; | ||
| } | ||
|
|
||
| seenKeys.add(key); | ||
| aliases.push(alias); | ||
| } | ||
|
|
||
| if (records.length < MONARCH_ADAPTER_ALIAS_PAGE_SIZE) { | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| return aliases; | ||
| } catch (error) { | ||
| console.warn('Error fetching Monarch vault adapter aliases:', error); | ||
| return []; | ||
| } |
There was a problem hiding this comment.
Don't hide Monarch alias fetch failures behind an empty list.
Returning [] from the catch block makes the alias source look healthy even when the query is broken, so consumers silently fall back to short addresses and the registry never sees an error. Let the request reject after logging so React Query can surface the failure.
Small fix
} catch (error) {
console.warn('Error fetching Monarch vault adapter aliases:', error);
- return [];
+ throw error;
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/data-sources/monarch-api/vaults.ts` around lines 362 - 399, The catch in
fetchMonarchVaultAdapterAliases currently swallows failures by returning [] —
instead log the error (keep the console.warn) and then rethrow a
normalized/typed error so callers (e.g., React Query) can surface the failure;
specifically, replace the "return []" in fetchMonarchVaultAdapterAliases's catch
with throwing a new application-level error (wrapping the original error from
monarchGraphqlFetcher) or rethrowing the original after normalization, ensuring
the thrown error includes context like "Failed fetching Monarch adapter aliases"
and the original error details.
Summary by CodeRabbit
New Features
Improvements