diff --git a/packages/ui/cypress/tests/transactions.cy.ts b/packages/ui/cypress/tests/transactions.cy.ts index 235a7441..3c2010c9 100644 --- a/packages/ui/cypress/tests/transactions.cy.ts +++ b/packages/ui/cypress/tests/transactions.cy.ts @@ -4,7 +4,6 @@ import { landingPageUrl } from '../fixtures/landingData' import { multisigPage } from '../support/page-objects/multisigPage' import { notifications } from '../support/page-objects/notifications' import { sendTxModal } from '../support/page-objects/sendTxModal' -import { topMenuItems } from '../support/page-objects/topMenuItems' import { clickOnConnect } from '../utils/clickOnConnect' import { waitForTxRequest } from '../utils/waitForTxRequests' diff --git a/packages/ui/src/components/EasySetup/BalancesTransfer.tsx b/packages/ui/src/components/EasySetup/BalancesTransfer.tsx index 0937de14..62378f84 100644 --- a/packages/ui/src/components/EasySetup/BalancesTransfer.tsx +++ b/packages/ui/src/components/EasySetup/BalancesTransfer.tsx @@ -20,7 +20,7 @@ interface Props { } const BalancesTransfer = ({ className, onSetExtrinsic, onSetErrorMessage, from }: Props) => { - const accountBase = useAccountBaseFromAccountList() + const accountBase = useAccountBaseFromAccountList({ withAccountsFromAddressBook: true }) const [selected, setSelected] = useState() const { api, chainInfo } = useApi() const [amountString, setAmountString] = useState('') diff --git a/packages/ui/src/hooks/useAccountBaseFromAccountList.tsx b/packages/ui/src/hooks/useAccountBaseFromAccountList.tsx index db6ad4d9..6dc3c024 100644 --- a/packages/ui/src/hooks/useAccountBaseFromAccountList.tsx +++ b/packages/ui/src/hooks/useAccountBaseFromAccountList.tsx @@ -1,15 +1,26 @@ import { useMemo } from 'react' import { AccountBaseInfo } from '../components/select/GenericAccountSelection' import { useAccounts } from '../contexts/AccountsContext' +import { useAccountNames } from '../contexts/AccountNamesContext' -export const useAccountBaseFromAccountList = () => { +interface Params { + withAccountsFromAddressBook: boolean +} + +export const useAccountBaseFromAccountList = (params?: Params) => { + const { withAccountsFromAddressBook = false } = params || {} const { ownAccountList } = useAccounts() + const { accountNames } = useAccountNames() const accountBase = useMemo((): AccountBaseInfo[] => { - return ( - (ownAccountList && ownAccountList?.map((account) => ({ address: account.address }))) || [] - ) - }, [ownAccountList]) + const ownAccountListAddresses = + (ownAccountList && ownAccountList.map(({ address }) => address)) || [] + const accountFromNameRegistry = + (withAccountsFromAddressBook && Object.keys(accountNames).map((address) => address)) || [] + const addressesSet = new Set([...accountFromNameRegistry, ...ownAccountListAddresses]) + + return Array.from(addressesSet).map((address) => ({ address })) + }, [accountNames, ownAccountList, withAccountsFromAddressBook]) return accountBase }