Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughRefactors transaction fetching to operate on a single Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant UI as Client (hook/component)
participant Q as fetchUserTransactions
participant Check as isSupportedChain
participant Morpho as Morpho API
participant Subgraph as Subgraph
UI->>Q: call(filters with chainId)
Q->>Check: isSupportedChain(chainId)
alt chain unsupported
Check-->>Q: false
Q-->>UI: error ("unsupported chain")
else chain supported
Check-->>Q: true
Q->>Morpho: attempt fetch (if Morpho supported)
alt Morpho supported & success
Morpho-->>Q: transactions
Q-->>UI: return transactions
else Morpho fails or not supported
Morpho-->>Q: error / not available
Q->>Subgraph: fetch transactions (single-chain path)
alt Subgraph success
Subgraph-->>Q: transactions
Q-->>UI: return transactions
else Subgraph error
Subgraph-->>Q: error
Q-->>UI: return error (fallback path)
end
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ 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: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/hooks/queries/fetchUserTransactions.ts (1)
118-123: Subgraph fallback ignores server-side pagination flag.The Morpho API path respects
useServerSidePagination(lines 85-96), but the subgraph fallback always usesskip: 0regardless of the flag. This creates inconsistent behavior when the subgraph is used.For consistency, consider applying the same pagination logic to subgraph requests.
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/hooks/queries/fetchUserTransactions.tssrc/hooks/queries/useUserTransactionsQuery.ts
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2024-10-23T16:17:02.841Z
Learnt from: antoncoding
Repo: antoncoding/monarch PR: 77
File: src/graphql/queries.ts:168-193
Timestamp: 2024-10-23T16:17:02.841Z
Learning: In `src/graphql/queries.ts`, handling only `MarketTransferTransactionData` is intentional at this time.
Applied to files:
src/hooks/queries/fetchUserTransactions.ts
📚 Learning: 2025-12-09T10:06:39.848Z
Learnt from: antoncoding
Repo: antoncoding/monarch PR: 231
File: src/hooks/useDeployMorphoMarketV1Adapter.ts:3-3
Timestamp: 2025-12-09T10:06:39.848Z
Learning: In Wagmi v3, useConnection is the correct hook to obtain the connected wallet address, chainId, and connection status (isConnected). This replaces the useAccount hook from Wagmi v2. In your code under src/hooks, use: const { address, chainId, isConnected } = useConnection() from 'wagmi' to access the connected wallet information.
Applied to files:
src/hooks/queries/fetchUserTransactions.tssrc/hooks/queries/useUserTransactionsQuery.ts
🔇 Additional comments (5)
src/hooks/queries/useUserTransactionsQuery.ts (2)
50-50: Logic change looks reasonable.Now respects
filters.firstwhen provided, falling back topageSizeif absent.
64-64: Server-side pagination flag set correctly.The flag is appropriately enabled in pagination mode.
src/hooks/queries/fetchUserTransactions.ts (3)
17-22: Documentation added for the new flag.The description clearly explains the intended behavior.
104-104: Using countTotal from Morpho response.This propagates the server's total count, which is correct for single-network queries with server-side pagination. However, when combined with the multi-network issue flagged above, this count may be misleading.
176-180: Client-side pagination correctly skipped in server mode.The conditional logic appropriately bypasses client-side slicing when server-side pagination is enabled.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/features/history/components/transaction-history-preview.tsx (1)
157-158: Dead fallback code.
chainIdis now required (non-optional), so the?? allMarkets.find(...)fallback will never execute.Suggested simplification
- const chainIdForTx = - chainId ?? allMarkets.find((m) => m.uniqueKey === group.transactions[0].data.market.uniqueKey)?.morphoBlue.chain.id; + const chainIdForTx = chainId;src/features/history/components/history-table.tsx (1)
85-86: Consider validating vaultAdapterChainId.If
chainIdURL param is missing or non-numeric,Number(searchParams.get('chainId'))returnsNaNor0. The query won't run (guarded byBoolean(activeChainId)), but users get no feedback.Optional: Add validation
- const vaultAdapterChainId = isVaultAdapter ? Number(searchParams.get('chainId')) : null; + const vaultAdapterChainIdRaw = searchParams.get('chainId'); + const vaultAdapterChainId = isVaultAdapter && vaultAdapterChainIdRaw + ? Number(vaultAdapterChainIdRaw) + : null; + const hasInvalidVaultChainId = isVaultAdapter && (!vaultAdapterChainId || Number.isNaN(vaultAdapterChainId));Then show an error state when
hasInvalidVaultChainIdis true.
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
src/data-sources/morpho-api/transactions.tssrc/features/history/components/history-table.tsxsrc/features/history/components/transaction-history-preview.tsxsrc/features/history/history-view.tsxsrc/hooks/queries/fetchUserTransactions.tssrc/hooks/queries/useUserTransactionsQuery.tssrc/hooks/usePositionReport.ts
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2024-10-23T16:17:02.841Z
Learnt from: antoncoding
Repo: antoncoding/monarch PR: 77
File: src/graphql/queries.ts:168-193
Timestamp: 2024-10-23T16:17:02.841Z
Learning: In `src/graphql/queries.ts`, handling only `MarketTransferTransactionData` is intentional at this time.
Applied to files:
src/data-sources/morpho-api/transactions.tssrc/hooks/queries/fetchUserTransactions.tssrc/hooks/usePositionReport.tssrc/hooks/queries/useUserTransactionsQuery.tssrc/features/history/components/history-table.tsx
📚 Learning: 2025-12-09T10:06:39.848Z
Learnt from: antoncoding
Repo: antoncoding/monarch PR: 231
File: src/hooks/useDeployMorphoMarketV1Adapter.ts:3-3
Timestamp: 2025-12-09T10:06:39.848Z
Learning: In Wagmi v3, useConnection is the correct hook to obtain the connected wallet address, chainId, and connection status (isConnected). This replaces the useAccount hook from Wagmi v2. In your code under src/hooks, use: const { address, chainId, isConnected } = useConnection() from 'wagmi' to access the connected wallet information.
Applied to files:
src/hooks/queries/fetchUserTransactions.tssrc/hooks/usePositionReport.tssrc/hooks/queries/useUserTransactionsQuery.ts
📚 Learning: 2024-11-25T09:39:42.148Z
Learnt from: antoncoding
Repo: antoncoding/monarch PR: 87
File: app/home/HomePage.tsx:17-39
Timestamp: 2024-11-25T09:39:42.148Z
Learning: In `app/home/HomePage.tsx`, the `useEffect` hook depends on `[showCustomized]` because changing `showCustomized` triggers updates to the yield and risk terms.
Applied to files:
src/features/history/components/history-table.tsx
📚 Learning: 2024-10-12T09:23:16.495Z
Learnt from: antoncoding
Repo: antoncoding/monarch PR: 63
File: app/markets/components/MarketRowDetail.tsx:49-52
Timestamp: 2024-10-12T09:23:16.495Z
Learning: When rendering oracle feeds in `ExpandedMarketDetail` (`app/markets/components/MarketRowDetail.tsx`), prefer explicit rendering over iterating keys when dealing with a small number of feeds.
Applied to files:
src/features/history/components/history-table.tsx
🧬 Code graph analysis (3)
src/hooks/queries/fetchUserTransactions.ts (4)
src/utils/networks.ts (1)
isSupportedChain(179-181)src/config/dataSources.ts (1)
supportsMorphoApi(6-20)src/data-sources/morpho-api/transactions.ts (1)
fetchMorphoTransactions(13-61)src/data-sources/subgraph/transactions.ts (1)
fetchSubgraphTransactions(129-217)
src/hooks/queries/useUserTransactionsQuery.ts (3)
src/hooks/queries/fetchUserTransactions.ts (2)
TransactionFilters(11-21)fetchUserTransactions(39-89)src/utils/networks.ts (1)
ALL_SUPPORTED_NETWORKS(38-46)src/utils/types.ts (1)
UserTransaction(37-49)
src/features/history/components/history-table.tsx (3)
src/hooks/useProcessedMarkets.ts (1)
useProcessedMarkets(27-91)src/features/positions-report/components/asset-selector.tsx (1)
AssetKey(8-13)src/hooks/queries/useUserTransactionsQuery.ts (1)
useUserTransactionsQuery(38-125)
🔇 Additional comments (10)
src/hooks/usePositionReport.ts (1)
85-93: LGTM!Clean alignment with the new single-chain
fetchUserTransactionsAPI. TheselectedAssetnull check at line 49 ensureschainIdis always defined here.src/features/history/history-view.tsx (1)
19-22: LGTM!Cleaner API. HistoryTable now owns its data fetching internally.
src/data-sources/morpho-api/transactions.ts (1)
15-18: LGTM!Type narrowing from
anytounknownis a nice improvement. Single chainId wrapped in array correctly matches the GraphQLchainId_infilter format.src/features/history/components/transaction-history-preview.tsx (1)
21-21: LGTM!Making
chainIdrequired aligns with the single-chain fetch model.src/hooks/queries/useUserTransactionsQuery.ts (2)
58-107: LGTM!Paginate mode now correctly fetches all pages per chain client-side before merging. This addresses the previous concern about server-side pagination breaking with multiple networks.
109-119: LGTM!Clear enforcement of single-chain requirement for non-paginated queries with a helpful error message.
src/hooks/queries/fetchUserTransactions.ts (1)
39-89: LGTM!Clean single-chain implementation with proper Morpho API → Subgraph fallback. Error handling is solid.
src/features/history/components/history-table.tsx (3)
73-76: LGTM!Clean ownership shift - component now fetches its own position and market data.
107-127: LGTM!Query setup is correct. The
Boolean(activeChainId)guard inenabledprevents queries when chainId is invalid.
203-228: LGTM!Clean URL parameter initialization with proper fallback to first available asset.
Summary by CodeRabbit
Improvements
Breaking Changes
✏️ Tip: You can customize this high-level summary in your review settings.