Skip to content

fix/wallet-connect-qa-fixes#254

Merged
RanaBug merged 4 commits intostagingfrom
fix/wallet-connect-qa-fixes
Mar 13, 2025
Merged

fix/wallet-connect-qa-fixes#254
RanaBug merged 4 commits intostagingfrom
fix/wallet-connect-qa-fixes

Conversation

@RanaBug
Copy link
Collaborator

@RanaBug RanaBug commented Mar 12, 2025

Description

  • WalletConnect sendTransaction request send back a transaction hash to the dApp.

How Has This Been Tested?

  • Existing Unit Tests and Manual Testing

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

  • New Features

    • Enhanced WalletConnect transaction processing with real-time status updates and a timeout mechanism that alerts users if a transaction takes too long.
    • Added functionality for managing transaction hashes within the WalletConnect integration.
  • Bug Fixes

    • Fixed a minor UI inconsistency with the send action for a smoother experience.
  • Chores

    • Updated internal dependencies to further improve overall system stability and performance.

@RanaBug RanaBug requested a review from IAmKio March 12, 2025 17:04
@RanaBug RanaBug self-assigned this Mar 12, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 12, 2025

Walkthrough

The pull request updates dependency versions in the project’s package configuration and refines transaction handling throughout the application. It upgrades @etherspot/transaction-kit and viem, corrects a UI element identifier, and enhances the WalletConnect transaction flow. The changes integrate a new asynchronous function to retrieve transaction hashes, update the global transaction context to store WalletConnect-specific hashes, and adjust corresponding tests to support these modifications.

Changes

File(s) Change Summary
package.json Updated dependency versions: @etherspot/transaction-kit bumped from ^1.0.1 to ^1.0.4, and viem changed from ^2.6.1 to 2.21.53.
src/.../SendModalBottomButtons.tsx Fixed a typo in the Button component's id attribute (removed an extraneous semicolon).
src/.../SendModal.test.skip.tsx Enhanced mock of useEtherspotTransactions by adding getTransactionHash: async () => ''.
src/.../SendModalTokensTabView.tsx
src/.../GlobalTransactionsBatchProvider.tsx
src/.../walletConnect.ts
Enhanced WalletConnect transaction handling: added a getTransactionHash function (and its mock), updated the transaction flow in the tokens tab view, extended the global transactions context with walletConnectTxHash and setWalletConnectTxHash, and implemented a timeout mechanism with state reset in the WalletConnect service.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant T as SendModalTokensTabView
    participant W as WalletConnect Service
    participant G as GlobalTransactionsBatchProvider

    U->>T: Initiates WalletConnect transaction
    T->>W: call getTransactionHash(newUserOpHash)
    W->>W: Wait up to 3 minutes for txHash
    alt Transaction hash obtained
        W-->>T: Return txHash
        T->>G: setWalletConnectTxHash(txHash)
    else Timeout reached
        W-->>T: Return undefined
        T->>G: setWalletConnectTxHash(undefined)
        W->>T: Show timeout error notification
    end
    T->>T: Proceed with transaction confirmation flow
Loading

Suggested reviewers

  • IAmKio

Poem

I'm a bunny, hopping with cheer,
New code's here, crisp and clear!
Dependencies upgraded, flows refined,
WalletConnect magic now aligned.
With every change, I dance in delight—
A rabbit's dream in code so bright!
🐇✨

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c87b9c5 and 245fa6f.

