Skip to content

Commit

Permalink
Improve contacts management #296
Browse files Browse the repository at this point in the history
  • Loading branch information
redDwarf03 committed Sep 16, 2022
1 parent b9461af commit b38f36a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/util/keychain_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'dart:math';
import 'dart:typed_data';

// Package imports:
import 'package:aewallet/model/data/contact.dart';
import 'package:archethic_lib_dart/archethic_lib_dart.dart';
import 'package:event_taxi/event_taxi.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
Expand Down Expand Up @@ -190,6 +191,12 @@ class KeychainUtil {

await appWallet.save();

final Contact newContact = Contact(
name: '@$name',
address: uint8ListToHex(genesisAddress),
type: 'keychainService');
await sl.get<DBHelper>().saveContact(newContact);

return appWallet;
}

Expand Down Expand Up @@ -256,6 +263,16 @@ class KeychainUtil {
}

accounts.add(account);

try {
await sl.get<DBHelper>().getContactWithName(account.name!);
} catch (e) {
final Contact newContact = Contact(
name: '@$nameDecoded',
address: uint8ListToHex(genesisAddress),
type: 'keychainService');
await sl.get<DBHelper>().saveContact(newContact);
}
}
});

Expand Down

0 comments on commit b38f36a

Please sign in to comment.