Skip to content

Commit

Permalink
refactor: Remove Account debris (#7909)
Browse files Browse the repository at this point in the history
* refactor(2.0): Dynamic password

* refactor(2.0): Remove Profile Manager (wip)

* clean up and fix

* clean up

* clean up more code

* clean up

* adapt and remove for profile-manager related code

* clean up more code

* fmt

* more cleanup

* more cleanup

* small tweaks

* more cleanup

* format

* update

* clean up

* https://api.testnet.shimmer.network

* revert Wallet.svelte

* clean up

* remove account debris

* clean up

* fix

---------

Co-authored-by: Begoña Álvarez de la Cruz <[email protected]>
  • Loading branch information
marc2332 and begonaalvarezd authored Feb 1, 2024
1 parent 6808007 commit 312a8a8
Show file tree
Hide file tree
Showing 61 changed files with 204 additions and 217 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { AccountActionsButton } from '@components'
import { WalletActionsButton } from '@components'
import { Text, TogglableAssetBalanceLabel } from '@ui'
import { TextType } from '@ui/enums'
Expand All @@ -16,14 +16,14 @@
$: ({ baseCoin } = $selectedWalletAssets[$activeProfile?.network.id])
</script>

<account-summary class="block relative space-y-4">
<wallet-summary class="block relative space-y-4">
<div class="flex flex-row items-center justify-between">
<Text type={TextType.h5} classes="text-left">
{localize('general.balanceWithNetwork', { values: { network: fomattedNetworkName } })}
</Text>
<AccountActionsButton />
<WalletActionsButton />
</div>
<div class="flex flex-col flex-wrap items-start space-y-1">
<TogglableAssetBalanceLabel asset={baseCoin} />
</div>
</account-summary>
</wallet-summary>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
let modal: Modal
</script>

<account-actions-button class="block relative">
<wallet-actions-button class="block relative">
<MeatballMenuButton onClick={modal?.toggle} />
<WalletActionsMenu bind:modal position={{ right: '0' }} classes="mt-1.5" />
</account-actions-button>
</wallet-actions-button>
2 changes: 1 addition & 1 deletion packages/desktop/components/buttons/menu-buttons/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as AccountActionsButton } from './AccountActionsButton.svelte'
export { default as WalletActionsButton } from './WalletActionsButton.svelte'
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import { OnboardingButton } from '@ui'
import { localize } from '@core/i18n'
import { refreshAccountAssetsForActiveProfile } from '@core/wallet'
import { refreshWalletAssetsForActiveProfile } from '@core/wallet'
import { showAppNotification } from '@auxiliary/notification'
import { closePopup, openPopup, PopupId } from '@auxiliary/popup'
import { TextHintVariant } from 'shared/components/enums'
function refreshTokenMetadata(): void {
refreshAccountAssetsForActiveProfile(true)
refreshWalletAssetsForActiveProfile(true)
showAppNotification({
type: 'success',
message: localize('notifications.refreshTokenMetadata.success'),
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export * from './modals'
export * from './panes'
export * from './popups'

export { default as AccountActivity } from './AccountActivity.svelte'
export { default as AccountSummary } from './AccountSummary.svelte'
export { default as WalletActivity } from './WalletActivity.svelte'
export { default as WalletSummary } from './WalletSummary.svelte'
export { default as WalletSwitcher } from './WalletSwitcher.svelte'
export { default as OnboardingLayout } from './OnboardingLayout.svelte'
export { default as Proposals } from './Proposals.svelte'
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop/components/modals/VestingModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
</script>

<Modal bind:this={modal} {...$$restProps}>
<account-actions-menu class="flex flex-col">
<vesting-modal class="flex flex-col">
<MenuItem
icon={Icon.Search}
title={localize('actions.viewVestingRewardsFinder')}
onClick={onVestingFinderClick}
/>
</account-actions-menu>
</vesting-modal>
</Modal>
26 changes: 13 additions & 13 deletions packages/desktop/components/modals/WalletActionsMenu.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { MenuItem, MenuItemVariant, Modal, ToggleHiddenAccountMenuItem } from '@ui'
import { MenuItem, MenuItemVariant, Modal, ToggleHiddenWalletMenuItem } from '@ui'
import { localize } from '@core/i18n'
import { activeProfile, isActiveLedgerProfile } from '@core/profile/stores'
Expand All @@ -16,10 +16,10 @@
export let modal: Modal = undefined
const showDeleteAccount = false // TODO(2.0) It doesn't make sense to allow removing
const showDeleteWallet = false // TODO(2.0) It doesn't make sense to allow removing
// the wallet as there is only one for each profile at the moment
function onCustomiseAccountClick(): void {
function onCustomiseWalletClick(): void {
openPopup({ id: PopupId.ManageWallet })
modal?.close()
}
Expand Down Expand Up @@ -60,11 +60,11 @@
})
}
function onDeleteAccountClick(): void {
function onDeleteWalletClick(): void {
openPopup({
id: PopupId.DeleteAccount,
id: PopupId.DeleteWallet,
props: {
account: selectedWallet,
wallet: selectedWallet,
deleteWallet,
},
})
Expand All @@ -73,7 +73,7 @@
</script>

<Modal bind:this={modal} {...$$restProps}>
<account-actions-menu class="flex flex-col">
<wallet-actions-menu class="flex flex-col">
<MenuItem icon={Icon.Doc} title={localize('actions.viewBalanceBreakdown')} onClick={onViewBalanceClick} />
{#if $activeProfile?.network?.id === NetworkId.Iota || $activeProfile?.network?.id === NetworkId.IotaAlphanet}
<MenuItem
Expand All @@ -82,23 +82,23 @@
onClick={onViewAddressHistoryClick}
/>
{/if}
<MenuItem icon={Icon.Customize} title={localize('actions.customizeAcount')} onClick={onCustomiseAccountClick} />
<MenuItem icon={Icon.Customize} title={localize('actions.customizeAcount')} onClick={onCustomiseWalletClick} />
{#if $isActiveLedgerProfile}
<MenuItem
icon={Icon.Ledger}
title={localize('actions.verifyDepositAddress')}
onClick={onVerifyAddressClick}
/>
{/if}
<ToggleHiddenAccountMenuItem onClick={modal?.close} />
<ToggleHiddenWalletMenuItem onClick={modal?.close} />
<hr />
{#if showDeleteAccount}
{#if showDeleteWallet}
<MenuItem
icon={Icon.Delete}
title={localize('actions.deleteAccount')}
onClick={onDeleteAccountClick}
title={localize('actions.showDeleteWallet')}
onClick={onDeleteWalletClick}
variant={MenuItemVariant.Error}
/>
{/if}
</account-actions-menu>
</wallet-actions-menu>
</Modal>
12 changes: 6 additions & 6 deletions packages/desktop/components/modals/WalletSwitcherModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
async function scrollToSelectedWallet(): Promise<void> {
await tick()
const element = document.getElementById(`account-${$selectedWallet.id}`)
const element = document.getElementById(`wallet-${$selectedWallet.id}`)
element?.scrollIntoView({ behavior: 'auto' })
}
Expand All @@ -34,13 +34,13 @@
size="large"
position={{ top: '30px', left: '50%' }}
>
<account-list-container class="block p-4">
<account-list class="flex flex-col space-y-1 max-h-96 scrollable-y">
<wallet-list-container class="block p-4">
<wallet-list class="flex flex-col space-y-1 max-h-96 scrollable-y">
{#each $visibleActiveWallets as wallet}
<WalletSwitcherMenuItem id="account-{wallet.id}" {wallet} onClick={modal?.close} />
<WalletSwitcherMenuItem id="wallet-{wallet.id}" {wallet} onClick={modal?.close} />
{/each}
</account-list>
</account-list-container>
</wallet-list>
</wallet-list-container>
<hr />
<button
type="button"
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/components/popups/AddProposalPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
label={localize('views.governance.details.proposalInformation.eventId')}
/>
{#if !isEditMode}
<Checkbox label={localize('popups.addProposal.addToAllAccounts')} bind:checked={isAddingForAllWallets} />
<Checkbox label={localize('popups.addProposal.addToAllWallets')} bind:checked={isAddingForAllWallets} />
{/if}
</div>
<div class="flex w-full space-x-4 mt-6">
Expand Down
14 changes: 7 additions & 7 deletions packages/desktop/components/popups/BalanceBreakdownPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
Timelock = 'timelock',
}
$: accountBalance = $selectedWallet?.balances
$: accountBalance, void setBreakdown()
$: walletBalance = $selectedWallet?.balances
$: walletBalance, void setBreakdown()
let breakdown: { [key: string]: BalanceBreakdown } = {}
Expand All @@ -44,14 +44,14 @@
}
function getAvailableBreakdown(): BalanceBreakdown {
return { amount: Number(accountBalance?.baseCoin?.available ?? 0) }
return { amount: Number(walletBalance?.baseCoin?.available ?? 0) }
}
async function getPendingBreakdown(): Promise<BalanceBreakdown> {
let pendingOutputsStorageDeposit = 0
const subBreakdown = {}
for (const [outputId, unlocked] of Object.entries(accountBalance?.potentiallyLockedOutputs ?? {})) {
for (const [outputId, unlocked] of Object.entries(walletBalance?.potentiallyLockedOutputs ?? {})) {
if (!unlocked) {
const output = (await $selectedWallet.getOutput(outputId)).output
Expand Down Expand Up @@ -100,9 +100,9 @@
}
function getStorageDepositBreakdown(): BalanceBreakdown {
const storageDeposits = accountBalance?.requiredStorageDeposit
const storageDeposits = walletBalance?.requiredStorageDeposit
const totalStorageDeposit = storageDeposits
? Object.values(accountBalance.requiredStorageDeposit).reduce(
? Object.values(walletBalance.requiredStorageDeposit).reduce(
(total: number, value: string): number => total + Number(value ?? 0),
0
)
Expand Down Expand Up @@ -161,7 +161,7 @@
subBreakdown={breakdown[breakdownKey].subBreakdown}
/>
{/each}
<BalanceSummarySection titleKey="totalBalance" amount={Number(accountBalance?.baseCoin?.total ?? 0)} bold />
<BalanceSummarySection titleKey="totalBalance" amount={Number(walletBalance?.baseCoin?.total ?? 0)} bold />
</div>
<Button onClick={onConsolidationClick}>
{localize('popups.balanceBreakdown.minimizeStorageDepositButton')}
Expand Down
24 changes: 12 additions & 12 deletions packages/desktop/components/popups/BalanceFinderPopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
} from '@core/profile'
import {
formatTokenAmountBestMatch,
generateAndStoreActivitiesForAllAccounts,
refreshAccountAssetsForActiveProfile,
generateAndStoreActivitiesForAllWallets,
refreshWalletAssetsForActiveProfile,
} from '@core/wallet'
import {
Button,
Expand All @@ -41,7 +41,7 @@
export let searchForBalancesOnLoad = false
export let hasUsedBalanceFinder = false
export let showConsolidation = false
export let consolidateAccountsOnLoad = false
export let consolidateWalletsOnLoad = false
export let title: string
export let body: string
export let searchInCurrentWallet: boolean = false
Expand All @@ -59,7 +59,7 @@
? $visibleActiveWallets?.filter((_wallet) => _wallet.id === $selectedWalletId)
: $visibleActiveWallets
$: searchForBalancesOnLoad && !$isStrongholdLocked && onFindBalancesClick()
$: consolidateAccountsOnLoad && !$isStrongholdLocked && onConsolidateAccountsClick()
$: consolidateWalletsOnLoad && !$isStrongholdLocked && onConsolidateWalletsClick()
$: totalBalance = sumBalanceForWallets($visibleActiveWallets)
$: searchInCurrentWallet, (shouldInitSearch = true)
$: searchAlgorithm = searchInCurrentWallet
Expand All @@ -79,11 +79,11 @@
}
}
async function onConsolidateAccountsClick(): Promise<void> {
async function onConsolidateWalletsClick(): Promise<void> {
if ($isSoftwareProfile && $isStrongholdLocked) {
openUnlockStrongholdPopup(false, true)
} else {
await handleAction(consolidateProfileAccounts)
await handleAction(consolidateProfileWallets)
}
}
Expand All @@ -99,7 +99,7 @@
shouldInitSearch = false
}
async function consolidateProfileAccounts(): Promise<void> {
async function consolidateProfileWallets(): Promise<void> {
const consolidationPromises: Promise<void>[] = []
for (const wallet of get(visibleActiveWallets)) {
Expand Down Expand Up @@ -134,7 +134,7 @@
}
}
function openUnlockStrongholdPopup(searchForBalancesOnLoad: boolean, consolidateAccountsOnLoad: boolean) {
function openUnlockStrongholdPopup(searchForBalancesOnLoad: boolean, consolidateWalletsOnLoad: boolean) {
openPopup({
id: PopupId.UnlockStronghold,
props: {
Expand All @@ -143,7 +143,7 @@
id: PopupId.BalanceFinder,
props: {
searchForBalancesOnLoad,
consolidateAccountsOnLoad,
consolidateWalletsOnLoad,
showConsolidation,
hasUsedBalanceFinder,
title,
Expand Down Expand Up @@ -172,8 +172,8 @@
onDestroy(async () => {
if (hasUsedBalanceFinder) {
await refreshAccountAssetsForActiveProfile()
await generateAndStoreActivitiesForAllAccounts()
await refreshWalletAssetsForActiveProfile()
await generateAndStoreActivitiesForAllWallets()
loadNftsForActiveProfile()
}
})
Expand Down Expand Up @@ -252,7 +252,7 @@
/>
<Button
classes="w-full"
onClick={onConsolidateAccountsClick}
onClick={onConsolidateWalletsClick}
disabled={isBusy || isTransferring}
isBusy={isTransferring}
busyMessage={localize('popups.minimizeStorageDeposit.title')}
Expand Down
Loading

0 comments on commit 312a8a8

Please sign in to comment.