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
5 changes: 5 additions & 0 deletions .changeset/two-pandas-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Add token details screen in token selection UI in SwapWidget, BridgeWidget
1 change: 1 addition & 0 deletions packages/thirdweb/src/react/web/ui/Bridge/FundWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export function FundWallet(props: FundWalletProps) {
>
<SelectToken
type="buy"
currency={props.currency}
selections={{
buyChainId: props.selectedToken?.chainId,
sellChainId: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,15 @@ export function SelectedTokenButton(props: {
{props.selectedToken?.isFetching ? (
<Skeleton width="60px" height={fontSize.md} />
) : (
<Text size="md" color="primaryText" weight={500}>
<Text
size="md"
color="primaryText"
weight={500}
style={{
whiteSpace: "nowrap",
maxWidth: "200px",
}}
>
{props.selectedToken?.data?.symbol}
</Text>
)}
Expand All @@ -138,8 +146,6 @@ export function SelectedTokenButton(props: {
size="xs"
color="secondaryText"
style={{
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
}}
>
Expand Down
28 changes: 27 additions & 1 deletion packages/thirdweb/src/react/web/ui/Bridge/swap-widget/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { useQuery } from "@tanstack/react-query";
import { useMemo } from "react";
import type { ThirdwebClient } from "../../../../../client/client.js";
import { getToken } from "../../../../../pay/convert/get-token.js";
import type { Wallet } from "../../../../../wallets/interfaces/wallet.js";
import { useActiveAccount } from "../../../../core/hooks/wallets/useActiveAccount.js";
import { useActiveWallet } from "../../../../core/hooks/wallets/useActiveWallet.js";
import { useActiveWalletChain } from "../../../../core/hooks/wallets/useActiveWalletChain.js";
import type { ActiveWalletInfo } from "./types.js";
import type { ActiveWalletInfo, TokenSelection } from "./types.js";

export function useActiveWalletInfo(
activeWalletOverride?: Wallet,
Expand All @@ -25,3 +28,26 @@ export function useActiveWalletInfo(
: undefined;
}, [activeAccount, activeWallet, activeChain, activeWalletOverride]);
}

export function useTokenPrice(options: {
token: TokenSelection | undefined;
client: ThirdwebClient;
}) {
return useQuery({
queryKey: ["token-price", options.token],
enabled: !!options.token,
queryFn: () => {
if (!options.token) {
throw new Error("Token is required");
}
return getToken(
options.client,
options.token.tokenAddress,
options.token.chainId,
);
},
refetchOnMount: false,
retry: false,
refetchOnWindowFocus: false,
});
}
Loading
Loading