@@ -5,8 +5,8 @@ import type { Chain } from "../../../../../../../chains/types.js";
5
5
import type { ThirdwebClient } from "../../../../../../../client/client.js" ;
6
6
import { NATIVE_TOKEN_ADDRESS } from "../../../../../../../constants/addresses.js" ;
7
7
import {
8
- FiatProviders ,
9
8
type FiatProvider ,
9
+ FiatProviders ,
10
10
} from "../../../../../../../pay/utils/commonTypes.js" ;
11
11
import { formatNumber } from "../../../../../../../utils/formatNumber.js" ;
12
12
import {
@@ -90,10 +90,14 @@ export function FiatScreenContent(props: {
90
90
const supportedProviders = ( ( ) => {
91
91
if ( ! buyWithFiatOptions ) return [ ] ;
92
92
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 ) ;
97
101
} ) ( ) ;
98
102
99
103
const fiatQuoteQuery = useBuyWithFiatQuote (
@@ -110,7 +114,8 @@ export function FiatScreenContent(props: {
110
114
isTestMode : buyWithFiatOptions ?. testMode ,
111
115
purchaseData : props . payOptions . purchaseData ,
112
116
fromAddress : payer . account . address ,
113
- preferredProvider : preferredProvider ,
117
+ preferredProvider :
118
+ preferredProvider ?? supportedProviders ?. [ 0 ] ?? undefined ,
114
119
}
115
120
: undefined ,
116
121
) ;
0 commit comments