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

Improve swap status UI in PayEmbed
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import type { ThirdwebClient } from "../../../../../../../client/client.js";
import type { BuyWithCryptoQuote } from "../../../../../../../pay/buyWithCrypto/getQuote.js";
import type { ValidBuyWithCryptoStatus } from "../../../../../../../pay/buyWithCrypto/getStatus.js";
import { shortenAddress } from "../../../../../../../utils/address.js";
import { formatExplorerTxUrl } from "../../../../../../../utils/url.js";
import {
fontSize,
Expand All @@ -19,7 +18,7 @@
import { Container, Line, ModalHeader } from "../../../../components/basic.js";
import { ButtonLink } from "../../../../components/buttons.js";
import { Text } from "../../../../components/text.js";
import { formatSeconds } from "../swap/formatSeconds.js";
import { WalletRow } from "../swap/WalletRow.js";
import { TokenInfoRow } from "./TokenInfoRow.js";
import { type StatusMeta, getBuyWithCryptoStatusMeta } from "./statusMeta.js";

Expand Down Expand Up @@ -174,7 +173,6 @@
destinationTxHash,
isPartialSuccess,
gotToken,
estimatedDuration,
} = uiData;

const fromChainId = fromToken.chainId;
Expand Down Expand Up @@ -222,6 +220,17 @@

return (
<div>
{/* Pay */}
<TokenInfoRow
chainId={fromToken.chainId}
client={client}
label="Paid"
tokenAmount={fromToken.amount}
tokenSymbol={fromToken.symbol || ""}
tokenAddress={fromToken.address}
/>

Check warning on line 231 in packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx#L224-L231

Added lines #L224 - L231 were not covered by tests

{lineSpacer}

Check warning on line 233 in packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx#L233

Added line #L233 was not covered by tests
{isPartialSuccess && gotToken ? (
// Expected + Got
<>
Expand Down Expand Up @@ -252,83 +261,54 @@
<TokenInfoRow
chainId={toToken.chainId}
client={client}
label="Receive"
label="Received"

Check warning on line 264 in packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx#L264

Added line #L264 was not covered by tests
tokenAmount={toToken.amount}
tokenSymbol={toToken.symbol || ""}
tokenAddress={toToken.address}
/>
)}

{lineSpacer}

{/* Pay */}
<TokenInfoRow
chainId={fromToken.chainId}
client={client}
label="Pay"
tokenAmount={fromToken.amount}
tokenSymbol={fromToken.symbol || ""}
tokenAddress={fromToken.address}
/>

{lineSpacer}

{/* Duration */}
<Container
flex="row"
center="y"
style={{
justifyContent: "space-between",
}}
>
<Text> Time </Text>
<Container flex="row" gap="xs" center="y">
<Text color="primaryText">
~{formatSeconds(estimatedDuration || 0)}
</Text>
<>
{lineSpacer}
<Container
flex="row"
style={{
justifyContent: "space-between",
}}

Check warning on line 277 in packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx#L271-L277

Added lines #L271 - L277 were not covered by tests
>
<Text size="sm">Recipient</Text>
<WalletRow address={uiData.toAddress} iconSize="sm" client={client} />

Check warning on line 280 in packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx#L279-L280

Added lines #L279 - L280 were not covered by tests
</Container>
</Container>
</>

Check warning on line 282 in packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx#L282

Added line #L282 was not covered by tests

{/* Status */}
{statusMeta && showStatusRow && (
<>
{lineSpacer}
<Container
flex="row"
center="y"
style={{
justifyContent: "space-between",
}}
>
<Text>Status</Text>
<Container flex="row" gap="xs" center="y">
<Text color={statusMeta.color}>{statusMeta.status}</Text>
</Container>
</Container>
</>
)}

{uiData.fromAddress.toLowerCase() !== uiData.toAddress.toLowerCase() && (
<>
{lineSpacer}
<Container
flex="row"
center="y"
style={{
justifyContent: "space-between",
}}
>
<Text>Send to</Text>
<Container flex="row" gap="xs" center="y">
<Text color="primaryText" size="sm">
{shortenAddress(uiData.toAddress)}
<Text size="sm">Status</Text>
<Container
flex="column"
gap="3xs"
center="y"
style={{
alignItems: "flex-end",
}}

Check warning on line 301 in packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx#L294-L301

Added lines #L294 - L301 were not covered by tests
>
<Text color={statusMeta.color} size="sm">
{statusMeta.status}

Check warning on line 304 in packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx#L303-L304

Added lines #L303 - L304 were not covered by tests
</Text>
</Container>
</Container>
</>
)}

{lineSpacer}
<Spacer y="lg" />

Check warning on line 311 in packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx#L311

Added line #L311 was not covered by tests

{/* source chain Tx hash link */}
{fromChainExplorers.explorers?.[0]?.url && sourceTxHash && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<Text size="sm">{props.label}</Text>
<Container
flex="column"
gap="xxs"
gap="3xs"

Check warning on line 34 in packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.tsx#L34

Added line #L34 was not covered by tests
style={{
alignItems: "flex-end",
}}
Expand All @@ -45,11 +45,11 @@
}}
client={props.client}
/>
<Text color="primaryText">
<Text color="primaryText" size="sm">

Check warning on line 48 in packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.tsx#L48

Added line #L48 was not covered by tests
{formatNumber(Number(props.tokenAmount), 6)} {props.tokenSymbol}
</Text>
</Container>
<Text size="sm">{name}</Text>
<Text size="xs">{name}</Text>

Check warning on line 52 in packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.tsx

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.tsx#L52

Added line #L52 was not covered by tests
</Container>
</Container>
);
Expand Down
Loading