Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ export function ProjectWalletDetailsSection(props: ProjectWalletControlsProps) {
<Dialog onOpenChange={setIsSwapOpen} open={isSwapOpen}>
<DialogContent className="gap-0 p-0 overflow-hidden max-w-md">
<SwapProjectWalletModalContent
client={props.client}
chainId={selectedChainId}
tokenAddress={selectedTokenAddress}
walletAddress={projectWallet.address}
Expand Down Expand Up @@ -613,6 +614,7 @@ function ChangeProjectWalletDialogContent(props: {
}

type SwapProjectWalletModalContentProps = {
client: ThirdwebClient;
chainId: number;
tokenAddress: string | undefined;
walletAddress: string;
Expand All @@ -630,6 +632,7 @@ function SwapProjectWalletModalContent(
props: SwapProjectWalletModalContentProps,
) {
const {
client,
chainId,
tokenAddress,
walletAddress,
Expand All @@ -655,6 +658,7 @@ function SwapProjectWalletModalContent(
if (!secretKey.trim()) {
return null;
}
// use the inputted secret key to create the client used for the serverWallet
return createThirdwebClient({
clientId: publishableKey,
secretKey: secretKey.trim(),
Expand Down Expand Up @@ -777,9 +781,9 @@ function SwapProjectWalletModalContent(
</DialogHeader>

<div className="px-4 pb-4 lg:px-6 lg:pb-6 flex justify-center">
{swapClient && activeWallet && (
{activeWallet && (
<SwapWidget
client={swapClient}
client={props.client}
prefill={{
sellToken: {
chainId: chainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

// owned tokens
const ownedTokensQuery = useTokenBalances({
clientId: props.client.clientId,
client: props.client,

Check warning on line 93 in packages/thirdweb/src/react/web/ui/Bridge/swap-widget/select-token-ui.tsx

View check run for this annotation

Codecov / codecov/patch

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

Added line #L93 was not covered by tests
chainId: selectedChain?.chainId,
limit,
page: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import type { ThirdwebClient } from "../../../../../client/client.js";
import { isAddress } from "../../../../../utils/address.js";
import { getThirdwebBaseUrl } from "../../../../../utils/domains.js";
import { getClientFetch } from "../../../../../utils/fetch.js";

export function useTokens(options: {
client: ThirdwebClient;
Expand Down Expand Up @@ -72,7 +73,7 @@
};

export function useTokenBalances(options: {
clientId: string;
client: ThirdwebClient;
page: number;
limit: number;
walletAddress: string | undefined;
Expand Down Expand Up @@ -101,11 +102,8 @@
url.searchParams.set("sortOrder", "desc");
url.searchParams.set("includeWithoutPrice", "false"); // filter out tokens with no price

const response = await fetch(url.toString(), {
headers: {
"x-client-id": options.clientId,
},
});
const clientFetch = getClientFetch(options.client);
const response = await clientFetch(url.toString());

Check warning on line 106 in packages/thirdweb/src/react/web/ui/Bridge/swap-widget/use-tokens.ts

View check run for this annotation

Codecov / codecov/patch

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

Added lines #L105 - L106 were not covered by tests

if (!response.ok) {
throw new Error(
Expand Down
Loading