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: add backup seed #8659

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
fix: add get seed popup
brancoder committed Mar 12, 2025
commit 1c07ca3d7b9b7fcf972165a529c93e300abec4a4
44 changes: 44 additions & 0 deletions packages/desktop/components/popups/GetSeedPopup.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<script lang="ts">
import { localize } from '@core/i18n'
import { Button, Logo, Text, TextType, KeyValueBox, TextHint } from 'shared/components'
import { closePopup } from '@auxiliary/popup'
import { Logo as LogoEnum, TextHintVariant } from 'shared/components/enums'
import { setClipboard } from '@core/utils'

export let seed: string

function onCancelClick(): void {
closePopup()
}
function onCopyClick(): void {
setClipboard(seed)
}
</script>

<div class="flex w-full flex-col space-y-6">
<Text type={TextType.h4}>Backup your seed</Text>
<div class="flex flex-col space-y-4">
<div class="w-full p-10 bg-gray-50 dark:bg-gray-800 flex justify-center content-center">
<Logo width="50%" logo={LogoEnum.Stronghold} />
</div>
<div class="w-full space-y-3">
<Text type={TextType.p} color="gray-700">
It is important to back up your seed to ensure you have a copy of your wallets and transaction history.
If you lose your seed and recovery phrase you will lose access to your funds.
</Text>
<TextHint
variant={TextHintVariant.Warning}
text="You can import this seed into the new IOTA rebased wallet to access your funds."
/>
<KeyValueBox keyText="Seed" valueText={seed} isCopyable />
</div>
</div>
<div class="flex flex-row justify-between space-x-4 w-full">
<Button outline classes="w-1/2" onClick={onCancelClick}>
{localize('actions.cancel')}
</Button>
<Button classes="w-1/2" onClick={onCopyClick}>
{localize('actions.copy')}
</Button>
</div>
</div>
2 changes: 2 additions & 0 deletions packages/desktop/components/popups/Popup.svelte
Original file line number Diff line number Diff line change
@@ -58,6 +58,7 @@
import PayoutDetailsPopup from './PayoutDetailsPopup.svelte'
import VestingRewardsFinderPopup from './VestingRewardsFinderPopup.svelte'
import WithdrawFromL2Popup from './WithdrawFromL2Popup.svelte'
import GetSeedPopup from './GetSeedPopup.svelte'

export let id: PopupId
export let props: any
@@ -146,6 +147,7 @@
[PopupId.PayoutDetails]: PayoutDetailsPopup,
[PopupId.VestingRewardsFinder]: VestingRewardsFinderPopup,
[PopupId.WithdrawFromL2]: WithdrawFromL2Popup,
[PopupId.GetSeedPopup]: GetSeedPopup,
}

function onKey(event: KeyboardEvent): void {
40 changes: 33 additions & 7 deletions packages/shared/components/modals/InitProfileActionsModal.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<script lang="ts">
import { localize } from '@core/i18n'
import { ProfileType } from '@core/profile'
import { api, initialiseProfileManager } from '@core/profile-manager'
import { ProfileType, isSoftwareProfile } from '@core/profile'
import { api, initialiseProfileManager, getProfileManager } from '@core/profile-manager'
import { buildProfileManagerOptionsFromProfileData } from '@core/profile-manager/utils'
import { Icon } from '@lib/auxiliary/icon'
import { showAppNotification } from '@lib/auxiliary/notification'
import { activeProfile, getStorageDirectoryOfProfile } from '@lib/core/profile'
import { setClipboard } from '@lib/core/utils'
import { MenuItem, Modal } from 'shared/components'
import { PopupId, openPopup } from '@auxiliary/popup'
import { profileManager } from '@core/profile-manager/stores'

export let modal: Modal | undefined
const { isStrongholdLocked } = $activeProfile

async function handleCopyProfileSystemLocation(): Promise<void> {
const profileDirectory = await getStorageDirectoryOfProfile($activeProfile?.id)
@@ -21,6 +24,28 @@
modal?.close()
}

function openUnlockStrongholdPopup(): void {
openPopup({
id: PopupId.UnlockStronghold,
props: {
onSuccess: () => {
openGetSeedPopup()
},
onCancelled: () => {},
},
})
}
async function openGetSeedPopup(): Promise<void> {
const managerId = await getProfileManager().id
const secretManager = await api.getSecretManager(managerId)
const seed = await secretManager?.getSeed()
openPopup({
id: PopupId.GetSeedPopup,
props: {
seed,
},
})
}
async function backupSeed(): Promise<void> {
const profileManagerOptions = await buildProfileManagerOptionsFromProfileData($activeProfile)
const { storagePath, coinType, clientOptions, secretManager: secretManagerType } = profileManagerOptions
@@ -31,11 +56,12 @@
secretManagerType,
$activeProfile?.id
)
await manager.clearStrongholdPassword()
await manager.setStrongholdPassword('passwordhere')
const secretManager = await api.getSecretManager(manager.id)
const seed = await secretManager?.getSeed()
console.log('seed', seed)
profileManager.set(manager)
if ($isSoftwareProfile && $isStrongholdLocked) {
openUnlockStrongholdPopup()
} else {
openGetSeedPopup()
}
}
</script>

1 change: 1 addition & 0 deletions packages/shared/lib/auxiliary/popup/enums/popup-id.enum.ts
Original file line number Diff line number Diff line change
@@ -50,4 +50,5 @@ export enum PopupId {
PayoutDetails = 'payoutDetails',
VestingRewardsFinder = 'vestingRewardsFinder',
WithdrawFromL2 = 'withdrawFromL2',
GetSeedPopup = 'getseed',
}