diff --git a/packages/checkout/widgets-lib/src/widgets/on-ramp/OnRampWidget.tsx b/packages/checkout/widgets-lib/src/widgets/on-ramp/OnRampWidget.tsx index 5514cec2e2..ded8730416 100644 --- a/packages/checkout/widgets-lib/src/widgets/on-ramp/OnRampWidget.tsx +++ b/packages/checkout/widgets-lib/src/widgets/on-ramp/OnRampWidget.tsx @@ -24,6 +24,7 @@ import { StatusType } from '../../components/Status/StatusType'; import { StatusView } from '../../components/Status/StatusView'; import { EventTargetContext } from '../../context/event-target-context/EventTargetContext'; import { OrderInProgress } from './views/OrderInProgress'; +import { ServiceUnavailableErrorView } from '../../views/error/ServiceUnavailableErrorView'; export type OnRampWidgetInputs = OnRampWidgetParams & { config: StrongCheckoutWidgetsConfig @@ -153,6 +154,12 @@ export default function OnRampWidget({ onCloseButtonClick={() => sendOnRampWidgetCloseEvent(eventTarget)} /> )} + {viewState.view.type + === SharedViews.SERVICE_UNAVAILABLE_ERROR_VIEW && ( + sendOnRampWidgetCloseEvent(eventTarget)} + /> + )} ); } diff --git a/packages/checkout/widgets-lib/src/widgets/on-ramp/views/OnRampMain.tsx b/packages/checkout/widgets-lib/src/widgets/on-ramp/views/OnRampMain.tsx index 0501628ff1..04215250b5 100644 --- a/packages/checkout/widgets-lib/src/widgets/on-ramp/views/OnRampMain.tsx +++ b/packages/checkout/widgets-lib/src/widgets/on-ramp/views/OnRampMain.tsx @@ -3,7 +3,9 @@ import { Box } from '@biom3/react'; import { useContext, useEffect, useMemo, useRef, useState, } from 'react'; -import { ExchangeType, IMTBLWidgetEvents } from '@imtbl/checkout-sdk'; +import { + ExchangeType, fetchRiskAssessment, IMTBLWidgetEvents, isAddressSanctioned, +} from '@imtbl/checkout-sdk'; import url from 'url'; import { useTranslation } from 'react-i18next'; import { HeaderNavigation } from '../../../components/Header/HeaderNavigation'; @@ -131,6 +133,7 @@ export function OnRampMain({ default: } }; + const transakEventHandler = (event: TransakEventData) => { if (eventTimer.current) clearTimeout(eventTimer.current); @@ -219,6 +222,24 @@ export function OnRampMain({ let userWalletAddress = ''; (async () => { + const walletAddress = await provider.getSigner().getAddress(); + + const assessment = await fetchRiskAssessment([walletAddress], checkout.config); + + if (isAddressSanctioned(assessment)) { + viewDispatch({ + payload: { + type: ViewActions.UPDATE_VIEW, + view: { + type: SharedViews.SERVICE_UNAVAILABLE_ERROR_VIEW, + error: new Error('Sanctioned address'), + }, + }, + }); + + return; + } + const params = { exchangeType: ExchangeType.ONRAMP, web3Provider: provider,