From 1e1c4f413f293a90bd07e559d24123854b6cf380 Mon Sep 17 00:00:00 2001 From: Javad Khalilian Date: Thu, 16 Jan 2025 12:48:08 +0100 Subject: [PATCH 1/2] feat(dw): discover all accounts on all networks --- .../apps/dev-wallet/src/App/layout-full.tsx | 16 + .../dev-wallet/src/App/layout-mini.css.ts | 14 + packages/apps/dev-wallet/src/App/routes.tsx | 8 +- packages/apps/dev-wallet/src/config.ts | 2 +- .../src/modules/account/account.service.ts | 158 +++++----- .../communication/communication.provider.tsx | 10 +- .../modules/db/migration/migrateFrom44to45.ts | 24 ++ .../src/modules/db/migration/migration.ts | 2 + .../key-source/key-source.repository.ts | 59 +++- .../src/modules/network/network.repository.ts | 2 - .../src/modules/wallet/wallet.hook.tsx | 3 +- .../src/modules/wallet/wallet.repository.ts | 1 + .../account-discovery/account-dsicovery.tsx | 292 ++++++++++-------- .../src/pages/keys/Components/Keys.tsx | 20 +- .../src/pages/settings/settings.tsx | 2 +- .../recover-from-mnemonic.tsx | 103 +++--- 16 files changed, 434 insertions(+), 282 deletions(-) create mode 100644 packages/apps/dev-wallet/src/App/layout-full.tsx create mode 100644 packages/apps/dev-wallet/src/modules/db/migration/migrateFrom44to45.ts diff --git a/packages/apps/dev-wallet/src/App/layout-full.tsx b/packages/apps/dev-wallet/src/App/layout-full.tsx new file mode 100644 index 0000000000..be9e466a0c --- /dev/null +++ b/packages/apps/dev-wallet/src/App/layout-full.tsx @@ -0,0 +1,16 @@ +import { Stack } from '@kadena/kode-ui'; +import { FC } from 'react'; +import { Outlet } from 'react-router-dom'; +import { LayoutFullContainerStyle } from './layout-mini.css'; + +export const LayoutFull: FC = () => { + return ( + <> + + + + +
+ + ); +}; diff --git a/packages/apps/dev-wallet/src/App/layout-mini.css.ts b/packages/apps/dev-wallet/src/App/layout-mini.css.ts index 06574463f4..25df37c629 100644 --- a/packages/apps/dev-wallet/src/App/layout-mini.css.ts +++ b/packages/apps/dev-wallet/src/App/layout-mini.css.ts @@ -21,3 +21,17 @@ export const containerStyle = style([ height: '100dvh', }, ]); + +export const LayoutFullContainerStyle = style([ + atoms({ + padding: 'sm', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + }), + { + margin: '0 auto', + textAlign: 'center', + height: '100dvh', + }, +]); diff --git a/packages/apps/dev-wallet/src/App/routes.tsx b/packages/apps/dev-wallet/src/App/routes.tsx index a9e1c2c3ca..98f1662ae7 100644 --- a/packages/apps/dev-wallet/src/App/routes.tsx +++ b/packages/apps/dev-wallet/src/App/routes.tsx @@ -43,6 +43,7 @@ import { HomePage } from '../pages/home/home-page'; import { SelectProfile } from '../pages/select-profile/select-profile'; import { UnlockProfile } from '../pages/unlock-profile/unlock-profile'; import { getScriptType } from '../utils/window'; +import { LayoutFull } from './layout-full'; import { LayoutMini } from './layout-mini'; import { Layout } from './Layout/Layout'; import { useGlobalState } from './providers/globalState'; @@ -142,12 +143,11 @@ export const Routes: FC = () => { path="/settings/keep-password-policy" element={} /> - } - /> + }> + } /> + }> } /> async ( - network: INetwork, + networks: INetwork[], keySource: IKeySource, profileId: string, numberOfKeys = 20, @@ -140,7 +141,6 @@ export const accountDiscovery = ( } const keySourceService = await keySourceManager.get(keySource.source); const accounts: IAccount[] = []; - const keysets: IKeySet[] = []; const usedKeys: IKeyItem[] = []; const saveCallbacks: Array<() => Promise> = []; for (let i = 0; i < numberOfKeys; i++) { @@ -150,95 +150,87 @@ export const accountDiscovery = ( } await emit('key-retrieved')(key); const principal = `k:${key.publicKey}`; - const chainResult = await discoverAccount( - principal, - network.networkId, - undefined, - contract, - ) - .on('chain-result', async (data) => { - await emit('chain-result')({ - chainId: data.chainId, - result: data.result - ? { - ...data.result, - guard: data.result.details.guard - ? { - ...data.result.details.guard, - principal: data.result.principal, - } - : undefined, - } - : undefined, + for (const network of networks) { + const chainResult = await discoverAccount( + principal, + network.networkId, + undefined, + contract, + ) + .on('chain-result', async (data) => { + await emit('chain-result')({ + chainId: data.chainId, + networkUUID: network.uuid, + result: data.result + ? { + ...data.result, + guard: data.result.details.guard + ? { + ...data.result.details.guard, + principal: data.result.principal, + } + : undefined, + balance: data.result.details.balance, + } + : undefined, + }); + }) + .execute() + .catch((error) => { + console.log('DISCOVERY_ERROR', error); + return []; }); - }) - .execute(); - if (chainResult.filter(({ result }) => Boolean(result)).length > 0) { - const availableKeyset = await accountRepository.getKeysetByPrincipal( - principal, - profileId, - ); - usedKeys.push(key); - const keyset: IKeySet = availableKeyset || { - uuid: crypto.randomUUID(), - principal, - profileId, - guard: { - keys: [key.publicKey], - pred: 'keys-all', - }, - alias: '', - }; - if (!availableKeyset) { - keysets.push(keyset); + if (chainResult.filter(({ result }) => Boolean(result)).length > 0) { + usedKeys.push(key); + const account: IAccount = { + uuid: crypto.randomUUID(), + profileId, + networkUUID: network.uuid, + contract, + guard: { + keys: [key.publicKey], + pred: 'keys-all', + principal, + }, + address: `k:${key.publicKey}`, + chains: chainResult + .filter(({ result }) => Boolean(result)) + .map(({ chainId, result }) => ({ + chainId: chainId!, + balance: + new PactNumber(result!.details.balance).toDecimal() || + '0.0', + })), + overallBalance: chainResult.reduce( + (acc, { result }) => + result && result.details.balance + ? new PactNumber(result.details.balance) + .plus(acc) + .toDecimal() + : acc, + '0', + ), + }; + accounts.push(account); + saveCallbacks.push(async () => { + if (!keySource.keys.find((k) => k.publicKey === key.publicKey)) { + await keySourceService.createKey( + keySource.uuid, + key.index as number, + ); + } + await accountRepository.addAccount(account); + }); } - const account: IAccount = { - uuid: crypto.randomUUID(), - profileId, - networkUUID: network.uuid, - contract, - keysetId: keyset.uuid, - guard: { - keys: [key.publicKey], - pred: 'keys-all', - principal, - }, - address: `k:${key.publicKey}`, - chains: chainResult - .filter(({ result }) => Boolean(result)) - .map(({ chainId, result }) => ({ - chainId: chainId!, - balance: - new PactNumber(result!.details.balance).toDecimal() || '0.0', - })), - overallBalance: chainResult.reduce( - (acc, { result }) => - result && result.details.balance - ? new PactNumber(result.details.balance).plus(acc).toDecimal() - : acc, - '0', - ), - }; - accounts.push(account); - saveCallbacks.push(async () => { - if (!keySource.keys.find((k) => k.publicKey === key.publicKey)) { - await keySourceService.createKey( - keySource.uuid, - key.index as number, - ); - } - if (!availableKeyset) { - await accountRepository.addKeyset(keyset); - } - await accountRepository.addAccount(account); - }); } } await emit('query-done')(accounts); - await Promise.all(saveCallbacks.map((cb) => cb().catch(console.error))); + for (const cb of saveCallbacks) { + await cb().catch(console.error); + } keySourceService.clearCache(); await emit('accounts-saved')(accounts); diff --git a/packages/apps/dev-wallet/src/modules/communication/communication.provider.tsx b/packages/apps/dev-wallet/src/modules/communication/communication.provider.tsx index 9cc39202e8..8e48423f0f 100644 --- a/packages/apps/dev-wallet/src/modules/communication/communication.provider.tsx +++ b/packages/apps/dev-wallet/src/modules/communication/communication.provider.tsx @@ -137,7 +137,15 @@ export const CommunicationProvider: FC = ({ children }) => { return () => { handlers.forEach((unsubscribe) => unsubscribe()); }; - }, [navigate, requests, isUnlocked]); + }, [ + navigate, + requests, + isUnlocked, + accounts, + profile, + networks, + activeNetwork, + ]); return ( diff --git a/packages/apps/dev-wallet/src/modules/db/migration/migrateFrom44to45.ts b/packages/apps/dev-wallet/src/modules/db/migration/migrateFrom44to45.ts new file mode 100644 index 0000000000..430ad78e9d --- /dev/null +++ b/packages/apps/dev-wallet/src/modules/db/migration/migrateFrom44to45.ts @@ -0,0 +1,24 @@ +// check the change log for more details +import { INetwork } from '@/modules/network/network.repository'; +import { getAllItems, putItem } from '../indexeddb'; + +const changeLog = ['Enable mainnet by default']; + +export async function migrateFrom44to45( + db: IDBDatabase, + transaction: IDBTransaction, +) { + console.log('change log:'); + changeLog.forEach((log, index) => console.log(index, log)); + const allNetworks = await getAllItems(db, transaction)('network'); + const update = putItem(db, transaction); + const mainnet = allNetworks.find( + (network) => network.networkId === 'mainnet01', + ); + if (mainnet?.disabled) { + await update('network', { + ...mainnet, + disabled: false, + }); + } +} diff --git a/packages/apps/dev-wallet/src/modules/db/migration/migration.ts b/packages/apps/dev-wallet/src/modules/db/migration/migration.ts index f4141908fd..0f3f9126ca 100644 --- a/packages/apps/dev-wallet/src/modules/db/migration/migration.ts +++ b/packages/apps/dev-wallet/src/modules/db/migration/migration.ts @@ -8,6 +8,7 @@ import { migrateFrom40to41 } from './migrateFrom40to41'; import { migrateFrom41to42 } from './migrateFrom41to42'; import { migrateFrom42to43 } from './migrateFrom42to43'; import { migrateFrom43to44 } from './migrateFrom43to44'; +import { migrateFrom44to45 } from './migrateFrom44to45'; const { DB_NAME, DB_VERSION } = config.DB; @@ -19,6 +20,7 @@ const migrationMap = { 41: migrateFrom41to42, 42: migrateFrom42to43, 43: migrateFrom43to44, + 44: migrateFrom44to45, }; export async function migration(result: { diff --git a/packages/apps/dev-wallet/src/modules/key-source/key-source.repository.ts b/packages/apps/dev-wallet/src/modules/key-source/key-source.repository.ts index 624e714f2a..bec7a6ee17 100644 --- a/packages/apps/dev-wallet/src/modules/key-source/key-source.repository.ts +++ b/packages/apps/dev-wallet/src/modules/key-source/key-source.repository.ts @@ -36,29 +36,68 @@ export interface IWebAuthn { }>; } -export type KeySourceType = IHDBIP44 | IHDChainweaver | IWebAuthn; +export type KeySourceType = (IHDBIP44 | IHDChainweaver | IWebAuthn) & { + isDefault?: boolean; +}; export interface HDWalletRepository { getKeySource: (id: string) => Promise; + getKeySources: (profileId: string) => Promise; addKeySource: (profile: KeySourceType) => Promise; updateKeySource: (profile: KeySourceType) => Promise; + patchKeySource: (id: string, patch: Partial) => Promise; + setAsDefault: (id: string, profileId: string) => Promise; } const createKeySourceRepository = ({ getOne, add, update, + getAll, }: IDBService): HDWalletRepository => { + const getKeySource = async (id: string): Promise => { + return getOne('keySource', id); + }; + const getKeySources = async (profileId: string): Promise => { + return getAll('keySource', profileId, 'profileId'); + }; + const addKeySource = async (keySource: KeySourceType): Promise => { + return add('keySource', keySource); + }; + const updateKeySource = async (keySource: KeySourceType): Promise => { + return update('keySource', keySource); + }; + const patchKeySource = async ( + id: string, + patch: Partial, + ): Promise => { + const keySource = await getOne('keySource', id); + if (!keySource) return; + return update('keySource', { ...keySource, ...patch }); + }; + const setAsDefault = async (id: string, profileId: string): Promise => { + const keySources: KeySourceType[] = await getAll( + 'keySource', + profileId, + 'profileId', + ); + if (!keySources || !keySources.length) return; + await Promise.all( + keySources + .filter((ks) => ks.uuid !== id) + .map((ks) => update('keySource', { ...ks, isDefault: false })), + ); + const keySource: KeySourceType = await getOne('keySource', id); + return update('keySource', { ...keySource, isDefault: true }); + }; + return { - getKeySource: async (id: string): Promise => { - return getOne('keySource', id); - }, - addKeySource: async (keySource: KeySourceType): Promise => { - return add('keySource', keySource); - }, - updateKeySource: async (keySource: KeySourceType): Promise => { - return update('keySource', keySource); - }, + getKeySource, + getKeySources, + addKeySource, + updateKeySource, + patchKeySource, + setAsDefault, }; }; diff --git a/packages/apps/dev-wallet/src/modules/network/network.repository.ts b/packages/apps/dev-wallet/src/modules/network/network.repository.ts index 265ff92c11..8a37492b42 100644 --- a/packages/apps/dev-wallet/src/modules/network/network.repository.ts +++ b/packages/apps/dev-wallet/src/modules/network/network.repository.ts @@ -79,8 +79,6 @@ export const addDefaultNetworks = execInSequence(async () => { uuid: crypto.randomUUID(), networkId: 'mainnet01', name: 'Mainnet', - // make mainnet disabled for now - disabled: true, hosts: [ { url: 'https://api.chainweb.com', diff --git a/packages/apps/dev-wallet/src/modules/wallet/wallet.hook.tsx b/packages/apps/dev-wallet/src/modules/wallet/wallet.hook.tsx index 6cfe7e21a6..87dcb5ed5c 100644 --- a/packages/apps/dev-wallet/src/modules/wallet/wallet.hook.tsx +++ b/packages/apps/dev-wallet/src/modules/wallet/wallet.hook.tsx @@ -306,7 +306,8 @@ export const useWallet = () => { return keys[0]; } }); - const keySource = context.keySources[0]; + const keySource = + context.keySources.find((ks) => ks.isDefault) || context.keySources[0]; const availableKey = keySource.keys.find( (key) => !usedKeys.includes(key.publicKey), ); diff --git a/packages/apps/dev-wallet/src/modules/wallet/wallet.repository.ts b/packages/apps/dev-wallet/src/modules/wallet/wallet.repository.ts index f44bdc920d..d29fee028b 100644 --- a/packages/apps/dev-wallet/src/modules/wallet/wallet.repository.ts +++ b/packages/apps/dev-wallet/src/modules/wallet/wallet.repository.ts @@ -17,6 +17,7 @@ export interface IKeySource { profileId: string; source: KeySourceType; keys: Array; + isDefault?: boolean; } export interface IProfile { diff --git a/packages/apps/dev-wallet/src/pages/account-discovery/account-dsicovery.tsx b/packages/apps/dev-wallet/src/pages/account-discovery/account-dsicovery.tsx index 79190cf7c2..c80b7ebe5f 100644 --- a/packages/apps/dev-wallet/src/pages/account-discovery/account-dsicovery.tsx +++ b/packages/apps/dev-wallet/src/pages/account-discovery/account-dsicovery.tsx @@ -1,7 +1,6 @@ -import { IKeyItem } from '@/modules/wallet/wallet.repository'; -import { Button, Card, Heading, Stack, Text } from '@kadena/kode-ui'; -import { useRef, useState } from 'react'; -import { useParams } from 'react-router-dom'; +import { IKeyItem, IKeySource } from '@/modules/wallet/wallet.repository'; +import { Button, Card, Checkbox, Heading, Stack, Text } from '@kadena/kode-ui'; +import { useState } from 'react'; import { ListItem } from '@/Components/ListItem/ListItem'; import { IAccount } from '@/modules/account/account.repository'; @@ -10,20 +9,21 @@ import { accountDiscovery, } from '@/modules/account/account.service'; import { keySourceManager } from '@/modules/key-source/key-source-manager'; +import { keySourceRepository } from '@/modules/key-source/key-source.repository'; import { useWallet } from '@/modules/wallet/wallet.hook'; import { shorten } from '@/utils/helpers'; import { usePatchedNavigate } from '@/utils/usePatchedNavigate'; import { ChainId } from '@kadena/client'; import { MonoKey } from '@kadena/kode-icons/system'; +import { PactNumber } from '@kadena/pactjs'; +import { Label } from '../transaction/components/helpers'; const NUMBER_OF_KEYS_TO_DISCOVER = 20; export function AccountDiscovery() { const navigate = usePatchedNavigate(); - const processRef = useRef>(); - const { profile, keySources, unlockKeySource, activeNetwork } = useWallet(); - const { keySourceId } = useParams(); - const [key, setKey] = useState(); + const { profile, keySources, unlockKeySource, networks } = useWallet(); + const [key, setKey] = useState<{ [key: string]: IKeyItem }>({}); const [discoveryStatus, setDiscoveryStatus] = useState< 'idle' | 'discovering' | 'finished' >('idle'); @@ -31,36 +31,38 @@ export function AccountDiscovery() { Array >([]); const [accounts, setAccounts] = useState(); + const [selectedNetworks, setSelectedNetworks] = useState( + networks.map((network) => network.uuid), + ); - async function start() { - const keySource = keySources.find((ks) => ks.uuid === keySourceId); - if (!activeNetwork || !keySource || !profile) return; + async function start(keySource: IKeySource) { + if (!selectedNetworks.length || !keySource || !profile) return []; if ( keySource.source !== 'HD-BIP44' && keySource.source !== 'HD-chainweaver' ) { throw new Error('Unsupported key source'); } - setDiscoveryStatus('discovering'); + await unlockKeySource(keySource); - processRef.current = accountDiscovery( - activeNetwork, + const process = accountDiscovery( + networks.filter((network) => selectedNetworks.includes(network.uuid)), keySource, profile.uuid, NUMBER_OF_KEYS_TO_DISCOVER, ) .on('key-retrieved', (data: IKeyItem) => { - setKey(data); + setKey((st) => ({ ...st, [keySource.source]: data })); }) .on('chain-result', (data: IWalletDiscoveredAccount) => { setDiscoveredAccounts((prev) => [...prev, data]); }); - const accounts = await processRef.current.executeTo('query-done'); - if (!accounts || !accounts.length) { - keySourceManager.disconnect(); - } - setDiscoveryStatus('finished'); - setAccounts(accounts); + const accounts: IAccount[] = await process.executeTo('query-done'); + setAccounts((acc = []) => [...acc, ...accounts]); + await process.execute().catch((e) => { + console.log('error', e); + }); + return accounts; } console.log('accounts', discoveredAccounts); @@ -68,70 +70,149 @@ export function AccountDiscovery() { (data) => data?.result, ) as Array<{ chainId: ChainId; + networkUUID: string; result: Exclude; }>; return ( - - - Account Discovery - - You can discover the accounts that you have created with the imported - mnemonic - - - - network: + + + + Find Your Assets + + We will discover the accounts that you have created with the + imported mnemonic - {activeNetwork?.networkId} - + {discoveryStatus === 'idle' && ( + <> + + + Networks: + + Please select the networks you want to query + + + {networks.map((network) => ( + { + setSelectedNetworks( + checked + ? [...selectedNetworks, network.uuid] + : selectedNetworks.filter((n) => n !== network.uuid), + ); + }} + > + {network.name + ? `${network.networkId} - ${network.name}` + : network.networkId} + + ))} + - {discoveryStatus === 'idle' && ( - - - - )} + + + + + )} - {discoveryStatus === 'discovering' && ( - - We are trying for first 20 keys - only K: account - - checking - {key && ( - <> - #{key.index} - Address: - - k:{key.publicKey} - - + {discoveryStatus === 'discovering' && + keySources.map((keySource) => ( + + {keySource.source} + We are trying for first 20 keys - only K: account + + checking + {key && ( + <> + + #{key[keySource.source]?.index} + + Address: + + k:{key[keySource.source]?.publicKey} + + + )} + + + ))} + {discoveryStatus === 'discovering' && ( + + Discoverd Funds + {filteredDiscoveredAccounts.length === 0 ? ( + Pending + ) : ( + + {networks + .filter((n) => selectedNetworks.includes(n.uuid)) + .map((network) => ( + + + + {filteredDiscoveredAccounts + .filter((d) => d.networkUUID === network.uuid) + .reduce((acc, data) => { + return new PactNumber(data.result.balance) + .plus(acc) + .toDecimal(); + }, '0')}{' '} + KDA + + + ))} + )} - - )} - {discoveryStatus !== 'idle' && ( - - Discoverd Accounts Details - {filteredDiscoveredAccounts.length === 0 ? ( - no accounts found yet - ) : ( + )} + {discoveryStatus === 'finished' && ( + + Discoverd Accounts + {!accounts?.length && no accounts found} - {filteredDiscoveredAccounts.map((data, index) => ( + {accounts?.map((account, index) => ( - Chain #{data.chainId}: - {data.result.account} + {account.address} + - {data.result.guard.pred}: - {data.result.guard.keys.map((key) => ( + {account.guard.pred}: + {account.guard.keys.map((key) => ( @@ -139,66 +220,27 @@ export function AccountDiscovery() { {shorten(key)}{' '} ))} - {data.result.balance} KDA + {account.overallBalance} KDA ))} - )} - - )} - {accounts && ( - - Discoverd Accounts - {!accounts.length && no accounts found} - - {accounts.map((account, index) => ( - - - - {account.address} - - - - {account.guard.pred}: - {account.guard.keys.map((key) => ( - - - - - {shorten(key)}{' '} - - ))} - {account.overallBalance} KDA - - - - ))} - - - - + + + - - )} - - + )} + + + ); } diff --git a/packages/apps/dev-wallet/src/pages/keys/Components/Keys.tsx b/packages/apps/dev-wallet/src/pages/keys/Components/Keys.tsx index f9f6d663de..2933c8b30d 100644 --- a/packages/apps/dev-wallet/src/pages/keys/Components/Keys.tsx +++ b/packages/apps/dev-wallet/src/pages/keys/Components/Keys.tsx @@ -1,6 +1,7 @@ import { ListItem } from '@/Components/ListItem/ListItem.tsx'; import { useHDWallet } from '@/modules/key-source/hd-wallet/hd-wallet.tsx'; import { keySourceManager } from '@/modules/key-source/key-source-manager'; +import { keySourceRepository } from '@/modules/key-source/key-source.repository.ts'; import { WebAuthnService } from '@/modules/key-source/web-authn/webauthn'; import { useWallet } from '@/modules/wallet/wallet.hook'; import { shorten } from '@/utils/helpers.ts'; @@ -63,6 +64,8 @@ export function Keys() { await createHDWallet(profile?.uuid, type, password); }; + const defaultIndex = keySources.findIndex((ks) => ks.isDefault) || 0; + return ( <> - {keySources.map((keySource) => ( + {keySources.map((keySource, index) => ( - Method: {keySource.source} + + Method: {keySource.source}{' '} + {defaultIndex === index && (Default method)} + + - - + + +
{ + setImporting(true); + await importWallet(data); + setImporting(false); + })} className={displayContentsClass} ref={formRef} > {step === 'import' && ( + + + Back + + Import mnemonic @@ -171,29 +180,14 @@ export function RecoverFromMnemonic() { id="phrase" {...register('mnemonic')} /> - - { - return ( - - Generated by Chainweaver v1/v2 - - ); - }} - > - @@ -285,7 +279,12 @@ export function RecoverFromMnemonic() { /> - @@ -294,6 +293,6 @@ export function RecoverFromMnemonic() {
{error && {error}}
- +
); } From f42264f6da6fdb47f9a2d7c65d3e9b96e67d60e9 Mon Sep 17 00:00:00 2001 From: Javad Khalilian Date: Thu, 16 Jan 2025 13:46:25 +0100 Subject: [PATCH 2/2] refactor(dw): discovery --- .../src/modules/wallet/wallet.hook.tsx | 4 ++-- .../account-discovery/account-dsicovery.tsx | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/apps/dev-wallet/src/modules/wallet/wallet.hook.tsx b/packages/apps/dev-wallet/src/modules/wallet/wallet.hook.tsx index 87dcb5ed5c..69cdbbf672 100644 --- a/packages/apps/dev-wallet/src/modules/wallet/wallet.hook.tsx +++ b/packages/apps/dev-wallet/src/modules/wallet/wallet.hook.tsx @@ -65,7 +65,7 @@ export const useWallet = () => { ); const unlockProfile = useCallback( - async (profileId: string, password: string) => { + async (profileId: string, password: string, unlockSecurity = false) => { console.log('unlockProfile', profileId, password); const profile = await WalletService.unlockProfile(profileId, password); await securityService.clearSecurityPhrase(); @@ -73,7 +73,7 @@ export const useWallet = () => { const res = await setProfile(profile); channel.postMessage({ action: 'switch-profile', payload: profile }); backupDatabase().catch(console.log); - if (profile.options.rememberPassword === 'on-login') { + if (profile.options.rememberPassword === 'on-login' || unlockSecurity) { const sessionEntropy = (await Session.get('sessionId')) as string; if (!sessionEntropy) { return res; diff --git a/packages/apps/dev-wallet/src/pages/account-discovery/account-dsicovery.tsx b/packages/apps/dev-wallet/src/pages/account-discovery/account-dsicovery.tsx index c80b7ebe5f..08eff87c97 100644 --- a/packages/apps/dev-wallet/src/pages/account-discovery/account-dsicovery.tsx +++ b/packages/apps/dev-wallet/src/pages/account-discovery/account-dsicovery.tsx @@ -151,24 +151,23 @@ export function AccountDiscovery() { {discoveryStatus === 'discovering' && keySources.map((keySource) => ( - - {keySource.source} - We are trying for first 20 keys - only K: account + + + {keySource.source} + {key[keySource.source]?.index === undefined + ? '' + : `(${key[keySource.source]?.index})`} + - checking {key && ( <> - - #{key[keySource.source]?.index} - - Address: k:{key[keySource.source]?.publicKey} )} - +
))} {discoveryStatus === 'discovering' && (