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

refactor: new single wallet 2.0 sdk #7726

Merged
merged 43 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
cc015d7
feat: Single account wallet creation, WIP
marc2332 Nov 16, 2023
66626f0
typo
marc2332 Nov 17, 2023
0816ecc
Merge branch 'develop-iota2.0' into feat/single-account-wallet-creation
marc2332 Nov 21, 2023
7817294
refactor(wip): create api core module
begonaalvarezd Nov 22, 2023
33d0e27
refactor(wip): refactor profile core module
begonaalvarezd Nov 22, 2023
ee2931c
refactor(wip): refactor profile core module
begonaalvarezd Nov 23, 2023
751df16
refactor(wip): refactor profilemanager core module
begonaalvarezd Nov 23, 2023
e05e7bb
refactor(wip): refactor profilemanager core module
begonaalvarezd Nov 23, 2023
66163e4
merge account into wallet
marc2332 Nov 28, 2023
ea5c673
move utils from profile manager to profile
marc2332 Nov 29, 2023
82fc7e8
rename every createAccount to createWallet
marc2332 Nov 29, 2023
709eecc
remove old mocks and tests
marc2332 Nov 29, 2023
d72754f
rename account stuff to wallet
marc2332 Nov 29, 2023
94a708c
rename account errors to wallet errors
marc2332 Nov 29, 2023
3fd299a
clean up `deleteWallet`
marc2332 Nov 29, 2023
a9e4865
fix imports
marc2332 Nov 29, 2023
acf2f9a
fix more imports
marc2332 Nov 29, 2023
23a9e7e
:slightly_smiling_face:
marc2332 Nov 29, 2023
341bfc6
import fixes and logic improvements..
marc2332 Nov 30, 2023
7aa03ac
fix links
marc2332 Dec 1, 2023
86b3f24
:hurtrealbad:
marc2332 Dec 1, 2023
e5f75c4
:godmode:
marc2332 Dec 4, 2023
fea68d6
Merge pull request #7742 from iotaledger/refactor/profile-manager
begonaalvarezd Dec 5, 2023
f7cfffb
refactor: Onboarding (#7763)
marc2332 Dec 12, 2023
f35309e
refactor: login WIP
cpl121 Dec 12, 2023
7e9b6ae
fix: selected wallet id
cpl121 Dec 13, 2023
d37ca7b
mmm, some improvements and fixes
marc2332 Dec 13, 2023
ce4b1e1
fixes and improvements
marc2332 Dec 14, 2023
169324a
fixes and clean up
marc2332 Dec 18, 2023
a758ef1
refactor: Fix Login and onboarding improvements (#7779)
cpl121 Dec 19, 2023
df69799
refactor(2.0): Fix the Dashboard component
marc2332 Dec 19, 2023
630f862
clean up
marc2332 Dec 19, 2023
777a6be
refactor(2.0): Hide Wallet switcher
marc2332 Dec 19, 2023
821de05
Merge pull request #7796 from iotaledger/refactor/dashboard-component
begonaalvarezd Dec 19, 2023
8a9548c
Merge pull request #7797 from iotaledger/refactor/hide-wallet-switcher
begonaalvarezd Dec 19, 2023
c2df08c
format
marc2332 Dec 19, 2023
5c2fd26
lint
marc2332 Dec 19, 2023
e2891a4
format
marc2332 Dec 19, 2023
1a05b72
lint
marc2332 Dec 19, 2023
446ec99
fix as many as possible tests
marc2332 Dec 20, 2023
0d92c6f
revert non-english translations changes
marc2332 Dec 20, 2023
e81705d
mm
marc2332 Dec 20, 2023
b75d034
revert other non-english translations changes
marc2332 Dec 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion docs/specifications/activities/class-diagram.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ classDiagram
class Subject {
- type: "address" | "account"
- address?: string
- account?: IAccountState
- account?: IWalletState
}
class Activity Direction {
<<Enum>>
Expand Down
6 changes: 3 additions & 3 deletions packages/desktop/components/AccountActivity.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
activityFilter,
activitySearchTerm,
queriedActivities,
selectedAccountActivities,
selectedWalletActivities,
setAsyncStatusOfAccountActivities,
} from '@core/wallet'
import { ActivityTile, Text, TextInput, TogglableButton, FontWeight } from '@ui'
Expand All @@ -22,7 +22,7 @@
$: if (searchActive && inputElement) inputElement.focus()
$: searchValue = searchActive ? searchValue.toLowerCase() : ''
$: setAsyncStatusOfAccountActivities($time)
$: if (searchActive && $selectedAccountActivities) {
$: if (searchActive && $selectedWalletActivities) {
debounce(() => {
$activitySearchTerm = searchValue
})()
Expand All @@ -46,7 +46,7 @@

$: $activityFilter, $activitySearchTerm, scrollToTop()
$: isEmptyBecauseOfFilter =
$selectedAccountActivities.filter((_activity) => !_activity.isHidden).length > 0 &&
$selectedWalletActivities.filter((_activity) => !_activity.isHidden).length > 0 &&
activityListWithTitles.length === 0

function scrollToTop(): void {
Expand Down
8 changes: 4 additions & 4 deletions packages/desktop/components/AccountSummary.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import { TextType } from '@ui/enums'

import { localize } from '@core/i18n'
import { nodeInfo } from '@core/network'
import { selectedAccountAssets } from '@core/wallet'
import { nodeInfoNetworkName } from '@core/network'
import { selectedWalletAssets } from '@core/wallet'
import { activeProfile } from '@core/profile'

$: fomattedNetworkName = $nodeInfo?.protocol.networkName
$: fomattedNetworkName = $nodeInfoNetworkName
.split(' ')
.map((word) => word[0].toUpperCase() + word.substring(1))
.join(' ')

$: ({ baseCoin } = $selectedAccountAssets[$activeProfile?.network.id])
$: ({ baseCoin } = $selectedWalletAssets[$activeProfile?.network.id])
</script>

<account-summary class="block relative space-y-4">
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop/components/ProposalCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import { ProposalStatus } from '@contexts/governance/enums'
import { IProposal } from '@contexts/governance/interfaces'
import { participationOverviewForSelectedAccount, selectedProposalId } from '@contexts/governance/stores'
import { participationOverviewForSelectedWallet, selectedProposalId } from '@contexts/governance/stores'
import { isVotingForProposal } from '@contexts/governance/utils'

import { Icon } from '@auxiliary/icon/enums'
Expand All @@ -20,7 +20,7 @@

let hasVoted = false

$: $participationOverviewForSelectedAccount, setHasVoted()
$: $participationOverviewForSelectedWallet, setHasVoted()
$: dark = $appSettings.darkMode

function setHasVoted(): void {
Expand All @@ -37,7 +37,7 @@

<proposal-card
on:click={onProposalClick}
on:keydown={(e) => e.key === 'Enter' && onProposalClick()}

Check warning on line 40 in packages/desktop/components/ProposalCard.svelte

View workflow job for this annotation

GitHub Actions / lint

Missing return type on function
class:dark
class:ended={proposal?.status === ProposalStatus.Ended}
class="flex flex-col p-6 border border-solid border-gray-200 dark:border-transparent rounded-xl cursor-pointer h-fit shadow-elevation-1 focus:shadow-inner
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop/components/Proposals.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import { localize } from '@core/i18n'

import { proposalFilter, registeredProposalsForSelectedAccount } from '@contexts/governance/stores'
import { proposalFilter, registeredProposalsForSelectedWallet } from '@contexts/governance/stores'
import { isVisibleProposal, sortProposals } from '@contexts/governance/utils'

$: proposals = Object.values($registeredProposalsForSelectedAccount)
$: proposals = Object.values($registeredProposalsForSelectedWallet)

let searchTerm = ''

Expand Down
14 changes: 7 additions & 7 deletions packages/desktop/components/ProposalsDetails.svelte
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<script lang="ts">
import { onMount } from 'svelte'
import { Button, KeyValueBox, Text, Modal, MeatballMenuButton, ButtonSize, FontWeight, MenuItem } from '@ui'
import { selectedAccount } from '@core/account'
import { selectedWallet } from '@core/wallet'
import { localize } from '@core/i18n'
import { activeProfileId } from '@core/profile'
import {
getNumberOfActiveProposals,
getNumberOfTotalProposals,
getNumberOfVotedProposals,
getNumberOfVotingProposals,
participationOverviewForSelectedAccount,
registeredProposalsForSelectedAccount,
participationOverviewForSelectedWallet,
registeredProposalsForSelectedWallet,
updateParticipationOverview,
IProposalsDetails,
} from '@contexts/governance'
Expand All @@ -25,9 +25,9 @@
votedProposals: null,
}

$: isOverviewLoaded = !!$participationOverviewForSelectedAccount
$: $registeredProposalsForSelectedAccount, $participationOverviewForSelectedAccount, updateProposalsDetails()
$: $selectedAccount, void setParticipationOverview()
$: isOverviewLoaded = !!$participationOverviewForSelectedWallet
$: $registeredProposalsForSelectedWallet, $participationOverviewForSelectedWallet, updateProposalsDetails()
$: $selectedWallet, void setParticipationOverview()

function updateProposalsDetails(): void {
if ($activeProfileId) {
Expand All @@ -42,7 +42,7 @@

async function setParticipationOverview(): Promise<void> {
if (!isOverviewLoaded || getNumberOfVotedProposals() === 0) {
await updateParticipationOverview($selectedAccount.index)
await updateParticipationOverview($selectedWallet.id)
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/desktop/components/VestingSchedule.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { IVestingPayout, VestingOutputStatus } from '@contexts/vesting'
import { getFormattedTimeStamp, localize } from '@core/i18n'
import { activeProfile } from '@core/profile'
import { formatTokenAmountBestMatch, selectedAccountAssets } from '@core/wallet'
import { formatTokenAmountBestMatch, selectedWalletAssets } from '@core/wallet'
import { Pill, Text, TextType, Tooltip } from '@ui'

export let payouts: IVestingPayout[] = []
Expand All @@ -13,7 +13,7 @@

$: columnsAmount = calculateOptimalColumns(payouts.length)
$: remainingSpaces = calculateRemainingGridSpaces(payouts.length, columnsAmount)
$: baseCoin = ($selectedAccountAssets?.[$activeProfile?.network?.id] ?? {}).baseCoin
$: baseCoin = ($selectedWalletAssets?.[$activeProfile?.network?.id] ?? {}).baseCoin

const MAX_GRID_COLUMNS = 14

Expand Down Expand Up @@ -68,10 +68,10 @@
{#each payouts as payout}
{@const onMouseEnterOutput = handleHoverEvent(payout)}
{@const onMouseLeaveOutput = handleHoverEvent()}
<vesting-output

Check warning on line 71 in packages/desktop/components/VestingSchedule.svelte

View workflow job for this annotation

GitHub Actions / lint

A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event
on:mouseleave={onMouseLeaveOutput}
on:mouseenter={onMouseEnterOutput}
on:click={() => onPayoutClick(payout)}

Check warning on line 74 in packages/desktop/components/VestingSchedule.svelte

View workflow job for this annotation

GitHub Actions / lint

Missing return type on function
class:unlocked={payout.status === VestingOutputStatus.Unlocked}
/>
{/each}
Expand Down
18 changes: 9 additions & 9 deletions packages/desktop/components/VotingPower.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
import { Button, Text } from '@ui'
import { ButtonSize, FontWeight, TextType } from '@ui/enums'

import { selectedAccount } from '@core/account'
import { selectedWallet } from '@core/wallet'
import { localize } from '@core/i18n'
import { formatTokenAmountBestMatch, visibleSelectedAccountAssets } from '@core/wallet'
import { formatTokenAmountBestMatch, visibleSelectedWalletAssets } from '@core/wallet'
import { openPopup, PopupId } from '@auxiliary/popup'
import { activeProfile } from '@core/profile'

const asset = $visibleSelectedAccountAssets?.[$activeProfile?.network.id]?.baseCoin
const asset = $visibleSelectedWalletAssets?.[$activeProfile?.network.id]?.baseCoin

$: votingPower = parseInt($selectedAccount?.votingPower, 10)
$: maxVotingPower = parseInt($selectedAccount?.balances?.baseCoin?.available) + votingPower
$: votingPower = parseInt($selectedWallet?.votingPower, 10)
$: maxVotingPower = parseInt($selectedWallet?.balances?.baseCoin?.available) + votingPower
$: formattedVotingPower = formatTokenAmountBestMatch(votingPower, asset?.metadata)
$: formattedMaxVotingPower = formatTokenAmountBestMatch(maxVotingPower, asset?.metadata)
$: hasTransactionInProgress =
$selectedAccount?.hasVotingPowerTransactionInProgress ||
$selectedAccount?.hasVotingTransactionInProgress ||
$selectedAccount?.hasConsolidatingOutputsTransactionInProgress ||
$selectedAccount?.isTransferring
$selectedWallet?.hasVotingPowerTransactionInProgress ||
$selectedWallet?.hasVotingTransactionInProgress ||
$selectedWallet?.hasConsolidatingOutputsTransactionInProgress ||
$selectedWallet?.isTransferring

function onManageVotingPowerClick(): void {
openPopup({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { AccountLabel, Icon, Modal } from '@ui'
import { AccountSwitcherModal } from '@components'
import { selectedAccount } from '@core/account/stores'
import { WalletLabel, Icon, Modal } from '@ui'
import { WalletSwitcherModal } from '@components'
import { selectedWallet } from '@core/wallet/stores'
import { Icon as IconEnum } from '@auxiliary/icon'

let modal: Modal
Expand All @@ -17,18 +17,18 @@
</script>

<svelte:window on:click={onOutsideClick} />
<account-switcher>
<wallet-switcher>
<button type="button" on:click={onButtonClick} class="flex flex-row justify-center items-center space-x-2">
<AccountLabel account={$selectedAccount} />
<WalletLabel wallet={$selectedWallet} />
<icon-container class:rotate={isModalOpened}>
<Icon height="18" width="18" icon={IconEnum.ChevronDown} classes="text-gray-800 dark:text-white" />
</icon-container>
</button>
<AccountSwitcherModal bind:modal />
</account-switcher>
<WalletSwitcherModal bind:modal />
</wallet-switcher>

<style lang="scss">
account-switcher {
wallet-switcher {
@apply block relative;
-webkit-app-region: none;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script lang="ts">
import { AccountActionsMenu } from '@components'
import { WalletActionsMenu } from '@components'
import { Modal, MeatballMenuButton } from '@ui'

let modal: Modal
</script>

<account-actions-button class="block relative">
<MeatballMenuButton onClick={modal?.toggle} />
<AccountActionsMenu bind:modal position={{ right: '0' }} classes="mt-1.5" />
<WalletActionsMenu bind:modal position={{ right: '0' }} classes="mt-1.5" />
</account-actions-button>
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<script lang="ts">
import { OnboardingButton } from '@ui'

import { selectedAccount } from '@core/account'
import { selectedWallet } from '@core/wallet'
import { localize } from '@core/i18n'
import { resetMintTokenDetails } from '@core/wallet'

import { closePopup, openPopup, PopupId } from '@auxiliary/popup'
import { TextHintVariant } from 'shared/components/enums'

$: hasAliases = $selectedAccount.balances?.aliases.length > 0
// TODO(2.0) Should this be checking if it has accounts?
$: hasAccounts = $selectedWallet.balances?.accounts.length > 0

function onMintNativeTokenClick(): void {
resetMintTokenDetails()
if (hasAliases) {
if (hasAccounts) {
openPopup({
id: PopupId.MintNativeTokenForm,
})
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export * from './popups'

export { default as AccountActivity } from './AccountActivity.svelte'
export { default as AccountSummary } from './AccountSummary.svelte'
export { default as AccountSwitcher } from './AccountSwitcher.svelte'
export { default as WalletSwitcher } from './WalletSwitcher.svelte'
export { default as OnboardingLayout } from './OnboardingLayout.svelte'
export { default as Proposals } from './Proposals.svelte'
export { default as ProposalAnswer } from './ProposalAnswer.svelte'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script lang="ts">
import { onMount } from 'svelte'
import { Modal, MenuItem, MeatballMenuButton, MenuItemVariant } from '@ui'
import { selectedAccount } from '@core/account/stores'
import { selectedWallet } from '@core/wallet/stores'
import { handleError } from '@core/error/handlers'
import { localize } from '@core/i18n'
import { IProposal } from '@contexts/governance'
import { participationOverviewForSelectedAccount } from '@contexts/governance/stores'
import { participationOverviewForSelectedWallet } from '@contexts/governance/stores'
import { isVotingForSelectedProposal } from '@contexts/governance/utils'
import { Icon } from '@auxiliary/icon'
import { openPopup, PopupId } from '@auxiliary/popup'
Expand All @@ -17,8 +17,8 @@
let isVotingForProposal: boolean
let isBusy = true // starts in a busy state because data needs to be fetched before displaying selectable options

$: isTransferring = $selectedAccount?.isTransferring
$: isTransferring, $participationOverviewForSelectedAccount, void updateIsVoting() // vote/stop vote changes the isTransferring value. Relying on this requires less updates than relying on proposalsState
$: isTransferring = $selectedWallet?.isTransferring
$: isTransferring, $participationOverviewForSelectedWallet, void updateIsVoting() // vote/stop vote changes the isTransferring value. Relying on this requires less updates than relying on proposalsState
$: isBusy = isVotingForProposal === undefined

$: buttons = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<script lang="ts">
import { MenuItem, MenuItemVariant, Modal, ToggleHiddenAccountMenuItem } from '@ui'

import { selectedAccount } from '@core/account/stores'
import { localize } from '@core/i18n'
import { activeAccounts, activeProfile, isActiveLedgerProfile, visibleActiveAccounts } from '@core/profile/stores'
import { deleteAccount } from '@core/profile-manager/actions'
import { activeProfile, isActiveLedgerProfile } from '@core/profile/stores'

import { Icon } from '@auxiliary/icon/enums'
import { openPopup, PopupId } from '@auxiliary/popup'
import { profileManager } from '@core/profile-manager'
import { checkOrConnectLedger } from '@core/ledger'
import { showAppNotification } from '@auxiliary/notification'
import { handleError } from '@core/error/handlers'
import { NetworkId } from '@core/network/enums'
import { selectedWallet } from '@core/wallet/stores'
import { activeProfileSecretManager } from '@core/secret-manager'
import { deleteWallet } from '@core/profile'

export let modal: Modal = undefined

const showDeleteAccount =
$selectedAccount?.index === $activeAccounts?.length - 1 && $visibleActiveAccounts?.length > 1
const showDeleteAccount = true // TODO(2.0) Is there anything preventing us from deleting any account ?
// $selectedWallet?.id === $activeWallets?.length - 1 && $visibleActiveWallets?.length > 1

function onCustomiseAccountClick(): void {
openPopup({ id: PopupId.ManageAccount })
openPopup({ id: PopupId.ManageWallet })
modal?.close()
}

Expand All @@ -38,10 +38,13 @@
const ADDRESS_INDEX = 0
checkOrConnectLedger(() => {
try {
if ($profileManager && $selectedAccount && $isActiveLedgerProfile) {
$profileManager.generateEd25519Address($selectedAccount.index, ADDRESS_INDEX, {
internal: false,
ledgerNanoPrompt: true,
if ($activeProfileSecretManager && $selectedWallet && $isActiveLedgerProfile) {
$activeProfileSecretManager.generateEd25519Addresses({
accountIndex: ADDRESS_INDEX, // TODO(2.0) This shouldn't be named accountIndex
options: {
internal: false,
ledgerNanoPrompt: true,
},
})
showAppNotification({
type: 'info',
Expand All @@ -61,8 +64,8 @@
openPopup({
id: PopupId.DeleteAccount,
props: {
account: selectedAccount,
deleteAccount,
account: selectedWallet,
deleteWallet,
},
})
modal?.close()
Expand Down
Loading
Loading