Skip to content

Commit

Permalink
Change default account name
Browse files Browse the repository at this point in the history
  • Loading branch information
bbedward committed Mar 7, 2024
1 parent 7a9452d commit 36edf6c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/localization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ class AppLocalization {
}

String get defaultNewAccountNameAdHoc {
return Intl.message("Imported Account %1",
return Intl.message("Imported Account",
desc:
"Default new account name for accounts imported with a different seed - e.g. Imported 1",
name: 'defaultNewAccountNameAdHoc');
Expand Down
12 changes: 2 additions & 10 deletions lib/model/db/appdb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -285,24 +285,16 @@ ORDER BY
}

Future<Account> addAccountWithPrivateKey(
{String nameBuilder, String privateKey}) async {
{String accountName, String privateKey}) async {
var dbClient = await db;
Account account;
int newAccountId;
await dbClient.transaction((Transaction txn) async {
int nextID = 1;
var result = await txn.rawQuery('SELECT MAX(id) AS max_id FROM Accounts');
if (result[0]["max_id"] != null) {
int maxId = result[0]["max_id"];
nextID = maxId + 1;
}

String nextName = nameBuilder.replaceAll("%1", "${nextID.toString()}");
String address = NanoUtil.privateToAddress(privateKey);
account = Account(
id: 0,
index: -1,
name: nextName,
name: accountName,
lastAccess: 0,
selected: false,
address: address);
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/accounts/import_external_account_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class _ImportExternalAccountSheetState
// Add account
try {
Account acct = await sl.get<DBHelper>().addAccountWithPrivateKey(
nameBuilder: AppLocalization.of(context).defaultNewAccountNameAdHoc,
accountName: AppLocalization.of(context).defaultNewAccountNameAdHoc,
privateKey: privateKey);
widget.accountAddedCallback(acct);
Navigator.of(context).pop();
Expand Down
3 changes: 3 additions & 0 deletions lib/util/nanoutil.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import 'package:kalium_wallet_flutter/model/db/account.dart';
import 'package:kalium_wallet_flutter/appstate_container.dart';
import 'package:kalium_wallet_flutter/localization.dart';

import '../model/vault.dart';

class NanoUtil {
static String seedToPrivate(String seed, int index) {
return NanoKeys.seedToPrivate(seed, index);
Expand All @@ -30,6 +32,7 @@ class NanoUtil {
index: 0,
lastAccess: 0,
name: AppLocalization.of(context).defaultAccountName,
address: NanoUtil.seedToAddress(await sl.get<Vault>().getSeed(), 0),
selected: true);
await sl.get<DBHelper>().saveAccount(selectedAcct);
}
Expand Down

0 comments on commit 36edf6c

Please sign in to comment.