File tree 2 files changed +31
-8
lines changed
2 files changed +31
-8
lines changed Original file line number Diff line number Diff line change @@ -220,14 +220,35 @@ describe('Selectors', () => {
220
220
) ;
221
221
222
222
jestIt (
223
- 'returns false if feature flag is enabled, not a HW and is BSC network' ,
223
+ 'returns true if feature flag is enabled, not a HW and is BSC network with a default RPC URL ' ,
224
224
( ) => {
225
225
const state = createSwapsMockStore ( ) ;
226
226
const newState = {
227
227
...state ,
228
228
metamask : {
229
229
...state . metamask ,
230
- ...mockNetworkState ( { chainId : CHAIN_IDS . BSC } ) ,
230
+ ...mockNetworkState ( {
231
+ chainId : CHAIN_IDS . BSC ,
232
+ rpcUrl : 'https://bsc-dataseed.binance.org/' ,
233
+ } ) ,
234
+ } ,
235
+ } ;
236
+ expect ( getSmartTransactionsEnabled ( newState ) ) . toBe ( true ) ;
237
+ } ,
238
+ ) ;
239
+
240
+ jestIt (
241
+ 'returns false if feature flag is enabled, not a HW and is BSC network with a non-default RPC URL' ,
242
+ ( ) => {
243
+ const state = createSwapsMockStore ( ) ;
244
+ const newState = {
245
+ ...state ,
246
+ metamask : {
247
+ ...state . metamask ,
248
+ ...mockNetworkState ( {
249
+ chainId : CHAIN_IDS . BSC ,
250
+ rpcUrl : 'https://bsc-dataseed1.defibit.io/' ,
251
+ } ) ,
231
252
} ,
232
253
} ;
233
254
expect ( getSmartTransactionsEnabled ( newState ) ) . toBe ( false ) ;
Original file line number Diff line number Diff line change @@ -137,17 +137,19 @@ export const getCurrentChainSupportsSmartTransactions = (
137
137
138
138
const getIsAllowedRpcUrlForSmartTransactions = ( state : NetworkState ) => {
139
139
const chainId = getCurrentChainId ( state ) ;
140
+ // Allow in non-production or if chain ID is on skip list.
140
141
if ( ! isProduction ( ) || SKIP_STX_RPC_URL_CHECK_CHAIN_IDS . includes ( chainId ) ) {
141
- // Allow any STX RPC URL in development and testing environments or for specific chain IDs.
142
142
return true ;
143
143
}
144
- const currentNetwork = getCurrentNetwork ( state ) ;
145
- if ( ! currentNetwork ?. rpcUrl ) {
144
+ const rpcUrl = getCurrentNetwork ( state ) ?. rpcUrl ;
145
+ if ( ! rpcUrl ) {
146
146
return false ;
147
147
}
148
- const rpcUrl = new URL ( currentNetwork . rpcUrl ) ;
149
- // Only allow STX in prod if an Infura RPC URL is being used.
150
- return rpcUrl ?. hostname ?. endsWith ( '.infura.io' ) ;
148
+ const { hostname } = new URL ( rpcUrl ) ;
149
+ if ( ! hostname ) {
150
+ return false ;
151
+ }
152
+ return hostname . endsWith ( '.infura.io' ) || hostname . endsWith ( '.binance.org' ) ;
151
153
} ;
152
154
153
155
export const getSmartTransactionsEnabled = (
You can’t perform that action at this time.
0 commit comments