From 43bc9eed843ee19f8ce33c89a64f9deeddb53f23 Mon Sep 17 00:00:00 2001 From: An Nguyen Date: Thu, 6 Jun 2024 10:49:29 -0500 Subject: [PATCH] Fix bridging on testnets and adjust seedless expired token check (#1350) --- .../app/screens/bridge/hooks/useTransferAssetEVM.ts | 13 +++++++++++-- .../app/seedless/store/listeners.test.ts | 2 +- .../core-mobile/app/seedless/store/listeners.ts | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/core-mobile/app/screens/bridge/hooks/useTransferAssetEVM.ts b/packages/core-mobile/app/screens/bridge/hooks/useTransferAssetEVM.ts index c91a13068f..53482b2118 100644 --- a/packages/core-mobile/app/screens/bridge/hooks/useTransferAssetEVM.ts +++ b/packages/core-mobile/app/screens/bridge/hooks/useTransferAssetEVM.ts @@ -12,6 +12,7 @@ import { selectBridgeAppConfig } from 'store/bridge' import { useNetworks } from 'hooks/networks/useNetworks' import { useInAppRequest } from 'hooks/useInAppRequest' import BridgeService from 'services/bridge/BridgeService' +import { selectIsDeveloperMode } from 'store/settings/advanced/slice' type TransferParams = { amount: Big @@ -34,6 +35,7 @@ export function useTransferAssetEVM(): { const { networks } = useNetworks() const activeAccount = useSelector(selectActiveAccount) const config = useSelector(selectBridgeAppConfig) + const isDeveloperMode = useSelector(selectIsDeveloperMode) const { currentBlockchain } = useBridgeSDK() const { request } = useInAppRequest() @@ -62,13 +64,20 @@ export function useTransferAssetEVM(): { config, activeAccount, allNetworks: networks, - isTestnet: false, + isTestnet: isDeveloperMode, onStatusChange, onTxHashChange, request }) }, - [currentBlockchain, config, activeAccount, networks, request] + [ + currentBlockchain, + config, + activeAccount, + isDeveloperMode, + networks, + request + ] ) return { diff --git a/packages/core-mobile/app/seedless/store/listeners.test.ts b/packages/core-mobile/app/seedless/store/listeners.test.ts index eab263d228..c1778ea4ff 100644 --- a/packages/core-mobile/app/seedless/store/listeners.test.ts +++ b/packages/core-mobile/app/seedless/store/listeners.test.ts @@ -65,7 +65,7 @@ describe('seedless - listeners', () => { store.dispatch(onRehydrationComplete()) GlobalEvents.triggerErrorEvent({ status: 403, - isUserMfaError: () => false + isSessionExpiredError: () => true } as ErrorEvent) expect(mockNavigate).toHaveBeenCalledWith({ name: 'Root.RefreshToken', diff --git a/packages/core-mobile/app/seedless/store/listeners.ts b/packages/core-mobile/app/seedless/store/listeners.ts index 920653d5c2..81a162f895 100644 --- a/packages/core-mobile/app/seedless/store/listeners.ts +++ b/packages/core-mobile/app/seedless/store/listeners.ts @@ -55,7 +55,7 @@ const registerSeedlessErrorHandler = async ( Logger.error('seedless error', JSON.stringify({ ...e, url: '' })) // handle re-auth for expired token - if (e.status === 403 && !e.isUserMfaError()) { + if (e.isSessionExpiredError()) { dispatch(onTokenExpired) } }