From 763553255e829412e85ca1fe0a989d4c4d7ab337 Mon Sep 17 00:00:00 2001 From: abtestingalpha Date: Thu, 19 Sep 2024 13:11:36 -0400 Subject: [PATCH] Additional checks on screen --- .../contexts/UserProvider.tsx | 16 +++++++++------ .../synapse-interface/utils/screenAddress.ts | 20 ++++++++++--------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/packages/synapse-interface/contexts/UserProvider.tsx b/packages/synapse-interface/contexts/UserProvider.tsx index 6476d8e19e..82323c3402 100644 --- a/packages/synapse-interface/contexts/UserProvider.tsx +++ b/packages/synapse-interface/contexts/UserProvider.tsx @@ -21,12 +21,16 @@ export const UserProvider = ({ children }) => { useAccountEffect({ onConnect() { - segmentAnalyticsEvent(`[Wallet Analytics] connects`, { - walletId: connector?.id, - chainId: chain?.id, - query, - pathname, - }) + segmentAnalyticsEvent( + `[Wallet Analytics] connects`, + { + walletId: connector?.id, + chainId: chain?.id, + query, + pathname, + }, + true + ) }, onDisconnect() { segmentAnalyticsEvent('[Wallet Analytics] disconnect', {}) diff --git a/packages/synapse-interface/utils/screenAddress.ts b/packages/synapse-interface/utils/screenAddress.ts index 5f383a94e5..45e7aaa9c9 100644 --- a/packages/synapse-interface/utils/screenAddress.ts +++ b/packages/synapse-interface/utils/screenAddress.ts @@ -12,15 +12,18 @@ const createRiskDetectedEvent = (address: Address | string) => { }) } +const dispatchRiskDetectedEvent = (address: Address | string) => { + const event = createRiskDetectedEvent(address) + GlobalEventEmitter.dispatchEvent(event) +} + export const screenAddress = async ( address: Address | string ): Promise => { const url = `https://screener.omnirpc.io/fe/address/${address}` if (isBlacklisted(address)) { - const event = createRiskDetectedEvent(address) - - GlobalEventEmitter.dispatchEvent(event) + dispatchRiskDetectedEvent(address) return true } @@ -29,14 +32,13 @@ export const screenAddress = async ( const { risk } = await response.json() if (risk) { - const event = createRiskDetectedEvent(address) - - GlobalEventEmitter.dispatchEvent(event) + dispatchRiskDetectedEvent(address) return true + } else { + return false } - return false } catch (error) { - console.error('Error:', error) - return false + dispatchRiskDetectedEvent(address) + return true } }