diff --git a/packages/uikit/src/hooks/blockchain/useSender.ts b/packages/uikit/src/hooks/blockchain/useSender.ts index 11c03838..6d44e8fa 100644 --- a/packages/uikit/src/hooks/blockchain/useSender.ts +++ b/packages/uikit/src/hooks/blockchain/useSender.ts @@ -77,7 +77,7 @@ export const useAvailableSendersChoices = ( const gaslessConfig = useGaslessConfig(); const batteryEnableConfig = useBatteryEnabledConfig(); const [walletInfo] = useAssets(); - const { data: twoFaConfig } = useTwoFAWalletConfig(); + const { data: twoFaConfig, isEnabled: isTwoFAEnabled } = useTwoFAWalletConfig(); const asset = 'asset' in operation ? operation.asset : undefined; @@ -165,7 +165,7 @@ export const useAvailableSendersChoices = ( batteryBalance !== undefined && walletInfo !== undefined && config !== undefined && - twoFaConfig !== undefined + (!isTwoFAEnabled || twoFaConfig !== undefined) } ); }; @@ -236,7 +236,7 @@ export const useTonConnectAvailableSendersChoices = (payload: TonConnectTransact export const EXTERNAL_SENDER_CHOICE = { type: 'external' } as const satisfies SenderChoice; export const BATTERY_SENDER_CHOICE = { type: 'battery' } as const satisfies SenderChoice; -export const useGetEstimationSender = (senderChoice: SenderChoice = { type: 'external' }) => { +export const useGetEstimationSender = (senderChoice: SenderChoice = EXTERNAL_SENDER_CHOICE) => { const appContext = useAppContext(); const api = useActiveApi(); const batteryApi = useBatteryApi(); @@ -411,7 +411,7 @@ export const useGetSender = () => { return useCallback( // eslint-disable-next-line complexity - async (senderChoice: SenderChoice = { type: 'external' }): Promise => { + async (senderChoice: SenderChoice = EXTERNAL_SENDER_CHOICE): Promise => { if (activeAccount.type === 'watch-only') { throw new Error("Can't send a transfer using this account"); } diff --git a/packages/uikit/src/state/two-fa.ts b/packages/uikit/src/state/two-fa.ts index 8726177d..3cfd4ffa 100644 --- a/packages/uikit/src/state/two-fa.ts +++ b/packages/uikit/src/state/two-fa.ts @@ -140,7 +140,8 @@ export const useTwoFAWalletConfig = (options?: { account?: Account; walletId?: W const isSuitableAccount = account.type === 'mnemonic' || account.type === 'mam'; const serviceConfig = useTwoFAServiceConfig(); - return useQuery( + const isEnabled = isSuitableAccount; + const query = useQuery( [QueryKey.twoFAWalletConfig, wallet.id, isTwoFAEnabledGlobally], async () => { const twoFAEncoder = new TwoFAEncoder(api, wallet.rawAddress); @@ -214,7 +215,7 @@ export const useTwoFAWalletConfig = (options?: { account?: Account; walletId?: W }, { keepPreviousData: true, - enabled: isSuitableAccount, + enabled: isEnabled, refetchInterval: d => d?.status === 'tg-bot-bounding' || d?.status === 'ready-for-deployment' ? 1000 @@ -223,6 +224,11 @@ export const useTwoFAWalletConfig = (options?: { account?: Account; walletId?: W : false } ); + + return { + ...query, + isEnabled + }; }; const authUrlToBotUrl = (authUrl: string) => {