Skip to content

fix: use fallback HTTP transport in delegatedEoa mode#502

Merged
aldin4u merged 3 commits intostagingfrom
fix/delegated-eoa-signing
Feb 3, 2026
Merged

fix: use fallback HTTP transport in delegatedEoa mode#502
aldin4u merged 3 commits intostagingfrom
fix/delegated-eoa-signing

Conversation

@aldin4u
Copy link
Collaborator

@aldin4u aldin4u commented Feb 3, 2026

Description

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Summary by CodeRabbit

  • Bug Fixes
    • Improved connection handling across perpetuals trading flows to reduce intermittent transport/connection failures.
    • More robust wallet connection and fallback behavior for different wallet types, resulting in fewer connection errors and more reliable trade and account actions.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 3, 2026

Warning

Rate limit exceeded

@aldin4u has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 38 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

Walkthrough

Introduces a memoized clientTransport in useHyperliquid that safely obtains kit.getProvider() within try/catch and falls back to http(); replaces direct provider-based transport construction with clientTransport across wallet client creation paths.

Changes

Cohort / File(s) Summary
Provider transport refactor
src/apps/perps/hooks/useHyperliquid.ts
Adds useMemo and a guarded clientTransport (wraps kit.getProvider() in try/catch), imports http, replaces inline custom(provider as any) usages with `clientTransport
Project metadata
manifest_file, package.json
Unrelated metadata changes present in diff (no API/signature changes).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I hopped through code with whiskers bright,
I wrapped the transport safe and tight,
When provider trips or takes a nap,
http() fills the transport gap.
A little memo, a careful check — hop! 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description follows the template structure but all sections are empty or unchecked, providing no meaningful information about the changes. Fill in the Description section with details about why the change is needed, complete the testing section with specifics about how changes were validated, and check the appropriate Types of changes checkbox.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main change: introducing a fallback HTTP transport for delegatedEoa mode.

✏️ 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 fix/delegated-eoa-signing

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.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 3, 2026

Deploying pillarx-debug with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9fa9257
Status: ✅  Deploy successful!
Preview URL: https://d5ce5b41.pillarx-debug.pages.dev
Branch Preview URL: https://fix-delegated-eoa-signing.pillarx-debug.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 3, 2026

Deploying x with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9fa9257
Status: ✅  Deploy successful!
Preview URL: https://1adfb229.x-e62.pages.dev
Branch Preview URL: https://fix-delegated-eoa-signing.x-e62.pages.dev

View logs

Copy link
Contributor

@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.

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 (3)
src/apps/perps/hooks/useHyperliquid.ts (3)

194-194: ⚠️ Potential issue | 🔴 Critical

Missing clientTransport in dependency array causes stale closure.

The checkSetupStatus callback uses clientTransport (lines 76, 90) but the dependency array is empty. If kit changes and clientTransport is recomputed, this callback will continue using the stale transport value.

🐛 Proposed fix
-  }, []);
+  }, [clientTransport]);

245-245: ⚠️ Potential issue | 🔴 Critical

Missing clientTransport in dependency array.

The setupHyperliquid callback uses clientTransport (lines 208, 214) but it's not listed in the dependency array, causing a stale closure.

🐛 Proposed fix
-  }, [address, checkSetupStatus]);
+  }, [address, checkSetupStatus, clientTransport]);

395-395: ⚠️ Potential issue | 🔴 Critical

Missing clientTransport in dependency array.

The executeCopyTrade callback uses clientTransport (lines 312, 318) but it's not listed in the dependency array.

🐛 Proposed fix
-    [address, setupStatus, loadBalance]
+    [address, setupStatus, loadBalance, clientTransport]
🤖 Fix all issues with AI agents
In `@src/apps/perps/hooks/useHyperliquid.ts`:
- Around line 45-54: The current useMemo fallback returns http() which cannot
sign and breaks EOA signing; change the clientTransport logic so that when
kit.getProvider() throws you do NOT return http(), but instead return
undefined/null and emit a debug log indicating the provider was unavailable;
update any WalletClient creation sites (where WalletClient is constructed for
address-only accounts and where signUserAction calls walletClient.signTypedData)
to use custom(provider) only when clientTransport is present and otherwise
construct the WalletClient so it relies on the injected signer/account (i.e., do
not attach a non-signing http transport); ensure you reference the
clientTransport variable, the useMemo/provider retrieval code
(kit.getProvider()), WalletClient instantiation sites, and
signUserAction/walletClient.signTypedData to make these changes.

@github-actions github-actions bot temporarily deployed to Preview (fix/delegated-eoa-signing) February 3, 2026 10:25 Inactive
Copy link
Contributor

@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.

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/apps/perps/hooks/useHyperliquid.ts (1)

65-92: ⚠️ Potential issue | 🟠 Major

Don’t drop the EOA address when transport is unavailable.

When clientTransport is null, targetAddress stays null, so Line 136 short‑circuits and user state/orders never load in delegatedEoa. You can still set the EOA address for read‑only fetches and only gate wallet‑client creation on transport availability.

✅ Proposed fix
-      if (eoa && clientTransport) {
-        targetAddress = eoa;
-        client = createWalletClient({
-          account: eoa as `0x${string}`,
-          chain: arbitrum,
-          transport: clientTransport,
-        });
-      }
+      if (eoa) {
+        targetAddress = eoa;
+        if (clientTransport) {
+          client = createWalletClient({
+            account: eoa as `0x${string}`,
+            chain: arbitrum,
+            transport: clientTransport,
+          });
+        }
+      }
🤖 Fix all issues with AI agents
In `@src/apps/perps/hooks/useHyperliquid.ts`:
- Around line 45-54: The callbacks setupHyperliquid and executeCopyTrade capture
clientTransport but don't list it in their dependency arrays, causing stale
closures if the provider becomes available later; update the dependency arrays
for setupHyperliquid (currently [address, checkSetupStatus]) to include
clientTransport, and for executeCopyTrade (currently [address, setupStatus,
loadBalance]) to include clientTransport as well; also consider adding
clientTransport to checkSetupStatus's dependencies (it currently has an empty
array) for consistency since checkSetupStatus uses clientTransport when invoked.

@github-actions github-actions bot temporarily deployed to Preview (fix/delegated-eoa-signing) February 3, 2026 10:37 Inactive
@aldin4u aldin4u merged commit 337813e into staging Feb 3, 2026
6 of 7 checks passed
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