From 822b538aaab3226060dec0932587d0cc9dc2894d Mon Sep 17 00:00:00 2001 From: Nikita Kuznetsov Date: Thu, 28 Nov 2024 11:40:48 +0100 Subject: [PATCH 1/6] Bug 2 --- packages/uikit/src/components/settings/AccountSettings.tsx | 5 +++-- packages/uikit/src/pages/settings/Recovery.tsx | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/uikit/src/components/settings/AccountSettings.tsx b/packages/uikit/src/components/settings/AccountSettings.tsx index 9e8287b8d..fb21ed43e 100644 --- a/packages/uikit/src/components/settings/AccountSettings.tsx +++ b/packages/uikit/src/components/settings/AccountSettings.tsx @@ -24,7 +24,8 @@ import { import { SettingsItem, SettingsList } from './SettingsList'; import { isAccountTonWalletStandard, - isAccountVersionEditable + isAccountVersionEditable, + isMnemonicAndPassword } from '@tonkeeper/core/dist/entries/account'; import { useBatteryEnabledConfig } from '../../state/battery'; @@ -197,7 +198,7 @@ const MultipleAccountSettings = () => { const mainItems = useMemo(() => { const items: SettingsItem[] = []; - if (account.type === 'mnemonic' || account.type === 'mam') { + if (isMnemonicAndPassword(account)) { items.push({ name: t('settings_recovery_phrase'), icon: , diff --git a/packages/uikit/src/pages/settings/Recovery.tsx b/packages/uikit/src/pages/settings/Recovery.tsx index 710dd9107..df629eeb9 100644 --- a/packages/uikit/src/pages/settings/Recovery.tsx +++ b/packages/uikit/src/pages/settings/Recovery.tsx @@ -1,4 +1,4 @@ -import { AccountId } from '@tonkeeper/core/dist/entries/account'; +import { AccountId, isMnemonicAndPassword } from '@tonkeeper/core/dist/entries/account'; import { WalletId } from '@tonkeeper/core/dist/entries/wallet'; import { FC, useCallback, useEffect, useMemo, useState } from 'react'; import { Navigate, useNavigate, useParams, useSearchParams } from 'react-router-dom'; @@ -12,7 +12,7 @@ import { useAccountState, useActiveAccount } from '../../state/wallet'; export const ActiveRecovery = () => { const account = useActiveAccount(); - if (account.type === 'mnemonic' || account.type === 'mam') { + if (isMnemonicAndPassword(account)) { return ; } else { return ; From 39b5e7b03b8c8db1f85fda0c888a412f910f91c3 Mon Sep 17 00:00:00 2001 From: Nikita Kuznetsov Date: Thu, 28 Nov 2024 11:44:11 +0100 Subject: [PATCH 2/6] Bug 1 --- packages/uikit/src/components/account/AccountBadge.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/uikit/src/components/account/AccountBadge.tsx b/packages/uikit/src/components/account/AccountBadge.tsx index ce1327fa4..c3a42dfe7 100644 --- a/packages/uikit/src/components/account/AccountBadge.tsx +++ b/packages/uikit/src/components/account/AccountBadge.tsx @@ -168,7 +168,10 @@ export const AccountAndWalletBadgesGroup: FC<{ return ; } - if (account.type === 'mnemonic' && account.tonWallets.length > 1) { + if ( + (account.type === 'mnemonic' || account.type === 'testnet') && + account.tonWallets.length > 1 + ) { const wallet = account.tonWallets.find(w => w.id === walletId); if (wallet) { return ( From 3f064e5eb04c73d318e5375c3c148b7da412915a Mon Sep 17 00:00:00 2001 From: Nikita Kuznetsov Date: Thu, 28 Nov 2024 11:45:09 +0100 Subject: [PATCH 3/6] Bug 3 --- packages/uikit/src/components/settings/AccountSettings.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/uikit/src/components/settings/AccountSettings.tsx b/packages/uikit/src/components/settings/AccountSettings.tsx index fb21ed43e..6f0059864 100644 --- a/packages/uikit/src/components/settings/AccountSettings.tsx +++ b/packages/uikit/src/components/settings/AccountSettings.tsx @@ -82,7 +82,11 @@ const SingleAccountSettings = () => { }); } - if (account.type === 'mnemonic' || account.type === 'ton-only') { + if ( + account.type === 'mnemonic' || + account.type === 'testnet' || + account.type === 'ton-only' + ) { items.push({ name: t('settings_wallet_version'), icon: walletVersionText(account.activeTonWallet.version), From 003c1ed4f37b999a1c1e6751a0e006e018daad9f Mon Sep 17 00:00:00 2001 From: Nikita Kuznetsov Date: Thu, 28 Nov 2024 11:52:06 +0100 Subject: [PATCH 4/6] BUG 5 --- packages/uikit/src/state/wallet.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/uikit/src/state/wallet.ts b/packages/uikit/src/state/wallet.ts index ca28c7089..ae9d239e7 100644 --- a/packages/uikit/src/state/wallet.ts +++ b/packages/uikit/src/state/wallet.ts @@ -13,7 +13,8 @@ import { getNetworkByAccount, getWalletById, isAccountTonWalletStandard, - isAccountVersionEditable + isAccountVersionEditable, + isMnemonicAndPassword } from '@tonkeeper/core/dist/entries/account'; import { Network } from '@tonkeeper/core/dist/entries/network'; import { AuthKeychain, MnemonicType } from '@tonkeeper/core/dist/entries/password'; @@ -690,9 +691,7 @@ export const useMutateDeleteAll = () => { export const useIsPasswordSet = () => { const wallets = useAccountsState(); - return (wallets || []).some( - acc => (acc.type === 'mnemonic' || acc.type === 'mam') && acc.auth.kind === 'password' - ); + return (wallets || []).some(acc => isMnemonicAndPassword(acc) && acc.auth.kind === 'password'); }; export const useMutateLogOut = () => { From 7a85b92ed699b664fb296fd57a9a7c675d37c038 Mon Sep 17 00:00:00 2001 From: Nikita Kuznetsov Date: Thu, 28 Nov 2024 12:12:59 +0100 Subject: [PATCH 5/6] Bug 6 --- .../src/components/modals/AddWalletNotificationControlled.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/uikit/src/components/modals/AddWalletNotificationControlled.tsx b/packages/uikit/src/components/modals/AddWalletNotificationControlled.tsx index 1c7a9a016..74c2702c3 100644 --- a/packages/uikit/src/components/modals/AddWalletNotificationControlled.tsx +++ b/packages/uikit/src/components/modals/AddWalletNotificationControlled.tsx @@ -192,12 +192,12 @@ export const AddWalletNotificationControlled = () => { const navigateHome = useMemo( () => - !params?.walletType + selectedMethod ? () => { setSelectedMethod(undefined); } : undefined, - [params?.walletType] + [selectedMethod] ); return ( From 9425a2620222f0029495d4cbdd522976b47cd37b Mon Sep 17 00:00:00 2001 From: Nikita Kuznetsov Date: Thu, 28 Nov 2024 12:22:18 +0100 Subject: [PATCH 6/6] Update MaxMessages for ledger --- .../src/service/tonConnect/connectService.ts | 27 ++++++++++++++----- .../src/components/connect/connectHook.ts | 2 +- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/packages/core/src/service/tonConnect/connectService.ts b/packages/core/src/service/tonConnect/connectService.ts index 6852fa763..efa587648 100644 --- a/packages/core/src/service/tonConnect/connectService.ts +++ b/packages/core/src/service/tonConnect/connectService.ts @@ -385,21 +385,36 @@ export const tonDisconnectRequest = async (options: { storage: IStorage; webView await disconnectAccountConnection({ ...options, wallet: connection.wallet }); }; +const getMaxMessages = (account: Account) => { + if (account.type === 'ledger') { + return 1; + } + + const wallet = account.activeTonWallet; + + return isStandardTonWallet(wallet) && wallet.version === WalletVersion.V5R1 ? 255 : 4; +}; + export const saveWalletTonConnect = async (options: { storage: IStorage; - wallet: TonContract; + account: Account; manifest: DAppManifest; params: TonConnectParams; replyItems: ConnectItemReply[]; appVersion: string; webViewUrl?: string; }): Promise => { - await saveAccountConnection(options); + const wallet = options.account.activeTonWallet; + await saveAccountConnection({ + storage: options.storage, + wallet, + manifest: options.manifest, + params: options.params, + webViewUrl: options.webViewUrl + }); + + const maxMessages = getMaxMessages(options.account); - const maxMessages = - isStandardTonWallet(options.wallet) && options.wallet.version === WalletVersion.V5R1 - ? 255 - : 4; return { id: Date.now(), event: 'connect', diff --git a/packages/uikit/src/components/connect/connectHook.ts b/packages/uikit/src/components/connect/connectHook.ts index bdc13b271..fe96149a5 100644 --- a/packages/uikit/src/components/connect/connectHook.ts +++ b/packages/uikit/src/components/connect/connectHook.ts @@ -87,7 +87,7 @@ export const useResponseConnectionMutation = () => { if (replyItems && manifest && data) { const response = await saveWalletTonConnect({ storage: sdk.storage, - wallet: data.activeTonWallet, + account: data, manifest, params, replyItems,