Skip to content

Commit 5fb98b5

Browse files
authored
chore(checkout-widgets): Remove sanctions check from onramp widget (#2693)
1 parent 2108b0a commit 5fb98b5

File tree

1 file changed

+7
-24
lines changed

1 file changed

+7
-24
lines changed

packages/checkout/widgets-lib/src/widgets/on-ramp/views/OnRampMain.tsx

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Passport } from '@imtbl/passport';
22
import { Box } from '@biom3/react';
33
import {
4+
useCallback,
45
useContext, useEffect, useMemo, useRef, useState,
56
} from 'react';
67
import {
7-
ExchangeType, fetchRiskAssessment, IMTBLWidgetEvents, isAddressSanctioned,
8+
ExchangeType, IMTBLWidgetEvents,
89
} from '@imtbl/checkout-sdk';
910
import url from 'url';
1011
import { useTranslation } from 'react-i18next';
@@ -74,7 +75,7 @@ export function OnRampMain({
7475

7576
const { track } = useAnalytics();
7677

77-
const trackSegmentEvents = async (
78+
const trackSegmentEvents = useCallback(async (
7879
event: TransakEventData,
7980
walletAddress: string,
8081
) => {
@@ -139,9 +140,9 @@ export function OnRampMain({
139140
break;
140141
default:
141142
}
142-
};
143+
}, [isPassport, track]);
143144

144-
const transakEventHandler = (event: TransakEventData) => {
145+
const transakEventHandler = useCallback((event: TransakEventData) => {
145146
if (eventTimer.current) clearTimeout(eventTimer.current);
146147

147148
if (event.event_id === TransakEvents.TRANSAK_WIDGET_OPEN) {
@@ -221,32 +222,14 @@ export function OnRampMain({
221222
},
222223
});
223224
}
224-
};
225+
}, [viewDispatch, tokenAmount, tokenAddress, viewState.view.data?.amount, viewState.view.data?.tokenAddress]);
225226

226227
useEffect(() => {
227228
if (!checkout || !provider) return;
228229

229230
let userWalletAddress = '';
230231

231232
(async () => {
232-
const walletAddress = await (await provider.getSigner()).getAddress();
233-
234-
const assessment = await fetchRiskAssessment([walletAddress], checkout.config);
235-
236-
if (isAddressSanctioned(assessment)) {
237-
viewDispatch({
238-
payload: {
239-
type: ViewActions.UPDATE_VIEW,
240-
view: {
241-
type: SharedViews.SERVICE_UNAVAILABLE_ERROR_VIEW,
242-
error: new Error('Sanctioned address'),
243-
},
244-
},
245-
});
246-
247-
return;
248-
}
249-
250233
const params = {
251234
exchangeType: ExchangeType.ONRAMP,
252235
browserProvider: provider,
@@ -279,7 +262,7 @@ export function OnRampMain({
279262
}
280263
};
281264
window.addEventListener('message', handleTransakEvents);
282-
}, [checkout, provider, tokenAmount, tokenAddress, passport]);
265+
}, [checkout, provider, tokenAmount, tokenAddress, passport, trackSegmentEvents, transakEventHandler]);
283266

284267
return (
285268
<Box sx={boxMainStyle(showIframe)}>

0 commit comments

Comments
 (0)