Skip to content

Commit 3444d4b

Browse files
authored
fix: no duplicate address options and make sure alias matches for cus… (#2323)
1 parent c9b9d73 commit 3444d4b

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

apps/namadillo/src/App/Transfer/DestinationAddressModal.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,12 @@ export const DestinationAddressModal = ({
107107
: getChainImageUrl(getChainFromAddress(keplrAddress ?? "")),
108108
type: "keplr",
109109
});
110+
const addressOptionsAddresses = addressOptions.map((addr) => addr.address);
110111

111112
// Build recent addresses options
112-
const recentAddressOptions: AddressOption[] = recentAddresses.map(
113-
(recent) => ({
113+
const recentAddressOptions: AddressOption[] = recentAddresses
114+
.filter((addresses) => !addressOptionsAddresses.includes(addresses.address))
115+
.map((recent) => ({
114116
id: `recent-${recent.address}`,
115117
label: recent.label || getAddressLabel(recent.address, recent.type),
116118
address: recent.address,
@@ -119,8 +121,7 @@ export const DestinationAddressModal = ({
119121
: recent.type === "transparent" ? namadaTransparentIcon
120122
: getChainImageUrl(getChainFromAddress(recent.address ?? "")), // fallback for IBC
121123
type: recent.type,
122-
})
123-
);
124+
}));
124125

125126
const validateAddress = (address: string): ValidationResult => {
126127
// Check if address is empty

apps/namadillo/src/App/Transfer/TransferDestination.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ export const TransferDestination = ({
138138
: isTransparentAddress(destinationAddress ?? "") ? "transparent"
139139
: "ibc";
140140

141+
const getDestinationAddressLabel = (): string => {
142+
if (!destinationAddress) return "";
143+
if (isIbcAddress(destinationAddress ?? "")) return "Keplr";
144+
const shieldedAddress = shieldedAccount?.address;
145+
const transparentAddress = transparentAccount?.address;
146+
if ([shieldedAddress, transparentAddress].includes(destinationAddress))
147+
return alias ?? "";
148+
return "Custom";
149+
};
150+
141151
return (
142152
<>
143153
<div
@@ -216,7 +226,7 @@ export const TransferDestination = ({
216226
<div className="flex flex-col ml-4">
217227
<div className="flex flex-col">
218228
<span className="text-neutral-500 text-left font-normal text-xs">
219-
{isIbcAddress(destinationAddress) ? "Keplr" : alias}
229+
{getDestinationAddressLabel()}
220230
</span>
221231
<span className="text-white text-sm font-normal">
222232
{shortenAddress(destinationAddress, 15, 15)}

0 commit comments

Comments
 (0)