Skip to content

Conversation

@joaquim-verges
Copy link
Member

@joaquim-verges joaquim-verges commented Sep 26, 2025


PR-Codex overview

This PR introduces an onConnect callback to the InAppWalletParameters type and updates the inAppWalletConnector function to support this new feature, allowing developers to execute custom logic when a wallet is connected.

Detailed summary

  • Added onConnect optional callback to InAppWalletParameters.
  • Updated inAppWalletConnector to accept and handle onConnect.
  • Called args.onConnect(wallet) upon successful wallet connection.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features
    • Added an optional onConnect callback in the wagmi adapter that runs when a wallet connects or reconnects, letting apps perform custom actions (e.g., UI updates, analytics).
  • Chores
    • Patch release of the wagmi adapter to include the new callback capability.

@vercel
Copy link

vercel bot commented Sep 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
docs-v2 Ready Ready Preview Comment Sep 26, 2025 2:18am
nebula Ready Ready Preview Comment Sep 26, 2025 2:18am
thirdweb_playground Canceled Canceled Sep 26, 2025 2:18am
thirdweb-www Ready Ready Preview Comment Sep 26, 2025 2:18am
wallet-ui Ready Ready Preview Comment Sep 26, 2025 2:18am

@changeset-bot
Copy link

changeset-bot bot commented Sep 26, 2025

🦋 Changeset detected

Latest commit: 4c0641d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@thirdweb-dev/wagmi-adapter Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@joaquim-verges joaquim-verges marked this pull request as ready for review September 26, 2025 01:39
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 26, 2025

Walkthrough

Adds an optional onConnect callback to InAppWalletParameters, threads it into wallet autoConnect flows for reconnect and provider initialization in the wagmi adapter, and adds a changeset entry for a patch release of @thirdweb-dev/wagmi-adapter.

Changes

Cohort / File(s) Change Summary
Release metadata
\.changeset/famous-places-hug.md
Added changeset for a patch bump of @thirdweb-dev/wagmi-adapter, noting addition of onConnect callback.
Wagmi adapter connector updates
packages/wagmi-adapter/src/connector.ts
Added onConnect?: (wallet: Wallet) => void to InAppWalletParameters; imported type Wallet from thirdweb/wallets; passed onConnect through to autoConnect in reconnect and provider-init paths; invoked args.onConnect?.(wallet) after successful connect.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as App
  participant Connector as wagmi-adapter Connector
  participant Wallet as InApp Wallet

  rect rgba(200,220,255,0.20)
    note right of App: App initiates connect (initial or reconnect) with optional onConnect
    App->>Connector: connect({ ..., onConnect })
    alt Reconnecting path
      Connector->>Wallet: autoConnect({ ..., onConnect })
      Wallet-->>Connector: wallet instance
    else Provider init path
      Connector->>Wallet: autoConnect({ ..., onConnect })
      Wallet-->>Connector: wallet instance
    end
    Connector->>Connector: args.onConnect?.(wallet)
    Note right of Connector: onConnect callback executed with connected wallet
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description still contains the raw template comments and lacks the required structured sections for the title, reviewer notes, and testing instructions, instead only providing a PR-Codex overview. Because the template placeholders were not replaced with actual content, the description does not adhere to the repository’s required format. Please replace the template comments with a proper PR title following the “[SDK/Dashboard/Portal] Feature/Fix: Concise title” format, add a “Notes for the reviewer” section summarizing any important context, and include a “How to test” section with clear steps to verify the new onConnect callback functionality.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title “[wagmi-adapter] Add onConnect callback” succinctly and accurately reflects the main change in this PR by indicating the addition of an onConnect callback in the wagmi-adapter package. It is concise, specific, and follows the expected bracketed module prefix convention.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch _wagmi-adapter_Add_onConnect_callback

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.

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

Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@codecov
Copy link

codecov bot commented Sep 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.28%. Comparing base (f152139) to head (4c0641d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8131   +/-   ##
=======================================
  Coverage   56.28%   56.28%           
=======================================
  Files         906      906           
  Lines       59193    59193           
  Branches     4172     4172           
=======================================
  Hits        33316    33316           
  Misses      25772    25772           
  Partials      105      105           
Flag Coverage Δ
packages 56.28% <ø> (ø)
🚀 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

🧹 Nitpick comments (3)
packages/wagmi-adapter/src/connector.ts (3)

111-112: Forward only defined callbacks to autoConnect.

Passing onConnect: undefined creates noisy runtime payloads and obscures intent. Wrap the property so it’s sent only when provided.

-        await autoConnect({
-          chain: defineChain(chainId),
-          client,
-          wallets: [wallet],
-          onConnect: args.onConnect,
-        });
+        await autoConnect({
+          chain: defineChain(chainId),
+          client,
+          wallets: [wallet],
+          ...(args.onConnect && { onConnect: args.onConnect }),
+        });

146-147: Guard callback for smart-account wrappers as well.

When smartAccount is enabled, wallet becomes an InAppWalletWithSmartAccount, which won't type-match (wallet: InAppWallet) => void and could cause runtime surprises for consumers expecting the base wallet. Consider normalizing to the underlying wallet instance before invoking the callback.

You can normalize like this:

-      args.onConnect?.(wallet);
+      if (args.onConnect) {
+        const baseWallet = "getPersonalWallet" in wallet
+          ? wallet.getPersonalWallet()
+          : wallet;
+        args.onConnect(baseWallet);
+      }

170-174: Same optional spread nit as above.

Keep the payload clean by omitting the onConnect key when it’s not supplied.

        await autoConnect({
          chain,
          client,
          wallets: [wallet],
-          onConnect: args.onConnect,
+          ...(args.onConnect && { onConnect: args.onConnect }),
        });
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f152139 and 4c0641d.

📒 Files selected for processing (2)
  • .changeset/famous-places-hug.md (1 hunks)
  • packages/wagmi-adapter/src/connector.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from @/types where applicable
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size

Files:

  • packages/wagmi-adapter/src/connector.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • packages/wagmi-adapter/src/connector.ts
packages/wagmi-adapter/**

📄 CodeRabbit inference engine (CLAUDE.md)

Wagmi ecosystem integration is in packages/wagmi-adapter/

Files:

  • packages/wagmi-adapter/src/connector.ts
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

.changeset/*.md: Each change in packages/* must include a changeset for the appropriate package
Version bump rules: patch for non‑API changes; minor for new/modified public API

Files:

  • .changeset/famous-places-hug.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Size
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
.changeset/famous-places-hug.md (1)

1-5: Looks good — changeset formatted correctly.

The package bump level and summary align with the surfaced API change. 👍

Comment on lines +19 to 20
onConnect?: (wallet: Wallet) => void;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Type mismatch: callback should receive InAppWallet type.

ecosystemWallet / thirdwebInAppWallet both return an InAppWallet instance (or InAppWalletWithSmartAccount), not the broader Wallet union. Typing onConnect as (wallet: Wallet) => void forces downstream consumers to handle wallet shapes we never pass here and can break inference in existing code that narrows to in-app wallets. Please type the callback to the concrete in-app wallet type we actually hand back.

Apply this diff to align the type:

-import {
-  EIP1193,
-  ecosystemWallet,
-  type InAppWalletConnectionOptions,
-  type InAppWalletCreationOptions,
-  type MultiStepAuthArgsType,
-  type SingleStepAuthArgsType,
-  inAppWallet as thirdwebInAppWallet,
-  type Wallet,
-} from "thirdweb/wallets";
+import {
+  EIP1193,
+  ecosystemWallet,
+  type InAppWallet,
+  type InAppWalletConnectionOptions,
+  type InAppWalletCreationOptions,
+  type MultiStepAuthArgsType,
+  type SingleStepAuthArgsType,
+  inAppWallet as thirdwebInAppWallet,
+} from "thirdweb/wallets";
@@
-    ecosystemId?: `ecosystem.${string}`;
-    onConnect?: (wallet: Wallet) => void;
+    ecosystemId?: `ecosystem.${string}`;
+    onConnect?: (wallet: InAppWallet) => void;
🤖 Prompt for AI Agents
In packages/wagmi-adapter/src/connector.ts around lines 19-20, the onConnect
callback is currently typed as (wallet: Wallet) => void but callers only ever
pass InAppWallet (or InAppWalletWithSmartAccount); change the onConnect
parameter type to the concrete in-app wallet type (e.g. InAppWallet |
InAppWalletWithSmartAccount or the shared InAppWallet type used in the
codebase), and add the necessary import(s) at the top of the file; update any
related exports/usages to reflect the new signature so downstream consumers get
the correct narrowed type.

@github-actions
Copy link
Contributor

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 64.09 KB (0%) 1.3 s (0%) 239 ms (+170.78% 🔺) 1.6 s
thirdweb (cjs) 361.63 KB (0%) 7.3 s (0%) 784 ms (+6.3% 🔺) 8.1 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 86 ms (+2046.97% 🔺) 200 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 41 ms (+1900% 🔺) 51 ms
thirdweb/react (minimal + tree-shaking) 19.14 KB (0%) 383 ms (0%) 67 ms (+1538.58% 🔺) 450 ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants