Skip to content

Conversation

@chalabi2
Copy link
Collaborator

@chalabi2 chalabi2 commented Jun 9, 2025

fixes #450

The issue was that the wallet was caching stale data in the ChainProvider for web3auth wallets

This PR does not meet the target coverage because it does not contain tests for the useTx hook but #466 does.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added a reset function to fully clear and reinitialize wallet and chain provider state, accessible from relevant modals and components.
  • Bug Fixes

    • Improved transaction simulation error messages for greater clarity and support for more error types.
    • Enhanced handling of wallet address switching during transaction signing to reduce potential issues.
  • Chores

    • Updated internal hooks and context to support comprehensive client and state resets.
    • Added tests for client reset functionality, web3 authentication context, and modal component behavior.

@vercel
Copy link

vercel bot commented Jun 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
manifest-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 11, 2025 11:51pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 9, 2025

Warning

Rate limit exceeded

@chalabi2 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 13 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.

📥 Commits

Reviewing files that changed from the base of the PR and between e4efa12 and 8f7ca53.

📒 Files selected for processing (3)
  • components/react/__tests__/modal.test.tsx (1 hunks)
  • contexts/__tests__/web3AuthContext.test.tsx (1 hunks)
  • tests/format.ts (2 hunks)

Walkthrough

The changes introduce a new useClientReset hook and related logic to fully reset wallet and client state when switching social wallets. Enhancements in context providers and modal components ensure that client and provider state are cleared and remounted, addressing issues with stale state during wallet switching and transaction flows.

Changes

File(s) Change Summary
hooks/useClientReset.ts New hook to reset Web3Auth clients, clear React Query cache, and force ChainProvider remount.
contexts/web3AuthContext.tsx Added resetWeb3AuthClients and optional forceChainProviderReset to context; implemented client reset logic.
contexts/manifestAppProviders.tsx Added logic to remount ChainProvider with a key and expose forceChainProviderReset via context.
components/react/modal.tsx Integrated useClientReset; updated wallet connection/disconnect logic to force complete client resets.
hooks/useTx.tsx Improved error extraction for transaction simulation; added logic to handle address switching delays.
contexts/tests/web3AuthContext.test.tsx Added tests for Web3AuthContext including resetWeb3AuthClients functionality.
hooks/tests/useClientReset.test.tsx Added tests for useClientReset hook covering reset flows and error handling.
components/react/tests/modal.test.tsx Added tests for modal behavior including wallet connection, disconnect, and client reset scenarios.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Modal
    participant useClientReset
    participant Web3AuthContext
    participant ChainProvider

    User->>Modal: Clicks to connect/disconnect social wallet
    Modal->>useClientReset: Calls forceCompleteReset()
    useClientReset->>Web3AuthContext: Calls resetWeb3AuthClients()
    Web3AuthContext-->>useClientReset: Resets Web3Auth state
    useClientReset->>ChainProvider: Triggers forceChainProviderReset()
    ChainProvider-->>useClientReset: Remounts and clears cached state
    useClientReset-->>Modal: Reset complete
    Modal->>User: Proceeds with wallet connection or disconnection
Loading

Assessment against linked issues

