Skip to content

Commit c3d0ea0

Browse files
[PayEmbed] Respect supportedTokens prop (#6580)
1 parent 35c5f57 commit c3d0ea0

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

.changeset/modern-tables-sing.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+
respect supportedTokens prop in PayEmbed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useQueryClient } from "@tanstack/react-query";
22
import { useCallback, useMemo, useState } from "react";
33
import type { Chain } from "../../../../../../chains/types.js";
4+
import { getCachedChain } from "../../../../../../chains/utils.js";
45
import type { ThirdwebClient } from "../../../../../../client/client.js";
56
import { NATIVE_TOKEN_ADDRESS } from "../../../../../../constants/addresses.js";
67
import type { BuyWithCryptoStatus } from "../../../../../../pay/buyWithCrypto/getStatus.js";
@@ -112,10 +113,21 @@ export default function BuyScreen(props: BuyScreenProps) {
112113
return <LoadingScreen />;
113114
}
114115

116+
const supportedDestinations = props.supportedTokens
117+
? Object.entries(props.supportedTokens).map(([chainId, tokens]) => ({
118+
chain: getCachedChain(Number.parseInt(chainId)),
119+
tokens: tokens.map((t) => ({
120+
...t,
121+
buyWithCryptoEnabled: true,
122+
buyWithFiatEnabled: true,
123+
})),
124+
}))
125+
: supportedDestinationsQuery.data;
126+
115127
return (
116128
<BuyScreenContent
117129
{...props}
118-
supportedDestinations={supportedDestinationsQuery.data}
130+
supportedDestinations={supportedDestinations}
119131
/>
120132
);
121133
}

0 commit comments

Comments
 (0)