Skip to content

Commit

Permalink
fix(mobile): Hide non-wallet addresses from addressbook (#698)
Browse files Browse the repository at this point in the history
* fix(mobile): Hide non-wallet addresses from addressbook

* fix(mobile): Remove isStakingPool check
  • Loading branch information
voloshinskii authored Feb 6, 2024
1 parent 5f41427 commit 593838f
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions packages/mobile/src/core/Send/hooks/useSuggestedAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { SuggestedAddress, SuggestedAddressType } from '../Send.interface';
import { walletAddressSelector } from '$store/wallet';
import { CryptoCurrencies } from '$shared/constants';
import { Tonapi } from '$libs/Tonapi';
import { useStakingStore } from '$store';
import { ActionItem, ActionType, Address } from '@tonkeeper/core';
import { tk } from '@tonkeeper/shared/tonkeeper';

Expand All @@ -22,8 +21,6 @@ export const useSuggestedAddresses = () => {
useSelector(favoritesSelector);
const address = useSelector(walletAddressSelector);

const stakingPools = useStakingStore((s) => s.pools.map((pool) => pool.address));

const favoriteAddresses = useMemo(
(): SuggestedAddress[] =>
favorites
Expand Down Expand Up @@ -66,7 +63,8 @@ export const useSuggestedAddresses = () => {
!recipientAddress ||
Address.compare(walletAddress, recipientAddress) ||
payload.sender?.is_scam ||
payload.recipient?.is_scam
payload.recipient?.is_scam ||
!payload.recipient?.is_wallet
) {
return false;
}
Expand All @@ -76,17 +74,11 @@ export const useSuggestedAddresses = () => {
Address.compare(favorite.address, recipientAddress),
) !== -1;

const isStakingPool =
stakingPools.findIndex((poolAddress) =>
Address.compare(poolAddress, recipientAddress),
) !== -1;

const rawAddress = Address.parse(recipientAddress).toRaw();

if (
hiddenRecentAddresses.some((addr) => Address.compare(addr, rawAddress)) ||
isFavorite ||
isStakingPool
isFavorite
) {
return false;
}
Expand All @@ -105,7 +97,7 @@ export const useSuggestedAddresses = () => {
);

return uniqBy(addresses, (item) => item.address).slice(0, 8);
}, [address, favoriteAddresses, hiddenRecentAddresses, stakingPools]);
}, [address, favoriteAddresses, hiddenRecentAddresses]);

const suggestedAddresses = useMemo(
() => [...favoriteAddresses, ...recentAddresses],
Expand Down

0 comments on commit 593838f

Please sign in to comment.