CW-673: Save Haven seeds to show it to the user after Haven removal (#1518)

* haven: backup seeds

* haven backup fixes

* ci fix

* reorder build script

* disable haven

* properly call cw_haven code

* [skip ci] update PR

* Update evm_chain_transaction_history.dart

remove print

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
cyan
2024-12-11 22:31:01 +02:00
committed by GitHub
co-authored by Omar Hatem
parent 329a1fd6de
commit e2a1d865af
7 changed files with 87 additions and 14 deletions
+17
View File
@@ -307,6 +307,23 @@ class CWHaven extends Haven {
return havenTransactionInfo.accountIndex;
}
@override
Future<void> backupHavenSeeds(Box<HavenSeedStore> havenSeedStore) async {
final walletInfoSource = await CakeHive.openBox<WalletInfo>(WalletInfo.boxName);
final wallets = walletInfoSource.values
.where((element) => element.type == WalletType.haven);
for (var w in wallets) {
final walletService = HavenWalletService(walletInfoSource);
final flutterSecureStorage = secureStorageShared;
final keyService = KeyService(flutterSecureStorage);
final password = await keyService.getWalletPassword(walletName: w.name);
final wallet = await walletService.openWallet(w.name, password);
await havenSeedStore.add(HavenSeedStore(id: wallet.id, seed: wallet.seed));
wallet.close();
}
await havenSeedStore.flush();
}
@override
WalletService createHavenWalletService(Box<WalletInfo> walletInfoSource) {
return HavenWalletService(walletInfoSource);