Skip to content

Commit ab55aec

Browse files
[SDK] feat: Optional wallet activation during connection (#6105)
1 parent ca22e46 commit ab55aec

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

.changeset/thirty-cheetahs-matter.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Allow connecting wallets without setting them as active with useConnect

packages/thirdweb/src/react/core/account/provider.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import type React from "react";
44
import { createContext, useContext } from "react";
55
import type { ThirdwebClient } from "../../../client/client.js";
6-
import { isAddress } from "../../../utils/address.js";
76
/**
87
* Props for the <AccountProvider /> component
98
* @component
@@ -53,9 +52,6 @@ export function AccountProvider(
5352
"AccountProvider: No address passed. Ensure an address is always provided to the AccountProvider",
5453
);
5554
}
56-
if (!isAddress(props.address)) {
57-
throw new Error(`AccountProvider: Invalid address: ${props.address}`);
58-
}
5955
return (
6056
<AccountProviderContext.Provider value={props}>
6157
{props.children}

packages/thirdweb/src/react/core/utils/walletname.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function useWalletName(props: {
2424
/**
2525
* @internal Exported for tests only
2626
*/
27-
function getQueryKeys(props: {
27+
export function getQueryKeys(props: {
2828
id: WalletId;
2929
formatFn?: (str: string) => string;
3030
}) {
@@ -41,7 +41,7 @@ function getQueryKeys(props: {
4141
/**
4242
* @internal Exported for tests only
4343
*/
44-
async function fetchWalletName(props: {
44+
export async function fetchWalletName(props: {
4545
id: WalletId;
4646
formatFn?: (str: string) => string;
4747
}) {

packages/thirdweb/src/wallets/manager/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export type ConnectionManager = ReturnType<typeof createConnectionManager>;
2424
export type ConnectManagerOptions = {
2525
client: ThirdwebClient;
2626
accountAbstraction?: SmartWalletOptions;
27+
setWalletAsActive?: boolean;
2728
onConnect?: (wallet: Wallet) => void;
2829
};
2930

@@ -146,7 +147,9 @@ export function createConnectionManager(storage: AsyncStorage) {
146147
// add personal wallet to connected wallets list even if it's not the active one
147148
addConnectedWallet(wallet);
148149

149-
handleSetActiveWallet(activeWallet);
150+
if (options?.setWalletAsActive !== false) {
151+
handleSetActiveWallet(activeWallet);
152+
}
150153

151154
wallet.subscribe("accountChanged", async () => {
152155
// We reimplement connect here to prevent memory leaks

0 commit comments

Comments
 (0)