Skip to content

Commit d750cd1

Browse files
authored
Receive dropdown shouldn't concat account names if they have the same address (#287)
1 parent e4eb82f commit d750cd1

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

renderer/pages/receive/index.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,19 @@ export function ReceiveAccountsContent({
4545
return accountsData?.map((account) => {
4646
return {
4747
label: account.name,
48-
value: account.address,
48+
value: account.name,
4949
};
5050
});
5151
}, [accountsData]);
52+
const addressLookup = useMemo(() => {
53+
return accountsData?.reduce(
54+
(acc, account) => {
55+
acc[account.name] = account.address;
56+
return acc;
57+
},
58+
{} as Record<string, string>,
59+
);
60+
}, [accountsData]);
5261

5362
const defaultAccount = useMemo(() => {
5463
const queryMatch = accountOptions?.find(
@@ -73,7 +82,7 @@ export function ReceiveAccountsContent({
7382
},
7483
});
7584

76-
const addressValue = watch("account");
85+
const selectedAccount = watch("account");
7786

7887
return (
7988
<MainLayout>
@@ -92,12 +101,12 @@ export function ReceiveAccountsContent({
92101
<VStack alignItems="stretch" gap={4}>
93102
<Select
94103
{...register("account")}
95-
value={addressValue}
104+
value={selectedAccount}
96105
label={formatMessage(messages.fromLabel)}
97106
options={accountOptions}
98107
error={errors.account?.message}
99108
/>
100-
<AccountAddressDisplay address={addressValue} />
109+
<AccountAddressDisplay address={addressLookup[selectedAccount]} />
101110
</VStack>
102111
)}
103112
</WithExplanatorySidebar>

0 commit comments

Comments
 (0)