Skip to content

Commit 75e9be0

Browse files
[SDK] Update token balances query to use client instead of clientId (#8507)
1 parent a704c3f commit 75e9be0

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/project-wallet/project-wallet-details.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ export function ProjectWalletDetailsSection(props: ProjectWalletControlsProps) {
419419
<Dialog onOpenChange={setIsSwapOpen} open={isSwapOpen}>
420420
<DialogContent className="gap-0 p-0 overflow-hidden max-w-md">
421421
<SwapProjectWalletModalContent
422+
client={props.client}
422423
chainId={selectedChainId}
423424
tokenAddress={selectedTokenAddress}
424425
walletAddress={projectWallet.address}
@@ -613,6 +614,7 @@ function ChangeProjectWalletDialogContent(props: {
613614
}
614615

615616
type SwapProjectWalletModalContentProps = {
617+
client: ThirdwebClient;
616618
chainId: number;
617619
tokenAddress: string | undefined;
618620
walletAddress: string;
@@ -630,6 +632,7 @@ function SwapProjectWalletModalContent(
630632
props: SwapProjectWalletModalContentProps,
631633
) {
632634
const {
635+
client,
633636
chainId,
634637
tokenAddress,
635638
walletAddress,
@@ -655,6 +658,7 @@ function SwapProjectWalletModalContent(
655658
if (!secretKey.trim()) {
656659
return null;
657660
}
661+
// use the inputted secret key to create the client used for the serverWallet
658662
return createThirdwebClient({
659663
clientId: publishableKey,
660664
secretKey: secretKey.trim(),
@@ -777,9 +781,9 @@ function SwapProjectWalletModalContent(
777781
</DialogHeader>
778782

779783
<div className="px-4 pb-4 lg:px-6 lg:pb-6 flex justify-center">
780-
{swapClient && activeWallet && (
784+
{activeWallet && (
781785
<SwapWidget
782-
client={swapClient}
786+
client={props.client}
783787
prefill={{
784788
sellToken: {
785789
chainId: chainId,

packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export function SelectToken(props: SelectTokenUIProps) {
9090

9191
// owned tokens
9292
const ownedTokensQuery = useTokenBalances({
93-
clientId: props.client.clientId,
93+
client: props.client,
9494
chainId: selectedChain?.chainId,
9595
limit,
9696
page: 1,

packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { tokens } from "../../../../../bridge/Token.js";
44
import type { ThirdwebClient } from "../../../../../client/client.js";
55
import { isAddress } from "../../../../../utils/address.js";
66
import { getThirdwebBaseUrl } from "../../../../../utils/domains.js";
7+
import { getClientFetch } from "../../../../../utils/fetch.js";
78

89
export function useTokens(options: {
910
client: ThirdwebClient;
@@ -72,7 +73,7 @@ type TokenBalancesResponse = {
7273
};
7374

7475
export function useTokenBalances(options: {
75-
clientId: string;
76+
client: ThirdwebClient;
7677
page: number;
7778
limit: number;
7879
walletAddress: string | undefined;
@@ -101,11 +102,8 @@ export function useTokenBalances(options: {
101102
url.searchParams.set("sortOrder", "desc");
102103
url.searchParams.set("includeWithoutPrice", "false"); // filter out tokens with no price
103104

104-
const response = await fetch(url.toString(), {
105-
headers: {
106-
"x-client-id": options.clientId,
107-
},
108-
});
105+
const clientFetch = getClientFetch(options.client);
106+
const response = await clientFetch(url.toString());
109107

110108
if (!response.ok) {
111109
throw new Error(

0 commit comments

Comments
 (0)