📒 Files selected for processing (1)
  • src/services/walletConnect.ts (6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: unit-tests
  • GitHub Check: lint
  • GitHub Check: build
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (10)
src/services/walletConnect.ts (10)

14-14: Good addition of useRef import

Adding useRef to the React imports is necessary for the new reference implementation that will help track transaction hash values between renders.


41-42: Well-structured global state integration

Good implementation of accessing the WalletConnect transaction hash from the global state. This enables proper communication between the WalletConnect service and the global transaction context.


47-49: Effective use of useRef for async operation

Using useRef to store the transaction hash is an excellent approach that prevents stale closure issues in async functions. This ensures that the async operations will always access the latest transaction hash value.


96-98: Proper ref synchronization

The useEffect hook correctly ensures that the reference is always synchronized with the current transaction hash state. This is critical for the polling mechanism to work properly.


100-129: Well-implemented transaction hash polling with timeout handling

The getTransactionHash function effectively implements a polling mechanism with appropriate timeout handling. This resolves the core issue of returning transaction hashes to dApps.

A few notes:

  • The 3-minute timeout provides ample time for user interaction
  • Error handling is comprehensive with appropriate cleanup
  • User feedback via toast notification is well-implemented

420-424: Good extraction of dApp metadata

Retrieving the dApp name from session metadata improves the user experience by providing context about which application is requesting the transaction.


472-472: Improved transaction description with dApp name

Including the dApp name in the transaction description provides better context to users about which application is requesting the transaction.


473-478: Well-structured transaction object

The transaction object is properly structured with all necessary properties:

  • to: Properly checksummed address for security
  • value: Correctly formatted from hex to human-readable ether value
  • data: Transaction data preserved
  • chainId: Chain identifier properly extracted

This ensures accurate transaction information is displayed to the user.


491-491: Key improvement: Return actual transaction hash

This is the critical line that fulfills the PR objective - returning the actual transaction hash to the dApp instead of a static message. This enables proper transaction tracking in the dApp.


499-499: Proper cleanup of transaction hash state

Good practice to reset the transaction hash after responding to the session request. This ensures a clean state for future transactions and prevents potential state conflicts.

Also applies to: 506-506

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 12, 2025

Deploying x with  Cloudflare Pages  Cloudflare Pages

Latest commit: 245fa6f
Status: ✅  Deploy successful!
Preview URL: https://256dbb4b.x-e62.pages.dev
Branch Preview URL: https://fix-wallet-connect-qa-fixes.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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ef7edf4 and 9036bf4.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json
  • src/apps/pillarx-app/components/PointsTile/test/__snapshots__/PointsTile.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (7)
  • config-overrides.js (1 hunks)
  • package.json (2 hunks)
  • src/components/BottomMenuModal/SendModal/SendModal.test.skip.tsx (1 hunks)
  • src/components/BottomMenuModal/SendModal/SendModalBottomButtons.tsx (1 hunks)
  • src/components/BottomMenuModal/SendModal/SendModalTokensTabView.tsx (2 hunks)
  • src/providers/GlobalTransactionsBatchProvider.tsx (3 hunks)
  • src/services/walletConnect.ts (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: unit-tests
  • GitHub Check: lint
  • GitHub Check: build
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (19)
src/components/BottomMenuModal/SendModal/SendModalBottomButtons.tsx (1)

53-53: Good fix: Corrected ID attribute typo

You've fixed the typo in the button's ID attribute, removing the incorrect semicolon. This improves HTML correctness and ensures proper element identification for testing and accessibility purposes.

package.json (2)

100-100:

Details

❓ Verification inconclusive

Pinned viem to specific version

You've changed from a flexible version range (^2.6.1) to a specific version (2.21.53). This ensures consistent behavior but may prevent receiving minor bug fixes.


🏁 Script executed:

#!/bin/bash
# Check for breaking changes between current and previous viem versions

echo "Checking for potential breaking changes between viem 2.6.1 and 2.21.53..."

# Check if package.json uses this dependency in any imports
grep -r "from 'viem'" --include="*.ts" --include="*.tsx" src/

# Check changelog or release notes from GitHub API
echo "Fetching release information from GitHub..."
curl -s "https://api.github.com/repos/wagmi-dev/viem/releases" | grep -A 1 "\"name\": \"v2" | grep -E "\"name\": \"v2.(6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21)." | head -10

Length of output: 532


Dependency Version Pinning: Validate Impact on Bug Fixes & Usage

  • You've pinned viem to version 2.21.53 instead of using a flexible version range (like ^2.6.1). While this guarantees consistent dependency resolution, it also prevents automatic incorporation of minor bug fixes.
  • The verification script attempted to search for viem imports in a src/ directory but returned an error (No such file or directory). If your code isn’t located in src/, please ensure the search is adjusted to reflect your repository’s actual structure.
  • The release notes retrieval via GitHub’s API was initiated. It’s advisable to manually review the changelog between versions 2.6.1 and 2.21.53 to confirm that no critical breaking changes or important updates have been overlooked.

22-22:

Details

✅ Verification successful

Updated @etherspot/transaction-kit dependency

Upgrading from ^1.0.1 to ^1.0.4 should provide bug fixes or minor improvements while maintaining backward compatibility.


🌐 Web query:

What changes were introduced in @etherspot/transaction-kit between versions 1.0.1 and 1.0.4?

💡 Result:

The provided search results do not explicitly list the specific changes introduced in @etherspot/transaction-kit between versions 1.0.1 and 1.0.4. However, based on the available resources, here are the key insights about Transaction Kit's development focus during this period:


Core Functional Improvements

  1. Cross-Chain Transaction Batching
    Transaction Kit introduced enhanced support for composing multi-chain transactions into a single user interaction, leveraging Etherspot's Prime SDK for cross-chain interoperability[4][6].

  2. Paymaster Integration
    Added utilities for handling gas fees via stablecoins or sponsored transactions using Etherspot's Arka Paymaster system[4][6].

  3. Smart Contract Interaction Simplification
    Streamlined components like <EtherspotTransaction> and hooks like useEtherspotUI() for easier integration with smart contracts[4][7].


Developer Experience Updates

  • React Component Optimization
    Improved error handling and state management in core components like <EtherspotTransactionKit> and <EtherspotBatches>[7][11].

  • Documentation Expansions
    Added tutorials for common use cases (staking, token swaps) and improved TypeScript support in the SDK[6][11].


Infrastructure Changes

  • Ethers v5 Compatibility
    Ensured compatibility with Ethers.js v5.4.0 for wallet management and provider interactions[1][11].

  • Multi-Chain Support
    Expanded EVM chain compatibility, though specific chains added between these versions aren't detailed in the search results[4][6].


For precise version-to-version changelogs, refer to:

  1. GitHub Releases
  2. NPM Version History

The lack of explicit release notes in the provided sources highlights Etherspot's ongoing development to simplify Web3 interactions through its React-based abstraction layer[6][11].

Citations:


Dependency Update: @etherspot/transaction-kit

The upgrade from version ^1.0.1 to ^1.0.4 in package.json appears well justified. Based on available resources, this update delivers several incremental improvements—including enhanced support for cross-chain transaction batching, built-in paymaster integration for better handling of gas fees, and developer experience optimizations such as improved error handling and cleaner smart contract interaction components. These modifications provide essential bug fixes and incremental functionality improvements while maintaining backward compatibility.

No further changes are required. Please verify the changelog linked in the release notes for any additional updates that might influence usage.

src/components/BottomMenuModal/SendModal/SendModal.test.skip.tsx (1)

185-185:

Details

✅ Verification successful

Added transaction hash retrieval to mock

This change adds the getTransactionHash method to the mock implementation of useEtherspotTransactions, which aligns with the PR objective of returning a transaction hash to the dApp when using WalletConnect.


🏁 Script executed:

#!/bin/bash
# Check for implementations of getTransactionHash in the codebase

echo "Looking for implementations of getTransactionHash function..."
grep -r "getTransactionHash" --include="*.ts" --include="*.tsx" src/

echo "Looking for related WalletConnect transaction handling..."
grep -r "walletConnect.*transaction" --include="*.ts" --include="*.tsx" src/

Length of output: 959


Transaction hash retrieval mock verified and aligned with WalletConnect usage.

The mock implementation in the test (i.e., getTransactionHash: async () => '') is consistent with its usage across the codebase, as seen in both SendModalTokensTabView.tsx and the service in walletConnect.ts. No further changes are needed.

src/providers/GlobalTransactionsBatchProvider.tsx (4)

21-24: Interface extension looks good

This addition to the IGlobalTransactionsBatchContext interface properly defines the new properties for managing WalletConnect transaction hashes.


39-41: State implementation is well structured

Good implementation of the state hook with proper typing and initialization to undefined.


60-65: Context data enhancement is appropriate

The new properties are correctly added to the context data, making them accessible to consumers of this context.


66-66: Dependency array properly updated

Correctly added walletConnectTxHash to the dependency array to ensure the context is updated when this value changes.

src/components/BottomMenuModal/SendModal/SendModalTokensTabView.tsx (3)

88-88: Hooks usage updated correctly

Properly destructured the new setWalletConnectTxHash function from the context.


91-91: Added required transaction hash retrieval

Good addition of the getTransactionHash method from the Etherspot transactions hook.


271-280: Well-implemented transaction hash handling for WalletConnect

This implementation correctly handles WalletConnect transactions by:

  1. Checking if the transaction is from WalletConnect
  2. Retrieving the transaction hash
  3. Appropriately updating the global state

This fulfills the PR objective of returning a transaction hash to the dApp.

src/services/walletConnect.ts (8)

14-14: Added necessary React hook import

Added useRef to the import statement to support the new reference implementation.


41-42: Correctly using global transaction context

Properly destructured both the transaction hash and its setter from the global context.


47-49: Proper reference implementation

Good use of useRef to keep track of the current transaction hash value between renders.


96-98: Effective reference update mechanism

This effect ensures the reference is always updated when the actual state changes, maintaining synchronization.


100-129: Well-implemented transaction hash retrieval with timeout

Excellent implementation of the transaction hash retrieval function with:

  1. A reasonable timeout (3 minutes) to allow for transaction processing
  2. Polling mechanism that checks every 2 seconds
  3. Proper error handling with user feedback
  4. Cleanup of state when timeout occurs

This is a robust solution that provides good UX even in failure cases.


465-474: Improved transaction presentation to users

Good enhancement of the transaction confirmation UI with better structured data and proper formatting of address and value.


486-486: Transaction hash now returned to dApp

This is the key change that fulfills the PR objective - now the WalletConnect request returns the actual transaction hash instead of a static message.


494-494: Good state cleanup after response

Properly resets the transaction hash state after handling the request, preventing stale data issues in subsequent requests.

Also applies to: 501-502

Comment on lines 30 to 39
// // Chunking
// config.optimization.splitChunks = {
// cacheGroups: {
// vendor: {
// test: /[\\/]node_modules[\\/]/,
// chunks: 'all',
// maxSize: 50000,
// },
// },
// };
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Disabled Webpack chunking optimization

You've commented out the Webpack splitChunks configuration that was previously splitting node_modules code into vendor chunks. This change may affect bundle size and load performance.

Disabling code splitting might increase initial bundle size and load time, but could potentially solve issues with chunked dependencies. Was this change made to address specific WalletConnect issues? Consider adding a comment explaining why this optimization was disabled to help future maintainers understand the reasoning.


🏁 Script executed:

#!/bin/bash
# Check for any related performance or bundle size tracking

echo "Checking for performance monitoring or bundle size tooling..."
grep -r "performance\|bundle" --include="package.json" .

echo "Looking for related issues in bundle processing..."
grep -r "splitChunks\|chunk" --include="*.md" --include="*.log" .

Length of output: 5294


Attention: Clarify Rationale for Disabled SplitChunks Configuration

  • The Webpack splitChunks setting in config-overrides.js (lines 30–39) has been disabled by commenting it out, which stops vendor code from being split into separate chunks.
  • Disabling this optimization can lead to a larger initial bundle size and increased load times.
  • If this change was specifically implemented to address WalletConnect (or similar) dependency issues, please add an inline comment explaining the reasoning. Providing this context will help future maintainers understand the trade-offs made at this point.

Copy link
Collaborator

@IAmKio IAmKio left a comment

Choose a reason for hiding this comment

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

One additional change to the question I sent on Slack also, other than that looks good!

to: checksumAddress(request.params[0].to),
value: formatEther(hexToBigInt(request.params[0].value)),
data: request.params[0].data,
description: 'This will execute a transaction coming from a dApp',
Copy link
Collaborator

Choose a reason for hiding this comment

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

we'll need to change this message, can you include the dapp name here that is requested the transaction please?

Suggested change
description: 'This will execute a transaction coming from a dApp',
description: '{dappName} wants to send a transaction',

@github-actions github-actions bot temporarily deployed to Preview (fix/wallet-connect-qa-fixes) March 12, 2025 17:24 Inactive
@github-actions github-actions bot temporarily deployed to Preview (fix/wallet-connect-qa-fixes) March 13, 2025 09:30 Inactive
@github-actions github-actions bot temporarily deployed to Preview (fix/wallet-connect-qa-fixes) March 13, 2025 09:40 Inactive
Copy link
Collaborator

@IAmKio IAmKio left a comment

Choose a reason for hiding this comment

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

LGTM

@RanaBug RanaBug merged commit 713898b into staging Mar 13, 2025
7 checks passed
@IAmKio IAmKio deleted the fix/wallet-connect-qa-fixes branch March 13, 2025 10:06
@coderabbitai coderabbitai bot mentioned this pull request Nov 27, 2025
3 tasks
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.

2 participants