Objective Addressed Explanation
Prevent transaction hanging when switching social wallets by fully resetting client and provider state (#450)
Ensure wallet disconnect and reconnect flows clear all cached and internal state (#450)
Provide a way to remount provider components to avoid stale state after wallet switch (#450)

Poem

Hopping through code with a twitch of my nose,
I reset the clients and clear out the woes.
No more stuck transactions, no endless delay—
Just fresh wallet magic, the bunny way!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

Attention: Patch coverage is 68.42105% with 30 lines in your changes missing coverage. Please review.

Project coverage is 58.46%. Comparing base (82d68e4) to head (8f7ca53).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
hooks/useTx.tsx 15.15% 28 Missing ⚠️
components/react/modal.tsx 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #467      +/-   ##
==========================================
+ Coverage   56.07%   58.46%   +2.39%     
==========================================
  Files         235      236       +1     
  Lines       16179    16106      -73     
==========================================
+ Hits         9073     9417     +344     
+ Misses       7106     6689     -417     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

🔭 Outside diff range comments (1)
components/react/modal.tsx (1)

268-283: ⚠️ Potential issue

Missing implementation for social wallet reset logic.

The comments indicate steps 2-3 should check if this is a social wallet and reset clients if already connected, but the actual implementation is missing from the onWalletClicked function body.

Based on the PR objectives to fix transaction issues from social wallets, add the missing reset logic:

  // Step 2: Check if this is a social wallet and if we should reset clients
+ const isSocialWallet = wallet?.walletInfo.name?.includes('web3auth');
+ if (isSocialWallet && current?.address) {
+   await forceCompleteReset();
+ }
+
  // Step 3: Special case for keplr - check immediately
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 268-270: components/react/modal.tsx#L268-L270
Added lines #L268 - L270 were not covered by tests


[warning] 273-273: components/react/modal.tsx#L273
Added line #L273 was not covered by tests


[warning] 282-283: components/react/modal.tsx#L282-L283
Added lines #L282 - L283 were not covered by tests

🧹 Nitpick comments (1)
hooks/useTx.tsx (1)

27-49: Improved error message extraction with comprehensive patterns.

The multiple regex patterns provide better coverage for different error message formats, making error messages more user-friendly.

Fix the optional chaining issue flagged by Biome on line 39:

-    if (match && match[1]) {
+    if (match?.[1]) {
🧰 Tools
🪛 Biome (1.9.4)

[error] 39-39: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🪛 GitHub Check: codecov/patch

[warning] 27-41: hooks/useTx.tsx#L27-L41
Added lines #L27 - L41 were not covered by tests


[warning] 44-47: hooks/useTx.tsx#L44-L47
Added lines #L44 - L47 were not covered by tests

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82d68e4 and 77b7e49.

📒 Files selected for processing (5)
  • components/react/modal.tsx (6 hunks)
  • contexts/manifestAppProviders.tsx (3 hunks)
  • contexts/web3AuthContext.tsx (5 hunks)
  • hooks/useClientReset.ts (1 hunks)
  • hooks/useTx.tsx (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
hooks/useClientReset.ts (1)
contexts/web3AuthContext.tsx (1)
  • Web3AuthContext (29-38)
components/react/modal.tsx (1)
hooks/useClientReset.ts (1)
  • useClientReset (10-34)
hooks/useTx.tsx (2)
contexts/web3AuthContext.tsx (1)
  • Web3AuthContext (29-38)
contexts/toastContext.tsx (1)
  • useToast (34-40)
🪛 GitHub Check: codecov/patch
hooks/useClientReset.ts

[warning] 10-32: hooks/useClientReset.ts#L10-L32
Added lines #L10 - L32 were not covered by tests

components/react/modal.tsx

[warning] 86-86: components/react/modal.tsx#L86
Added line #L86 was not covered by tests


[warning] 268-270: components/react/modal.tsx#L268-L270
Added lines #L268 - L270 were not covered by tests


[warning] 273-273: components/react/modal.tsx#L273
Added line #L273 was not covered by tests


[warning] 282-283: components/react/modal.tsx#L282-L283
Added lines #L282 - L283 were not covered by tests


[warning] 294-294: components/react/modal.tsx#L294
Added line #L294 was not covered by tests


[warning] 302-302: components/react/modal.tsx#L302
Added line #L302 was not covered by tests


[warning] 308-308: components/react/modal.tsx#L308
Added line #L308 was not covered by tests


[warning] 424-427: components/react/modal.tsx#L424-L427
Added lines #L424 - L427 were not covered by tests

hooks/useTx.tsx

[warning] 27-41: hooks/useTx.tsx#L27-L41
Added lines #L27 - L41 were not covered by tests


[warning] 44-47: hooks/useTx.tsx#L44-L47
Added lines #L44 - L47 were not covered by tests


[warning] 74-79: hooks/useTx.tsx#L74-L79
Added lines #L74 - L79 were not covered by tests


[warning] 82-84: hooks/useTx.tsx#L82-L84
Added lines #L82 - L84 were not covered by tests

contexts/web3AuthContext.tsx

[warning] 139-171: contexts/web3AuthContext.tsx#L139-L171
Added lines #L139 - L171 were not covered by tests


[warning] 181-189: contexts/web3AuthContext.tsx#L181-L189
Added lines #L181 - L189 were not covered by tests

🪛 Biome (1.9.4)
hooks/useTx.tsx

[error] 39-39: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: build
🔇 Additional comments (15)
components/react/modal.tsx (4)

26-26: LGTM! Clean import of the client reset hook.


86-86: LGTM! Proper destructuring of the reset function.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 86-86: components/react/modal.tsx#L86
Added line #L86 was not covered by tests


273-273: LGTM! Function correctly converted to async.

The async conversion enables the use of await for the client reset operations.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 273-273: components/react/modal.tsx#L273
Added line #L273 was not covered by tests


424-427: LGTM! Client reset on disconnect prevents stale state.

Calling forceCompleteReset() after disconnection ensures clean state for subsequent connections.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 424-427: components/react/modal.tsx#L424-L427
Added lines #L424 - L427 were not covered by tests

contexts/manifestAppProviders.tsx (4)

40-40: LGTM! State for managing ChainProvider resets.


80-83: LGTM! Clean implementation of force reset function.

The useCallback ensures stable reference and the key increment pattern is a standard React technique for forcing component remounts.


85-92: LGTM! Proper context value extension.

Using useMemo with correct dependencies ensures the context value is stable unless the underlying values change.


95-122: LGTM! ChainProvider setup with reset capability.

The key prop on ChainProvider ensures complete remount when chainProviderKey changes, effectively clearing all cached state. The Web3AuthContext.Provider wrapper makes the reset function available to consumers.

hooks/useTx.tsx (3)

53-54: LGTM! Extended destructuring for wallet connection management.

Adding disconnect and connect aligns with the broader wallet connection management improvements in this PR.


57-57: LGTM! Address tracking for switch detection.


74-83: Smart address change handling with delay.

The 200ms delay allows ongoing wallet state changes to complete before acquiring the signing client, which should prevent issues with rapid account switching.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 74-79: hooks/useTx.tsx#L74-L79
Added lines #L74 - L79 were not covered by tests

contexts/web3AuthContext.tsx (4)

25-27: LGTM! Clean interface extension for reset functionality.


36-37: LGTM! Consistent default values in context.


139-170: LGTM! Comprehensive Web3Auth client reset implementation.

The function properly:

  • Clears login hints for all Web3Auth wallets
  • Handles concurrent disconnection with Promise.all
  • Includes proper error handling and logging
  • Checks wallet types and connection status before operations
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 139-171: contexts/web3AuthContext.tsx#L139-L171
Added lines #L139 - L171 were not covered by tests


181-189: LGTM! Context value properly includes reset function.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 181-189: contexts/web3AuthContext.tsx#L181-L189
Added lines #L181 - L189 were not covered by tests

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: 2

🧹 Nitpick comments (1)
hooks/__tests__/useClientReset.test.tsx (1)

78-86: Consider adding tests for other potential error scenarios.

While the current error test covers resetWeb3AuthClients failures, you might want to consider adding tests for scenarios where queryClient.clear() or forceChainProviderReset() throw errors to ensure complete error handling coverage.

Example additional test cases:

test('forceCompleteReset handles queryClient.clear errors gracefully', async () => {
  mockQueryClient.clear.mockImplementation(() => {
    throw new Error('Query client clear failed');
  });

  const { result } = renderHook(() => useClientReset(), { wrapper });

  await expect(result.current.forceCompleteReset()).rejects.toThrow('Query client clear failed');

  expect(mockResetWeb3AuthClients).toHaveBeenCalledTimes(1);
  expect(mockQueryClient.clear).toHaveBeenCalledTimes(1);
});

test('forceCompleteReset handles forceChainProviderReset errors gracefully', async () => {
  mockForceChainProviderReset.mockImplementation(() => {
    throw new Error('Chain provider reset failed');
  });

  const { result } = renderHook(() => useClientReset(), { wrapper });

  await expect(result.current.forceCompleteReset()).rejects.toThrow('Chain provider reset failed');

  expect(mockResetWeb3AuthClients).toHaveBeenCalledTimes(1);
  expect(mockQueryClient.clear).toHaveBeenCalledTimes(1);
  expect(mockForceChainProviderReset).toHaveBeenCalledTimes(1);
});
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 77b7e49 and 78a65c7.

📒 Files selected for processing (2)
  • contexts/__tests__/web3AuthContext.test.tsx (1 hunks)
  • hooks/__tests__/useClientReset.test.tsx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
contexts/__tests__/web3AuthContext.test.tsx (2)
tests/mock.ts (2)
  • mockModule (23-60)
  • clearAllMocks (11-15)
contexts/web3AuthContext.tsx (2)
  • Web3AuthContext (29-38)
  • Web3AuthProvider (40-194)
hooks/__tests__/useClientReset.test.tsx (3)
tests/mock.ts (2)
  • mockModule (23-60)
  • clearAllMocks (11-15)
contexts/web3AuthContext.tsx (1)
  • Web3AuthContext (29-38)
hooks/useClientReset.ts (1)
  • useClientReset (10-34)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: build
🔇 Additional comments (14)
hooks/__tests__/useClientReset.test.tsx (8)

1-8: LGTM: Clean imports and proper setup.

The imports are well-organized and include all necessary testing utilities and dependencies.


10-36: LGTM: Comprehensive mock setup.

The mock setup properly covers all dependencies of the useClientReset hook, including the Web3Auth context functions and React Query client. The mocks are appropriately configured to match the expected behavior.


38-46: LGTM: Proper cleanup and wrapper setup.

The cleanup strategy is thorough, clearing all mocks and performing React Testing Library cleanup. The wrapper component correctly provides the mocked context.


48-53: LGTM: Basic functionality test.

This test correctly verifies that the hook returns the expected forceCompleteReset function.


55-64: LGTM: Comprehensive happy path test.

This test thoroughly verifies the complete reset sequence when all dependencies are available, ensuring all three operations are called in the correct order.


66-76: LGTM: Edge case handling.

This test correctly verifies the behavior when forceChainProviderReset is undefined, ensuring the function returns false and doesn't attempt to call the reset functions.


78-86: LGTM: Error handling test.

This test properly verifies that errors from resetWeb3AuthClients propagate correctly. The implementation correctly stops execution when the first async operation fails.


88-98: LGTM: Memoization verification.

This test correctly verifies that the forceCompleteReset callback is properly memoized using useCallback, which is important for performance in React applications.

contexts/__tests__/web3AuthContext.test.tsx (6)

1-8: LGTM: Clean imports and setup.

The imports are well-organized and appropriate for a React component test using Bun test framework.


10-53: Comprehensive mocking setup looks good.

The mock configuration correctly covers all the required dependencies:

  • @cosmos-kit/web3auth with realistic mock classes
  • @web3auth/auth for network types
  • cosmos-kit and extension wallets
  • Environment configuration

The mock classes provide the necessary methods and properties that match the real implementation based on the context from contexts/web3AuthContext.tsx.


55-59: Proper cleanup implementation.

Good use of multiple cleanup methods to ensure test isolation.


61-73: Good verification of resetWeb3AuthClients function availability.

This test correctly verifies that the new resetWeb3AuthClients function is provided by the context as expected.


75-100: Comprehensive context value validation.

Excellent coverage of all context properties and their expected types. The test properly validates the context interface.


102-122: Good async function testing.

The test correctly verifies that resetWeb3AuthClients can be called without throwing errors, which is important for the reset functionality.

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: 2

🧹 Nitpick comments (3)
components/react/__tests__/modal.test.tsx (3)

14-14: Replace any with proper types for better type safety.

Using any type defeats TypeScript's type checking. Consider creating proper type definitions or using the actual types from cosmos-kit.

-  let mockWalletRepo: any;
+  let mockWalletRepo: WalletRepository;

29-59: Consider extracting window mock setup to a helper function.

The window mock setup is extensive and could be reused across test files. Extracting it would improve maintainability and reduce duplication.

Create a helper function:

// In tests/helpers/windowMocks.ts
export function createMockWindow(overrides?: Partial<Window>) {
  return {
    keplr: undefined,
    open: jest.fn(),
    addEventListener: jest.fn(),
    removeEventListener: jest.fn(),
    localStorage: {
      getItem: jest.fn(),
      setItem: jest.fn(),
      removeItem: jest.fn(),
      clear: jest.fn(),
    },
    matchMedia: jest.fn(() => ({
      matches: false,
      addListener: jest.fn(),
      removeListener: jest.fn(),
      addEventListener: jest.fn(),
      removeEventListener: jest.fn(),
      dispatchEvent: jest.fn(),
    })),
    navigator: {
      platform: 'MacIntel',
      userAgent: 'test',
      maxTouchPoints: 0,
    },
    document: {
      body: {
        style: {},
      },
    },
    ...overrides,
  };
}

Then use it in the test:

-    (global as any).window = {
-      ...originalWindow,
-      keplr: undefined,
-      open: jest.fn(),
-      // ... rest of the mock
-    };
+    (global as any).window = createMockWindow({ ...originalWindow });

349-349: Consider a more robust approach for mocking Web3AuthClient instance.

Using Object.setPrototypeOf to satisfy instanceof checks is fragile and could break with library updates. Consider using a proper mock instance or adjusting the implementation to not rely on instanceof.

-      Object.setPrototypeOf(mockClient, Web3AuthClient.prototype);
+      // Create a proper mock instance that extends Web3AuthClient
+      const mockClient = Object.create(Web3AuthClient.prototype);
+      mockClient.setLoginHint = jest.fn();

Or better yet, mock the entire Web3AuthClient class:

jest.mock('@cosmos-kit/web3auth', () => ({
  Web3AuthClient: jest.fn().mockImplementation(() => ({
    setLoginHint: jest.fn(),
  })),
}));
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b66760 and fb446d0.

📒 Files selected for processing (1)
  • components/react/__tests__/modal.test.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: build
🔇 Additional comments (1)
components/react/__tests__/modal.test.tsx (1)

307-335: Good test coverage for the client reset functionality.

This test properly validates the new forceCompleteReset functionality that addresses the stale data issue mentioned in the PR objectives. The test correctly mocks the hook and verifies the reset is called on disconnect.

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fb446d0 and e4efa12.

⛔ Files ignored due to path filters (1)
  • components/react/__tests__/__snapshots__/ModalDialog.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • tests/format.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: build

Copy link
Contributor

@fmorency fmorency left a comment

Choose a reason for hiding this comment

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

Thank you! Merging!

icons: [],
<Web3AuthContext.Provider value={contextValue}>
<ChainProvider
key={chainProviderKey} // This forces complete re-mount and reset of cosmos-kit
Copy link
Contributor

Choose a reason for hiding this comment

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

Cute. Internal React mechanism. The key parameter doesn't belong to ChainProvider.

// Check if the address has changed since last use (indicating a potential account switch)
if (lastUsedAddress.current && lastUsedAddress.current !== address) {
// Add a small delay to allow any ongoing wallet state changes to complete
await new Promise(resolve => setTimeout(resolve, 200));
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] I'm not a big fan of those kinds of delays.

@fmorency fmorency merged commit d9be7c4 into main Jun 12, 2025
13 checks passed
@fmorency fmorency deleted the chalabi/transaction-hang branch June 12, 2025 13:33
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.

Transaction hanging

2 participants