Skip to content

Commit ee1bc3e

Browse files
[SDK] fix: show token + dollar values for wallet balances (#6240)
1 parent e9ab8cb commit ee1bc3e

File tree

7 files changed

+88
-15
lines changed

7 files changed

+88
-15
lines changed

.changeset/gentle-boats-grin.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+
Dont display dollar and token values for wallet balances

packages/thirdweb/src/extensions/erc1155/drops/read/canClaim.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,24 @@ export type CanClaimResult = {
1616
reason?: string;
1717
};
1818

19+
/**
20+
* Check if a user can claim a drop.
21+
*
22+
* @param options - The options for the transaction.
23+
* @returns Whether the user can claim the drop.
24+
*
25+
* @example
26+
* ```ts
27+
* const claimResult = await canClaim({
28+
* contract: contract,
29+
* claimer: "0x1234567890123456789012345678901234567890",
30+
* quantity: "1",
31+
* tokenId: 0n,
32+
* });
33+
* ```
34+
*
35+
* @extension ERC1155
36+
*/
1937
export async function canClaim(
2038
options: BaseTransactionOptions<CanClaimParams>,
2139
): Promise<CanClaimResult> {

packages/thirdweb/src/extensions/erc20/drops/read/canClaim.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ export type CanClaimResult = {
1515
reason?: string;
1616
};
1717

18+
/**
19+
* Check if a user can claim a drop.
20+
*
21+
* @param options - The options for the transaction.
22+
* @returns Whether the user can claim the drop.
23+
*
24+
* @example
25+
* ```ts
26+
* const claimResult = await canClaim({
27+
* contract: contract,
28+
* claimer: "0x1234567890123456789012345678901234567890",
29+
* quantity: "1",
30+
* });
31+
* ```
32+
*
33+
* @extension ERC20
34+
*/
1835
export async function canClaim(
1936
options: BaseTransactionOptions<CanClaimParams>,
2037
): Promise<CanClaimResult> {

packages/thirdweb/src/extensions/erc721/drops/read/canClaim.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ export type CanClaimResult = {
1515
reason?: string;
1616
};
1717

18+
/**
19+
* Check if a user can claim a drop.
20+
*
21+
* @param options - The options for the transaction.
22+
* @returns Whether the user can claim the drop.
23+
*
24+
* @example
25+
* ```ts
26+
* const claimResult = await canClaim({
27+
* contract: contract,
28+
* claimer: "0x1234567890123456789012345678901234567890",
29+
* quantity: "1",
30+
* });
31+
* ```
32+
*
33+
* @extension ERC721
34+
*/
1835
export async function canClaim(
1936
options: BaseTransactionOptions<CanClaimParams>,
2037
): Promise<CanClaimResult> {

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.tsx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { Container } from "../../../components/basic.js";
2323
import { Button } from "../../../components/buttons.js";
2424
import { Text } from "../../../components/text.js";
2525
import { Blobbie } from "../../Blobbie.js";
26+
import { formatTokenBalance } from "../formatTokenBalance.js";
2627
import { FiatValue } from "./swap/FiatValue.js";
2728
import type { TokenBalance } from "./swap/PaymentSelectionScreen.js";
2829

@@ -116,13 +117,26 @@ function TokenBalanceRow(props: {
116117
</Container>
117118
</Container>
118119
<Container flex="row" center="y" gap="3xs" color="secondaryText">
119-
<FiatValue
120-
tokenAmount={tokenBalance.balance.displayValue}
121-
token={tokenBalance.token}
122-
chain={tokenBalance.chain}
123-
client={client}
124-
size="xs"
125-
/>
120+
<Container
121+
flex="column"
122+
color="secondaryText"
123+
gap="3xs"
124+
style={{
125+
justifyContent: "flex-end",
126+
alignItems: "flex-end",
127+
}}
128+
>
129+
<Text size="xs" color="primaryText">
130+
{formatTokenBalance(tokenBalance.balance, true, 2)}
131+
</Text>
132+
<FiatValue
133+
tokenAmount={tokenBalance.balance.displayValue}
134+
token={tokenBalance.token}
135+
chain={tokenBalance.chain}
136+
client={client}
137+
size="xs"
138+
/>
139+
</Container>
126140
<ChevronRightIcon width={iconSize.md} height={iconSize.md} />
127141
</Container>
128142
</StyledButton>

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/BuyTokenInput.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,13 @@ export function BuyTokenInput(props: {
122122
</Container>
123123
</div>
124124

125-
<Container flex="row" center="both">
125+
<Container
126+
flex="row"
127+
center="both"
128+
style={{
129+
height: fontSize.xl,
130+
}}
131+
>
126132
<FiatValue
127133
tokenAmount={props.value}
128134
token={props.token}

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/FiatValue.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ export function FiatValue(
4141
return <Skeleton width={"50px"} height={fontSize.lg} />;
4242
}
4343

44-
return (
45-
<Text {...props}>
46-
{cryptoToFiatQuery.data?.result
47-
? `$${formatNumber(cryptoToFiatQuery.data.result, 2)}`
48-
: "-"}
49-
</Text>
50-
);
44+
return cryptoToFiatQuery.data?.result ? (
45+
<Text {...props}>${formatNumber(cryptoToFiatQuery.data.result, 2)}</Text>
46+
) : null;
5147
}

0 commit comments

Comments
 (0)