|
6 | 6 | import { fetchWithTimeout } from '@core/nfts' |
7 | 7 | import { checkActiveProfileAuth, getActiveProfile, updateAccountPersistedDataOnActiveProfile } from '@core/profile' |
8 | 8 | import { getProfileManager } from '@core/profile-manager/stores' |
9 | | - import { setClipboard, truncateString } from '@core/utils' |
| 9 | + import { |
| 10 | + setClipboard, |
| 11 | + truncateString, |
| 12 | + isValidBech32AddressAndPrefix, |
| 13 | + BECH32_DEFAULT_HRP, |
| 14 | + convertBech32ToHex, |
| 15 | + } from '@core/utils' |
10 | 16 | import { AccountAddress } from '@iota/sdk/out/types' |
11 | 17 | import VirtualList from '@sveltejs/svelte-virtual-list' |
12 | | - import { Button, FontWeight, KeyValueBox, Spinner, Text, TextType } from 'shared/components' |
| 18 | + import { Button, ButtonSize, FontWeight, KeyValueBox, Spinner, Text, TextType } from 'shared/components' |
13 | 19 | import { onMount } from 'svelte' |
| 20 | + import { HexAddressBox } from '@ui' |
14 | 21 |
|
15 | 22 | interface AddressHistory { |
16 | 23 | address: string |
|
42 | 49 | setClipboard(addresses) |
43 | 50 | } |
44 | 51 |
|
| 52 | + function onCopyAllHexAdressesClick(): void { |
| 53 | + const hexList = knownAddresses |
| 54 | + .map((address) => convertBech32ToHex(address.address, BECH32_DEFAULT_HRP)) |
| 55 | + .join(',') |
| 56 | + setClipboard(hexList) |
| 57 | + } |
| 58 | +
|
45 | 59 | onMount(() => { |
46 | 60 | knownAddresses = $selectedAccount?.knownAddresses |
47 | 61 | if (!knownAddresses?.length) { |
|
146 | 160 | {#if knownAddresses.length > 0} |
147 | 161 | <div class="w-full flex-col space-y-2 virtual-list-wrapper"> |
148 | 162 | <VirtualList items={knownAddresses} let:item> |
149 | | - <div class="mb-1"> |
| 163 | + <div class="flex flex-col space-y-1"> |
150 | 164 | <KeyValueBox |
151 | 165 | isCopyable |
152 | 166 | classes="flex items-center w-full py-4" |
|
161 | 175 | backgroundColor="gray-50" |
162 | 176 | darkBackgroundColor="gray-900" |
163 | 177 | /> |
| 178 | + |
| 179 | + {#if isValidBech32AddressAndPrefix(item.address, BECH32_DEFAULT_HRP)} |
| 180 | + <HexAddressBox address={item.address} isCopyable clearBackground clearBorder /> |
| 181 | + <hr class="border-gray-300 dark:border-gray-700 py-2" /> |
| 182 | + {/if} |
164 | 183 | </div> |
165 | 184 | </VirtualList> |
166 | 185 | </div> |
|
174 | 193 | {/if} |
175 | 194 | </div> |
176 | 195 | <div class="flex flex-row flex-nowrap w-full space-x-4 mt-6"> |
177 | | - <div class="flex w-full justify-center pt-8 space-x-4"> |
178 | | - <Button outline classes="w-1/2" onClick={onCopyClick}>{localize('actions.copy')}</Button> |
| 196 | + <div class="flex flex-col w-full justify-center pt-3 space-y-2"> |
| 197 | + <div class="flex w-full justify-center space-x-4"> |
| 198 | + <Button outline classes="w-1/2" onClick={onCopyClick} size={ButtonSize.Small}>Copy Addresses</Button> |
| 199 | + <Button outline classes="w-1/2" onClick={onCopyAllHexAdressesClick} size={ButtonSize.Small} |
| 200 | + >Copy Hex Addresses</Button |
| 201 | + > |
| 202 | + </div> |
179 | 203 | <Button |
180 | | - classes="w-1/2" |
181 | 204 | onClick={handleSearchClick} |
182 | 205 | disabled={isBusy} |
183 | 206 | {isBusy} |
| 207 | + size={ButtonSize.Medium} |
184 | 208 | busyMessage={localize('actions.searching')}>{localize('actions.search')}</Button |
185 | 209 | > |
186 | 210 | </div> |
|
199 | 223 | .virtual-list-wrapper :global(svelte-virtual-list-contents) { |
200 | 224 | margin-right: -1rem !important; |
201 | 225 | } |
| 226 | + .virtual-list-wrapper :global(svelte-virtual-list-row:last-of-type hr) { |
| 227 | + display: none !important; |
| 228 | + } |
202 | 229 | </style> |
0 commit comments