Skip to content

Commit cf02cbf

Browse files
[wagmi-adapter] Add onConnect callback (#8131)
1 parent f152139 commit cf02cbf

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

.changeset/famous-places-hug.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/wagmi-adapter": patch
3+
---
4+
5+
Add onConnect callback

packages/wagmi-adapter/src/connector.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ import {
99
type MultiStepAuthArgsType,
1010
type SingleStepAuthArgsType,
1111
inAppWallet as thirdwebInAppWallet,
12+
type Wallet,
1213
} from "thirdweb/wallets";
1314

1415
export type InAppWalletParameters = Prettify<
1516
InAppWalletCreationOptions & {
1617
client: ThirdwebClient;
1718
ecosystemId?: `ecosystem.${string}`;
19+
onConnect?: (wallet: Wallet) => void;
1820
}
1921
>;
2022
export type InAppWalletConnector = ReturnType<typeof inAppWalletConnector>;
@@ -106,6 +108,7 @@ export function inAppWalletConnector(
106108
chain: defineChain(chainId),
107109
client,
108110
wallets: [wallet],
111+
onConnect: args.onConnect,
109112
});
110113

111114
const account = wallet.getAccount();
@@ -140,6 +143,7 @@ export function inAppWalletConnector(
140143
rawStorage?.setItem(connectedWalletIdsKey, JSON.stringify([wallet.id]));
141144
rawStorage?.setItem(activeWalletIdKey, wallet.id);
142145
await config.storage?.setItem("thirdweb:lastChainId", chain.id);
146+
args.onConnect?.(wallet);
143147
return { accounts: [getAddress(account.address)], chainId: chain.id };
144148
},
145149
disconnect: async () => {
@@ -166,6 +170,7 @@ export function inAppWalletConnector(
166170
chain,
167171
client,
168172
wallets: [wallet],
173+
onConnect: args.onConnect,
169174
});
170175
}
171176
return EIP1193.toProvider({

0 commit comments

Comments
 (0)