Skip to content

Commit

Permalink
fix: infinite loading for ledger
Browse files Browse the repository at this point in the history
  • Loading branch information
siandreev committed Dec 26, 2024
1 parent dbd0e74 commit 584d47a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 4 additions & 4 deletions packages/uikit/src/hooks/blockchain/useSender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -165,7 +165,7 @@ export const useAvailableSendersChoices = (
batteryBalance !== undefined &&
walletInfo !== undefined &&
config !== undefined &&
twoFaConfig !== undefined
(!isTwoFAEnabled || twoFaConfig !== undefined)
}
);
};
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -411,7 +411,7 @@ export const useGetSender = () => {

return useCallback(
// eslint-disable-next-line complexity
async (senderChoice: SenderChoice = { type: 'external' }): Promise<Sender> => {
async (senderChoice: SenderChoice = EXTERNAL_SENDER_CHOICE): Promise<Sender> => {
if (activeAccount.type === 'watch-only') {
throw new Error("Can't send a transfer using this account");
}
Expand Down
10 changes: 8 additions & 2 deletions packages/uikit/src/state/two-fa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TwoFAWalletConfig>(
const isEnabled = isSuitableAccount;
const query = useQuery<TwoFAWalletConfig>(
[QueryKey.twoFAWalletConfig, wallet.id, isTwoFAEnabledGlobally],
async () => {
const twoFAEncoder = new TwoFAEncoder(api, wallet.rawAddress);
Expand Down Expand Up @@ -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
Expand All @@ -223,6 +224,11 @@ export const useTwoFAWalletConfig = (options?: { account?: Account; walletId?: W
: false
}
);

return {
...query,
isEnabled
};
};

const authUrlToBotUrl = (authUrl: string) => {
Expand Down

0 comments on commit 584d47a

Please sign in to comment.