Skip to content

Commit 2c44c89

Browse files
marc2332begonaalvarezdcpl121
authored
refactor: Remove ProfileManager remaining code (#7809)
* 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 * clean up * clean up * feat: remove getNftByIdFromAllAccountNfts debris * perf: remove todo comment * perf: rename isDestroyingWallets file * perf: bring back the wallet id argument * perf: update comments for activeProfileSecretManager * fix: update login steps literal * feat: update activeProfileSecretManager comment --------- Co-authored-by: Begoña Álvarez de la Cruz <[email protected]> Co-authored-by: cpl121 <[email protected]>
1 parent 61c6634 commit 2c44c89

File tree

132 files changed

+397
-603
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+397
-603
lines changed

packages/desktop/App.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
4545
appStage.set(AppStage[process.env.STAGE.toUpperCase()] ?? AppStage.ALPHA)
4646
47-
const { loggedIn, hasLoadedAccounts } = $activeProfile
47+
const { loggedIn, hasLoadedWallets } = $activeProfile
4848
4949
$: if ($activeProfile && !$loggedIn) {
5050
closePopup(true)
@@ -68,7 +68,7 @@
6868
document.dir = $localeDirection
6969
}
7070
71-
$: isDashboardVisible = $appRoute === AppRoute.Dashboard && $hasLoadedAccounts && $popupState.id !== 'busy'
71+
$: isDashboardVisible = $appRoute === AppRoute.Dashboard && $hasLoadedWallets && $popupState.id !== 'busy'
7272
7373
$: $nftDownloadQueue, downloadNextNftInQueue()
7474

packages/desktop/components/AccountActivity.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
activitySearchTerm,
77
queriedActivities,
88
selectedWalletActivities,
9-
setAsyncStatusOfAccountActivities,
9+
setAsyncStatusOfWalletActivities,
1010
} from '@core/wallet'
1111
import { ActivityTile, Text, TextInput, TogglableButton, FontWeight } from '@ui'
1212
import { Filter } from '@components'
@@ -21,7 +21,7 @@
2121
2222
$: if (searchActive && inputElement) inputElement.focus()
2323
$: searchValue = searchActive ? searchValue.toLowerCase() : ''
24-
$: setAsyncStatusOfAccountActivities($time)
24+
$: setAsyncStatusOfWalletActivities($time)
2525
$: if (searchActive && $selectedWalletActivities) {
2626
debounce(() => {
2727
$activitySearchTerm = searchValue

packages/desktop/components/TitleBar.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
import { Icon as IconEnum } from '@auxiliary/icon'
99
import { popupState } from '@auxiliary/popup'
1010
11-
const { hasLoadedAccounts } = $activeProfile
11+
const { hasLoadedWallets } = $activeProfile
1212
1313
let isMaximized = false
1414
15-
$: isDashboardVisible = $appRoute === AppRoute.Dashboard && $hasLoadedAccounts && $popupState.id !== 'busy'
15+
$: isDashboardVisible = $appRoute === AppRoute.Dashboard && $hasLoadedWallets && $popupState.id !== 'busy'
1616
$: isWindows = $platform === PlatformOption.Windows
1717
1818
async function onResize(): Promise<void> {

packages/desktop/components/buttons/popup-buttons/MintNativeTokenButton.svelte

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
import { closePopup, openPopup, PopupId } from '@auxiliary/popup'
99
import { TextHintVariant } from 'shared/components/enums'
1010
11-
// TODO(2.0) Should this be checking if it has accounts?
12-
$: hasAccounts = $selectedWallet.balances?.accounts.length > 0
11+
$: hasAccounts = $selectedWallet?.accountOutputs.length > 0
1312
1413
function onMintNativeTokenClick(): void {
1514
resetMintTokenDetails()

packages/desktop/components/popups/AddNodePopup.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { closePopup } from '@auxiliary/popup'
77
import { Platform } from '@core/app'
88
import { activeWallets, activeProfile } from '@core/profile'
9-
import { registerProposalsForAccounts } from '@contexts/governance'
9+
import { registerProposalsForWallets } from '@contexts/governance'
1010
1111
export let node: INode = structuredClone(EMPTY_NODE)
1212
export let isEditingNode: boolean = false
@@ -33,7 +33,7 @@
3333
}
3434
3535
if (Platform.isFeatureFlagEnabled('governance')) {
36-
await registerProposalsForAccounts({ node }, $activeWallets)
36+
await registerProposalsForWallets({ node }, $activeWallets)
3737
}
3838
3939
onSuccess()

packages/desktop/electron/lib/nftDownloadHandlers.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const downloadItems = {}
88

99
export function initNftDownloadHandlers() {
1010
ipcMain.removeHandler('nft-download')
11-
ipcMain.handle('nft-download', async (event, url, destination, nftId, accountIndex) => {
11+
ipcMain.handle('nft-download', async (event, url, destination, nftId, walletId) => {
1212
const userPath = app.getPath('userData')
1313
const directory = app.isPackaged ? userPath : __dirname
1414

@@ -20,11 +20,11 @@ export function initNftDownloadHandlers() {
2020
showProgressBar: true,
2121
onCompleted: () => {
2222
delete downloadItems[nftId]
23-
getOrInitWindow('main').webContents.send('nft-download-done', { nftId, accountIndex })
23+
getOrInitWindow('main').webContents.send('nft-download-done', { nftId, walletId })
2424
},
2525
onCancel: () => {
2626
delete downloadItems[nftId]
27-
getOrInitWindow('main').webContents.send('nft-download-interrupted', { nftId, accountIndex })
27+
getOrInitWindow('main').webContents.send('nft-download-interrupted', { nftId, walletId })
2828
},
2929
onStarted: (item) => (downloadItems[nftId] = item),
3030
})

packages/desktop/electron/main.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ if (app.isPackaged) {
178178
* Handles url navigation events
179179
*/
180180
const handleNavigation = (e, url) => {
181-
if (url === 'http://localhost:8080/') {
181+
if (url === 'http://localhost:3333/') {
182182
// if localhost would be opened on the build versions, we need to block it to prevent errors
183183
if (app.isPackaged) {
184184
e.preventDefault()
@@ -244,7 +244,7 @@ function createWindow() {
244244
// Enable dev tools only in developer mode
245245
windows.main.webContents.openDevTools()
246246

247-
windows.main.loadURL('http://localhost:8080')
247+
windows.main.loadURL('http://localhost:3333')
248248
} else {
249249
initAutoUpdate()
250250

packages/desktop/views/dashboard/Dashboard.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
}
6262
6363
function handleDeepLinkRequest(data: string): void {
64-
if ($activeProfile?.hasLoadedAccounts) {
64+
if ($activeProfile?.hasLoadedWallets) {
6565
handleDeepLink(data)
6666
}
6767
}

packages/desktop/views/dashboard/collectibles/views/CollectiblesDetailsView.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
NftDownloadMetadata,
1111
allWalletNfts,
1212
convertAndFormatNftMetadata,
13-
getNftByIdFromAllAccountNfts,
13+
getNftByIdFromAllWalletNfts,
1414
selectedNftId,
1515
} from '@core/nfts'
1616
import { getBaseToken } from '@core/profile/actions'
@@ -43,7 +43,7 @@
4343
let modal: Modal
4444
4545
const explorerUrl = getOfficialExplorerUrl($activeProfile?.network?.id)
46-
const nft: INft = getNftByIdFromAllAccountNfts($selectedWalletId, $selectedNftId)
46+
const nft: INft = getNftByIdFromAllWalletNfts($selectedWalletId, $selectedNftId)
4747
4848
const { id, name, issuer, address, metadata, downloadMetadata, storageDeposit } = nft ?? {}
4949
const { standard, version, type, uri, description, issuerName, collectionName, attributes, soonaverseAttributes } =

packages/desktop/views/dashboard/settings/views/advanced/HiddenAccounts.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
let showHiddenAccounts = $activeProfile?.showHiddenAccounts
88
$: updateActiveProfile({ showHiddenAccounts: showHiddenAccounts })
99
10-
$: if ($activeProfile?.hasLoadedAccounts && !showHiddenAccounts) {
10+
$: if ($activeProfile?.hasLoadedWallets && !showHiddenAccounts) {
1111
setNextSelectedWallet()
1212
}
1313
</script>

packages/desktop/views/login/views/SelectProfileView.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
onMount(async () => {
4646
// Clean up if user has navigated back to this view from onboarding
4747
if ($onboardingProfile) {
48-
if ($onboardingProfile.hasInitialisedProfileManager) {
48+
if ($onboardingProfile.secretManagerOptions) {
4949
await clearProfileFromMemory()
5050
await removeProfileFolder($onboardingProfile.id)
5151
}

packages/desktop/views/onboarding/views/create-profile/views/ChooseCreateProfileFlowView.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
4141
onMount(async () => {
4242
// Clean up if user has navigated back to this view
43-
if ($onboardingProfile.hasInitialisedProfileManager) {
43+
if ($onboardingProfile.secretManagerOptions) {
4444
await clearProfileFromMemory()
4545
await removeProfileFolder($onboardingProfile.id)
4646
}
47-
updateOnboardingProfile({ type: undefined, createProfileType: undefined, hasInitialisedProfileManager: false })
47+
updateOnboardingProfile({ type: undefined, createProfileType: undefined, secretManagerOptions: undefined })
4848
})
4949
</script>
5050

packages/desktop/views/onboarding/views/network-setup/views/CustomNetworkView.svelte

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import { showAppNotification } from '@auxiliary/notification'
33
import { OnboardingLayout } from '@components'
44
import {
5-
cleanupOnboardingProfileManager,
6-
initialiseProfileManagerFromOnboardingProfile,
5+
cleanupOnboardingProfile,
6+
initialiseOnboardingProfile,
77
updateOnboardingProfile,
88
} from '@contexts/onboarding'
99
import { localize } from '@core/i18n'
@@ -41,7 +41,7 @@
4141
validateClientOptions: false,
4242
})
4343
updateOnboardingProfile({ clientOptions: { nodes: [node], primaryNode: node } })
44-
await initialiseProfileManagerFromOnboardingProfile(true)
44+
await initialiseOnboardingProfile(true)
4545
4646
// The API request to check if a node is reachable requires an existing account manager.
4747
const nodeInfoResponse = await getNodeInfo(node.url)
@@ -55,13 +55,13 @@
5555
const customCoinType = networkId === NetworkId.Custom ? Number(coinType) : undefined
5656
const network = buildPersistedNetworkFromNodeInfoResponse(nodeInfoResponse, customCoinType)
5757
updateOnboardingProfile({ network })
58-
await cleanupOnboardingProfileManager()
58+
await cleanupOnboardingProfile()
5959
$networkSetupRouter.next()
6060
} catch (err) {
6161
console.error(err)
6262
6363
updateOnboardingProfile({ clientOptions: undefined, network: undefined })
64-
await cleanupOnboardingProfileManager()
64+
await cleanupOnboardingProfile()
6565
6666
if (err?.error?.includes('error sending request for url')) {
6767
formError = localize('error.node.unabledToConnect')

packages/desktop/views/onboarding/views/restore-profile/views/ChooseRestoreProfileFlowView.svelte

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<script lang="ts">
22
import { OnboardingLayout } from '@components'
3-
import { RestoreProfileType, onboardingProfile, updateOnboardingProfile } from '@contexts/onboarding'
3+
import {
4+
RestoreProfileType,
5+
initialiseOnboardingProfile,
6+
onboardingProfile,
7+
updateOnboardingProfile,
8+
} from '@contexts/onboarding'
49
import { localize } from '@core/i18n'
510
import { getNetworkNameFromNetworkId } from '@core/network'
611
import { ProfileType, clearProfileFromMemory, removeProfileFolder } from '@core/profile'
@@ -25,8 +30,7 @@
2530
isBusy = { ...isBusy, [restoreProfileType]: true }
2631
const type = restoreProfileType === RestoreProfileType.Ledger ? ProfileType.Ledger : ProfileType.Software
2732
updateOnboardingProfile({ type, restoreProfileType })
28-
// TODO(2.0) This is gone
29-
await initialiseProfileManagerFromOnboardingProfile()
33+
await initialiseOnboardingProfile()
3034
$restoreProfileRouter.next()
3135
}
3236
@@ -36,11 +40,11 @@
3640
3741
onMount(async () => {
3842
// Clean up if user has navigated back to this view
39-
if ($onboardingProfile.hasInitialisedProfileManager) {
43+
if ($onboardingProfile.secretManagerOptions) {
4044
await clearProfileFromMemory()
4145
await removeProfileFolder($onboardingProfile.id)
4246
}
43-
updateOnboardingProfile({ type: undefined, restoreProfileType: undefined, hasInitialisedProfileManager: false })
47+
updateOnboardingProfile({ type: undefined, restoreProfileType: undefined, secretManagerOptions: undefined })
4448
})
4549
</script>
4650

packages/desktop/views/update-stronghold/UpdateStrongholdRouterView.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</Transition>
1717
{:else if $updateStrongholdRoute === UpdateStrongholdRoute.ChangePassword}
1818
<Transition>
19-
<ChangePasswordView bind:newPassword oldPassword={password} {isRecovery} />
19+
<ChangePasswordView bind:newPassword oldPassword={password} />
2020
</Transition>
2121
{:else if $updateStrongholdRoute === UpdateStrongholdRoute.SaveBackup}
2222
<Transition>

packages/desktop/views/update-stronghold/views/ChangePasswordView.svelte

+2-24
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,18 @@
33
import { OnboardingLayout } from '@components'
44
import { handleError } from '@core/error/handlers'
55
import { localize } from '@core/i18n'
6-
import { MAX_STRONGHOLD_PASSWORD_LENGTH, unlockStronghold } from '@core/profile'
7-
import { activeProfile, updateActiveProfile } from '@core/profile/stores'
6+
import { MAX_STRONGHOLD_PASSWORD_LENGTH, changePasswordAndUnlockStronghold, unlockStronghold } from '@core/profile'
87
import { PASSWORD_REASON_MAP } from '@core/stronghold'
98
import { Animation, Button, PasswordInput, Text, TextHint } from '@ui'
109
import { HTMLButtonType, TextType } from '@ui/enums'
11-
import { onMount } from 'svelte'
1210
import zxcvbn from 'zxcvbn'
1311
import { updateStrongholdRouter } from '../update-stronghold-router'
1412
import { TextHintVariant } from 'shared/components/enums'
1513
import { AnimationEnum } from '@auxiliary/animation'
1614
import { onboardingProfile, updateOnboardingProfile } from '@contexts/onboarding'
17-
import { changeStrongholdPassword } from '@core/secret-manager'
1815
1916
export let oldPassword: string
2017
export let newPassword: string
21-
export let isRecovery: boolean
2218
2319
let passwordError: string = ''
2420
let confirmPassword: string = ''
@@ -63,7 +59,7 @@
6359
if (isPasswordValid) {
6460
try {
6561
isSubmitBusy = true
66-
await changeStrongholdPassword(oldPassword, newPassword)
62+
await changePasswordAndUnlockStronghold(oldPassword, newPassword)
6763
if ($onboardingProfile) {
6864
updateOnboardingProfile({ strongholdPassword: newPassword })
6965
}
@@ -95,24 +91,6 @@
9591
isSkipBusy = false
9692
}
9793
}
98-
99-
onMount(async () => {
100-
// TODO(2.0) Profile manager is gone
101-
if (!isRecovery && !$profileManager) {
102-
const profileManagerOptions = await buildProfileManagerOptionsFromProfileData($activeProfile)
103-
const { storagePath, coinType, clientOptions, secretManager } = profileManagerOptions
104-
updateActiveProfile({ clientOptions })
105-
// TODO(2.0): Update initialiseProfileManager to new logic
106-
const manager = await initialiseProfileManager(
107-
$activeProfile?.id,
108-
storagePath,
109-
coinType,
110-
clientOptions,
111-
secretManager
112-
)
113-
profileManager.set(manager)
114-
}
115-
})
11694
</script>
11795

11896
<OnboardingLayout allowBack={false}>

packages/desktop/webpack.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ const webpackConfig: Configuration[] = [
233233
warnings: false,
234234
},
235235
},
236+
port: 3333,
236237
},
237238
},
238239
{

packages/shared/components/ActivityInformation.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
} from 'shared/components'
1414
import { Tab } from 'shared/components/enums'
1515
import { ActivityType, Activity } from '@core/wallet'
16-
import { getNftByIdFromAllAccountNfts } from '@core/nfts'
16+
import { getNftByIdFromAllWalletNfts } from '@core/nfts'
1717
import { selectedWalletId } from '@core/wallet'
1818
1919
export let activity: Activity
@@ -23,7 +23,7 @@
2323
$: {
2424
const storedNft =
2525
activity?.type === ActivityType.Nft
26-
? getNftByIdFromAllAccountNfts($selectedWalletId, activity?.nftId)
26+
? getNftByIdFromAllWalletNfts($selectedWalletId, activity?.nftId)
2727
: undefined
2828
hasMetadata = !!storedNft?.metadata
2929
}

packages/shared/components/NftActivityDetails.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { selectedWalletId } from '@core/wallet/stores'
44
import { time } from '@core/app'
55
import { localize } from '@core/i18n'
6-
import { getNftByIdFromAllAccountNfts, ownedNfts, selectedNftId } from '@core/nfts'
6+
import { getNftByIdFromAllWalletNfts, ownedNfts, selectedNftId } from '@core/nfts'
77
import { CollectiblesRoute, collectiblesRouter, DashboardRoute, dashboardRouter } from '@core/router'
88
import { ActivityAsyncStatus, NftActivity } from '@core/wallet'
99
import { getSubjectFromActivity } from '@core/wallet/utils/generateActivity/helper'
@@ -22,7 +22,7 @@
2222
2323
export let activity: NftActivity
2424
25-
$: nft = getNftByIdFromAllAccountNfts($selectedWalletId, activity.nftId)
25+
$: nft = getNftByIdFromAllWalletNfts($selectedWalletId, activity.nftId)
2626
$: nftIsOwned = $ownedNfts.some((nft) => nft.id === activity.nftId)
2727
$: isTimelocked = activity?.asyncData?.timelockDate > $time
2828
$: subject = getSubjectFromActivity(activity)

packages/shared/components/activity-info/NftActivityInformation.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import { selectedWalletId } from '@core/wallet'
33
import { localize } from '@core/i18n'
4-
import { getNftByIdFromAllAccountNfts } from '@core/nfts'
4+
import { getNftByIdFromAllWalletNfts } from '@core/nfts'
55
import { IKeyValueBoxList } from '@core/utils'
66
import {
77
ADDRESS_TYPE_ALIAS,
@@ -15,7 +15,7 @@
1515
1616
export let activity: NftActivity
1717
18-
$: nft = getNftByIdFromAllAccountNfts($selectedWalletId, activity.nftId)
18+
$: nft = getNftByIdFromAllWalletNfts($selectedWalletId, activity.nftId)
1919
$: issuerAddress = nft?.issuer && getBech32AddressFromAddressTypes(nft.issuer)
2020
$: collectionId = nft?.issuer && getHexAddressFromAddressTypes(nft.issuer)
2121

packages/shared/components/activity-info/NftMetadataInformation.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import { selectedWalletId } from '@core/wallet'
33
import { localize } from '@core/i18n'
4-
import { convertAndFormatNftMetadata, getNftByIdFromAllAccountNfts, IIrc27Metadata } from '@core/nfts'
4+
import { convertAndFormatNftMetadata, getNftByIdFromAllWalletNfts, IIrc27Metadata } from '@core/nfts'
55
import { NftActivity } from '@core/wallet'
66
import { KeyValueBox } from 'shared/components'
77
@@ -18,7 +18,7 @@
1818
}
1919
}
2020
21-
$: nft = getNftByIdFromAllAccountNfts($selectedWalletId, activity?.nftId)
21+
$: nft = getNftByIdFromAllWalletNfts($selectedWalletId, activity?.nftId)
2222
$: nftMetadataDetailsList = nft?.parsedMetadata
2323
? createIrc27NftMetadataDetailsList(nft?.parsedMetadata)
2424
: createNftMetadataDetailsList(nft?.metadata)

0 commit comments

Comments
 (0)