File tree Expand file tree Collapse file tree 15 files changed +77
-31
lines changed
apps/playground-web/src/components/in-app-wallet Expand file tree Collapse file tree 15 files changed +77
-31
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 @@ -19,5 +19,17 @@ const getEcosystemWallet = () => {
1919export function EcosystemConnectEmbed (
2020 props ?: Omit < ConnectButtonProps , "client" | "theme" > ,
2121) {
22- return < StyledConnectEmbed { ...props } wallets = { [ getEcosystemWallet ( ) ] } /> ;
22+ return (
23+ < StyledConnectEmbed
24+ { ...props }
25+ wallets = { [ getEcosystemWallet ( ) ] }
26+ onConnect = { ( activeWallet , allConnectedWallets ) => {
27+ console . log ( "active wallet" , activeWallet . id ) ;
28+ console . log (
29+ "all connected wallets" ,
30+ allConnectedWallets . map ( ( wallet ) => wallet . id ) ,
31+ ) ;
32+ } }
33+ />
34+ ) ;
2335}
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 = (
4+ activeWallet : Wallet ,
5+ allConnectedWallets : Wallet [ ] ,
6+ ) => void ;
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import {
1616 useSiweAuth ,
1717} from "../../../../core/hooks/auth/useSiweAuth.js" ;
1818import type { ConnectEmbedProps } from "../../../../core/hooks/connection/ConnectEmbedProps.js" ;
19+ import type { OnConnectCallback } from "../../../../core/hooks/connection/types.js" ;
1920import { useActiveAccount } from "../../../../core/hooks/wallets/useActiveAccount.js" ;
2021import { useActiveWallet } from "../../../../core/hooks/wallets/useActiveWallet.js" ;
2122import { useIsAutoConnecting } from "../../../../core/hooks/wallets/useIsAutoConnecting.js" ;
@@ -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 @@ -6,6 +6,7 @@ import type { Wallet } from "../../../../../wallets/interfaces/wallet.js";
66import type { SmartWalletOptions } from "../../../../../wallets/smart/types.js" ;
77import type { WalletId } from "../../../../../wallets/wallet-types.js" ;
88import type { SiweAuthOptions } from "../../../../core/hooks/auth/useSiweAuth.js" ;
9+ import type { OnConnectCallback } from "../../../../core/hooks/connection/types.js" ;
910import { useActiveAccount } from "../../../../core/hooks/wallets/useActiveAccount.js" ;
1011import {
1112 useIsWalletModalOpen ,
@@ -26,7 +27,7 @@ type ConnectModalOptions = {
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 99 type SiweAuthOptions ,
1010 useSiweAuth ,
1111} from "../../../../core/hooks/auth/useSiweAuth.js" ;
12+ import type { OnConnectCallback } from "../../../../core/hooks/connection/types.js" ;
1213import { useActiveAccount } from "../../../../core/hooks/wallets/useActiveAccount.js" ;
1314import { useActiveWallet } from "../../../../core/hooks/wallets/useActiveWallet.js" ;
1415import { useSetActiveWallet } from "../../../../core/hooks/wallets/useSetActiveWallet.js" ;
@@ -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 ( ( ) => {
You can’t perform that action at this time.
0 commit comments