@@ -60,6 +60,7 @@ import { CancelParams } from './types/cancel';
6060import { FiatRampService , FiatRampWidgetParams } from './fiatRamp' ;
6161import { getItemRequirementsFromRequirements } from './smartCheckout/itemRequirements' ;
6262import { CheckoutError , CheckoutErrorType } from './errors' ;
63+ import { AvailabilityService , availabilityService } from './availability' ;
6364
6465const SANDBOX_CONFIGURATION = {
6566 baseConfig : {
@@ -74,6 +75,8 @@ export class Checkout {
7475
7576 private readOnlyProviders : Map < ChainId , ethers . providers . JsonRpcProvider > ;
7677
78+ readonly availability : AvailabilityService ;
79+
7780 /**
7881 * Constructs a new instance of the CheckoutModule class.
7982 * @param {CheckoutModuleConfiguration } [config=SANDBOX_CONFIGURATION] - The configuration object for the CheckoutModule.
@@ -84,6 +87,7 @@ export class Checkout {
8487 this . config = new CheckoutConfiguration ( config ) ;
8588 this . fiatRampService = new FiatRampService ( this . config ) ;
8689 this . readOnlyProviders = new Map < ChainId , ethers . providers . JsonRpcProvider > ( ) ;
90+ this . availability = availabilityService ( this . config . isDevelopment , this . config . isProduction ) ;
8791 }
8892
8993 /**
@@ -472,4 +476,12 @@ export class Checkout {
472476 public async getExchangeFeeEstimate ( ) : Promise < OnRampProviderFees > {
473477 return await this . fiatRampService . feeEstimate ( ) ;
474478 }
479+
480+ /**
481+ * Fetches Swap widget availability.
482+ * @returns {Promise<boolean> } - A promise that resolves to a boolean.
483+ */
484+ public async isSwapAvailable ( ) : Promise < boolean > {
485+ return this . availability . checkDexAvailability ( ) ;
486+ }
475487}
0 commit comments