Skip to content

feat/update-modular-sdk-tx-kit-2 - #188

Merged
RanaBug merged 3 commits into
masterfrom
feat/update-modular-sdk-tx-kit-2
Jul 24, 2025
Merged

feat/update-modular-sdk-tx-kit-2#188
RanaBug merged 3 commits into
masterfrom
feat/update-modular-sdk-tx-kit-2

Conversation

@RanaBug

@RanaBug RanaBug commented Jul 24, 2025

Copy link
Copy Markdown
Collaborator

Description

  • Added 2 new methods to the Transaction Kit (getEtherspotProvider and getTransactionHash)
  • Updated Modular SDK to version 6.1.1

How Has This Been Tested?

  • Existing Unit Tests

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

    • Added a method to retrieve transaction hashes from user operation hashes with configurable timeout and retry options.
    • Introduced direct access to the underlying Etherspot Provider for advanced usage.
  • Bug Fixes

    • Improved JSON serialization in the example app to handle bigint values safely.
  • Refactor

    • Updated provider access patterns for consistency and clarity.
    • Enhanced static method usage for address checks.
  • Tests

    • Expanded test coverage for transaction hash retrieval and updated provider-related tests.
  • Chores

    • Updated dependency on @etherspot/modular-sdk to version ^6.1.1.
    • Added a new changelog entry for version 2.0.2 dated 2025-07-24.

@RanaBug
RanaBug requested review from IAmKio and vignesha22 July 24, 2025 16:25
@RanaBug RanaBug self-assigned this Jul 24, 2025
@coderabbitai

coderabbitai Bot commented Jul 24, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This update introduces new methods for accessing the Etherspot provider and retrieving transaction hashes in the transaction kit. The provider access pattern is clarified and expanded, and a polling-based getTransactionHash method is added. Related interfaces and tests are updated, and JSON serialization in the example app is enhanced to support bigint values.

Changes

File(s) Change Summary
CHANGELOG.md, package.json Changelog updated for v2.0.1; modular-sdk dependency bumped to ^6.1.1; peerDependencies removed.
lib/TransactionKit.ts, lib/interfaces/index.ts Added getEtherspotProvider and getTransactionHash methods; updated provider access and interfaces.
tests/EtherspotTransactionKit.test.ts Updated tests for provider method changes; added comprehensive tests for getTransactionHash.
example/src/App.tsx Added bigIntReplacer for safe JSON serialization of bigint values.
lib/EtherspotUtils.ts Changed static method reference from this.addressesEqual to EtherspotUtils.addressesEqual.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant EtherspotTransactionKit
  participant EtherspotProvider
  participant ModularSDK

  User->>EtherspotTransactionKit: getTransactionHash(userOpHash, chainId, ...)
  EtherspotTransactionKit->>EtherspotProvider: getSdk(chainId)
  EtherspotProvider->>ModularSDK: getUserOpReceipt(userOpHash)
  ModularSDK-->>EtherspotProvider: {receipt with transactionHash or null}
  EtherspotProvider-->>EtherspotTransactionKit: receipt
  alt transactionHash found
    EtherspotTransactionKit-->>User: transactionHash
  else not found & timeout not reached
    EtherspotTransactionKit->>ModularSDK: (retry after interval)
  else timeout reached
    EtherspotTransactionKit-->>User: null
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15–20 minutes

Possibly related PRs

Suggested reviewers

  • IAmKio
  • vignesha22

Poem

A patch hops in with methods new,
To fetch a hash and peek right through.
Providers clear, interfaces neat,
BigInts now in JSON greet.
With every test and doc aligned,
This code is crisp, robust, refined!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 74f1337 and 59a652c.

📒 Files selected for processing (1)
  • CHANGELOG.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/update-modular-sdk-tx-kit-2

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 generate unit tests to generate unit tests 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
CHANGELOG.md (1)

3-10: LGTM! Comprehensive and accurate changelog entry.

The changelog correctly documents all changes in this patch release, including the two new methods and dependency update. The descriptions clearly explain the purpose of each addition.

Consider varying the sentence beginnings to improve readability:

### Added Changes

- Added `getEtherspotProvider` to access directly the Etherspot Provider.
- Introduced `getTransactionHash` to get a transaction hash with a userOp Hash and chain id.
- Updated the `modular-sdk` version to 6.1.1.
lib/TransactionKit.ts (1)

1798-1837: Consider adjusting the polling loop timing

The getTransactionHash method implementation is well-structured with proper error handling and timeout logic. However, there's a potential timing issue:

while (!transactionHash && Date.now() < timeoutTotal) {
  await new Promise<void>((resolve) => setTimeout(resolve, retryInterval)); // This delays before first attempt
  try {
    transactionHash = await etherspotModulaSdk.getUserOpReceipt(userOpHash);
  } catch (error) {
    // ...
  }
}

The delay occurs before every attempt, including the first one. Consider moving the delay to the end of the loop or adding a condition to skip it on the first iteration for more responsive behavior:

+let isFirstAttempt = true;
while (!transactionHash && Date.now() < timeoutTotal) {
+  if (!isFirstAttempt) {
    await new Promise<void>((resolve) => setTimeout(resolve, retryInterval));
+  }
+  isFirstAttempt = false;
  try {
    transactionHash = await etherspotModulaSdk.getUserOpReceipt(userOpHash);
  } catch (error) {
    // ...
  }
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 49542dd and 03066ea.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • CHANGELOG.md (1 hunks)
  • __tests__/EtherspotTransactionKit.test.ts (4 hunks)
  • example/src/App.tsx (11 hunks)
  • lib/EtherspotUtils.ts (1 hunks)
  • lib/TransactionKit.ts (7 hunks)
  • lib/interfaces/index.ts (1 hunks)
  • package.json (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
__tests__/EtherspotTransactionKit.test.ts (1)
__mocks__/@etherspot/modular-sdk.js (1)
  • ModularSdk (10-178)
lib/TransactionKit.ts (1)
lib/EtherspotProvider.ts (1)
  • EtherspotProvider (15-154)
🪛 LanguageTool
CHANGELOG.md

[style] ~8-~8: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...cess directly the Etherspot Provider. - Added getTransactionHash to get a transacti...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

🔇 Additional comments (19)
example/src/App.tsx (2)

12-14: LGTM! Well-implemented bigint serialization handler.

The bigIntReplacer function correctly handles bigint serialization by converting to strings, which is essential since JSON.stringify() cannot serialize bigint values by default.


140-142: LGTM! Comprehensive application of bigint replacer.

The bigIntReplacer function is consistently applied to all JSON.stringify calls throughout the file, ensuring robust handling of bigint values in transaction estimates, sends, error messages, and state logging.

Also applies to: 153-155, 172-172, 177-179, 191-191, 488-490, 501-503, 678-679, 694-695, 716-716, 760-760

package.json (2)

28-28: LGTM! Appropriate dependency version update.

The update from "6.1.0" to "^6.1.1" correctly enables automatic minor and patch updates while supporting the new methods introduced in this PR.


68-68: LGTM! Good cleanup of empty peerDependencies.

Removing the empty peerDependencies object is a good housekeeping improvement.

lib/EtherspotUtils.ts (1)

85-85: LGTM! Improved static method call clarity.

Changing from this.addressesEqual(...) to EtherspotUtils.addressesEqual(...) makes the static method call explicit and improves code readability. This is a good practice for static method invocations.

lib/interfaces/index.ts (2)

40-41: LGTM! Well-designed provider access pattern.

The change from EtherspotProvider to WalletProviderLike for getProvider() provides better abstraction, while the new getEtherspotProvider() method offers direct access when needed. This separation of concerns is well-designed.


44-49: LGTM! Well-structured transaction hash polling interface.

The getTransactionHash() method signature is well-designed with:

  • Required parameters for core functionality (userOpHash, txChainId)
  • Optional parameters for customizing polling behavior (timeout, retryInterval)
  • Appropriate return type (Promise<string | null>) that handles both success and failure cases
__tests__/EtherspotTransactionKit.test.ts (6)

107-107: LGTM: Correct API method update

The change from getProvider() to getEtherspotProvider() correctly aligns with the API refactoring where getEtherspotProvider() now returns the underlying EtherspotProvider instance.


799-799: LGTM: Test correctly updated for new API

The test correctly calls getEtherspotProvider() which should return the underlying EtherspotProvider instance, matching the updated API design.


966-968: LGTM: Correct method chaining for API update

The change to getEtherspotProvider().getSdk is correct since getProvider() now returns a WalletProviderLike without the getSdk method, while getEtherspotProvider() provides access to the underlying EtherspotProvider with SDK functionality.


1101-1101: LGTM: Correct error condition testing

The test correctly mocks getProvider() to return null to validate the error handling in estimateBatches(), which matches the implementation's provider validation logic.


1109-1109: LGTM: Correct error condition testing

The test correctly mocks getProvider() to return null to validate the error handling in sendBatches(), which matches the implementation's provider validation logic.


1116-1192: LGTM: Comprehensive test coverage for new getTransactionHash method

The new test suite provides excellent coverage of the getTransactionHash polling functionality:

  1. Immediate success case - Tests when transaction hash is available on first call
  2. Polling behavior - Validates retry logic with eventual success
  3. Timeout handling - Ensures null is returned when timeout is exceeded
  4. Error resilience - Confirms polling continues despite SDK errors

The test implementation correctly mocks the SDK's getUserOpReceipt method and uses realistic timeout/retry parameters. The test logic aligns well with the actual implementation.

lib/TransactionKit.ts (6)

1-1: LGTM: Required import for API refactoring

The addition of WalletProviderLike import is necessary to support the updated getProvider() method return type.


592-592: LGTM: Good abstraction of provider access

The change from this.etherspotProvider.getProvider() to this.getProvider() provides better encapsulation and a consistent interface for provider access.


820-820: LGTM: Consistent provider access pattern

Using this.getProvider() maintains consistency with the abstracted provider access pattern established throughout the class.


1089-1089: LGTM: Consistent provider access abstraction

The abstracted provider access through this.getProvider() maintains consistency and improves maintainability.


1360-1360: LGTM: Consistent provider access pattern

Using the abstracted this.getProvider() method maintains consistency across all provider access points in the class.


1756-1776: LGTM: Well-designed API separation

The refactored provider access methods provide clear separation of concerns:

  • getProvider() returns the underlying WalletProviderLike for general web3 interactions
  • getEtherspotProvider() returns the wrapper class for advanced Etherspot-specific operations

The documentation clearly explains the intended use cases for each method, making the API more intuitive and user-friendly.

vignesha22
vignesha22 previously approved these changes Jul 24, 2025

@vignesha22 vignesha22 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

just one minor change rest all good. Make sure to change that before merging

Comment thread package.json Outdated
@RanaBug
RanaBug merged commit 99b7215 into master Jul 24, 2025
5 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Oct 16, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants