Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/famous-places-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@thirdweb-dev/wagmi-adapter": patch
---

Add onConnect callback
5 changes: 5 additions & 0 deletions packages/wagmi-adapter/src/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import {
type MultiStepAuthArgsType,
type SingleStepAuthArgsType,
inAppWallet as thirdwebInAppWallet,
type Wallet,
} from "thirdweb/wallets";

export type InAppWalletParameters = Prettify<
InAppWalletCreationOptions & {
client: ThirdwebClient;
ecosystemId?: `ecosystem.${string}`;
onConnect?: (wallet: Wallet) => void;
}
Comment on lines +19 to 20
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.

>;
export type InAppWalletConnector = ReturnType<typeof inAppWalletConnector>;
Expand Down Expand Up @@ -106,6 +108,7 @@ export function inAppWalletConnector(
chain: defineChain(chainId),
client,
wallets: [wallet],
onConnect: args.onConnect,
});

const account = wallet.getAccount();
Expand Down Expand Up @@ -140,6 +143,7 @@ export function inAppWalletConnector(
rawStorage?.setItem(connectedWalletIdsKey, JSON.stringify([wallet.id]));
rawStorage?.setItem(activeWalletIdKey, wallet.id);
await config.storage?.setItem("thirdweb:lastChainId", chain.id);
args.onConnect?.(wallet);
return { accounts: [getAddress(account.address)], chainId: chain.id };
},
disconnect: async () => {
Expand All @@ -166,6 +170,7 @@ export function inAppWalletConnector(
chain,
client,
wallets: [wallet],
onConnect: args.onConnect,
});
}
return EIP1193.toProvider({
Expand Down
Loading