Skip to content

Commit 7476b79

Browse files
[SDK] fix: Improve swap transaction details UI (#6509)
1 parent ccb6416 commit 7476b79

File tree

5 files changed

+218
-196
lines changed

5 files changed

+218
-196
lines changed

.changeset/all-windows-travel.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+
Improve swap status UI in PayEmbed

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

Lines changed: 36 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { getCachedChain } from "../../../../../../../chains/utils.js";
33
import type { ThirdwebClient } from "../../../../../../../client/client.js";
44
import type { BuyWithCryptoQuote } from "../../../../../../../pay/buyWithCrypto/getQuote.js";
55
import type { ValidBuyWithCryptoStatus } from "../../../../../../../pay/buyWithCrypto/getStatus.js";
6-
import { shortenAddress } from "../../../../../../../utils/address.js";
76
import { formatExplorerTxUrl } from "../../../../../../../utils/url.js";
87
import {
98
fontSize,
@@ -19,7 +18,7 @@ import { Spacer } from "../../../../components/Spacer.js";
1918
import { Container, Line, ModalHeader } from "../../../../components/basic.js";
2019
import { ButtonLink } from "../../../../components/buttons.js";
2120
import { Text } from "../../../../components/text.js";
22-
import { formatSeconds } from "../swap/formatSeconds.js";
21+
import { WalletRow } from "../swap/WalletRow.js";
2322
import { TokenInfoRow } from "./TokenInfoRow.js";
2423
import { type StatusMeta, getBuyWithCryptoStatusMeta } from "./statusMeta.js";
2524

@@ -174,7 +173,6 @@ export function SwapTxDetailsTable(
174173
destinationTxHash,
175174
isPartialSuccess,
176175
gotToken,
177-
estimatedDuration,
178176
} = uiData;
179177

180178
const fromChainId = fromToken.chainId;
@@ -222,6 +220,17 @@ export function SwapTxDetailsTable(
222220

223221
return (
224222
<div>
223+
{/* Pay */}
224+
<TokenInfoRow
225+
chainId={fromToken.chainId}
226+
client={client}
227+
label="Paid"
228+
tokenAmount={fromToken.amount}
229+
tokenSymbol={fromToken.symbol || ""}
230+
tokenAddress={fromToken.address}
231+
/>
232+
233+
{lineSpacer}
225234
{isPartialSuccess && gotToken ? (
226235
// Expected + Got
227236
<>
@@ -252,83 +261,54 @@ export function SwapTxDetailsTable(
252261
<TokenInfoRow
253262
chainId={toToken.chainId}
254263
client={client}
255-
label="Receive"
264+
label="Received"
256265
tokenAmount={toToken.amount}
257266
tokenSymbol={toToken.symbol || ""}
258267
tokenAddress={toToken.address}
259268
/>
260269
)}
261270

262-
{lineSpacer}
263-
264-
{/* Pay */}
265-
<TokenInfoRow
266-
chainId={fromToken.chainId}
267-
client={client}
268-
label="Pay"
269-
tokenAmount={fromToken.amount}
270-
tokenSymbol={fromToken.symbol || ""}
271-
tokenAddress={fromToken.address}
272-
/>
273-
274-
{lineSpacer}
275-
276-
{/* Duration */}
277-
<Container
278-
flex="row"
279-
center="y"
280-
style={{
281-
justifyContent: "space-between",
282-
}}
283-
>
284-
<Text> Time </Text>
285-
<Container flex="row" gap="xs" center="y">
286-
<Text color="primaryText">
287-
~{formatSeconds(estimatedDuration || 0)}
288-
</Text>
271+
<>
272+
{lineSpacer}
273+
<Container
274+
flex="row"
275+
style={{
276+
justifyContent: "space-between",
277+
}}
278+
>
279+
<Text size="sm">Recipient</Text>
280+
<WalletRow address={uiData.toAddress} iconSize="sm" client={client} />
289281
</Container>
290-
</Container>
282+
</>
291283

292284
{/* Status */}
293285
{statusMeta && showStatusRow && (
294286
<>
295287
{lineSpacer}
296288
<Container
297289
flex="row"
298-
center="y"
299-
style={{
300-
justifyContent: "space-between",
301-
}}
302-
>
303-
<Text>Status</Text>
304-
<Container flex="row" gap="xs" center="y">
305-
<Text color={statusMeta.color}>{statusMeta.status}</Text>
306-
</Container>
307-
</Container>
308-
</>
309-
)}
310-
311-
{uiData.fromAddress.toLowerCase() !== uiData.toAddress.toLowerCase() && (
312-
<>
313-
{lineSpacer}
314-
<Container
315-
flex="row"
316-
center="y"
317290
style={{
318291
justifyContent: "space-between",
319292
}}
320293
>
321-
<Text>Send to</Text>
322-
<Container flex="row" gap="xs" center="y">
323-
<Text color="primaryText" size="sm">
324-
{shortenAddress(uiData.toAddress)}
294+
<Text size="sm">Status</Text>
295+
<Container
296+
flex="column"
297+
gap="3xs"
298+
center="y"
299+
style={{
300+
alignItems: "flex-end",
301+
}}
302+
>
303+
<Text color={statusMeta.color} size="sm">
304+
{statusMeta.status}
325305
</Text>
326306
</Container>
327307
</Container>
328308
</>
329309
)}
330310

331-
{lineSpacer}
311+
<Spacer y="lg" />
332312

333313
{/* source chain Tx hash link */}
334314
{fromChainExplorers.explorers?.[0]?.url && sourceTxHash && (

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function TokenInfoRow(props: {
3131
<Text size="sm">{props.label}</Text>
3232
<Container
3333
flex="column"
34-
gap="xxs"
34+
gap="3xs"
3535
style={{
3636
alignItems: "flex-end",
3737
}}
@@ -45,11 +45,11 @@ export function TokenInfoRow(props: {
4545
}}
4646
client={props.client}
4747
/>
48-
<Text color="primaryText">
48+
<Text color="primaryText" size="sm">
4949
{formatNumber(Number(props.tokenAmount), 6)} {props.tokenSymbol}
5050
</Text>
5151
</Container>
52-
<Text size="sm">{name}</Text>
52+
<Text size="xs">{name}</Text>
5353
</Container>
5454
</Container>
5555
);

0 commit comments

Comments
 (0)