Skip to content
Merged
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 @@ -506,34 +506,6 @@
});
const token = tokenQuery.data;

if (tokenQuery.isPending) {
return (
<Container
flex="column"
center="both"
expand
style={{ minHeight: "350px" }}
>
<Spinner size="lg" color="secondaryText" />
</Container>
);
}

if (!token) {
return (
<Container
flex="column"
center="both"
expand
style={{ minHeight: "350px" }}
>
<Text size="sm" color="secondaryText">
Token not found
</Text>
</Container>
);
}

const isNativeToken = isNativeTokenAddress(props.tokenAddress);
const explorerLink = isNativeToken
? `https://thirdweb.com/${props.chainId}`
Expand All @@ -543,7 +515,7 @@
<Container
flex="column"
expand
style={{ minHeight: "350px" }}
style={{ minHeight: "450px" }}

Check warning on line 518 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#L518

Added line #L518 was not covered by tests
animate="fadein"
>
{/* Header */}
Expand All @@ -552,125 +524,136 @@
</Container>
<Line dashed />

{/* Content */}
<Container flex="column" gap="md" px="md" py="lg">
{/* name + icon */}
<Container
flex="row"
style={{
justifyContent: "space-between",
alignItems: "center",
}}
>
{tokenQuery.isPending ? (
<Container flex="column" center="both" expand>
<Spinner size="lg" color="secondaryText" />
</Container>
) : !token ? (
<Container flex="column" center="both" expand>

Check warning on line 532 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#L527-L532

Added lines #L527 - L532 were not covered by tests
<Text size="sm" color="secondaryText">
Name
Token not found
</Text>

<Container flex="row" gap="xxs" center="y">
<Img
src={token.iconUri || ""}
client={props.client}
width={iconSize.sm}
height={iconSize.sm}
style={{
borderRadius: radius.full,
}}
fallback={
<Container
style={{
background: `linear-gradient(45deg, white, ${theme.colors.accentText})`,
borderRadius: radius.full,
width: `${iconSize.sm}px`,
height: `${iconSize.sm}px`,
}}
/>
}
/>
<Text
size="sm"
color="primaryText"
weight={500}
style={{
maxWidth: "200px",
whiteSpace: "nowrap",
}}
>
{token.name}
</Container>

Check warning on line 536 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#L536

Added line #L536 was not covered by tests
) : (
<Container flex="column" gap="md" px="md" py="lg">

Check warning on line 538 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#L538

Added line #L538 was not covered by tests
{/* name + icon */}
<Container
flex="row"
style={{
justifyContent: "space-between",
alignItems: "center",
}}

Check warning on line 545 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#L540-L545

Added lines #L540 - L545 were not covered by tests
>
<Text size="sm" color="secondaryText">

Check warning on line 547 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#L547

Added line #L547 was not covered by tests
Name
</Text>

<Container flex="row" gap="xxs" center="y">
<Img
src={token.iconUri || ""}
client={props.client}
width={iconSize.sm}
height={iconSize.sm}
style={{
borderRadius: radius.full,
}}
fallback={
<Container
style={{
background: `linear-gradient(45deg, white, ${theme.colors.accentText})`,
borderRadius: radius.full,
width: `${iconSize.sm}px`,
height: `${iconSize.sm}px`,
}}
/>

Check warning on line 568 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#L551-L568

Added lines #L551 - L568 were not covered by tests
}
/>
<Text
size="sm"
color="primaryText"
weight={500}
style={{
maxWidth: "200px",
whiteSpace: "nowrap",
}}

Check warning on line 578 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#L570-L578

Added lines #L570 - L578 were not covered by tests
>
{token.name}
</Text>
</Container>

Check warning on line 582 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#L580-L582

Added lines #L580 - L582 were not covered by tests
</Container>
</Container>

{/* symbol */}
<TokenInfoRow label="Symbol" value={token.symbol} />

{/* price */}
{"prices" in token && (
<TokenInfoRow
label="Price"
value={
token.prices[props.currency]
? formatCurrencyAmount(
props.currency,
token.prices[props.currency] as number,
)
: "N/A"
}
/>
)}
{/* symbol */}
<TokenInfoRow label="Symbol" value={token.symbol} />

Check warning on line 586 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#L586

Added line #L586 was not covered by tests

{/* price */}
{"prices" in token && (
<TokenInfoRow
label="Price"
value={
token.prices[props.currency]
? formatCurrencyAmount(
props.currency,
token.prices[props.currency] as number,
)
: "N/A"

Check warning on line 598 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#L589-L598

Added lines #L589 - L598 were not covered by tests
}
/>

Check warning on line 600 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#L600

Added line #L600 was not covered by tests
)}

{/* market cap */}
{!!token.marketCapUsd && (
<TokenInfoRow
label="Market Cap"
value={formatCurrencyAmount(props.currency, token.marketCapUsd)}
/>
)}
{/* market cap */}
{!!token.marketCapUsd && (
<TokenInfoRow
label="Market Cap"
value={formatCurrencyAmount(props.currency, token.marketCapUsd)}
/>

Check warning on line 608 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#L604-L608

Added lines #L604 - L608 were not covered by tests
)}

{/* volume 24h */}
{!!token.volume24hUsd && (
<TokenInfoRow
label="Volume (24h)"
value={formatCurrencyAmount(props.currency, token.volume24hUsd)}
/>
)}
{/* volume 24h */}
{!!token.volume24hUsd && (
<TokenInfoRow
label="Volume (24h)"
value={formatCurrencyAmount(props.currency, token.volume24hUsd)}
/>

Check warning on line 616 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#L612-L616

Added lines #L612 - L616 were not covered by tests
)}

{/* address + link */}
<Container
flex="row"
style={{
justifyContent: "space-between",
alignItems: "center",
}}
>
<Text size="sm" color="secondaryText">
Contract Address
</Text>
{/* address + link */}
<Container
flex="row"
style={{
justifyContent: "space-between",
alignItems: "center",
}}

Check warning on line 625 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#L620-L625

Added lines #L620 - L625 were not covered by tests
>
<Text size="sm" color="secondaryText">

Check warning on line 627 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#L627

Added line #L627 was not covered by tests
Contract Address
</Text>

Check warning on line 629 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#L629

Added line #L629 was not covered by tests

<Container flex="row" gap="3xs" center="y">
{!isNativeToken && (
<CopyIcon
text={props.tokenAddress}
iconSize={13}
tip="Copy Address"
/>
)}
<Container flex="row" gap="3xs" center="y">
{!isNativeToken && (
<CopyIcon
text={props.tokenAddress}
iconSize={13}
tip="Copy Address"
/>

Check warning on line 637 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#L631-L637

Added lines #L631 - L637 were not covered by tests
)}

<Link
href={explorerLink}
target="_blank"
rel="noreferrer"
color="accentText"
hoverColor="primaryText"
weight={500}
size="sm"
>
{isNativeToken
? "Native Currency"
: shortenAddress(props.tokenAddress)}
</Link>
<Link
href={explorerLink}
target="_blank"
rel="noreferrer"
color="accentText"
hoverColor="primaryText"
weight={500}
size="sm"

Check warning on line 647 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#L640-L647

Added lines #L640 - L647 were not covered by tests
>
{isNativeToken
? "Native Currency"
: shortenAddress(props.tokenAddress)}
</Link>
</Container>

Check warning on line 653 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#L649-L653

Added lines #L649 - L653 were not covered by tests
</Container>
</Container>
</Container>
)}
</Container>
);
}
Expand Down
Loading