Skip to content

🩹 app: avoid zero address contract reads#802

Merged
cruzdanilo merged 1 commit intomainfrom
account
Feb 18, 2026
Merged

🩹 app: avoid zero address contract reads#802
cruzdanilo merged 1 commit intomainfrom
account

Conversation

@cruzdanilo
Copy link
Member

@cruzdanilo cruzdanilo commented Feb 18, 2026


Open with Devin

Summary by CodeRabbit

  • Bug Fixes
    • Removed placeholder fallback addresses so queries, simulations and previews only run when a real account or market address is available, reducing spurious contract reads and incorrect results.
    • Made refresh/refetch and simulation flows conditional on required inputs (address, credentials, bytecode), avoiding unnecessary network calls and improving data accuracy and stability.

@changeset-bot
Copy link

changeset-bot bot commented Feb 18, 2026

🦋 Changeset detected

Latest commit: 4aee44e

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Feb 18, 2026

Warning

Rate limit exceeded

@cruzdanilo has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 4 minutes and 3 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Walkthrough

Removed zeroAddress fallbacks across mobile components and utilities: hooks and contract calls now receive raw addresses or undefined, and queries/args are gated on actual address presence. Added a changeset documenting the patch release.

Changes

Cohort / File(s) Summary
Changeset
.changeset/calm-lions-guard.md
Added patch changeset noting avoidance of zero address contract reads.
Core UI / Card & Home
src/components/card/Card.tsx, src/components/home/Home.tsx, src/components/home/HomeActions.tsx
Removed zeroAddress fallbacks; pass raw account/address to useBytecode and related hooks; made query args conditional on address presence and guarded refetchs.
DeFi & Getting Started
src/components/defi/DeFi.tsx, src/components/getting-started/GettingStarted.tsx
Eliminated zeroAddress import; useBytecode now receives undefined when no address instead of zeroAddress, preserving enabled gating.
Pay & Pay-mode
src/components/pay-mode/Pay.tsx, src/components/pay-mode/PaySelector.tsx, src/components/pay-mode/OverduePayments.tsx, src/components/pay-mode/UpcomingPayments.tsx
Replaced zeroAddress coalescing with conditional args/enabled flags; adjusted approve/repay flows and simulations to require explicit asset/address; added validations.
Loans & Roll Debt
src/components/loans/Amount.tsx, src/components/loans/CreditLine.tsx, src/components/loans/LoanSummary.tsx, src/components/loans/Review.tsx, src/components/roll-debt/RollDebt.tsx
Removed zeroAddress defaults for bytecode and market queries; pass undefined when address/market absent; added guarded refetch/error handling.
Send Funds & Shared
src/components/send-funds/Amount.tsx, src/components/shared/InstallmentSelector.tsx, src/components/shared/PluginUpgrade.tsx, src/components/shared/Success.tsx
Eliminated zeroAddress imports/fallbacks; transfer and preview simulation args now conditional on receiver/market/plugin presence.
Utilities / Hooks
src/utils/usePendingOperations.ts, src/utils/useSimulateProposal.ts
useBytecode and proposal-related hooks now receive raw addresses; proposal args and nonce lookups guarded to only run when account/market exist and are non-zero.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • dieguezguille
  • franm91
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'app: avoid zero address contract reads' clearly and accurately summarizes the main objective of the changeset, which systematically removes zeroAddress fallbacks across the codebase to prevent unnecessary contract reads.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch account

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @cruzdanilo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines how contract-related data is fetched by preventing queries from being initiated with a zero address. By ensuring that contract read hooks and refetch operations are only executed when a valid account address and necessary credentials are available, the changes enhance the application's robustness, reduce potential errors from invalid contract calls, and optimize network resource usage.

Highlights

  • Prevented Zero Address Contract Reads: Removed the use of zeroAddress as a fallback for contract read hooks (e.g., useBytecode, useReadUpgradeableModularAccountGetInstalledPlugins) when an account address is not available. This ensures that contract calls are only attempted with a valid address.
  • Improved Conditional Refetching: Added explicit conditional checks before refetching installed plugins, ensuring that refetchInstalledPlugins is only called when both address and credential are present, further preventing unnecessary or erroneous contract interactions.
  • Removed Unused Import: Cleaned up imports by removing zeroAddress from viem in files where it is no longer used.
Changelog
  • .changeset/calm-lions-guard.md
    • Added a new changeset file for the patch.
  • src/components/card/Card.tsx
    • Removed ?? zeroAddress from the address prop in useReadUpgradeableModularAccountGetInstalledPlugins.
    • Added a conditional check for address and credential before calling refetchInstalledPlugins.
  • src/components/getting-started/GettingStarted.tsx
    • Removed the import of zeroAddress from viem.
    • Removed ?? zeroAddress from the address prop in useBytecode.
  • src/components/home/Home.tsx
    • Removed ?? zeroAddress from the address prop in useBytecode.
    • Removed ?? zeroAddress from the address prop in useReadUpgradeableModularAccountGetInstalledPlugins.
  • src/components/home/HomeActions.tsx
    • Removed ?? zeroAddress from the address prop in useBytecode.
    • Removed ?? zeroAddress from the address prop in useReadUpgradeableModularAccountGetInstalledPlugins.
  • src/components/loans/Review.tsx
    • Removed ?? zeroAddress from the address prop in useReadUpgradeableModularAccountGetInstalledPlugins.
  • src/components/pay-mode/Pay.tsx
    • Removed ?? zeroAddress from the address prop in useBytecode.
    • Removed ?? zeroAddress from the address prop in useReadUpgradeableModularAccountGetInstalledPlugins.
  • src/components/send-funds/Amount.tsx
    • Removed ?? zeroAddress from the address prop in useReadUpgradeableModularAccountGetInstalledPlugins.
  • src/components/shared/Success.tsx
    • Removed the import of zeroAddress from viem.
    • Removed ?? zeroAddress from the address prop in useReadUpgradeableModularAccountGetInstalledPlugins.
  • src/utils/useSimulateProposal.ts
    • Removed ?? zeroAddress from the address prop in useBytecode.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

