Skip to content

Commit

Permalink
fix: 🐛 Fix target keychain seed affectation
Browse files Browse the repository at this point in the history
  • Loading branch information
redDwarf03 committed Jan 7, 2025
1 parent 926df7b commit 553b976
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/domain/usecases/new_keychain.usecase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ class CreateNewAppWalletCase with aedappfm.TransactionMixin {
Future<void> run(
String seed,
archethic.ApiService targetApiService,
List<String> nameList,
) async {
List<String> nameList, {
String? keychainSeed,
}) async {
/// Get Wallet KeyPair
final walletKeyPair = archethic.deriveKeyPair(seed, 0);

/// Generate keyChain Seed from random value
final keychainSeed = archethic.uint8ListToHex(
/// If null, generate keyChain Seed from random value
keychainSeed ??= archethic.uint8ListToHex(
Uint8List.fromList(
List<int>.generate(32, (int i) => Random.secure().nextInt(256)),
),
Expand Down
9 changes: 8 additions & 1 deletion lib/ui/menu/settings/environment_change.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class EnvironmentChange extends ConsumerWidget {
ref.read(sessionNotifierProvider).loggedIn?.wallet.seed;

var keychainNetworkExists = false;

try {
await archethic.ApiService(
_selectedEnvironment.endpoint,
Expand Down Expand Up @@ -98,10 +99,16 @@ class EnvironmentChange extends ConsumerWidget {
title:
AppLocalizations.of(context)!.pleaseWaitChangeNetwork,
);
final originKeychain = await archethic.ApiService(
_saveEnvironment.endpoint,
).getKeychain(seed!);
await ref.read(createNewAppWalletCaseProvider).run(
seed!,
seed,
archethic.ApiService(_selectedEnvironment.endpoint),
nameList,
keychainSeed: originKeychain.seed == null
? null
: archethic.uint8ListToHex(originKeychain.seed!),
);

UIUtil.showSnackbar(
Expand Down

0 comments on commit 553b976

Please sign in to comment.