@@ -5,8 +5,8 @@ import type { Chain } from "../../../../../../../chains/types.js";
55import type { ThirdwebClient } from "../../../../../../../client/client.js" ;
66import { NATIVE_TOKEN_ADDRESS } from "../../../../../../../constants/addresses.js" ;
77import {
8- FiatProviders ,
98 type FiatProvider ,
9+ FiatProviders ,
1010} from "../../../../../../../pay/utils/commonTypes.js" ;
1111import { formatNumber } from "../../../../../../../utils/formatNumber.js" ;
1212import {
@@ -90,10 +90,14 @@ export function FiatScreenContent(props: {
9090 const supportedProviders = ( ( ) => {
9191 if ( ! buyWithFiatOptions ) return [ ] ;
9292 const options = buyWithFiatOptions ?. supportedProviders ?? [ ] ;
93- return options . length > 0 &&
94- ( ! preferredProvider || options . includes ( preferredProvider ) )
95- ? options
96- : [ ...FiatProviders ] ;
93+ const optionsWithPreferred =
94+ options . length > 0
95+ ? new Set ( [
96+ ...( preferredProvider ? [ preferredProvider ] : [ ] ) ,
97+ ...options ,
98+ ] )
99+ : FiatProviders ;
100+ return Array . from ( optionsWithPreferred ) ;
97101 } ) ( ) ;
98102
99103 const fiatQuoteQuery = useBuyWithFiatQuote (
@@ -110,7 +114,8 @@ export function FiatScreenContent(props: {
110114 isTestMode : buyWithFiatOptions ?. testMode ,
111115 purchaseData : props . payOptions . purchaseData ,
112116 fromAddress : payer . account . address ,
113- preferredProvider : preferredProvider ,
117+ preferredProvider :
118+ preferredProvider ?? supportedProviders ?. [ 0 ] ?? undefined ,
114119 }
115120 : undefined ,
116121 ) ;
0 commit comments