devin-ai-integration[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request consistently removes the unnecessary ?? zeroAddress fallback in wagmi hooks across multiple files. The changes correctly rely on the enabled query option to prevent contract reads with a zero address, which improves code clarity and robustness. I've found one place where this pattern was missed, and I've left a comment with a suggestion to fix it for consistency.

@sentry
Copy link

sentry bot commented Feb 18, 2026

Codecov Report

❌ Patch coverage is 91.93548% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.34%. Comparing base (b6afa4e) to head (4aee44e).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/components/card/Card.tsx 33.33% 2 Missing ⚠️
src/components/loans/Loans.tsx 66.66% 1 Missing ⚠️
src/components/pay-mode/Pay.tsx 83.33% 1 Missing ⚠️
src/components/shared/PluginUpgrade.tsx 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #802      +/-   ##
==========================================
- Coverage   69.34%   69.34%   -0.01%     
==========================================
  Files         208      208              
  Lines        7096     7092       -4     
  Branches     2264     2251      -13     
==========================================
- Hits         4921     4918       -3     
+ Misses       1991     1990       -1     
  Partials      184      184              
Flag Coverage Δ
e2e 69.31% <91.93%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
src/components/pay-mode/PaySelector.tsx (1)

42-42: ⚠️ Potential issue | 🟡 Minor

Missed zeroAddress fallback in PaySelector — inconsistent with the PR's objective.

useReadPreviewerExactly in the PaySelector component still passes address ?? zeroAddress and has no address-presence gate, so a contract read against 0x000…000 fires whenever address is undefined.

🩹 Proposed fix
-  const { data: markets } = useReadPreviewerExactly({ address: previewerAddress, args: [address ?? zeroAddress] });
+  const { data: markets } = useReadPreviewerExactly({
+    address: previewerAddress,
+    args: address ? [address] : undefined,
+    query: { enabled: !!address },
+  });
src/components/card/Card.tsx (1)

118-121: ⚠️ Potential issue | 🟡 Minor

Missed zero-address contract read: useReadPreviewerExactly still falls back to zeroAddress.

This call has no enabled guard and will unconditionally hit the RPC with 0x0000… as the account argument when address is undefined — the exact pattern the PR set out to eliminate.

🛠️ Suggested fix
  const {
    data: markets,
    refetch: refetchMarkets,
    isFetching: isFetchingMarkets,
  } = useReadPreviewerExactly({
    address: previewerAddress,
-   args: [address ?? zeroAddress],
+   args: address ? [address] : undefined,
+   query: { enabled: !!address },
  });
src/components/home/Home.tsx (1)

103-103: ⚠️ Potential issue | 🟡 Minor

Missed zero-address contract read: useReadPreviewerExactly still falls back to zeroAddress.

Same pattern as Card.tsx (line 120): this call has no enabled guard and fires unconditionally with 0x0000… as the account argument when account is undefined, keeping the zeroAddress import alive.

🛠️ Suggested fix
  const {
    data: markets,
    refetch: refetchMarkets,
    isPending: isPendingPreviewer,
- } = useReadPreviewerExactly({ address: previewerAddress, args: [account ?? zeroAddress] });
+ } = useReadPreviewerExactly({
+   address: previewerAddress,
+   args: account ? [account] : undefined,
+   query: { enabled: !!account },
+ });

With this, the zeroAddress import on line 11 can also be removed.

src/components/pay-mode/Pay.tsx (1)

339-359: ⚠️ Potential issue | 🟡 Minor

Residual ?? zeroAddress in useSimulateContract args is dead code — worth cleaning up for consistency.

Line 342 still passes selectedAsset.address ?? zeroAddress as the collateral argument. The mode computation at lines 111–122 requires selectedAsset.address to be truthy for mode to ever equal "legacyCrossRepay", so the ?? zeroAddress branch is unreachable. Removing it (and the now-unused zeroAddress import, once line 433 is also addressed) would complete the PR's stated goal.

🧹 Proposed fix
-    args: [maturity ?? 0n, selectedAsset.address ?? zeroAddress],
+    args: [maturity ?? 0n, selectedAsset.address as `0x${string}`],

Or, if the TypeScript narrowing from the mode guard is already sufficient to satisfy the type checker, a non-null assertion selectedAsset.address! is also acceptable here.

devin-ai-integration[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 0 new potential issues.

View 8 additional findings in Devin Review.

Open in Devin Review

sentry[bot]

This comment was marked as resolved.

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 0 new potential issues.

View 9 additional findings in Devin Review.

Open in Devin Review

chatgpt-codex-connector[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View 10 additional findings in Devin Review.

Open in Devin Review

@cruzdanilo cruzdanilo merged commit 4aee44e into main Feb 18, 2026
14 of 15 checks passed
@cruzdanilo cruzdanilo deleted the account branch February 18, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments