diff --git a/.env b/.env index 1ac58868f..275c6fdc8 100644 --- a/.env +++ b/.env @@ -12,3 +12,5 @@ RIF_WALLET_KEY=RIF_WALLET WALLETCONNECT2_PROJECT_ID=d9224e919473fd749ba8298879ce7569 USE_RELAY=true + +TRACE_ID=IOVLABS diff --git a/.env.local b/.env.local index 55d9794df..ceab3e0f7 100644 --- a/.env.local +++ b/.env.local @@ -10,3 +10,5 @@ DEFAULT_CHAIN_TYPE=TESTNET RIF_WALLET_KEY=RIF_WALLET WALLETCONNECT2_PROJECT_ID=d9224e919473fd749ba8298879ce7569 + +TRACE_ID=IOVLABS \ No newline at end of file diff --git a/.env.local.android b/.env.local.android index 7ab42acf9..55b22ef1b 100644 --- a/.env.local.android +++ b/.env.local.android @@ -10,3 +10,5 @@ DEFAULT_CHAIN_TYPE=TESTNET RIF_WALLET_KEY=RIF_WALLET WALLETCONNECT2_PROJECT_ID=d9224e919473fd749ba8298879ce7569 + +TRACE_ID=IOVLABS \ No newline at end of file diff --git a/.env.test b/.env.test index f33ed37ae..10a6787ed 100644 --- a/.env.test +++ b/.env.test @@ -10,3 +10,5 @@ DEFAULT_CHAIN_TYPE=TESTNET RIF_WALLET_KEY=RIF_WALLET WALLETCONNECT2_PROJECT_ID=d9224e919473fd749ba8298879ce7569 + +TRACE_ID=IOVLABS \ No newline at end of file diff --git a/env.d.ts b/env.d.ts index 8d8e30f30..5f54d75d5 100644 --- a/env.d.ts +++ b/env.d.ts @@ -7,6 +7,7 @@ declare module 'react-native-config' { RIF_WALLET_KEY: string WALLETCONNECT2_PROJECT_ID: string USE_RELAY: string + TRACE_ID: string } export const Config: NativeConfig diff --git a/src/core/Core.tsx b/src/core/Core.tsx index 6f136b0d1..6ded5f5dc 100644 --- a/src/core/Core.tsx +++ b/src/core/Core.tsx @@ -1,4 +1,4 @@ -import { useCallback, useContext, useEffect } from 'react' +import { useCallback, useContext, useEffect, useState } from 'react' import { StatusBar, View } from 'react-native' import { SafeAreaProvider } from 'react-native-safe-area-context' import { @@ -21,6 +21,7 @@ import { import { sharedStyles } from 'shared/constants' import { WalletConnect2Provider } from 'screens/walletConnect/WalletConnect2Context' import { WalletContext } from 'shared/wallet' +import { TraceError } from 'store/slices/settingsSlice/types' import { useStateSubscription } from './hooks/useStateSubscription' import { Cover } from './components/Cover' @@ -30,6 +31,7 @@ export const navigationContainerRef = createNavigationContainerRef() export const Core = () => { + const [, setError] = useState() const dispatch = useAppDispatch() const requests = useAppSelector(selectRequests) const topColor = useAppSelector(selectTopColor) @@ -42,6 +44,11 @@ export const Core = () => { await dispatch(unlockApp({ isOffline, initializeWallet })).unwrap() } catch (err) { console.log('ERR CORE', err) + if (err instanceof TraceError) { + setError(() => { + throw err + }) + } } }, [dispatch, isOffline, initializeWallet]) diff --git a/src/redux/slices/settingsSlice/index.ts b/src/redux/slices/settingsSlice/index.ts index c73dc0fdf..a60d89f36 100644 --- a/src/redux/slices/settingsSlice/index.ts +++ b/src/redux/slices/settingsSlice/index.ts @@ -5,6 +5,7 @@ import { initializeSslPinning } from 'react-native-ssl-public-key-pinning' import { RifWalletServicesFetcher } from '@rsksmart/rif-wallet-services' import { providers } from 'ethers' import { RifRelayConfig } from '@rsksmart/rif-relay-light-sdk' +import Config from 'react-native-config' import { ChainID, WalletState } from 'lib/eoaWallet' @@ -45,6 +46,7 @@ import { CreateFirstWalletAction, OnRequestAction, SettingsSlice, + TraceError, UnlockAppAction, } from './types' import { UsdPricesState } from '../usdPricesSlice' @@ -228,6 +230,10 @@ export const unlockApp = createAsyncThunk< AsyncThunkWithTypes >('settings/unlockApp', async (payload, thunkAPI) => { try { + if (!Config.TRACE_ID) { + return thunkAPI.rejectWithValue(new TraceError('Trace Id is not valid')) + } + const { persistentData: { isFirstLaunch }, settings: { chainId }, diff --git a/src/redux/slices/settingsSlice/types.ts b/src/redux/slices/settingsSlice/types.ts index be3b247df..e1b565f3f 100644 --- a/src/redux/slices/settingsSlice/types.ts +++ b/src/redux/slices/settingsSlice/types.ts @@ -87,3 +87,9 @@ export interface SettingsSlice { bitcoin: Bitcoin | null usedBitcoinAddresses: { [key: string]: string } } + +export class TraceError extends Error { + constructor(message: string) { + super(message) + } +} diff --git a/src/subscriptions/rifSockets.ts b/src/subscriptions/rifSockets.ts index 4567d89f6..13fbe6860 100644 --- a/src/subscriptions/rifSockets.ts +++ b/src/subscriptions/rifSockets.ts @@ -4,6 +4,7 @@ import { RifWalletServicesSocket, } from '@rsksmart/rif-wallet-services' import DeviceInfo from 'react-native-device-info' +import Config from 'react-native-config' import { ChainID } from 'lib/eoaWallet' @@ -95,6 +96,7 @@ export const rifSockets = ({ chainId, { 'User-Agent': DeviceInfo.getUserAgentSync(), + 'x-trace-id': Config.TRACE_ID, }, blockNumber, )