diff --git a/src/renderer/features/wallets/WalletSelect/lib/wallet-select-utils.ts b/src/renderer/features/wallets/WalletSelect/lib/wallet-select-utils.ts index a2939f5a6..92bcae209 100644 --- a/src/renderer/features/wallets/WalletSelect/lib/wallet-select-utils.ts +++ b/src/renderer/features/wallets/WalletSelect/lib/wallet-select-utils.ts @@ -30,7 +30,7 @@ const getWalletByGroups = (wallets: Wallet[], query = ''): Record { +const getFirstWallet = (wallets: Wallet[]): Wallet | null => { return Object.values(getWalletByGroups(wallets)).flat().at(0) ?? null; }; diff --git a/src/renderer/shared/ui-kit/Combobox/Combobox.tsx b/src/renderer/shared/ui-kit/Combobox/Combobox.tsx index 33fbb7798..c6f0f85ca 100644 --- a/src/renderer/shared/ui-kit/Combobox/Combobox.tsx +++ b/src/renderer/shared/ui-kit/Combobox/Combobox.tsx @@ -146,9 +146,9 @@ const Group = ({ title, children }: PropsWithChildren) => { if (Children.count(children) === 0) return null; return ( - + -
{title}
+
{title}
{children}
diff --git a/src/renderer/widgets/CreateWallet/ui/MultisigWallet/SelectSignatoriesThreshold.tsx b/src/renderer/widgets/CreateWallet/ui/MultisigWallet/SelectSignatoriesThreshold.tsx index f319b6c57..5042b6335 100644 --- a/src/renderer/widgets/CreateWallet/ui/MultisigWallet/SelectSignatoriesThreshold.tsx +++ b/src/renderer/widgets/CreateWallet/ui/MultisigWallet/SelectSignatoriesThreshold.tsx @@ -5,7 +5,7 @@ import { type FormEvent, useState } from 'react'; import { useI18n } from '@/shared/i18n'; import { nonNullable } from '@/shared/lib/utils'; import { Alert, Button, InputHint, SmallTitleText } from '@/shared/ui'; -import { Box, Select } from '@/shared/ui-kit'; +import { Box, Field, Select } from '@/shared/ui-kit'; import { walletModel } from '@/entities/wallet'; import { Step } from '../../lib/types'; import { flowModel } from '../../model/flow-model'; @@ -113,23 +113,25 @@ export const SelectSignatoriesThreshold = () => { {t('createMultisigAccount.notEmptySignatoryName')} -
+
- + + + - + {t('createMultisigAccount.thresholdHint')}
@@ -176,12 +178,7 @@ export const SelectSignatoriesThreshold = () => {
-
diff --git a/src/renderer/widgets/CreateWallet/ui/MultisigWallet/components/Signatory.tsx b/src/renderer/widgets/CreateWallet/ui/MultisigWallet/components/Signatory.tsx index d5b7ba5be..2d2502ad7 100644 --- a/src/renderer/widgets/CreateWallet/ui/MultisigWallet/components/Signatory.tsx +++ b/src/renderer/widgets/CreateWallet/ui/MultisigWallet/components/Signatory.tsx @@ -1,9 +1,10 @@ import { useUnit } from 'effector-react'; import { useEffect, useMemo, useState } from 'react'; -import { type Account, type Address as AccountAddress, type WalletFamily } from '@/shared/core'; +import { type Account, type Address as AccountAddress, type ID, type WalletFamily } from '@/shared/core'; import { useI18n } from '@/shared/i18n'; import { + includesMultiple, performSearch, toAccountId, toAddress, @@ -24,7 +25,7 @@ import { signatoryModel } from '../../../model/signatory-model'; interface Props { signatoryName: string; - signatoryAddress: string; + signatoryAddress: AccountAddress; signatoryIndex: number; selectedWalletId?: string; isOwnAccount?: boolean; @@ -87,33 +88,29 @@ export const Signatory = ({ useEffect(() => { if (!isOwnAccount || wallets.length === 0 || !chain) return; - const walletByGroup = walletSelectUtils.getWalletByGroups(wallets, query); + const filteredWallets = walletUtils.getWalletsFilteredAccounts(wallets, { + walletFn: walletUtils.isValidSignatory, + accountFn: (account, wallet) => { + const isChainMatch = accountUtils.isChainAndCryptoMatch(account, chain); + const isCorrectAccount = accountUtils.isNonBaseVaultAccount(account, wallet); + const address = toAddress(account.accountId, { prefix: chain.addressPrefix }); + const queryPass = includesMultiple([account.name, address], query); + + return isChainMatch && isCorrectAccount && queryPass; + }, + }); + const walletByGroup = walletSelectUtils.getWalletByGroups(filteredWallets || []); const options: [WalletFamily, Account[]][] = []; - const checkedAddresses: Set = new Set(); for (const [walletFamily, walletsGroup] of Object.entries(walletByGroup)) { if (walletsGroup.length === 0) continue; const accountOptions: Account[] = []; for (const wallet of walletsGroup) { - if (!wallet.accounts.length || !walletUtils.isValidSignatory(wallet)) continue; - - for (const account of wallet.accounts) { - if (checkedAddresses.has(account.accountId)) continue; - - const isChainMatch = accountUtils.isChainAndCryptoMatch(account, chain); - const isCorrectAccount = accountUtils.isNonBaseVaultAccount(account, wallet); - - if (!isChainMatch || !isCorrectAccount) continue; - - accountOptions.push(account); - checkedAddresses.add(account.accountId); - } + accountOptions.push(...wallet.accounts); } - if (accountOptions.length === 0) continue; - options.push([walletFamily as WalletFamily, accountOptions]); } @@ -142,24 +139,20 @@ export const Signatory = ({ }); }; - const onAddressChange = (address: AccountAddress) => { + const onAddressChange = (address: T) => { if (!chain) return; + const [accountAddress, walletId] = address.split('_'); const isEthereumChain = networkUtils.isEthereumBased(chain.options); const validateFn = isEthereumChain ? validateEthereumAddress : validateSubstrateAddress; - if (!validateFn(address)) return; - - const wallet = walletUtils.getWalletFilteredAccounts(wallets, { - walletFn: walletUtils.isValidSignatory, - accountFn: ({ accountId }) => accountId === toAccountId(address), - }); + if (!validateFn(accountAddress)) return; signatoryModel.events.changeSignatory({ - address, + address: accountAddress, index: signatoryIndex, name: signatoryName, - walletId: wallet?.id.toString() ?? undefined, + walletId: walletId, // will be undefined for contact }); }; @@ -193,20 +186,23 @@ export const Signatory = ({ - +
+ - {t(GroupLabels[walletType as WalletFamily])} + {t(GroupLabels[walletType])}
} > {accounts.map((account) => { const address = toAddress(account.accountId, { prefix: chain?.addressPrefix }); + const itemValue = `${address}_${account.walletId}`; return ( - -
+ +
+
+
); })}