Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: set a primary key (account management) #8077

Merged
merged 70 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
40512e3
feat: add account management router
evavirseda Feb 6, 2024
b6a15f2
feat: update icon
evavirseda Feb 6, 2024
b6ceba1
feat: add account list
evavirseda Feb 6, 2024
094f722
Merge branch 'develop-iota2.0' into feat/add-account-management-router
evavirseda Feb 6, 2024
45e6f80
Merge branch 'develop-iota2.0' into feat/add-acount-management-list-ui
evavirseda Feb 7, 2024
97969ac
Merge branch 'develop-iota2.0' into feat/add-account-management-router
evavirseda Feb 7, 2024
00136ce
Merge branch 'feat/add-account-management-router' into feat/add-acoun…
evavirseda Feb 7, 2024
96d9438
fix: display as isBusy if hasImplicitAccountCreationTransactionInProg…
evavirseda Feb 7, 2024
ebd0372
feat: format and truncate address
evavirseda Feb 7, 2024
b7a6c67
feat: cleanup code
evavirseda Feb 8, 2024
222e941
feat: add features flag
evavirseda Feb 8, 2024
c92a0cb
feat: add account management details ui
evavirseda Feb 8, 2024
a241985
feat: add locales
evavirseda Feb 9, 2024
2772f39
feat: enable features
evavirseda Feb 9, 2024
4fa8d55
feat: update accountManagement
evavirseda Feb 9, 2024
3fba6a5
Merge branch 'develop-iota2.0' into feat/add-acount-management-list-ui
evavirseda Feb 9, 2024
7741032
Merge branch 'feat/add-acount-management-list-ui' into feat/add-accou…
evavirseda Feb 12, 2024
01d151e
feat: use real data
evavirseda Feb 12, 2024
b922eec
feat: fix wrong merge
evavirseda Feb 12, 2024
6c40111
Merge branch 'develop-iota2.0' into feat/add-acount-management-list-ui
evavirseda Feb 12, 2024
c01b709
feat: add isImplicitAccountAccountOutput function
evavirseda Feb 12, 2024
2b55cb6
Merge branch 'feat/add-acount-management-list-ui' into feat/add-accou…
evavirseda Feb 12, 2024
d73eb3d
fix import
evavirseda Feb 12, 2024
2d5e4d9
Merge branch 'feat/add-acount-management-list-ui' into feat/add-accou…
evavirseda Feb 12, 2024
1e6710d
fix: improve function
evavirseda Feb 13, 2024
c74de66
Merge branch 'feat/add-acount-management-list-ui' into feat/add-accou…
evavirseda Feb 13, 2024
826ac45
feat: cleanup
evavirseda Feb 13, 2024
152171e
feat: cleanup
evavirseda Feb 13, 2024
d7f94ed
feat: cleanup
evavirseda Feb 13, 2024
687d022
Merge branch 'feat/add-account-info' into feat/add-account-info-logic
evavirseda Feb 13, 2024
9f40d56
minor fix
evavirseda Feb 13, 2024
c5b76e9
feat: show address
evavirseda Feb 13, 2024
65d8b5d
fix type
evavirseda Feb 13, 2024
015446c
Merge branch 'feat/add-acount-management-list-ui' into feat/add-accou…
evavirseda Feb 13, 2024
67fdb22
Merge branch 'develop-iota2.0' into feat/add-account-info
evavirseda Feb 13, 2024
26b74db
Merge branch 'feat/add-account-info' into feat/add-account-info-logic
evavirseda Feb 13, 2024
910f6ba
Merge branch 'develop-iota2.0' into feat/add-account-info-logic
evavirseda Feb 13, 2024
f47602c
feat: cleanup
evavirseda Feb 13, 2024
f137ff8
feat: hide implicitAccount address, clenaup and display transition bu…
evavirseda Feb 14, 2024
ce39114
feat: update main account id and persist
evavirseda Feb 14, 2024
75fdc17
feat: cleanup
evavirseda Feb 14, 2024
91f7195
feat: add locales and menuItem
evavirseda Feb 14, 2024
77bebe2
feat: update details and cleanup
evavirseda Feb 14, 2024
4746c51
fix warnings
evavirseda Feb 14, 2024
d490304
Merge branches 'feat/add-account-info-logic' and 'develop-iota2.0' of…
cpl121 Feb 16, 2024
2ede84c
feat: update logic for details view - display popup activate account …
cpl121 Feb 16, 2024
cdfa863
fix: fixes
cpl121 Feb 16, 2024
0e5e5a9
Merge branches 'feat/add-account-info-logic' and 'develop-iota2.0' of…
cpl121 Feb 16, 2024
88cc985
fix: format
cpl121 Feb 16, 2024
12ca588
Merge branches 'feat/add-account-info-logic' and 'develop-iota2.0' of…
cpl121 Feb 16, 2024
244f3df
fix: minor improvements
cpl121 Feb 16, 2024
a66daea
Merge branches 'feat/update-logic-for-activate-account-in-details-vie…
cpl121 Feb 16, 2024
487b4ae
Merge branches 'feat/update-logic-for-activate-account-in-details-vie…
cpl121 Feb 16, 2024
b72e992
fixes
cpl121 Feb 19, 2024
edc0089
feat: update styles
evavirseda Feb 19, 2024
9af8f1e
Merge branch 'develop-iota2.0' into feat/update-logic-for-activate-ac…
evavirseda Feb 20, 2024
b43ed6f
Merge branches 'feat/update-logic-for-activate-account-in-details-vie…
cpl121 Feb 20, 2024
69a45af
feat: add primary key
evavirseda Feb 20, 2024
36c1819
fixes
cpl121 Feb 20, 2024
b030f90
minor fixes
evavirseda Feb 20, 2024
72ef0f5
fix imports
evavirseda Feb 22, 2024
34fc142
minor fix
evavirseda Feb 22, 2024
cd4357a
Merge branch 'develop-iota2.0' into feat/update-logic-for-activate-ac…
cpl121 Feb 22, 2024
5556b27
fix: improve UX to open link
cpl121 Feb 22, 2024
f6aecfa
fix: improve UX again
cpl121 Feb 22, 2024
3618ced
Merge branch 'feat/update-logic-for-activate-account-in-details-view'…
evavirseda Feb 22, 2024
6617f0d
Merge branch 'develop-iota2.0' into feat/set-a-primary-key
evavirseda Feb 22, 2024
3065a9c
Merge branch 'develop-iota2.0' into feat/set-a-primary-key
evavirseda Feb 23, 2024
3b6e84b
fix: remove unnecessary ?
evavirseda Feb 23, 2024
6ebe4dc
Merge branch 'develop-iota2.0' into feat/set-a-primary-key
evavirseda Feb 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions packages/desktop/components/AccountManagementDetails.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
getBech32AddressFromAddressTypes,
isAccountOutput,
isImplicitAccountOutput,
selectedWallet,
selectedWalletMainAccountId,
} from '@core/wallet'
import {
Expand Down Expand Up @@ -49,15 +50,16 @@

const explorerUrl = getOfficialExplorerUrl($activeProfile?.network?.id)

$: isImplicitAccount = isImplicitAccountOutput(selectedOutput?.output as CommonOutput)
$: accountId = isAccountOutput(selectedOutput) ? (selectedOutput?.output as AccountOutput)?.accountId : null
$: isImplicitAccount = isImplicitAccountOutput(selectedOutput.output as CommonOutput)
$: accountId = isAccountOutput(selectedOutput) ? (selectedOutput.output as AccountOutput)?.accountId : null
$: address = accountId ? getBech32AddressFromAddressTypes(new AccountAddress(accountId)) : null
$: isMainAccount = accountId && accountId === $selectedWalletMainAccountId
$: balance = getAccountBalance(selectedOutput, isImplicitAccount)
$: formattedBalance = balance ? formatTokenAmountBestMatch(balance, getBaseToken()) : '-'
$: hasStakingFeature = hasOutputStakingFeature(selectedOutput)
$: rawStakedAmount = getStakedAmount(selectedOutput)
$: formattedStakedAmount = formatTokenAmountBestMatch(rawStakedAmount, getBaseToken())
$: primaryKey = $selectedWallet?.primaryKey
$: listBlockKeysFeature(selectedOutput)

function getAccountBalance(outputData: OutputData, isImplicitAccount: boolean): number | undefined {
Expand Down Expand Up @@ -157,7 +159,7 @@
>
{/if}
</title-container>
{#if selectedOutput?.outputId}
{#if selectedOutput.outputId}
<button
class="action w-max flex justify-start text-center font-medium text-14 text-blue-500"
on:click={onExplorerClick}
Expand Down Expand Up @@ -214,18 +216,17 @@
>{localize('views.accountManagement.details.mana')}</Text
>
<Text type={TextType.pre} fontSize="13" lineHeight="leading-120" classes="text-start w-[260px]"
>{selectedOutput?.output?.mana}</Text
>{selectedOutput.output?.mana}</Text
>
</div>
{/if}
{#if isAccountOutput && keys.length > 0}
{#if isAccountOutput && primaryKey}
<div class="flex flex-col space-y-2 w-1/2">
<Text color="gray-600" fontWeight={FontWeight.medium} fontSize="12" type={TextType.p}
>{localize('views.accountManagement.details.key')}</Text
>
<!-- TODO: When we can set a primary key, we will show the primary key here -->
<Text type={TextType.pre} fontSize="13" lineHeight="leading-120" classes="text-start w-[260px]"
>{keys[0]}</Text
>{primaryKey}</Text
>
</div>
{/if}
Expand Down
1 change: 0 additions & 1 deletion packages/desktop/components/popups/Popup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
case PopupId.LedgerAppGuide:
case PopupId.ActivateAccount:
case PopupId.LedgerConnection:
case PopupId.ManageKeys:
size = PopupSize.Large
break
default:
Expand Down
34 changes: 24 additions & 10 deletions packages/shared/components/KeyListRow.svelte
Original file line number Diff line number Diff line change
@@ -1,30 +1,42 @@
<script lang="ts">
import { Pill } from './pills'
import { Text, Modal, MeatballMenuButton, MenuItem } from 'shared/components'
import { Pill, Text, Modal, MeatballMenuButton, MenuItem, TooltipIcon } from '@ui'
import { localize } from '@core/i18n'
import { truncateString } from '@core/utils'
import { selectedWalletId, selectedWallet } from '@core/wallet'
import { updateActiveWalletPersistedData } from '@core/profile'

export let key: string

let modal: Modal | undefined
const truncatedKey: string = truncateString(key, 12, 12)
cpl121 marked this conversation as resolved.
Show resolved Hide resolved

const isPrimary: boolean = false
let isPrimary: boolean = $selectedWallet?.primaryKey === key

function toggleModal(): void {
modal?.toggle()
}

// eslint-disable-next-line @typescript-eslint/require-await
async function onTogglePrimaryKeyClick(): Promise<void> {
if (isPrimary) {
// TODO: Implement the logic to set primary key
function onTogglePrimaryKeyClick(): void {
if (!isPrimary) {
isPrimary = true
updateActiveWalletPersistedData($selectedWalletId, {
primaryKey: key,
})
} else {
isPrimary = false
updateActiveWalletPersistedData($selectedWalletId, {
primaryKey: undefined,
})
}
toggleModal()
}

$: MENU_ITEMS = [
{
title: localize(
`views.accountManagement.details.manageKeys.${isPrimary ? 'unsetAsPrimary' : 'setAsPrimary'}`
`views.accountManagement.details.manageKeys.${
$selectedWallet?.primaryKey === key || isPrimary ? 'unsetAsPrimary' : 'setAsPrimary'
}`
),
onClick: onTogglePrimaryKeyClick,
},
Expand All @@ -36,10 +48,12 @@
>
<div class="flex flex-row items-center space-x-4 overflow-hidden">
<Text classes="self-start overflow-hidden whitespace-nowrap">
{key}
{truncatedKey}
</Text>
{#if isPrimary}
<TooltipIcon text={key} width={15} height={15} classes="flex break-all" />
{#if $selectedWallet?.primaryKey === key}
<Pill
clearPadding
data={localize('views.accountManagement.details.manageKeys.primary').toLowerCase()}
textColor="blue-500"
/>
Expand Down
4 changes: 3 additions & 1 deletion packages/shared/components/pills/Pill.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
export let backgroundColor: string = ''
export let darkBackgroundColor: string = ''
export let classes: string = ''
export let clearPadding: boolean = false
</script>

<Text
smaller
fontWeight={FontWeight.semibold}
color={textColor}
darkColor={darkTextColor || textColor}
classes="px-2.5 py-1 rounded-2xl
classes="rounded-2xl
{backgroundColor ? 'bg-' + backgroundColor : ''}
{darkBackgroundColor ? 'dark:bg-' + darkBackgroundColor : ''}
{classes}
{clearPadding ? '' : 'px-2.5 py-1'}
"
>
{#if data}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export interface IPersistedWalletData {
removedProposalIds?: ParticipationEventId[]
walletOptions: WalletOptions
mainAccountId?: string | undefined
primaryKey?: string | undefined
}
Loading