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: Remove ProfileManager remaining code #7809

Merged
merged 38 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0e58e1a
refactor(2.0): Dynamic password
marc2332 Dec 21, 2023
2b25b9b
refactor(2.0): Remove Profile Manager (wip)
marc2332 Dec 22, 2023
027b69d
clean up and fix
marc2332 Dec 22, 2023
4bf970b
clean up
marc2332 Dec 22, 2023
d5f50d5
Merge branch 'refactor/dynamic-password' into refactor/remove-profile…
marc2332 Dec 22, 2023
a5a8969
clean up more code
marc2332 Dec 22, 2023
628f376
clean up
marc2332 Jan 8, 2024
60c6836
adapt and remove for profile-manager related code
marc2332 Jan 9, 2024
cc59db7
clean up more code
marc2332 Jan 10, 2024
3080203
fmt
marc2332 Jan 10, 2024
7457f42
Merge branch 'develop-iota2.0' into refactor/dynamic-password
marc2332 Jan 10, 2024
cff2fa6
more cleanup
marc2332 Jan 10, 2024
064d8c5
more cleanup
marc2332 Jan 11, 2024
10105c0
small tweaks
marc2332 Jan 12, 2024
38b7c9b
more cleanup
marc2332 Jan 15, 2024
3a885f6
Merge branch 'develop-iota2.0' into refactor/dynamic-password
marc2332 Jan 15, 2024
071bffc
format
marc2332 Jan 15, 2024
8445a28
Merge branch 'refactor/dynamic-password' into refactor/remove-profile…
marc2332 Jan 15, 2024
df286ea
Merge branch 'develop-iota2.0' into refactor/dynamic-password
begonaalvarezd Jan 16, 2024
67eba8c
update
marc2332 Jan 16, 2024
f8ba63f
clean up
marc2332 Jan 16, 2024
63e6125
Merge branch 'refactor/dynamic-password' into refactor/remove-profile…
marc2332 Jan 16, 2024
5f2a5fd
Merge branch 'develop-iota2.0' into refactor/remove-profile-manager
marc2332 Jan 16, 2024
c5d653d
resolve conflicts and clean up other stuff
marc2332 Jan 17, 2024
f5acc83
https://api.testnet.shimmer.network
marc2332 Jan 17, 2024
84b875f
revert Wallet.svelte
marc2332 Jan 17, 2024
71e06b9
clean up
marc2332 Jan 17, 2024
9496a3a
Merge branch 'develop-iota2.0' into refactor/remove-profile-manager
marc2332 Jan 19, 2024
03dfb32
clean up
marc2332 Jan 19, 2024
6b161d7
clean up
marc2332 Jan 19, 2024
ab2adf1
Merge branches 'refactor/remove-profile-manager' and 'develop-iota2.0…
Jan 22, 2024
aa162a0
feat: remove getNftByIdFromAllAccountNfts debris
Jan 22, 2024
4e9841a
perf: remove todo comment
Jan 23, 2024
fd6654c
perf: rename isDestroyingWallets file
Jan 23, 2024
79dbbb3
perf: bring back the wallet id argument
Jan 23, 2024
5cdb16e
perf: update comments for activeProfileSecretManager
Jan 23, 2024
6960442
fix: update login steps literal
Jan 23, 2024
d47cb42
feat: update activeProfileSecretManager comment
Jan 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
4 changes: 2 additions & 2 deletions packages/desktop/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

appStage.set(AppStage[process.env.STAGE.toUpperCase()] ?? AppStage.ALPHA)

const { loggedIn, hasLoadedAccounts } = $activeProfile
const { loggedIn, hasLoadedWallets } = $activeProfile

$: if ($activeProfile && !$loggedIn) {
closePopup(true)
Expand All @@ -68,7 +68,7 @@
document.dir = $localeDirection
}

