Feature/smart contract integration 4#31
Conversation
- Implemented comprehensive stablecoin multi-step swap interface - Added real-time token balance polling via useReadContract - Constructed automated fee calculation drop-downs per algorithm specifications - Handled critical concurrent rendering hydration mismatches in RainbowKit's chain guard - Fixed multiple NextJS JSX structural build errors throughout navigation components - Integrated active error reporting and programmatic transaction gating (insufficient balance protection)
📝 WalkthroughWalkthroughRedesigned the trade UI with animated swap form, added on-chain balance reads and multi-step approval/trade flow, introduced mount guards to avoid hydration issues, passed Wagmi initial state from server via cookies, and updated Wagmi/RainbowKit configuration and Next.js export settings. Changes
Sequence DiagramsequenceDiagram
participant User
participant UI as Trade Page UI
participant Wallet as Wallet/Connector
participant Contract as Smart Contract
participant Chain as Blockchain
User->>UI: Enter amount / choose buy or sell
UI->>Chain: Read baseCoin.balanceOf(user)
UI->>Chain: Read stableCoin.balanceOf(user)
Chain-->>UI: Balances
UI->>UI: compute parsedAmount, platformFee (2%), finalAmount, needsApproval, isInsufficientBalance
alt Approval Required
User->>UI: Click "Approve"
UI->>Wallet: send approve(tx)
Wallet->>Contract: approve(spender, amount)
Contract->>Chain: write allowance
Chain-->>Wallet: tx confirmed
Wallet-->>UI: approval confirmed
end
User->>UI: Click "Execute Trade"
UI->>Wallet: send trade(tx)
Wallet->>Contract: execute buy/sell with fee
Contract->>Chain: execute swap
Chain-->>Wallet: tx confirmed
Wallet-->>UI: trade confirmed
UI->>User: display success / update balances
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly Related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (2 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: 7
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/app/trade/page.tsx (2)
46-64:⚠️ Potential issue | 🔴 CriticalEarly return before hooks violates Rules of Hooks.
Returning JSX at line 47 before all hooks have been called (e.g.,
useReadContractcalls starting at line 116) violates React's Rules of Hooks. Hooks must be called unconditionally at the top level. This will cause runtime errors whencontractsis falsy.Move all hooks above this conditional return, or restructure to always call hooks and conditionally render based on state.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/app/trade/page.tsx` around lines 46 - 64, The early return that renders the "Unsupported Network" UI when contracts is falsy violates the Rules of Hooks because subsequent hooks like useReadContract are declared later; move all hook calls (e.g., useReadContract and any other React hooks used in this component) to the top-level of the component before any conditional returns, then compute a render flag (e.g., isUnsupported = !contracts) and conditionally render the fallback UI (including the Switch Network button using switchChainAsync) after hooks have been invoked; alternatively, restructure so hooks remain top-level and only the JSX output is conditional.
1-2:⚠️ Potential issue | 🟠 MajorRemove
eslint-disableand@ts-nocheckdirectives.These directives suppress all linting and type checking, hiding potential bugs. The
baseCoinAddressordering bug (lines 116-134) would likely have been caught by TypeScript. Address the underlying issues instead of disabling checks.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/app/trade/page.tsx` around lines 1 - 2, Remove the top-file directives disabling ESLint/TypeScript and fix the underlying type/lint issues instead of silencing them: delete the "/* eslint-disable */" and "// `@ts-nocheck`" lines, add proper TypeScript types/interfaces for any component props/state and annotate functions used in coin selection/ordering (notably the logic that sets or compares baseCoinAddress), and correct the ordering bug by making the baseCoinAddress comparison deterministic (e.g., normalize addresses and use a stable comparator or explicit priority logic in the function that computes baseCoinAddress). Run the TypeScript and ESLint fixes iteratively until no errors remain.
🧹 Nitpick comments (3)
src/app/trade/page.tsx (1)
327-328: Unused variables:isApprovingandisExecuting.These variables are defined but never referenced in the component. Remove them to reduce confusion.
♻️ Proposed fix
- const isApproving = isPending && isApprovalConfirmed === false && approvalHash !== undefined; - const isExecuting = isPending && !isApproving;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/app/trade/page.tsx` around lines 327 - 328, Remove the unused local constants isApproving and isExecuting from the component (the const declarations for isApproving and isExecuting) since they are never referenced; delete those two lines and any related unused imports or comments, and run a quick build/TS check to ensure no remaining references to isApprovalConfirmed or approvalHash were relying on them.src/components/layout/Navbar.tsx (1)
34-34: Simplify theme check —resolvedThemealone is sufficient.
resolvedThemealready resolves "system" to the actual theme. Checking boththemeandresolvedThemeis redundant and can cause inconsistent behavior whentheme === "system".♻️ Proposed fix
- const isDark = theme === "dark" || resolvedTheme === "dark"; + const isDark = resolvedTheme === "dark";🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/layout/Navbar.tsx` at line 34, The theme check is redundant and can mis-handle "system" because resolvedTheme already provides the effective theme; update the logic that sets isDark (variable isDark in Navbar.tsx) to use only resolvedTheme instead of combining theme and resolvedTheme, i.e. derive isDark from resolvedTheme === "dark" and remove the extra theme === "dark" condition so all theme-dependent rendering uses the unified resolvedTheme value.src/components/ui/tab-navigation.tsx (1)
33-39: Expose the active/focus state to non-pointer users.The new state treatment is hover-only, and the current page is still announced only visually. Adding
aria-current="page"plus a focus path keeps this nav usable for keyboard and assistive-tech users.♿ Suggested tweak
{tabs.map((tab) => ( <Link key={tab.path} href={tab.path} - className="flex items-center justify-center relative px-2 py-2.5 rounded-xl font-semibold text-sm overflow-hidden group text-center" + aria-current={isActive(tab.path) ? 'page' : undefined} + className="flex items-center justify-center relative px-2 py-2.5 rounded-xl font-semibold text-sm overflow-hidden group text-center focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-500/60" onMouseEnter={() => setHoveredTab(tab.path)} onMouseLeave={() => setHoveredTab(null)} + onFocus={() => setHoveredTab(tab.path)} + onBlur={() => setHoveredTab(null)} >Also applies to: 61-78
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/ui/tab-navigation.tsx` around lines 33 - 39, The Link currently only updates visual state on hover; make the active/focus state accessible by adding aria-current="page" when tab.path matches the current route and by handling keyboard focus—attach onFocus={() => setHoveredTab(tab.path)} and onBlur={() => setHoveredTab(null)} alongside the existing onMouseEnter/onMouseLeave so focus-driven users get the same state; use the same tab.path, setHoveredTab, and the router/currentPath check used elsewhere in TabNavigation to determine the active page.
🤖 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/app/trade/page.tsx`:
- Around line 312-316: The UI currently uses a hardcoded 2% calculation
(numericAmount, feePercentage, feeAmount, finalAmount) and presents it as
"Platform Fee"; update the implementation to avoid misleading users by either
(A) replacing the hardcoded feePercentage with a real lookup from your on‑chain
or backend fee estimator (e.g., call a new or existing getEstimatedFee(amount)
or fetchContractFee() and compute feeAmount from that result) or (B) if the real
fee cannot yet be retrieved, change the label and messaging to explicitly mark
the value as an estimate/placeholder (e.g., add “Estimated Platform Fee” and an
info tooltip) and keep the fallback numeric computation only for display. Ensure
the code paths that compute feeAmount and finalAmount reference the fetched fee
value or an isEstimate flag so consumers of numericAmount, feeAmount, and
finalAmount are unambiguous.
- Line 335: Button shows "Confirmed!" because isConfirmed persists across input
changes; update the component to reset transaction state when the user modifies
the trade inputs. Specifically, wherever you store the states (isConfirmed,
error, numericAmount/trade type) add a handler or useEffect that listens to
changes in numericAmount or tradeType and calls the state setters to clear
previous transaction state (e.g., call setIsConfirmed(false) and setError(null)
when numericAmount or tradeType changes). Ensure this reset logic runs on both
direct input change handlers and any trade-type selector changes so the
condition in the render (isConfirmed && !error && numericAmount > 0) reflects
the current inputs.
- Around line 116-123: The useReadContract hook for reading balance (const {
data: baseCoinBalance } = useReadContract(...)) references baseCoinAddress
before it's defined, which breaks hook ordering and causes undefined on first
render; move the computation/assignment of baseCoinAddress so it appears above
the useReadContract call (ensure baseCoinAddress is derived before the hook),
then keep the hook's args/props (address, chainId, COIN_ABI,
isDeployedAddress(baseCoinAddress)) unchanged so the hook can evaluate
correctly; update any dependent variables (e.g., the address variable used in
args and enabled) to preserve the same render order and avoid conditional hook
execution.
In `@src/components/layout/Navbar.tsx`:
- Around line 36-37: The Navbar currently returns null while waiting for the
mounted flag, causing a layout shift; instead of returning null in the Navbar
component when mounted is false, render an accessible placeholder element that
matches the navbar's fixed dimensions and classes (e.g., same height, padding
and positioning used by the real navbar) so spacing is preserved until the real
navbar mounts—update the conditional around the mounted variable in Navbar to
render that skeleton/placeholder (aria-hidden) rather than null.
In `@src/components/ui/tab-navigation.tsx`:
- Around line 51-56: The component references two CSS animations—"shimmer"
(already present) and "pulse" (missing)—so add a `@keyframes` pulse definition to
the global stylesheet (globals.css) that animates opacity between 1 and 0.5 at
0/50/100% to enable the hover glow animation used by the tab navigation
component (look for the inline style using animation: 'shimmer 2s infinite' and
the hover glow that expects "pulse").
In `@src/utils/wagmiConfig.ts`:
- Around line 6-10: Replace the hardcoded public WalletConnect fallback and the
typo: remove the fallback assignment for PROJECT_ID so that const PROJECT_ID
only uses process.env.NEXT_PUBLIC_PROJECT_ID (and do not silently default to the
shared ID), and add a runtime check in the export/initialization path (e.g.,
where PROJECT_ID is consumed) to throw or log a clear error when
NEXT_PUBLIC_PROJECT_ID is missing in production builds; also fix the comment
typo from "Inturrupted" to "Interrupted" and update the comment to explain this
value must be provided for production to avoid rate-limiting.
- Around line 65-66: The wagmi SSR setup is incomplete: update the
getDefaultConfig usage in wagmiConfig.ts to include storage: createStorage({
storage: cookieStorage }) so cookies are read during SSR, and ensure the server
layout extracts cookies and passes an initial state into the WagmiProvider (use
cookieToInitialState or equivalent to build the initialState) while also wiring
walletProvider.tsx to accept and pass that initialState prop to WagmiProvider;
locate getDefaultConfig in wagmiConfig.ts, the WagmiProvider usage in
walletProvider.tsx, and the root layout component (layout.tsx) to add cookie
extraction and propagate initialState.
---
Outside diff comments:
In `@src/app/trade/page.tsx`:
- Around line 46-64: The early return that renders the "Unsupported Network" UI
when contracts is falsy violates the Rules of Hooks because subsequent hooks
like useReadContract are declared later; move all hook calls (e.g.,
useReadContract and any other React hooks used in this component) to the
top-level of the component before any conditional returns, then compute a render
flag (e.g., isUnsupported = !contracts) and conditionally render the fallback UI
(including the Switch Network button using switchChainAsync) after hooks have
been invoked; alternatively, restructure so hooks remain top-level and only the
JSX output is conditional.
- Around line 1-2: Remove the top-file directives disabling ESLint/TypeScript
and fix the underlying type/lint issues instead of silencing them: delete the
"/* eslint-disable */" and "// `@ts-nocheck`" lines, add proper TypeScript
types/interfaces for any component props/state and annotate functions used in
coin selection/ordering (notably the logic that sets or compares
baseCoinAddress), and correct the ordering bug by making the baseCoinAddress
comparison deterministic (e.g., normalize addresses and use a stable comparator
or explicit priority logic in the function that computes baseCoinAddress). Run
the TypeScript and ESLint fixes iteratively until no errors remain.
---
Nitpick comments:
In `@src/app/trade/page.tsx`:
- Around line 327-328: Remove the unused local constants isApproving and
isExecuting from the component (the const declarations for isApproving and
isExecuting) since they are never referenced; delete those two lines and any
related unused imports or comments, and run a quick build/TS check to ensure no
remaining references to isApprovalConfirmed or approvalHash were relying on
them.
In `@src/components/layout/Navbar.tsx`:
- Line 34: The theme check is redundant and can mis-handle "system" because
resolvedTheme already provides the effective theme; update the logic that sets
isDark (variable isDark in Navbar.tsx) to use only resolvedTheme instead of
combining theme and resolvedTheme, i.e. derive isDark from resolvedTheme ===
"dark" and remove the extra theme === "dark" condition so all theme-dependent
rendering uses the unified resolvedTheme value.
In `@src/components/ui/tab-navigation.tsx`:
- Around line 33-39: The Link currently only updates visual state on hover; make
the active/focus state accessible by adding aria-current="page" when tab.path
matches the current route and by handling keyboard focus—attach onFocus={() =>
setHoveredTab(tab.path)} and onBlur={() => setHoveredTab(null)} alongside the
existing onMouseEnter/onMouseLeave so focus-driven users get the same state; use
the same tab.path, setHoveredTab, and the router/currentPath check used
elsewhere in TabNavigation to determine the active page.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a7afcdc0-1f7c-4ef0-b376-d653d88a2bbb
📒 Files selected for processing (5)
src/app/trade/page.tsxsrc/components/layout/Navbar.tsxsrc/components/ui/tab-navigation.tsxsrc/context/walletProvider.tsxsrc/utils/wagmiConfig.ts
| // Complex fee calculation (Mocked 2% platform fee for demonstration) | ||
| const numericAmount = parseFloat(amount || "0"); | ||
| const feePercentage = 0.02; | ||
| const feeAmount = numericAmount * feePercentage; | ||
| const finalAmount = numericAmount > 0 ? numericAmount - feeAmount : 0; |
There was a problem hiding this comment.
Mocked fee calculation displayed as actual transaction cost.
The 2% fee is hardcoded and labeled "Platform Fee" in the UI, but the actual on-chain fee logic may differ. This could mislead users about the real cost of their transaction. Either fetch the actual fee from the contract or clearly label this as an estimate/placeholder.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/app/trade/page.tsx` around lines 312 - 316, The UI currently uses a
hardcoded 2% calculation (numericAmount, feePercentage, feeAmount, finalAmount)
and presents it as "Platform Fee"; update the implementation to avoid misleading
users by either (A) replacing the hardcoded feePercentage with a real lookup
from your on‑chain or backend fee estimator (e.g., call a new or existing
getEstimatedFee(amount) or fetchContractFee() and compute feeAmount from that
result) or (B) if the real fee cannot yet be retrieved, change the label and
messaging to explicitly mark the value as an estimate/placeholder (e.g., add
“Estimated Platform Fee” and an info tooltip) and keep the fallback numeric
computation only for display. Ensure the code paths that compute feeAmount and
finalAmount reference the fetched fee value or an isEstimate flag so consumers
of numericAmount, feeAmount, and finalAmount are unambiguous.
| if (needsApproval) return { text: "Processing Approval...", icon: <Loader2 className="w-5 h-5 animate-spin" />, disabled: true }; | ||
| return { text: "Processing Trade...", icon: <Loader2 className="w-5 h-5 animate-spin" />, disabled: true }; | ||
| } | ||
| if (isConfirmed && !error && numericAmount > 0) return { text: "Confirmed! ✅", icon: null, disabled: false }; |
There was a problem hiding this comment.
Button shows "Confirmed!" even when a previous transaction error exists.
The condition isConfirmed && !error && numericAmount > 0 checks the current error state, but isConfirmed persists from the last successful transaction. If a user completes a trade, then enters a new amount and gets an error, the button could still show "Confirmed!" because isConfirmed wasn't reset.
Consider resetting transaction state when the user changes the amount or trade type.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/app/trade/page.tsx` at line 335, Button shows "Confirmed!" because
isConfirmed persists across input changes; update the component to reset
transaction state when the user modifies the trade inputs. Specifically,
wherever you store the states (isConfirmed, error, numericAmount/trade type) add
a handler or useEffect that listens to changes in numericAmount or tradeType and
calls the state setters to clear previous transaction state (e.g., call
setIsConfirmed(false) and setError(null) when numericAmount or tradeType
changes). Ensure this reset logic runs on both direct input change handlers and
any trade-type selector changes so the condition in the render (isConfirmed &&
!error && numericAmount > 0) reflects the current inputs.
| // WalletConnect Cloud explicitly severs websocket connections for invalid project IDs, causing the "Connection Inturrupted" React crash. | ||
| // We provide a public viable fallback ID so dev testing doesn't fail on WebSocket initialization. | ||
| const PROJECT_ID = process.env.NEXT_PUBLIC_PROJECT_ID && process.env.NEXT_PUBLIC_PROJECT_ID !== "DEFAULT_PROJECT_ID" | ||
| ? process.env.NEXT_PUBLIC_PROJECT_ID | ||
| : "21fef48091f12692cad574a6f7753643"; |
There was a problem hiding this comment.
Hardcoded fallback project ID may cause rate-limiting in production.
The fallback WalletConnect project ID is hardcoded and publicly visible. While useful for dev testing, this ID could be rate-limited or revoked by WalletConnect if abused. Ensure production deployments always provide a valid NEXT_PUBLIC_PROJECT_ID.
Minor: Typo on line 6 — "Inturrupted" should be "Interrupted".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/utils/wagmiConfig.ts` around lines 6 - 10, Replace the hardcoded public
WalletConnect fallback and the typo: remove the fallback assignment for
PROJECT_ID so that const PROJECT_ID only uses process.env.NEXT_PUBLIC_PROJECT_ID
(and do not silently default to the shared ID), and add a runtime check in the
export/initialization path (e.g., where PROJECT_ID is consumed) to throw or log
a clear error when NEXT_PUBLIC_PROJECT_ID is missing in production builds; also
fix the comment typo from "Inturrupted" to "Interrupted" and update the comment
to explain this value must be provided for production to avoid rate-limiting.
This commit includes several improvements to prevent layout shifts and hydration errors: - Navbar: Added a skeleton placeholder before mounting to prevent layout shift. - Tab Navigation: Fixed missing shimmer/pulse animations by adding @Keyframes pulse to globals.css. - Wagmi/RainbowKit: Refactored wagmiConfig.ts to use server-safe createConfig and added conditional connector initialization to prevent crashes on Next.js 15 server components. - SSR Hydration: Implemented server-side cookie reading in root layout to correctly pass initialState to WagmiProvider, ensuring wallet state is synchronized between server and client. - Theme Management: Removed redundant outer ThemeProvider and synced localStorage keys for a smoother theme transition. - Next.js Config: Disabled static export (output: 'export') to allow dynamic rendering with headers, which is required for SSR wallet state.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
next.config.mjs (1)
1-20:⚠️ Potential issue | 🟠 MajorRemoving static export will break GitHub Pages deployment.
The workflow at
.github/workflows/nextjs.ymlexplicitly uploads the./outdirectory (line 70) which is only generated whenoutput: "export"anddistDir: "out"are configured in next.config.mjs. Without these settings,next buildgenerates a.nextdirectory for server-side rendering, not./out, causing the deployment artifact upload to fail.The commit message indicates the change was intentional ("Fix hydration mismatches and enable proper SSR for Next.js 15"), but the workflow hasn't been updated to match. You'll need to either:
- Update the workflow to deploy to a Node.js hosting platform (Vercel, etc.)
- Update the workflow to use the
.nextdirectory for static export- Restore the static export configuration and find an alternative SSR approach
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@next.config.mjs` around lines 1 - 20, The repo removed the static export config from nextConfig so `next build` no longer produces ./out while the GitHub Actions workflow still uploads ./out; restore consistency by either adding back static export keys (set output: "export" and distDir: "out" inside the nextConfig object) so the workflow's artifact upload continues to work, or update the workflow (.github/workflows/nextjs.yml) to publish the correct build artifact produced by Next.js SSR (use .next or change to a Node deployment step); locate the nextConfig object in next.config.mjs and the artifact upload step in the workflow and make the chosen change so build output and CI match.
🧹 Nitpick comments (2)
src/app/layout.tsx (1)
7-7: Remove unusedThemeProviderimport.
ThemeProvideris imported but not used in this file. It's now rendered insideClientProvidersinLayout.tsx.🧹 Proposed fix
import Footer from "@/components/layout/Footer"; -import { ThemeProvider } from "@/components/themeProvider";🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/app/layout.tsx` at line 7, Remove the unused ThemeProvider import in Layout.tsx: delete the import statement "import { ThemeProvider } from "@/components/themeProvider"; since ThemeProvider is now provided inside ClientProviders; ensure no other references to ThemeProvider remain in this file and run a quick lint/typecheck to confirm the unused import is gone.src/components/layout/Navbar.tsx (1)
53-64: Consider extracting complex inline styles to CSS or a styles object.The inline
styleobject contains significant styling logic (theme-aware colors, backdrop filters, transitions). For maintainability, consider extracting these to a separate styles constant or CSS custom properties.♻️ Example extraction
+const headerStyles = (isDark: boolean, scrolled: boolean): React.CSSProperties => ({ + backgroundColor: isDark ? "rgba(15,23,42,0.15)" : "rgba(255,255,255,0.15)", + backdropFilter: "blur(60px) saturate(250%) brightness(1.1)", + WebkitBackdropFilter: "blur(60px) saturate(250%) brightness(1.1)", + borderBottom: "none", + boxShadow: scrolled ? "0 8px 32px rgba(251,146,60,0.3)" : "none", + transition: "all 0.5s cubic-bezier(0.16,1,0.3,1)", +}); // In render: - style={{ - backgroundColor: isDark - ? "rgba(15,23,42,0.15)" - : "rgba(255,255,255,0.15)", - backdropFilter: "blur(60px) saturate(250%) brightness(1.1)", - WebkitBackdropFilter: "blur(60px) saturate(250%) brightness(1.1)", - borderBottom: "none", - boxShadow: scrolled - ? "0 8px 32px rgba(251,146,60,0.3)" - : "none", - transition: "all 0.5s cubic-bezier(0.16,1,0.3,1)", - }} + style={headerStyles(isDark, scrolled)}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/layout/Navbar.tsx` around lines 53 - 64, The Navbar component's inline style block (using props isDark and scrolled) is too large and should be extracted; create a styles object or CSS module/class (e.g., NAVBAR_STYLES or Navbar.module.css) and move the theme-aware backgroundColor, backdropFilter/WebkitBackdropFilter, borderBottom, boxShadow (dependent on scrolled), and transition into that extracted location, then replace the inline style prop on the Navbar element with a reference to the new styles (or conditional classNames based on isDark and scrolled) so visual logic remains but the JSX is much cleaner (refer to the Navbar component, the isDark and scrolled variables, and the inline style prop to locate the code).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@next.config.mjs`:
- Around line 1-20: The repo removed the static export config from nextConfig so
`next build` no longer produces ./out while the GitHub Actions workflow still
uploads ./out; restore consistency by either adding back static export keys (set
output: "export" and distDir: "out" inside the nextConfig object) so the
workflow's artifact upload continues to work, or update the workflow
(.github/workflows/nextjs.yml) to publish the correct build artifact produced by
Next.js SSR (use .next or change to a Node deployment step); locate the
nextConfig object in next.config.mjs and the artifact upload step in the
workflow and make the chosen change so build output and CI match.
---
Nitpick comments:
In `@src/app/layout.tsx`:
- Line 7: Remove the unused ThemeProvider import in Layout.tsx: delete the
import statement "import { ThemeProvider } from "@/components/themeProvider";
since ThemeProvider is now provided inside ClientProviders; ensure no other
references to ThemeProvider remain in this file and run a quick lint/typecheck
to confirm the unused import is gone.
In `@src/components/layout/Navbar.tsx`:
- Around line 53-64: The Navbar component's inline style block (using props
isDark and scrolled) is too large and should be extracted; create a styles
object or CSS module/class (e.g., NAVBAR_STYLES or Navbar.module.css) and move
the theme-aware backgroundColor, backdropFilter/WebkitBackdropFilter,
borderBottom, boxShadow (dependent on scrolled), and transition into that
extracted location, then replace the inline style prop on the Navbar element
with a reference to the new styles (or conditional classNames based on isDark
and scrolled) so visual logic remains but the JSX is much cleaner (refer to the
Navbar component, the isDark and scrolled variables, and the inline style prop
to locate the code).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a0dfa685-50eb-464f-974c-cfc5e7ef59c0
📒 Files selected for processing (8)
next.config.mjssrc/app/globals.csssrc/app/layout.tsxsrc/app/trade/page.tsxsrc/components/layout/Layout.tsxsrc/components/layout/Navbar.tsxsrc/context/walletProvider.tsxsrc/utils/wagmiConfig.ts
✅ Files skipped from review due to trivial changes (1)
- src/app/globals.css
🚧 Files skipped from review as they are similar to previous changes (2)
- src/context/walletProvider.tsx
- src/app/trade/page.tsx
|
Hey @blizet , |
Resolves #4: Smart Contract Integration and Transaction Handling
Description
Integrating with Djed smart contracts requires handling complex algorithmic stablecoin mechanics including multi-token operations, fee calculations, and transaction validation while ensuring proper error handling and user feedback.
Key Features Implemented
useWriteContract.useReadContractto actively show the user's fetchedbaseCoinBalanceandstableCoinBalancestrictly validating what they currently hold.Processing...,Confirmed, and visually trapping network rejections with execution and confirmation states.approvalloops specifically into the action component. Users without active ERC-20 contract allowances are securely gated toStep 1: Approvebefore execution switches toStep 2: Buy/Sell.framer-motionto implement an automated transaction breakdown accordion that calculates input execution mathematically, deducting the 2% platform fee, and generating the Final Output expected in the wallet.Scope: Core Trading Functionality
🐛 Additional Infrastructure & Dependency Bug Fixes
(Bundled for Stability)
'Connection interrupted while trying to subscribe'socket ejections within the wagmiConfig.ts backend.HydrateConcurrent Mismatch: CorrectedRainbowKitcomponents by enforcing anisMountedhook check directly into SupportedChainGuard preventing catastrophic virtual DOM teardowns initially booting the web app.tab-navigation.tsx).Recordings:
Ankit.Djed.1.mp4
Checklist
AI Usage Disclosure
Check one of the checkboxes below:
I have used the following AI models and tools: TODO
We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.
Summary by CodeRabbit
New Features
Bug Fixes
Style