From d5e75483bd67696c302c0b994761c2562f159b57 Mon Sep 17 00:00:00 2001 From: spsjvc Date: Wed, 16 Oct 2024 12:00:32 +0200 Subject: [PATCH 1/3] fix: remove chain from query key (#1993) --- .../src/hooks/useAccountIsBlocked.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/hooks/useAccountIsBlocked.ts b/packages/arb-token-bridge-ui/src/hooks/useAccountIsBlocked.ts index d77dd84e70..d93791cfc4 100644 --- a/packages/arb-token-bridge-ui/src/hooks/useAccountIsBlocked.ts +++ b/packages/arb-token-bridge-ui/src/hooks/useAccountIsBlocked.ts @@ -1,10 +1,9 @@ import { useMemo } from 'react' -import { useAccount, useNetwork } from 'wagmi' +import { useAccount } from 'wagmi' import useSWRImmutable from 'swr/immutable' import { ApiResponseSuccess } from '../pages/api/screenings' import { trackEvent } from '../util/AnalyticsUtils' -import { isNetwork } from '../util/networks' import { Address } from '../util/AddressUtils' async function isBlocked(address: Address): Promise { @@ -40,7 +39,6 @@ async function fetcher(address: Address): Promise { export function useAccountIsBlocked() { const { address } = useAccount() - const { chain } = useNetwork() const queryKey = useMemo(() => { if (typeof address === 'undefined') { @@ -48,13 +46,8 @@ export function useAccountIsBlocked() { return null } - if (isNetwork(chain?.id ?? 0).isTestnet) { - // Don't fetch - return null - } - return [address.toLowerCase(), 'useAccountIsBlocked'] - }, [address, chain?.id]) + }, [address]) const { data: isBlocked } = useSWRImmutable( queryKey, From 4267958d4595713c7c7f057f5708ae2606ddc04d Mon Sep 17 00:00:00 2001 From: Fionna Chan <13184582+fionnachan@users.noreply.github.com> Date: Wed, 16 Oct 2024 22:19:44 +0800 Subject: [PATCH 2/3] feat: update router bridge url (#1994) --- packages/arb-token-bridge-ui/src/util/fastBridges.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/arb-token-bridge-ui/src/util/fastBridges.ts b/packages/arb-token-bridge-ui/src/util/fastBridges.ts index e30286313e..31e258336c 100644 --- a/packages/arb-token-bridge-ui/src/util/fastBridges.ts +++ b/packages/arb-token-bridge-ui/src/util/fastBridges.ts @@ -224,10 +224,10 @@ export const USDCFastBridges: USDCFastBridgeInfo[] = [ }: getHrefParams) => { switch (transferMode) { case 'deposit': - return `https://app.thevoyager.io/swap?fromChain=${from}&toChain=${to}&fromToken=${fromTokenAddress}&toToken=${toTokenAddress}` + return `https://app.routernitro.com/swap?fromChain=${from}&toChain=${to}&fromToken=${fromTokenAddress}&toToken=${toTokenAddress}` case 'withdraw': default: - return `https://app.thevoyager.io/swap?fromChain=${from}&toChain=${to}&fromToken=${fromTokenAddress}&toToken=${toTokenAddress}` + return `https://app.routernitro.com/swap?fromChain=${from}&toChain=${to}&fromToken=${fromTokenAddress}&toToken=${toTokenAddress}` } } } From a14da0d32ba38da84b98ced8f52345529c38ac20 Mon Sep 17 00:00:00 2001 From: doug <4741454+douglance@users.noreply.github.com> Date: Wed, 16 Oct 2024 12:08:50 -0400 Subject: [PATCH 3/3] feat: migrate to external screening api (#1990) --- .../arb-token-bridge-ui/.env.local.sample | 1 + .../src/hooks/useAccountIsBlocked.ts | 49 +++++++++++++------ 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/packages/arb-token-bridge-ui/.env.local.sample b/packages/arb-token-bridge-ui/.env.local.sample index f1b1d7ea73..9ccb08c10a 100644 --- a/packages/arb-token-bridge-ui/.env.local.sample +++ b/packages/arb-token-bridge-ui/.env.local.sample @@ -26,5 +26,6 @@ SELF_HOSTED_SUBGRAPH_API_KEY= SCREENING_API_ENDPOINT= SCREENING_API_KEY= +NEXT_PUBLIC_SCREENING_API_ENDPOINT= NEXT_PUBLIC_POSTHOG_KEY= diff --git a/packages/arb-token-bridge-ui/src/hooks/useAccountIsBlocked.ts b/packages/arb-token-bridge-ui/src/hooks/useAccountIsBlocked.ts index d93791cfc4..81f5a677d6 100644 --- a/packages/arb-token-bridge-ui/src/hooks/useAccountIsBlocked.ts +++ b/packages/arb-token-bridge-ui/src/hooks/useAccountIsBlocked.ts @@ -2,29 +2,48 @@ import { useMemo } from 'react' import { useAccount } from 'wagmi' import useSWRImmutable from 'swr/immutable' -import { ApiResponseSuccess } from '../pages/api/screenings' import { trackEvent } from '../util/AnalyticsUtils' import { Address } from '../util/AddressUtils' +import { captureSentryErrorWithExtraData } from '../util/SentryUtils' +/** + * Checks if an address is blocked using the external Screenings API service. + * @param {Address} address - The address to check. + * @returns {Promise} true if blocked or the request fails + */ async function isBlocked(address: Address): Promise { - if ( - process.env.NODE_ENV !== 'production' || - process.env.NEXT_PUBLIC_IS_E2E_TEST - ) { - return false - } + try { + if ( + process.env.NODE_ENV !== 'production' || + process.env.NEXT_PUBLIC_IS_E2E_TEST + ) { + return false + } + + const url = new URL(process.env.NEXT_PUBLIC_SCREENING_API_ENDPOINT ?? '') + url.searchParams.set('address', address) - const searchParams = new URLSearchParams({ address }) - const response = await fetch('/api/screenings?' + searchParams, { - method: 'GET', - headers: { 'Content-Type': 'application/json' } - }) + const response = await fetch(url, { + method: 'GET', + headers: { 'Content-Type': 'application/json' } + }) + + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`) + } + + const { blocked } = await response.json() + return blocked + } catch (error) { + console.error('Failed to check if address is blocked', error) + captureSentryErrorWithExtraData({ + error, + originFunction: 'isBlocked', + additionalData: { address } + }) - if (!response.ok) { return false } - - return ((await response.json()) as ApiResponseSuccess).blocked } async function fetcher(address: Address): Promise {