$: isDashboardVisible = $appRoute === AppRoute.Dashboard && $hasLoadedAccounts && $popupState.id !== 'busy'
$: isDashboardVisible = $appRoute === AppRoute.Dashboard && $hasLoadedWallets && $popupState.id !== 'busy'

$: $nftDownloadQueue, downloadNextNftInQueue()

Expand Down
4 changes: 2 additions & 2 deletions packages/desktop/components/AccountActivity.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
activitySearchTerm,
queriedActivities,
selectedWalletActivities,
setAsyncStatusOfAccountActivities,
setAsyncStatusOfWalletActivities,
} from '@core/wallet'
import { ActivityTile, Text, TextInput, TogglableButton, FontWeight } from '@ui'
import { Filter } from '@components'
Expand All @@ -21,7 +21,7 @@

$: if (searchActive && inputElement) inputElement.focus()
$: searchValue = searchActive ? searchValue.toLowerCase() : ''
$: setAsyncStatusOfAccountActivities($time)
$: setAsyncStatusOfWalletActivities($time)
$: if (searchActive && $selectedWalletActivities) {
debounce(() => {
$activitySearchTerm = searchValue
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop/components/TitleBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import { Icon as IconEnum } from '@auxiliary/icon'
import { popupState } from '@auxiliary/popup'

const { hasLoadedAccounts } = $activeProfile
const { hasLoadedWallets } = $activeProfile

let isMaximized = false

$: isDashboardVisible = $appRoute === AppRoute.Dashboard && $hasLoadedAccounts && $popupState.id !== 'busy'
$: isDashboardVisible = $appRoute === AppRoute.Dashboard && $hasLoadedWallets && $popupState.id !== 'busy'
$: isWindows = $platform === PlatformOption.Windows

async function onResize(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import { closePopup, openPopup, PopupId } from '@auxiliary/popup'
import { TextHintVariant } from 'shared/components/enums'

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

function onMintNativeTokenClick(): void {
resetMintTokenDetails()
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop/components/popups/AddNodePopup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { closePopup } from '@auxiliary/popup'
import { Platform } from '@core/app'
import { activeWallets, activeProfile } from '@core/profile'
import { registerProposalsForAccounts } from '@contexts/governance'
import { registerProposalsForWallets } from '@contexts/governance'

export let node: INode = structuredClone(EMPTY_NODE)
export let isEditingNode: boolean = false
Expand All @@ -33,7 +33,7 @@
}

if (Platform.isFeatureFlagEnabled('governance')) {
await registerProposalsForAccounts({ node }, $activeWallets)
await registerProposalsForWallets({ node }, $activeWallets)
}

onSuccess()
Expand Down
6 changes: 3 additions & 3 deletions packages/desktop/electron/lib/nftDownloadHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const downloadItems = {}

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

Expand All @@ -20,11 +20,11 @@ export function initNftDownloadHandlers() {
showProgressBar: true,
onCompleted: () => {
delete downloadItems[nftId]
getOrInitWindow('main').webContents.send('nft-download-done', { nftId, accountIndex })
getOrInitWindow('main').webContents.send('nft-download-done', { nftId, walletId })
},
onCancel: () => {
delete downloadItems[nftId]
getOrInitWindow('main').webContents.send('nft-download-interrupted', { nftId, accountIndex })
getOrInitWindow('main').webContents.send('nft-download-interrupted', { nftId, walletId })
},
onStarted: (item) => (downloadItems[nftId] = item),
})
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop/electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ if (app.isPackaged) {
* Handles url navigation events
*/
const handleNavigation = (e, url) => {
if (url === 'http://localhost:8080/') {
if (url === 'http://localhost:3333/') {
// if localhost would be opened on the build versions, we need to block it to prevent errors
if (app.isPackaged) {
e.preventDefault()
Expand Down Expand Up @@ -244,7 +244,7 @@ function createWindow() {
// Enable dev tools only in developer mode
windows.main.webContents.openDevTools()

windows.main.loadURL('http://localhost:8080')
windows.main.loadURL('http://localhost:3333')
} else {
initAutoUpdate()

Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/views/dashboard/Dashboard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
}

function handleDeepLinkRequest(data: string): void {
if ($activeProfile?.hasLoadedAccounts) {
if ($activeProfile?.hasLoadedWallets) {
handleDeepLink(data)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
NftDownloadMetadata,
allWalletNfts,
convertAndFormatNftMetadata,
getNftByIdFromAllAccountNfts,
getNftByIdFromAllWalletNfts,
selectedNftId,
} from '@core/nfts'
import { getBaseToken } from '@core/profile/actions'
Expand Down Expand Up @@ -43,7 +43,7 @@
let modal: Modal

const explorerUrl = getOfficialExplorerUrl($activeProfile?.network?.id)
const nft: INft = getNftByIdFromAllAccountNfts($selectedWalletId, $selectedNftId)
const nft: INft = getNftByIdFromAllWalletNfts($selectedWalletId, $selectedNftId)

const { id, name, issuer, address, metadata, downloadMetadata, storageDeposit } = nft ?? {}
const { standard, version, type, uri, description, issuerName, collectionName, attributes, soonaverseAttributes } =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let showHiddenAccounts = $activeProfile?.showHiddenAccounts
$: updateActiveProfile({ showHiddenAccounts: showHiddenAccounts })

$: if ($activeProfile?.hasLoadedAccounts && !showHiddenAccounts) {
$: if ($activeProfile?.hasLoadedWallets && !showHiddenAccounts) {
setNextSelectedWallet()
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
onMount(async () => {
// Clean up if user has navigated back to this view from onboarding
if ($onboardingProfile) {
if ($onboardingProfile.hasInitialisedProfileManager) {
if ($onboardingProfile.secretManagerOptions) {
await clearProfileFromMemory()
await removeProfileFolder($onboardingProfile.id)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@

onMount(async () => {
// Clean up if user has navigated back to this view
if ($onboardingProfile.hasInitialisedProfileManager) {
if ($onboardingProfile.secretManagerOptions) {
await clearProfileFromMemory()
await removeProfileFolder($onboardingProfile.id)
}
updateOnboardingProfile({ type: undefined, createProfileType: undefined, hasInitialisedProfileManager: false })
updateOnboardingProfile({ type: undefined, createProfileType: undefined, secretManagerOptions: undefined })
})
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import { showAppNotification } from '@auxiliary/notification'
import { OnboardingLayout } from '@components'
import {
cleanupOnboardingProfileManager,
initialiseProfileManagerFromOnboardingProfile,
cleanupOnboardingProfile,
initialiseOnboardingProfile,
updateOnboardingProfile,
} from '@contexts/onboarding'
import { localize } from '@core/i18n'
Expand Down Expand Up @@ -41,7 +41,7 @@
validateClientOptions: false,
})
updateOnboardingProfile({ clientOptions: { nodes: [node], primaryNode: node } })
await initialiseProfileManagerFromOnboardingProfile(true)
await initialiseOnboardingProfile(true)

// The API request to check if a node is reachable requires an existing account manager.
const nodeInfoResponse = await getNodeInfo(node.url)
Expand All @@ -55,13 +55,13 @@
const customCoinType = networkId === NetworkId.Custom ? Number(coinType) : undefined
const network = buildPersistedNetworkFromNodeInfoResponse(nodeInfoResponse, customCoinType)
updateOnboardingProfile({ network })
await cleanupOnboardingProfileManager()
await cleanupOnboardingProfile()
$networkSetupRouter.next()
} catch (err) {
console.error(err)

updateOnboardingProfile({ clientOptions: undefined, network: undefined })
await cleanupOnboardingProfileManager()
await cleanupOnboardingProfile()

if (err?.error?.includes('error sending request for url')) {
formError = localize('error.node.unabledToConnect')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<script lang="ts">
import { OnboardingLayout } from '@components'
import { RestoreProfileType, onboardingProfile, updateOnboardingProfile } from '@contexts/onboarding'
import {
RestoreProfileType,
initialiseOnboardingProfile,
onboardingProfile,
updateOnboardingProfile,
} from '@contexts/onboarding'
import { localize } from '@core/i18n'
import { getNetworkNameFromNetworkId } from '@core/network'
import { ProfileType, clearProfileFromMemory, removeProfileFolder } from '@core/profile'
Expand All @@ -25,8 +30,7 @@
isBusy = { ...isBusy, [restoreProfileType]: true }
const type = restoreProfileType === RestoreProfileType.Ledger ? ProfileType.Ledger : ProfileType.Software
updateOnboardingProfile({ type, restoreProfileType })
// TODO(2.0) This is gone
await initialiseProfileManagerFromOnboardingProfile()
await initialiseOnboardingProfile()
$restoreProfileRouter.next()
}

Expand All @@ -36,11 +40,11 @@

onMount(async () => {
// Clean up if user has navigated back to this view
if ($onboardingProfile.hasInitialisedProfileManager) {
if ($onboardingProfile.secretManagerOptions) {
await clearProfileFromMemory()
await removeProfileFolder($onboardingProfile.id)
}
updateOnboardingProfile({ type: undefined, restoreProfileType: undefined, hasInitialisedProfileManager: false })
updateOnboardingProfile({ type: undefined, restoreProfileType: undefined, secretManagerOptions: undefined })
})
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</Transition>
{:else if $updateStrongholdRoute === UpdateStrongholdRoute.ChangePassword}
<Transition>
<ChangePasswordView bind:newPassword oldPassword={password} {isRecovery} />
<ChangePasswordView bind:newPassword oldPassword={password} />
</Transition>
{:else if $updateStrongholdRoute === UpdateStrongholdRoute.SaveBackup}
<Transition>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,18 @@
import { OnboardingLayout } from '@components'
import { handleError } from '@core/error/handlers'
import { localize } from '@core/i18n'
import { MAX_STRONGHOLD_PASSWORD_LENGTH, unlockStronghold } from '@core/profile'
import { activeProfile, updateActiveProfile } from '@core/profile/stores'
import { MAX_STRONGHOLD_PASSWORD_LENGTH, changePasswordAndUnlockStronghold, unlockStronghold } from '@core/profile'
import { PASSWORD_REASON_MAP } from '@core/stronghold'
import { Animation, Button, PasswordInput, Text, TextHint } from '@ui'
import { HTMLButtonType, TextType } from '@ui/enums'
import { onMount } from 'svelte'
import zxcvbn from 'zxcvbn'
import { updateStrongholdRouter } from '../update-stronghold-router'
import { TextHintVariant } from 'shared/components/enums'
import { AnimationEnum } from '@auxiliary/animation'
import { onboardingProfile, updateOnboardingProfile } from '@contexts/onboarding'
import { changeStrongholdPassword } from '@core/secret-manager'

export let oldPassword: string
export let newPassword: string
export let isRecovery: boolean

let passwordError: string = ''
let confirmPassword: string = ''
Expand Down Expand Up @@ -63,7 +59,7 @@
if (isPasswordValid) {
try {
isSubmitBusy = true
await changeStrongholdPassword(oldPassword, newPassword)
await changePasswordAndUnlockStronghold(oldPassword, newPassword)
if ($onboardingProfile) {
updateOnboardingProfile({ strongholdPassword: newPassword })
}
Expand Down Expand Up @@ -95,24 +91,6 @@
isSkipBusy = false
}
}

onMount(async () => {
// TODO(2.0) Profile manager is gone
if (!isRecovery && !$profileManager) {
const profileManagerOptions = await buildProfileManagerOptionsFromProfileData($activeProfile)
const { storagePath, coinType, clientOptions, secretManager } = profileManagerOptions
updateActiveProfile({ clientOptions })
// TODO(2.0): Update initialiseProfileManager to new logic
const manager = await initialiseProfileManager(
$activeProfile?.id,
storagePath,
coinType,
clientOptions,
secretManager
)
profileManager.set(manager)
}
})
</script>

<OnboardingLayout allowBack={false}>
Expand Down
1 change: 1 addition & 0 deletions packages/desktop/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ const webpackConfig: Configuration[] = [
warnings: false,
},
},
port: 3333,
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/components/ActivityInformation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
} from 'shared/components'
import { Tab } from 'shared/components/enums'
import { ActivityType, Activity } from '@core/wallet'
import { getNftByIdFromAllAccountNfts } from '@core/nfts'
import { getNftByIdFromAllWalletNfts } from '@core/nfts'
import { selectedWalletId } from '@core/wallet'

export let activity: Activity
Expand All @@ -23,7 +23,7 @@
$: {
const storedNft =
activity?.type === ActivityType.Nft
? getNftByIdFromAllAccountNfts($selectedWalletId, activity?.nftId)
? getNftByIdFromAllWalletNfts($selectedWalletId, activity?.nftId)
: undefined
hasMetadata = !!storedNft?.metadata
}
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/components/NftActivityDetails.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { selectedWalletId } from '@core/wallet/stores'
import { time } from '@core/app'
import { localize } from '@core/i18n'
import { getNftByIdFromAllAccountNfts, ownedNfts, selectedNftId } from '@core/nfts'
import { getNftByIdFromAllWalletNfts, ownedNfts, selectedNftId } from '@core/nfts'
import { CollectiblesRoute, collectiblesRouter, DashboardRoute, dashboardRouter } from '@core/router'
import { ActivityAsyncStatus, NftActivity } from '@core/wallet'
import { getSubjectFromActivity } from '@core/wallet/utils/generateActivity/helper'
Expand All @@ -22,7 +22,7 @@

export let activity: NftActivity

$: nft = getNftByIdFromAllAccountNfts($selectedWalletId, activity.nftId)
$: nft = getNftByIdFromAllWalletNfts($selectedWalletId, activity.nftId)
$: nftIsOwned = $ownedNfts.some((nft) => nft.id === activity.nftId)
$: isTimelocked = activity?.asyncData?.timelockDate > $time
$: subject = getSubjectFromActivity(activity)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { selectedWalletId } from '@core/wallet'
import { localize } from '@core/i18n'
import { getNftByIdFromAllAccountNfts } from '@core/nfts'
import { getNftByIdFromAllWalletNfts } from '@core/nfts'
import { IKeyValueBoxList } from '@core/utils'
import {
ADDRESS_TYPE_ALIAS,
Expand All @@ -15,7 +15,7 @@

export let activity: NftActivity

$: nft = getNftByIdFromAllAccountNfts($selectedWalletId, activity.nftId)
$: nft = getNftByIdFromAllWalletNfts($selectedWalletId, activity.nftId)
$: issuerAddress = nft?.issuer && getBech32AddressFromAddressTypes(nft.issuer)
$: collectionId = nft?.issuer && getHexAddressFromAddressTypes(nft.issuer)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { selectedWalletId } from '@core/wallet'
import { localize } from '@core/i18n'
import { convertAndFormatNftMetadata, getNftByIdFromAllAccountNfts, IIrc27Metadata } from '@core/nfts'
import { convertAndFormatNftMetadata, getNftByIdFromAllWalletNfts, IIrc27Metadata } from '@core/nfts'
import { NftActivity } from '@core/wallet'
import { KeyValueBox } from 'shared/components'

Expand All @@ -18,7 +18,7 @@
}
}

$: nft = getNftByIdFromAllAccountNfts($selectedWalletId, activity?.nftId)
$: nft = getNftByIdFromAllWalletNfts($selectedWalletId, activity?.nftId)
$: nftMetadataDetailsList = nft?.parsedMetadata
? createIrc27NftMetadataDetailsList(nft?.parsedMetadata)
: createNftMetadataDetailsList(nft?.metadata)
Expand Down
Loading