From e0ffa404ac986fd4a57419eacb45f5935f49cd40 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Tue, 18 Feb 2025 13:46:51 +1300 Subject: [PATCH] [thirdweb] fix: Respect supportedTokens override in PayEmbed --- .changeset/sweet-items-compare.md | 5 +++++ .../ConnectWallet/screens/Buy/BuyScreen.tsx | 21 +++++-------------- 2 files changed, 10 insertions(+), 16 deletions(-) create mode 100644 .changeset/sweet-items-compare.md diff --git a/.changeset/sweet-items-compare.md b/.changeset/sweet-items-compare.md new file mode 100644 index 00000000000..17487083708 --- /dev/null +++ b/.changeset/sweet-items-compare.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +Respect supportedTokens override in PayEmbed diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx index bc6a6a7e26d..331ce36c61d 100644 --- a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +++ b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx @@ -932,13 +932,15 @@ function createSupportedTokens( payOptions: PayUIOptions, supportedTokensOverrides?: SupportedTokens, ): SupportedTokens { - const tokens: SupportedTokens = {}; + // dev override + if (supportedTokensOverrides) { + return supportedTokensOverrides; + } + const tokens: SupportedTokens = {}; const isBuyWithFiatDisabled = payOptions.buyWithFiat === false; const isBuyWithCryptoDisabled = payOptions.buyWithCrypto === false; - // FIXME (pay) when buywithFiat is disabled, missing a bunch of tokens on base?? - for (const x of data) { tokens[x.chain.id] = x.tokens.filter((t) => { // for source tokens, data is not provided, so we include all of them @@ -966,19 +968,6 @@ function createSupportedTokens( return true; // include the token }); } - - // override with props.supportedTokens - if (supportedTokensOverrides) { - for (const k in supportedTokensOverrides) { - const key = Number(k); - const tokenList = supportedTokensOverrides[key]; - - if (tokenList) { - tokens[key] = tokenList; - } - } - } - return tokens; }