2021-12-24 12:37:24 +00:00
|
|
|
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
2022-03-30 15:57:04 +00:00
|
|
|
import 'package:cake_wallet/haven/haven.dart';
|
2020-06-20 07:10:00 +00:00
|
|
|
import 'package:cake_wallet/core/validator.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/entities/mnemonic_item.dart';
|
2021-12-24 12:37:24 +00:00
|
|
|
import 'package:cw_core/wallet_type.dart';
|
|
|
|
import 'package:cake_wallet/monero/monero.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/utils/language_list.dart';
|
2020-06-20 07:10:00 +00:00
|
|
|
|
|
|
|
class SeedValidator extends Validator<MnemonicItem> {
|
|
|
|
SeedValidator({this.type, this.language})
|
|
|
|
: _words = getWordList(type: type, language: language);
|
|
|
|
|
|
|
|
final WalletType type;
|
|
|
|
final String language;
|
|
|
|
final List<String> _words;
|
|
|
|
|
|
|
|
static List<String> getWordList({WalletType type, String language}) {
|
|
|
|
switch (type) {
|
|
|
|
case WalletType.bitcoin:
|
|
|
|
return getBitcoinWordList(language);
|
2021-05-07 18:59:03 +00:00
|
|
|
case WalletType.litecoin:
|
|
|
|
return getBitcoinWordList(language);
|
2020-06-20 07:10:00 +00:00
|
|
|
case WalletType.monero:
|
2021-12-24 12:37:24 +00:00
|
|
|
return monero.getMoneroWordList(language);
|
2022-03-30 15:57:04 +00:00
|
|
|
case WalletType.haven:
|
|
|
|
return haven.getMoneroWordList(language);
|
2020-06-20 07:10:00 +00:00
|
|
|
default:
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static List<String> getBitcoinWordList(String language) {
|
2020-09-21 11:50:26 +00:00
|
|
|
assert(language.toLowerCase() == LanguageList.english.toLowerCase());
|
2021-12-24 12:37:24 +00:00
|
|
|
return bitcoin.getWordList();
|
2020-06-20 07:10:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool isValid(MnemonicItem value) => _words.contains(value.text);
|
|
|
|
}
|