diff --git a/src/core/methods/initApp/initApp.ts b/src/core/methods/initApp/initApp.ts index 8b414c9..d717fdf 100644 --- a/src/core/methods/initApp/initApp.ts +++ b/src/core/methods/initApp/initApp.ts @@ -8,7 +8,7 @@ import { InitAppType } from './initApp.types'; import { getIsLoggedIn } from '../account/getIsLoggedIn'; import { restoreProvider } from 'core/providers/helpers/restoreProvider'; import { registerWebsocketListener } from './websocket/registerWebsocket'; -import { refreshAccount } from 'utils'; +import { trackTransactions } from '../trackTransactions/trackTransactions'; const defaultInitAppProps = { storage: { @@ -34,6 +34,9 @@ export const initApp = async ({ }: InitAppType) => { initStore(storage.getStorageCallback); + const shouldEnableTransactionTracker = + dAppConfig.enableTansactionTracker !== false; + if (dAppConfig?.nativeAuth) { const nativeAuthConfig: NativeAuthConfigType = typeof dAppConfig.nativeAuth === 'boolean' @@ -48,6 +51,10 @@ export const initApp = async ({ environment: dAppConfig.environment }); + if (shouldEnableTransactionTracker) { + trackTransactions(); + } + const isLoggedIn = getIsLoggedIn(); if (isLoggedIn) { diff --git a/src/core/methods/initApp/initApp.types.ts b/src/core/methods/initApp/initApp.types.ts index 7a37019..f4121e7 100644 --- a/src/core/methods/initApp/initApp.types.ts +++ b/src/core/methods/initApp/initApp.types.ts @@ -2,7 +2,6 @@ import { StorageCallback } from 'store/storage'; import { CustomNetworkType } from 'types/network.types'; import { EnvironmentsEnum } from 'types/enums.types'; import { NativeAuthConfigType } from 'services/nativeAuth/nativeAuth.types'; -import { TransactionsTrackerType } from '../trackTransactions/trackTransactions.types'; type BaseDappConfigType = { /** @@ -13,10 +12,9 @@ type BaseDappConfigType = { */ nativeAuth?: boolean | NativeAuthConfigType; /** - * Transactions tracker configuration for the dApp. - * If set to `null`, will disable transaction tracking. + * default: `true` */ - tansactionTracker?: TransactionsTrackerType | null; + enableTansactionTracker?: boolean; }; export type EnvironmentDappConfigType = BaseDappConfigType & { diff --git a/src/core/methods/trackTransactions/trackTransactions.ts b/src/core/methods/trackTransactions/trackTransactions.ts index b94a7d5..895d527 100644 --- a/src/core/methods/trackTransactions/trackTransactions.ts +++ b/src/core/methods/trackTransactions/trackTransactions.ts @@ -9,6 +9,11 @@ import { import { getStore } from 'store/store'; import { websocketEventSelector } from 'store/selectors/accountSelectors'; +/** + * Tracks transactions using websocket or polling + * @param props - optional object with additional websocket parameters + * @returns cleanup function + */ export async function trackTransactions(props?: TransactionsTrackerType) { const store = getStore(); const pollingInterval = getPollingInterval();