Skip to content

Import wallet client and chains from viem#72

Open
aniket866 wants to merge 2 commits intoDjedAlliance:mainfrom
aniket866:patch-2
Open

Import wallet client and chains from viem#72
aniket866 wants to merge 2 commits intoDjedAlliance:mainfrom
aniket866:patch-2

Conversation

@aniket866
Copy link

@aniket866 aniket866 commented Jan 27, 2026

Changes:

File: stablepay-sdk/src/core/Wallet.js

  • Action: Added missing imports from viem and viem/chains.

  • Impact: The Wallet class can now be instantiated and connected without crashing.

@Zahnentferner , a Patch but crucial , Please review

Summary by CodeRabbit

  • Chores
    • Internal wallet implementation updated; no changes to public API or method signatures.
  • Bug Fixes
    • Wallet now validates network identifiers and will surface a clear error when an unsupported network is provided, preventing ambiguous failures.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

Added viem imports and chain constants to Wallet.js and introduced runtime validation that throws on unsupported chainId; no changes to public API signatures.

Changes

Cohort / File(s) Summary
Wallet — viem imports & chain validation
stablepay-sdk/src/core/Wallet.js
Added import { createWalletClient, custom } from 'viem' and import { mainnet, sepolia } from 'viem/chains'; added runtime validation in getChainConfig to throw Error('Unsupported chainId: ${chainId}') when chainId is not in the chains map. Minor formatting adjustments.

Sequence Diagram(s)

(omitted — change is a small validation addition and does not introduce a multi-component sequential flow)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • Zahnentferner

Poem

🐰 A tiny check hops into place,
Chains greet mainnet with gentle grace,
Sepolia nods, the code is neat,
Wallets now guard the chain complete,
Hooray — validation made the trace!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly describes the main change: adding imports from viem for wallet client and chains. This aligns with the primary objective of resolving missing imports that prevented the Wallet class from functioning.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ 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

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

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.

Actionable comments posted: 0

Caution

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

⚠️ Outside diff range comments (1)
stablepay-sdk/src/core/Wallet.js (1)

20-40: Guard against unsupported chainId before creating the client.

getChainConfig returns undefined for any chainId not in the map, which can lead to a misconfigured client or runtime errors. Consider throwing a clear error when the chain isn’t supported.

✅ Proposed fix
  getChainConfig(chainId) {
    const chains = {
      // Add other chains as needed
    };
-    return chains[chainId];
+    const chain = chains[chainId];
+    if (!chain) {
+      throw new Error(`Unsupported chainId: ${chainId}`);
+    }
+    return chain;
  }

Add error handling for unsupported chain IDs in Wallet.js
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