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/kind-pets-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

PayEmbed UI polish
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styled from "@emotion/styled";
import { ChevronRightIcon } from "@radix-ui/react-icons";
import { useState } from "react";
import type { Chain } from "../../../../../../chains/types.js";
import type { ThirdwebClient } from "../../../../../../client/client.js";
Expand All @@ -22,7 +23,7 @@ import { Container } from "../../../components/basic.js";
import { Button } from "../../../components/buttons.js";
import { Text } from "../../../components/text.js";
import { Blobbie } from "../../Blobbie.js";
import { formatTokenBalance } from "../formatTokenBalance.js";
import { FiatValue } from "./swap/FiatValue.js";
import type { TokenBalance } from "./swap/PaymentSelectionScreen.js";

export function WalletRowWithBalances(props: {
Expand Down Expand Up @@ -100,23 +101,29 @@ function TokenBalanceRow(props: {
onClick={() => onClick(tokenBalance.token, wallet)}
variant="secondary"
>
<TokenIcon
token={tokenBalance.token}
chain={tokenBalance.chain}
size="md"
client={client}
/>
<Container flex="column" gap="3xs">
<Text size="xs" color="primaryText">
{tokenBalance.token.symbol}
</Text>
{chainInfo && <Text size="xs">{chainInfo.name}</Text>}
<Container flex="row" center="y" gap="md">
<TokenIcon
token={tokenBalance.token}
chain={tokenBalance.chain}
size="md"
client={client}
/>
<Container flex="column" gap="3xs">
<Text size="xs" color="primaryText">
{tokenBalance.token.symbol}
</Text>
{chainInfo && <Text size="xs">{chainInfo.name}</Text>}
</Container>
</Container>
<div style={{ flex: 1 }} />
<Container flex="row" center="y" gap="3xs">
<Text size="xs" color="secondaryText">
{formatTokenBalance(tokenBalance.balance, true)}
</Text>
<Container flex="row" center="y" gap="3xs" color="secondaryText">
<FiatValue
tokenAmount={tokenBalance.balance.displayValue}
token={tokenBalance.token}
chain={tokenBalance.chain}
client={client}
size="xs"
/>
<ChevronRightIcon width={iconSize.md} height={iconSize.md} />
</Container>
</StyledButton>
);
Expand Down Expand Up @@ -149,7 +156,7 @@ export function WalletRow(props: {
width={props.iconSize ? iconSize[props.iconSize] : iconSize.md}
height={props.iconSize ? iconSize[props.iconSize] : iconSize.md}
style={{
borderRadius: "100%",
borderRadius: radius.sm,
overflow: "hidden",
border: `1px solid ${theme.colors.borderColor}`,
}}
Expand All @@ -166,7 +173,7 @@ export function WalletRow(props: {
style={{
width: iconSize.md,
height: iconSize.md,
borderRadius: "100%",
borderRadius: radius.sm,
overflow: "hidden",
border: `1px solid ${theme.colors.borderColor}`,
}}
Expand All @@ -186,7 +193,7 @@ const StyledButton = /* @__PURE__ */ styled(Button)((_) => {
const theme = useCustomTheme();
return {
background: theme.colors.tertiaryBg,
justifyContent: "flex-start",
justifyContent: "space-between",
flexDirection: "row",
padding: spacing.sm,
gap: spacing.sm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,25 +166,37 @@ export function PaymentSelectionScreen(props: {
return <LoadingScreen />;
}

const filteredWallets = Array.from(walletsAndBalances.data?.entries() || [])
.filter(([w]) => !props.hiddenWallets?.includes(w.id))
.filter(([, balances]) => {
const hasEnoughBalance = balances.some((b) => b.balance.value > 0);
return hasEnoughBalance;
});

return (
<Container>
<Container flex="column" gap="xs">
{Array.from(walletsAndBalances.data?.entries() || [])
.filter(([w]) => !props.hiddenWallets?.includes(w.id))
.map(([w, balances]) => {
const address = w.getAccount()?.address;
if (!address) return null;
return (
<WalletRowWithBalances
key={w.id}
wallet={w}
balances={balances}
client={props.client}
address={address}
onClick={props.onSelect}
/>
);
})}
{filteredWallets.length === 0 && (
<Container flex="column" gap="xs" py="md">
<Text size="xs" color="secondaryText" center>
<i>Insufficient funds in connected wallets</i>
</Text>
</Container>
)}
{filteredWallets.map(([w, balances]) => {
const address = w.getAccount()?.address;
if (!address) return null;
return (
<WalletRowWithBalances
key={w.id}
wallet={w}
balances={balances}
client={props.client}
address={address}
onClick={props.onSelect}
/>
);
})}
{!hideConnectButton && (
<Button
variant="secondary"
Expand Down
7 changes: 6 additions & 1 deletion packages/thirdweb/src/react/web/utils/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ export const defaultMessage = "Unable to get price quote";
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
export function getErrorMessage(err: any): ApiError {
if (typeof err.error === "object" && err.error.code) {
return err.error;
if (err.error.code === "MINIMUM_PURCHASE_AMOUNT") {
return {
code: "MINIMUM_PURCHASE_AMOUNT",
message: "Purchase amount is too low",
};
}
}
return {
code: "UNABLE_TO_GET_PRICE_QUOTE",
Expand Down
Loading