File tree Expand file tree Collapse file tree 14 files changed +61
-30
lines changed Expand file tree Collapse file tree 14 files changed +61
-30
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " thirdweb " : minor
3+ ---
4+
5+ Add all connected wallets in all onConnect callbacks
Original file line number Diff line number Diff line change @@ -17,7 +17,14 @@ export type {
1717 ConnectButton_detailsButtonOptions ,
1818 ConnectButton_detailsModalOptions ,
1919 ConnectButtonProps ,
20+ DirectPaymentOptions ,
21+ FundWalletOptions ,
22+ PaymentInfo ,
23+ PayUIOptions ,
24+ TransactionOptions ,
2025} from "../react/core/hooks/connection/ConnectButtonProps.js" ;
26+ export type { ConnectEmbedProps } from "../react/core/hooks/connection/ConnectEmbedProps.js" ;
27+ export type { OnConnectCallback } from "../react/core/hooks/connection/types.js" ;
2128export { useContractEvents } from "../react/core/hooks/contract/useContractEvents.js" ;
2229// contract
2330export { useReadContract } from "../react/core/hooks/contract/useReadContract.js" ;
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export type {
2323 TransactionOptions ,
2424} from "../react/core/hooks/connection/ConnectButtonProps.js" ;
2525export type { ConnectEmbedProps } from "../react/core/hooks/connection/ConnectEmbedProps.js" ;
26+ export type { OnConnectCallback } from "../react/core/hooks/connection/types.js" ;
2627export { useContractEvents } from "../react/core/hooks/contract/useContractEvents.js" ;
2728// contract
2829export { useReadContract } from "../react/core/hooks/contract/useReadContract.js" ;
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import type {
2525 TokenInfo ,
2626} from "../../utils/defaultTokens.js" ;
2727import type { SiweAuthOptions } from "../auth/useSiweAuth.js" ;
28+ import type { OnConnectCallback } from "./types.js" ;
2829
2930export type PaymentInfo = Prettify <
3031 {
@@ -937,13 +938,14 @@ export type ConnectButtonProps = {
937938 *
938939 * ```tsx
939940 * <ConnectButton
940- * onConnect={(wallet) => {
941- * console.log("connected to", wallet)
941+ * onConnect={(activeWallet, allConnectedWallets) => {
942+ * console.log("connected to", activeWallet)
943+ * console.log("all connected wallets", allConnectedWallets)
942944 * }}
943945 * />
944946 * ```
945947 */
946- onConnect ?: ( wallet : Wallet ) => void ;
948+ onConnect ?: OnConnectCallback ;
947949
948950 /**
949951 * Called when the user disconnects the wallet by clicking on the "Disconnect Wallet" button in the `ConnectButton`'s Details Modal.
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import type { WelcomeScreen } from "../../../web/ui/ConnectWallet/screens/types.
88import type { LocaleId } from "../../../web/ui/types.js" ;
99import type { Theme } from "../../design-system/index.js" ;
1010import type { SiweAuthOptions } from "../auth/useSiweAuth.js" ;
11+ import type { OnConnectCallback } from "./types.js" ;
1112
1213export type ConnectEmbedProps = {
1314 /**
@@ -213,14 +214,15 @@ export type ConnectEmbedProps = {
213214 *
214215 * ```tsx
215216 * <ConnectEmbed
216- * onConnect={(wallet) => {
217- * console.log("connected to", wallet)
217+ * onConnect={(activeWallet, allConnectedWallets) => {
218+ * console.log("connected to", activeWallet)
219+ * console.log("all connected wallets", allConnectedWallets)
218220 * }}
219221 * />
220222 * ```
221223 * ```
222224 */
223- onConnect ?: ( wallet : Wallet ) => void ;
225+ onConnect ?: OnConnectCallback ;
224226
225227 /**
226228 * By default, A "Powered by Thirdweb" branding is shown at the bottom of the embed.
Original file line number Diff line number Diff line change 1+ import type { Wallet } from "../../../../wallets/interfaces/wallet.js" ;
2+
3+ export type OnConnectCallback = ( activeWallet : Wallet , otherWallets : Wallet [ ] ) => void ;
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ import type { ConnectLocale } from "../locale/types.js";
4040import type { WelcomeScreen } from "../screens/types.js" ;
4141import { ConnectModalContent } from "./ConnectModalContent.js" ;
4242import { useSetupScreen } from "./screen.js" ;
43+ import type { OnConnectCallback } from "../../../../core/hooks/connection/types.js" ;
4344
4445/**
4546 * An inline wallet connection component that allows to:
@@ -354,7 +355,7 @@ const ConnectEmbedContent = (props: {
354355 | true
355356 | undefined ;
356357 localeId : LocaleId ;
357- onConnect : ( ( wallet : Wallet ) => void ) | undefined ;
358+ onConnect : OnConnectCallback | undefined ;
358359 recommendedWallets : Wallet [ ] | undefined ;
359360 showAllWallets : boolean | undefined ;
360361 hiddenWallets : WalletId [ ] | undefined ;
Original file line number Diff line number Diff line change @@ -19,14 +19,15 @@ import type { ConnectLocale } from "../locale/types.js";
1919import type { WelcomeScreen } from "../screens/types.js" ;
2020import { ConnectModalContent } from "./ConnectModalContent.js" ;
2121import { useSetupScreen } from "./screen.js" ;
22+ import type { OnConnectCallback } from "../../../../core/hooks/connection/types.js" ;
2223
2324type ConnectModalOptions = {
2425 onClose ?: ( ) => void ;
2526 shouldSetActive : boolean ;
2627 wallets : Wallet [ ] ;
2728 accountAbstraction : SmartWalletOptions | undefined ;
2829 auth : SiweAuthOptions | undefined ;
29- onConnect : ( ( wallet : Wallet ) => void ) | undefined ;
30+ onConnect : OnConnectCallback | undefined ;
3031 size : "compact" | "wide" ;
3132 welcomeScreen : WelcomeScreen | undefined ;
3233 meta : {
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ import {
2828} from "./ConnectModalSkeleton.js" ;
2929import { SmartConnectUI } from "./SmartWalletConnectUI.js" ;
3030import { type ScreenSetup , ScreenSetupContext } from "./screen.js" ;
31+ import type { OnConnectCallback } from "../../../../core/hooks/connection/types.js" ;
3132
3233const AllWalletsUI = /* @__PURE__ */ lazy ( ( ) => import ( "./AllWalletsUI.js" ) ) ;
3334
@@ -43,7 +44,7 @@ export const ConnectModalContent = (props: {
4344 wallets : Wallet [ ] ;
4445 accountAbstraction : SmartWalletOptions | undefined ;
4546 auth : SiweAuthOptions | undefined ;
46- onConnect : ( ( wallet : Wallet ) => void ) | undefined ;
47+ onConnect : OnConnectCallback | undefined ;
4748 size : "compact" | "wide" ;
4849 meta : {
4950 title ?: string ;
@@ -93,7 +94,7 @@ export const ConnectModalContent = (props: {
9394 }
9495
9596 if ( props . onConnect ) {
96- props . onConnect ( wallet ) ;
97+ props . onConnect ( wallet , connectionManager . connectedWallets . getValue ( ) ) ;
9798 }
9899
99100 onModalUnmount ( ( ) => {
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import { getConnectLocale } from "./locale/getConnectLocale.js";
1616import type { ConnectLocale } from "./locale/types.js" ;
1717import ConnectModal from "./Modal/ConnectModal.js" ;
1818import type { WelcomeScreen } from "./screens/types.js" ;
19+ import type { OnConnectCallback } from "../../../core/hooks/connection/types.js" ;
1920
2021/**
2122 * hook that allows you to open the Connect UI in a Modal to prompt the user to connect wallet.
@@ -90,7 +91,7 @@ export function useConnectModal() {
9091
9192function Modal (
9293 props : UseConnectModalOptions & {
93- onConnect : ( wallet : Wallet ) => void ;
94+ onConnect : OnConnectCallback ;
9495 onClose : ( ) => void ;
9596 connectLocale : ConnectLocale ;
9697 } ,
You can’t perform that action at this time.
0 commit comments