From 4c0641d28a37107e2c21be336b84b74e16313470 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Fri, 26 Sep 2025 13:39:25 +1200 Subject: [PATCH] [wagmi-adapter] Add onConnect callback --- .changeset/famous-places-hug.md | 5 +++++ packages/wagmi-adapter/src/connector.ts | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/famous-places-hug.md diff --git a/.changeset/famous-places-hug.md b/.changeset/famous-places-hug.md new file mode 100644 index 00000000000..e7fa4ff0f4c --- /dev/null +++ b/.changeset/famous-places-hug.md @@ -0,0 +1,5 @@ +--- +"@thirdweb-dev/wagmi-adapter": patch +--- + +Add onConnect callback diff --git a/packages/wagmi-adapter/src/connector.ts b/packages/wagmi-adapter/src/connector.ts index 1307d3f857a..1556bf33d92 100644 --- a/packages/wagmi-adapter/src/connector.ts +++ b/packages/wagmi-adapter/src/connector.ts @@ -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; } >; export type InAppWalletConnector = ReturnType; @@ -106,6 +108,7 @@ export function inAppWalletConnector( chain: defineChain(chainId), client, wallets: [wallet], + onConnect: args.onConnect, }); const account = wallet.getAccount(); @@ -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 () => { @@ -166,6 +170,7 @@ export function inAppWalletConnector( chain, client, wallets: [wallet], + onConnect: args.onConnect, }); } return EIP1193.toProvider({