Migration Service
Code Source:
src/services/migration/migration-service.ts
Overview
The MigrationService handles the critical task of importing data from the legacy "mpay" application. It orchestrates a multi-step process ensuring data integrity and security.
Migration Flow
The process is defined as a state machine:
idledetect: ScanslocalStoragefor legacy mpay data structures.verify: Validates the user's password against the legacy wallet encryption.transform: Converts legacy data formats to the new KeyApp schema (WalletInfo,ChainAddressInfo).import: Writes the transformed data toWalletStorageService(IndexedDB).complete
Key Features
- Progress Tracking: Reports granular progress updates to the UI.
- Resumability: Stores migration status in
localStorage(keyapp_migration_status). - Security: Decrypts legacy data in memory and immediately re-encrypts it using the new wallet lock system.
Data Mapping
| Legacy (mpay) | New (KeyApp) |
|---|---|
Wallet (localStorage) | WalletInfo (IndexedDB) |
AddressBook | Contact (Store) |
importPhrase | encryptedMnemonic |
