Cw 534 monero wallet generic enhancements (#1225)

* Fix word count for polyseed on pre_seed_page

* Fix naming of advanced setting

* Set default Seed Type to Polyseed and disable bg-sync by default

* Fix inconsistency between seed type field in restore screen and the one in advanced settings

* Use pub.dev release of polyseed

* Add Legacy Seed to wallet_keys-Page in case of Polyseed
This commit is contained in:
Konstantin Ullrich 2023-12-09 02:37:39 +01:00 committed by GitHub
parent 2138c35e38
commit 72777fbf2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 203 additions and 99 deletions

View file

@ -13,7 +13,6 @@ import 'package:cw_monero/api/wallet_manager.dart' as monero_wallet_manager;
import 'package:cw_monero/monero_wallet.dart';
import 'package:hive/hive.dart';
import 'package:polyseed/polyseed.dart';
import 'package:polyseed/src/utils/key_utils.dart';
class MoneroNewWalletCredentials extends WalletCredentials {
MoneroNewWalletCredentials({required String name, required this.language, required this.isPolyseed, String? password})
@ -275,7 +274,7 @@ class MoneroWalletService extends WalletService<
{PolyseedCoin coin = PolyseedCoin.POLYSEED_MONERO, int? overrideHeight}) async {
final height = overrideHeight ?? getMoneroHeigthByDate(
date: DateTime.fromMillisecondsSinceEpoch(polyseed.birthday * 1000));
final spendKey = keyToHexString(polyseed.generateKey(coin, 32));
final spendKey = polyseed.generateKey(coin, 32).toHexString();
final seed = polyseed.encode(lang, coin);
walletInfo.isRecovery = true;

View file

@ -266,6 +266,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.2.0"
hashlib:
dependency: transitive
description:
name: hashlib
sha256: "71bf102329ddb8e50c8a995ee4645ae7f1728bb65e575c17196b4d8262121a96"
url: "https://pub.dev"
source: hosted
version: "1.12.0"
hashlib_codecs:
dependency: transitive
description:
name: hashlib_codecs
sha256: "49e2a471f74b15f1854263e58c2ac11f2b631b5b12c836f9708a35397d36d626"
url: "https://pub.dev"
source: hosted
version: "2.2.0"
hive:
dependency: transitive
description:
@ -485,12 +501,11 @@ packages:
polyseed:
dependency: "direct main"
description:
path: "."
ref: HEAD
resolved-ref: "504d58a5b147fccd3bc85a25f2e72fb32771ddd7"
url: "https://github.com/cake-tech/polyseed_dart.git"
source: git
version: "0.0.1"
name: polyseed
sha256: "9b48ec535b10863f78f6354ec983b4cc0c88ca69ff48fee469d0fd1954b01d4f"
url: "https://pub.dev"
source: hosted
version: "0.0.2"
pool:
dependency: transitive
description:
@ -632,15 +647,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.1"
tor:
dependency: transitive
description:
path: "."
ref: main
resolved-ref: "09ba92cb11d4e3cacf97256e57863b805f79f2e5"
url: "https://github.com/cake-tech/tor.git"
source: git
version: "0.0.1"
typed_data:
dependency: transitive
description:

View file

@ -19,9 +19,7 @@ dependencies:
flutter_mobx: ^2.0.6+1
intl: ^0.18.0
encrypt: ^5.0.1
polyseed:
git:
url: https://github.com/cake-tech/polyseed_dart.git
polyseed: ^0.0.2
cw_core:
path: ../cw_core

View file

@ -90,6 +90,7 @@ import 'package:cake_wallet/view_model/ionia/ionia_purchase_merch_view_model.dar
import 'package:cake_wallet/view_model/nano_account_list/nano_account_edit_or_create_view_model.dart';
import 'package:cake_wallet/view_model/nano_account_list/nano_account_list_view_model.dart';
import 'package:cake_wallet/view_model/node_list/pow_node_list_view_model.dart';
import 'package:cake_wallet/view_model/seed_type_view_model.dart';
import 'package:cake_wallet/view_model/set_up_2fa_viewmodel.dart';
import 'package:cake_wallet/view_model/restore/restore_from_qr_vm.dart';
import 'package:cake_wallet/view_model/settings/display_settings_view_model.dart';
@ -719,6 +720,8 @@ Future<void> setup({
getIt.registerFactory(() => WalletSeedViewModel(getIt.get<AppStore>().wallet!));
getIt.registerFactory<SeedTypeViewModel>(() => SeedTypeViewModel(getIt.get<AppStore>()));
getIt.registerFactoryParam<WalletSeedPage, bool, void>((bool isWalletCreated, _) =>
WalletSeedPage(getIt.get<WalletSeedViewModel>(), isNewWalletCreated: isWalletCreated));
@ -850,7 +853,7 @@ Future<void> setup({
return ethereum!.createEthereumWalletService(_walletInfoSource);
case WalletType.bitcoinCash:
return bitcoinCash!
.createBitcoinCashWalletService(_walletInfoSource, _unspentCoinsInfoSource!);
.createBitcoinCashWalletService(_walletInfoSource, _unspentCoinsInfoSource);
case WalletType.nano:
return nano!.createNanoWalletService(_walletInfoSource);
case WalletType.polygon:
@ -879,8 +882,8 @@ Future<void> setup({
getIt.get<AppStore>(), getIt.get<WalletCreationService>(param1: type), _walletInfoSource,
type: type));
getIt.registerFactoryParam<WalletRestorePage, WalletType, void>(
(type, _) => WalletRestorePage(getIt.get<WalletRestoreViewModel>(param1: type)));
getIt.registerFactoryParam<WalletRestorePage, WalletType, void>((type, _) => WalletRestorePage(
getIt.get<WalletRestoreViewModel>(param1: type), getIt.get<SeedTypeViewModel>()));
getIt.registerFactoryParam<WalletRestoreChooseDerivationViewModel, List<DerivationInfo>, void>(
(derivations, _) => WalletRestoreChooseDerivationViewModel(derivationInfos: derivations));
@ -911,7 +914,7 @@ Future<void> setup({
getIt.registerFactoryParam<PreSeedPage, WalletType, AdvancedPrivacySettingsViewModel>(
(WalletType type, AdvancedPrivacySettingsViewModel advancedPrivacySettingsViewModel) =>
PreSeedPage(type, advancedPrivacySettingsViewModel));
PreSeedPage(type, advancedPrivacySettingsViewModel, getIt.get<SeedTypeViewModel>()));
getIt.registerFactoryParam<TradeDetailsViewModel, Trade, void>((trade, _) =>
TradeDetailsViewModel(

View file

@ -6,7 +6,7 @@ class SeedType extends EnumerableItem<int> with Serializable<int> {
static const all = [SeedType.legacy, SeedType.polyseed];
static const defaultSeedType = legacy;
static const defaultSeedType = polyseed;
static const legacy = SeedType(raw: 0, title: 'Legacy (25 words)');
static const polyseed = SeedType(raw: 1, title: 'Polyseed (16 words)');

View file

@ -56,13 +56,13 @@ import 'package:cake_wallet/src/screens/support_other_links/support_other_links_
import 'package:cake_wallet/src/screens/unspent_coins/unspent_coins_details_page.dart';
import 'package:cake_wallet/src/screens/unspent_coins/unspent_coins_list_page.dart';
import 'package:cake_wallet/src/screens/wallet_connect/wc_connections_listing_view.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/utils/payment_request.dart';
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
import 'package:cake_wallet/view_model/dashboard/nft_view_model.dart';
import 'package:cake_wallet/view_model/monero_account_list/account_list_item.dart';
import 'package:cake_wallet/view_model/node_list/node_create_or_edit_view_model.dart';
import 'package:cake_wallet/view_model/advanced_privacy_settings_view_model.dart';
import 'package:cake_wallet/view_model/seed_type_view_model.dart';
import 'package:cake_wallet/wallet_type_utils.dart';
import 'package:cw_core/nano_account.dart';
import 'package:cw_core/wallet_info.dart';
@ -147,9 +147,9 @@ Route<dynamic> createRoute(RouteSettings settings) {
case Routes.newWallet:
final type = settings.arguments as WalletType;
final walletNewVM = getIt.get<WalletNewVM>(param1: type);
final settingsStore = getIt.get<SettingsStore>();
final seedTypeViewModel = getIt.get<SeedTypeViewModel>();
return CupertinoPageRoute<void>(builder: (_) => NewWalletPage(walletNewVM, settingsStore));
return CupertinoPageRoute<void>(builder: (_) => NewWalletPage(walletNewVM, seedTypeViewModel));
case Routes.setupPin:
Function(PinCodeState<PinCodeWidget>, String)? callback;
@ -537,7 +537,7 @@ Route<dynamic> createRoute(RouteSettings settings) {
builder: (_) => AdvancedPrivacySettingsPage(
getIt.get<AdvancedPrivacySettingsViewModel>(param1: type),
getIt.get<NodeCreateOrEditViewModel>(param1: type, param2: false),
));
getIt.get<SeedTypeViewModel>()));
case Routes.anonPayInvoicePage:
final args = settings.arguments as List;

View file

@ -9,6 +9,7 @@ import 'package:cake_wallet/src/screens/settings/widgets/settings_switcher_cell.
import 'package:cake_wallet/themes/extensions/new_wallet_theme.dart';
import 'package:cake_wallet/view_model/node_list/node_create_or_edit_view_model.dart';
import 'package:cake_wallet/view_model/advanced_privacy_settings_view_model.dart';
import 'package:cake_wallet/view_model/seed_type_view_model.dart';
import 'package:cake_wallet/view_model/settings/choices_list_item.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:flutter/material.dart';
@ -18,25 +19,30 @@ import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
class AdvancedPrivacySettingsPage extends BasePage {
AdvancedPrivacySettingsPage(this.advancedPrivacySettingsViewModel, this.nodeViewModel);
AdvancedPrivacySettingsPage(
this.advancedPrivacySettingsViewModel, this.nodeViewModel, this.seedTypeViewModel);
final AdvancedPrivacySettingsViewModel advancedPrivacySettingsViewModel;
final NodeCreateOrEditViewModel nodeViewModel;
final SeedTypeViewModel seedTypeViewModel;
@override
String get title => S.current.privacy_settings;
@override
Widget body(BuildContext context) =>
AdvancedPrivacySettingsBody(advancedPrivacySettingsViewModel, nodeViewModel);
Widget body(BuildContext context) => AdvancedPrivacySettingsBody(
advancedPrivacySettingsViewModel, nodeViewModel, seedTypeViewModel);
}
class AdvancedPrivacySettingsBody extends StatefulWidget {
const AdvancedPrivacySettingsBody(this.privacySettingsViewModel, this.nodeViewModel, {Key? key})
const AdvancedPrivacySettingsBody(
this.privacySettingsViewModel, this.nodeViewModel, this.seedTypeViewModel,
{Key? key})
: super(key: key);
final AdvancedPrivacySettingsViewModel privacySettingsViewModel;
final NodeCreateOrEditViewModel nodeViewModel;
final SeedTypeViewModel seedTypeViewModel;
@override
_AdvancedPrivacySettingsBodyState createState() => _AdvancedPrivacySettingsBodyState();
@ -59,7 +65,7 @@ class _AdvancedPrivacySettingsBodyState extends State<AdvancedPrivacySettingsBod
Observer(builder: (_) {
return SettingsChoicesCell(
ChoicesListItem<FiatApiMode>(
title: S.current.disable_fiat,
title: S.current.fiat_api,
items: FiatApiMode.all,
selectedItem: widget.privacySettingsViewModel.fiatApiMode,
onItemSelected: (FiatApiMode mode) =>
@ -114,8 +120,8 @@ class _AdvancedPrivacySettingsBodyState extends State<AdvancedPrivacySettingsBod
ChoicesListItem<SeedType>(
title: S.current.seedtype,
items: SeedType.all,
selectedItem: widget.privacySettingsViewModel.seedType,
onItemSelected: widget.privacySettingsViewModel.setSeedType,
selectedItem: widget.seedTypeViewModel.moneroSeedType,
onItemSelected: widget.seedTypeViewModel.setMoneroSeedType,
),
);
}),

View file

@ -7,6 +7,7 @@ import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/themes/theme_base.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:cake_wallet/view_model/seed_type_view_model.dart';
import 'package:mobx/mobx.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:flutter/material.dart';
@ -23,13 +24,12 @@ import 'package:cake_wallet/view_model/wallet_new_vm.dart';
import 'package:cake_wallet/themes/extensions/new_wallet_theme.dart';
import 'package:cake_wallet/themes/extensions/send_page_theme.dart';
import 'package:cake_wallet/entities/seed_type.dart';
import 'package:cake_wallet/store/settings_store.dart';
class NewWalletPage extends BasePage {
NewWalletPage(this._walletNewVM, this._settingsStore);
NewWalletPage(this._walletNewVM, this._seedTypeViewModel);
final WalletNewVM _walletNewVM;
final SettingsStore _settingsStore;
final SeedTypeViewModel _seedTypeViewModel;
final walletNameImage = Image.asset('assets/images/wallet_name.png');
@ -40,15 +40,15 @@ class NewWalletPage extends BasePage {
@override
Widget body(BuildContext context) => WalletNameForm(
_walletNewVM, currentTheme.type == ThemeType.dark ? walletNameImage : walletNameLightImage, _settingsStore);
_walletNewVM, currentTheme.type == ThemeType.dark ? walletNameImage : walletNameLightImage, _seedTypeViewModel);
}
class WalletNameForm extends StatefulWidget {
WalletNameForm(this._walletNewVM, this.walletImage, this._settingsStore);
WalletNameForm(this._walletNewVM, this.walletImage, this._seedTypeViewModel);
final WalletNewVM _walletNewVM;
final Image walletImage;
final SettingsStore _settingsStore;
final SeedTypeViewModel _seedTypeViewModel;
@override
_WalletNameFormState createState() => _WalletNameFormState(_walletNewVM);
@ -194,7 +194,7 @@ class _WalletNameFormState extends State<WalletNameForm> {
builder: (BuildContext build) => Padding(
padding: EdgeInsets.only(top: 24),
child: SelectButton(
text: widget._settingsStore.moneroSeedType.title,
text: widget._seedTypeViewModel.moneroSeedType.title,
onTap: () async {
await showPopUp<void>(
context: context,
@ -217,7 +217,7 @@ class _WalletNameFormState extends State<WalletNameForm> {
key: _languageSelectorKey,
initialSelected: defaultSeedLanguage,
seedType: _walletNewVM.hasSeedType
? widget._settingsStore.moneroSeedType
? widget._seedTypeViewModel.moneroSeedType
: SeedType.legacy,
),
),
@ -277,10 +277,10 @@ class _WalletNameFormState extends State<WalletNameForm> {
}
}
bool get isPolyseed => widget._settingsStore.moneroSeedType == SeedType.polyseed;
bool get isPolyseed => widget._seedTypeViewModel.moneroSeedType == SeedType.polyseed;
void _setSeedType(SeedType item) {
widget._settingsStore.moneroSeedType = item;
widget._seedTypeViewModel.setMoneroSeedType(item);
_languageSelectorKey.currentState?.selected = defaultSeedLanguage; // Reset Seed language
}
}

View file

@ -9,8 +9,10 @@ import 'package:cake_wallet/src/widgets/seed_language_picker.dart';
import 'package:cake_wallet/src/widgets/seed_widget.dart';
import 'package:cake_wallet/themes/extensions/send_page_theme.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:cake_wallet/view_model/seed_type_view_model.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:flutter/material.dart';
import 'package:mobx/mobx.dart';
import 'package:polyseed/polyseed.dart';
class WalletRestoreFromSeedForm extends StatefulWidget {
@ -19,6 +21,7 @@ class WalletRestoreFromSeedForm extends StatefulWidget {
required this.displayLanguageSelector,
required this.displayBlockHeightSelector,
required this.type,
required this.seedTypeViewModel,
this.blockHeightFocusNode,
this.onHeightOrDateEntered,
this.onSeedChange,
@ -28,6 +31,7 @@ class WalletRestoreFromSeedForm extends StatefulWidget {
final WalletType type;
final bool displayLanguageSelector;
final bool displayBlockHeightSelector;
final SeedTypeViewModel seedTypeViewModel;
final FocusNode? blockHeightFocusNode;
final Function(bool)? onHeightOrDateEntered;
final void Function(String)? onSeedChange;
@ -52,16 +56,28 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
final TextEditingController nameTextEditingController;
final TextEditingController seedTypeController;
final GlobalKey<FormState> formKey;
late ReactionDisposer moneroSeedTypeReaction;
String language;
bool isPolyseed = false;
@override
void initState() {
_setSeedType(widget.seedTypeViewModel.moneroSeedType);
_setLanguageLabel(language);
_setSeedType(SeedType.defaultSeedType);
moneroSeedTypeReaction =
reaction((_) => widget.seedTypeViewModel.moneroSeedType, (SeedType item) {
_setSeedType(item);
_changeLanguage('English');
});
super.initState();
}
@override
void dispose() {
super.dispose();
moneroSeedTypeReaction();
}
void onSeedChange(String seed) {
if (widget.type == WalletType.monero && Polyseed.isValidSeed(seed)) {
final lang = PolyseedLang.getByPhrase(seed);
@ -181,6 +197,8 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
]));
}
bool get isPolyseed => widget.seedTypeViewModel.moneroSeedType == SeedType.polyseed;
Widget get expandIcon => Container(
padding: EdgeInsets.all(18),
width: 24,
@ -208,10 +226,10 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
void _changeSeedType(SeedType item) {
_setSeedType(item);
_changeLanguage('English');
widget.seedTypeViewModel.setMoneroSeedType(item);
}
void _setSeedType(SeedType item) {
setState(() => isPolyseed = item == SeedType.polyseed);
seedTypeController.text = item.toString();
}
}

View file

@ -15,6 +15,7 @@ import 'package:cake_wallet/themes/extensions/wallet_list_theme.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:cake_wallet/view_model/restore/restore_mode.dart';
import 'package:cake_wallet/view_model/seed_type_view_model.dart';
import 'package:cake_wallet/view_model/wallet_restore_view_model.dart';
import 'package:cw_core/nano_account_info_response.dart';
import 'package:cw_core/wallet_info.dart';
@ -27,7 +28,7 @@ import 'package:polyseed/polyseed.dart';
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
class WalletRestorePage extends BasePage {
WalletRestorePage(this.walletRestoreViewModel)
WalletRestorePage(this.walletRestoreViewModel, this.seedTypeViewModel)
: walletRestoreFromSeedFormKey = GlobalKey<WalletRestoreFromSeedFormState>(),
walletRestoreFromKeysFormKey = GlobalKey<WalletRestoreFromKeysFromState>(),
_pages = [],
@ -37,6 +38,7 @@ class WalletRestorePage extends BasePage {
switch (mode) {
case WalletRestoreMode.seed:
_pages.add(WalletRestoreFromSeedForm(
seedTypeViewModel: seedTypeViewModel,
displayBlockHeightSelector:
walletRestoreViewModel.hasBlockchainHeightLanguageSelector,
displayLanguageSelector: walletRestoreViewModel.hasSeedLanguageSelector,
@ -91,6 +93,7 @@ class WalletRestorePage extends BasePage {
));
final WalletRestoreViewModel walletRestoreViewModel;
final SeedTypeViewModel seedTypeViewModel;
final PageController _controller;
final List<Widget> _pages;
final GlobalKey<WalletRestoreFromSeedFormState> walletRestoreFromSeedFormKey;

View file

@ -1,6 +1,8 @@
import 'package:cake_wallet/entities/seed_type.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart';
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
import 'package:cake_wallet/view_model/advanced_privacy_settings_view_model.dart';
import 'package:cake_wallet/view_model/seed_type_view_model.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
@ -10,19 +12,21 @@ import 'package:cake_wallet/themes/theme_base.dart';
import 'package:flutter/material.dart';
class PreSeedPage extends BasePage {
PreSeedPage(this.type, this.advancedPrivacySettingsViewModel)
PreSeedPage(this.type, this.advancedPrivacySettingsViewModel, this.seedTypeViewModel)
: imageLight = Image.asset('assets/images/pre_seed_light.png'),
imageDark = Image.asset('assets/images/pre_seed_dark.png'),
seedPhraseLength =
advancedPrivacySettingsViewModel.seedPhraseLength.value {
wordsCount = _wordsCount(type, seedPhraseLength);
seedPhraseLength = advancedPrivacySettingsViewModel.seedPhraseLength.value,
moneroSeedType = seedTypeViewModel.moneroSeedType {
wordsCount = _wordsCount(type, seedPhraseLength, moneroSeedType);
}
final Image imageDark;
final Image imageLight;
final WalletType type;
final AdvancedPrivacySettingsViewModel advancedPrivacySettingsViewModel;
final SeedTypeViewModel seedTypeViewModel;
final int seedPhraseLength;
final SeedType moneroSeedType;
late final int wordsCount;
@override
@ -76,9 +80,11 @@ class PreSeedPage extends BasePage {
));
}
static int _wordsCount(WalletType type, int seedPhraseLength) {
static int _wordsCount(WalletType type, int seedPhraseLength, SeedType moneroSeedType) {
switch (type) {
case WalletType.monero:
if (moneroSeedType == SeedType.polyseed)
return 16;
return 25;
case WalletType.ethereum:
case WalletType.bitcoinCash:

View file

@ -877,7 +877,7 @@ abstract class SettingsStoreBase with Store {
}
final savedSyncMode = SyncMode.all.firstWhere((element) {
return element.type.index == (sharedPreferences.getInt(PreferencesKey.syncModeKey) ?? 1);
return element.type.index == (sharedPreferences.getInt(PreferencesKey.syncModeKey) ?? 0);
});
final savedSyncAll = sharedPreferences.getBool(PreferencesKey.syncAllKey) ?? true;

View file

@ -1,7 +1,6 @@
import 'package:cake_wallet/entities/exchange_api_mode.dart';
import 'package:cake_wallet/entities/fiat_api_mode.dart';
import 'package:cake_wallet/entities/seed_phrase_length.dart';
import 'package:cake_wallet/entities/seed_type.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:mobx/mobx.dart';
@ -20,9 +19,6 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store {
@computed
FiatApiMode get fiatApiMode => _settingsStore.fiatApiMode;
@computed
SeedType get seedType => _settingsStore.moneroSeedType;
@observable
bool _addCustomNode = false;
@ -44,9 +40,6 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store {
@action
void setFiatApiMode(FiatApiMode fiatApiMode) => _settingsStore.fiatApiMode = fiatApiMode;
@action
void setSeedType(SeedType seedType) => _settingsStore.moneroSeedType = seedType;
@action
void setExchangeApiMode(ExchangeApiMode value) => _settingsStore.exchangeStatus = value;

View file

@ -0,0 +1,19 @@
import 'package:cake_wallet/entities/seed_type.dart';
import 'package:cake_wallet/store/app_store.dart';
import 'package:mobx/mobx.dart';
part 'seed_type_view_model.g.dart';
class SeedTypeViewModel = SeedTypeViewModelBase with _$SeedTypeViewModel;
abstract class SeedTypeViewModelBase with Store {
SeedTypeViewModelBase(this._appStore);
@computed
SeedType get moneroSeedType => _appStore.settingsStore.moneroSeedType;
@action
void setMoneroSeedType(SeedType seedType) => _appStore.settingsStore.moneroSeedType = seedType;
final AppStore _appStore;
}

View file

@ -10,6 +10,7 @@ import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.d
import 'package:cake_wallet/monero/monero.dart';
import 'package:cake_wallet/haven/haven.dart';
import 'package:cw_monero/api/wallet.dart' as monero_wallet;
import 'package:polyseed/polyseed.dart';
part 'wallet_keys_view_model.g.dart';
@ -74,6 +75,15 @@ abstract class WalletKeysViewModelBase with Store {
StandartListItem(title: S.current.view_key_private, value: keys['privateViewKey']!),
StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
]);
if (_appStore.wallet?.seed != null && Polyseed.isValidSeed(_appStore.wallet!.seed!)) {
final lang = PolyseedLang.getByPhrase(_appStore.wallet!.seed!);
final legacyLang = _getLegacySeedLang(lang);
final legacySeed =
Polyseed.decode(_appStore.wallet!.seed!, lang, PolyseedCoin.POLYSEED_MONERO)
.toLegacySeed(legacyLang);
items.add(StandartListItem(title: S.current.wallet_seed_legacy, value: legacySeed));
}
}
if (_appStore.wallet!.type == WalletType.haven) {
@ -207,4 +217,23 @@ abstract class WalletKeysViewModelBase with Store {
}
String getRoundedRestoreHeight(int height) => ((height / 1000).floor() * 1000).toString();
LegacySeedLang _getLegacySeedLang(PolyseedLang lang) {
switch (lang.nameEnglish) {
case "Spanish":
return LegacySeedLang.getByEnglishName("Spanish");
case "French":
return LegacySeedLang.getByEnglishName("French");
case "Italian":
return LegacySeedLang.getByEnglishName("Italian");
case "Japanese":
return LegacySeedLang.getByEnglishName("Japanese");
case "Portuguese":
return LegacySeedLang.getByEnglishName("Portuguese");
case "Chinese (Simplified)":
return LegacySeedLang.getByEnglishName("Chinese (simplified)");
default:
return LegacySeedLang.getByEnglishName("English");
}
}
}

View file

@ -104,9 +104,7 @@ dependencies:
# ref: main
socks5_proxy: ^1.0.4
flutter_svg: ^2.0.9
polyseed:
git:
url: https://github.com/cake-tech/polyseed_dart.git
polyseed: ^0.0.2
dev_dependencies:
flutter_test:

View file

@ -747,5 +747,6 @@
"seed_language_korean": "الكورية",
"seed_language_chinese_traditional": "تقاليد صينية)",
"dfx_option_description": "ﺎﺑﻭﺭﻭﺃ ﻲﻓ ﺕﺎﻛﺮﺸﻟﺍﻭ ﺔﺋﺰﺠﺘﻟﺍ ءﻼﻤﻌﻟ .ﻲﻓﺎﺿﺇ KYC ﻥﻭﺪﺑ ﻭﺭﻮﻳ 990 ﻰﻟﺇ ﻞﺼﻳ ﺎﻣ .ﻱﺮﺴﻳﻮﺴﻟﺍ",
"polygonscan_history": "ﻥﺎﻜﺴﻧﻮﺠﻴﻟﻮﺑ ﺦﻳﺭﺎﺗ"
"polygonscan_history": "ﻥﺎﻜﺴﻧﻮﺠﻴﻟﻮﺑ ﺦﻳﺭﺎﺗ",
"wallet_seed_legacy": "بذرة محفظة قديمة"
}

View file

@ -743,5 +743,6 @@
"seed_language_korean": "Корейски",
"seed_language_chinese_traditional": "Традиционен китайски)",
"dfx_option_description": "Купете крипто с EUR и CHF. До 990 € без допълнителен KYC. За клиенти на дребно и корпоративни клиенти в Европа",
"polygonscan_history": "История на PolygonScan"
"polygonscan_history": "История на PolygonScan",
"wallet_seed_legacy": "Наследено портфейл семе"
}

View file

@ -743,5 +743,6 @@
"seed_language_korean": "korejština",
"seed_language_chinese_traditional": "Číňan (tradiční)",
"dfx_option_description": "Nakupujte kryptoměny za EUR a CHF. Až 990 € bez dalších KYC. Pro maloobchodní a firemní zákazníky v Evropě",
"polygonscan_history": "Historie PolygonScan"
"polygonscan_history": "Historie PolygonScan",
"wallet_seed_legacy": "Starší semeno peněženky"
}

View file

@ -751,5 +751,6 @@
"seed_language_korean": "Koreanisch",
"seed_language_chinese_traditional": "Chinesisch (Traditionell)",
"dfx_option_description": "Krypto mit EUR und CHF kaufen. Bis zu 990€ ohne zusätzliches KYC. Für Privat- und Firmenkunden in Europa",
"polygonscan_history": "PolygonScan-Verlauf"
"polygonscan_history": "PolygonScan-Verlauf",
"wallet_seed_legacy": "Legacy Wallet Seed"
}

View file

@ -752,5 +752,6 @@
"seed_language_korean": "Korean",
"seed_language_chinese_traditional": "Chinese (Traditional)",
"dfx_option_description": "Buy crypto with EUR & CHF. Up to 990€ without additional KYC. For retail and corporate customers in Europe",
"polygonscan_history": "PolygonScan history"
"polygonscan_history": "PolygonScan history",
"wallet_seed_legacy": "Legacy wallet seed"
}

View file

@ -752,5 +752,6 @@
"seed_language_chinese_traditional": "Chino tradicional)",
"dfx_option_description": "Compre criptomonedas con EUR y CHF. Hasta 990€ sin KYC adicional. Para clientes minoristas y corporativos en Europa",
"seed_language_chinese_traditional": "Chino (tradicional)",
"polygonscan_history": "Historial de PolygonScan"
"polygonscan_history": "Historial de PolygonScan",
"wallet_seed_legacy": "Semilla de billetera heredada"
}

View file

@ -751,5 +751,6 @@
"seed_language_korean": "coréen",
"seed_language_chinese_traditional": "Chinois (Traditionnel)",
"dfx_option_description": "Achetez des crypto-monnaies avec EUR et CHF. Jusqu'à 990€ sans KYC supplémentaire. Pour les clients particuliers et entreprises en Europe",
"polygonscan_history": "Historique de PolygonScan"
"polygonscan_history": "Historique de PolygonScan",
"wallet_seed_legacy": "Graine de portefeuille hérité"
}

View file

@ -729,5 +729,6 @@
"seed_language_korean": "Yaren Koriya",
"seed_language_chinese_traditional": "Sinanci (na gargajiya)",
"dfx_option_description": "Sayi crypto tare da EUR & CHF. Har zuwa € 990 ba tare da ƙarin KYC ba. Don 'yan kasuwa da abokan ciniki na kamfanoni a Turai",
"polygonscan_history": "PolygonScan tarihin kowane zamani"
"polygonscan_history": "PolygonScan tarihin kowane zamani",
"wallet_seed_legacy": "Tallarin walat walat"
}

View file

@ -751,5 +751,6 @@
"seed_language_korean": "कोरियाई",
"seed_language_chinese_traditional": "चीनी पारंपरिक)",
"dfx_option_description": "EUR और CHF के साथ क्रिप्टो खरीदें। अतिरिक्त केवाईसी के बिना 990€ तक। यूरोप में खुदरा और कॉर्पोरेट ग्राहकों के लिए",
"polygonscan_history": "पॉलीगॉनस्कैन इतिहास"
"polygonscan_history": "पॉलीगॉनस्कैन इतिहास",
"wallet_seed_legacy": "विरासत बटुए बीज"
}

View file

@ -750,5 +750,6 @@
"seed_language_chinese_traditional": "Kinesko tradicionalno)",
"dfx_option_description": "Kupujte kripto s EUR i CHF. Do 990 € bez dodatnog KYC-a. Za maloprodajne i poslovne korisnike u Europi",
"seed_language_chinese_traditional": "Kinesko (tradicionalno)",
"polygonscan_history": "Povijest PolygonScan"
"polygonscan_history": "Povijest PolygonScan",
"wallet_seed_legacy": "Sjeme naslijeđenog novčanika"
}

View file

@ -740,5 +740,6 @@
"seed_language_chinese_traditional": "Cina tradisional)",
"dfx_option_description": "Beli kripto dengan EUR & CHF. Hingga 990€ tanpa KYC tambahan. Untuk pelanggan ritel dan korporat di Eropa",
"seed_language_chinese_traditional": "Cina (tradisional)",
"polygonscan_history": "Sejarah PolygonScan"
"polygonscan_history": "Sejarah PolygonScan",
"wallet_seed_legacy": "Biji dompet warisan"
}

View file

@ -751,5 +751,6 @@
"seed_language_korean": "coreano",
"seed_language_chinese_traditional": "Cinese tradizionale)",
"dfx_option_description": "Acquista criptovalute con EUR e CHF. Fino a 990€ senza KYC aggiuntivi. Per clienti al dettaglio e aziendali in Europa",
"polygonscan_history": "Cronologia PolygonScan"
"polygonscan_history": "Cronologia PolygonScan",
"wallet_seed_legacy": "Seme di portafoglio legacy"
}

View file

@ -751,5 +751,6 @@
"seed_language_korean": "韓国語",
"seed_language_chinese_traditional": "中国の伝統的な)",
"dfx_option_description": "EUR と CHF で暗号通貨を購入します。追加のKYCなしで最大990ユーロ。ヨーロッパの小売および法人顧客向け",
"polygonscan_history": "ポリゴンスキャン履歴"
"polygonscan_history": "ポリゴンスキャン履歴",
"wallet_seed_legacy": "レガシーウォレットシード"
}

View file

@ -749,5 +749,6 @@
"seed_language_korean": "한국인",
"seed_language_chinese_traditional": "중국 전통)",
"dfx_option_description": "EUR 및 CHF로 암호화폐를 구매하세요. 추가 KYC 없이 최대 990€. 유럽의 소매 및 기업 고객용",
"polygonscan_history": "다각형 스캔 기록"
"polygonscan_history": "다각형 스캔 기록",
"wallet_seed_legacy": "레거시 지갑 시드"
}

View file

@ -749,5 +749,6 @@
"seed_language_korean": "ကိုးရီးယား",
"seed_language_chinese_traditional": "တရုတ်ရိုးရာ)",
"dfx_option_description": "EUR & CHF ဖြင့် crypto ကိုဝယ်ပါ။ အပို KYC မပါဘဲ 990€ အထိ။ ဥရောပရှိ လက်လီရောင်းချသူများနှင့် ကော်ပိုရိတ်ဖောက်သည်များအတွက်",
"polygonscan_history": "PolygonScan မှတ်တမ်း"
"polygonscan_history": "PolygonScan မှတ်တမ်း",
"wallet_seed_legacy": "အမွေအနှစ်ပိုက်ဆံအိတ်မျိုးစေ့"
}

View file

@ -752,5 +752,6 @@
"seed_language_chinese_traditional": "Chinese traditionele)",
"dfx_option_description": "Koop crypto met EUR & CHF. Tot 990€ zonder extra KYC. Voor particuliere en zakelijke klanten in Europa",
"seed_language_chinese_traditional": "Chinese (traditionele)",
"polygonscan_history": "PolygonScan-geschiedenis"
"polygonscan_history": "PolygonScan-geschiedenis",
"wallet_seed_legacy": "Legacy portemonnee zaad"
}

View file

@ -751,5 +751,6 @@
"seed_language_korean": "koreański",
"seed_language_chinese_traditional": "Chiński tradycyjny)",
"dfx_option_description": "Kupuj kryptowaluty za EUR i CHF. Do 990 € bez dodatkowego KYC. Dla klientów detalicznych i korporacyjnych w Europie",
"polygonscan_history": "Historia PolygonScan"
"polygonscan_history": "Historia PolygonScan",
"wallet_seed_legacy": "Dziedziczne ziarno portfela"
}

View file

@ -750,5 +750,6 @@
"seed_language_korean": "coreano",
"seed_language_chinese_traditional": "Chinês tradicional)",
"dfx_option_description": "Compre criptografia com EUR e CHF. Até 990€ sem KYC adicional. Para clientes de varejo e corporativos na Europa",
"polygonscan_history": "História do PolygonScan"
"polygonscan_history": "História do PolygonScan",
"wallet_seed_legacy": "Semente de carteira herdada"
}

View file

@ -751,5 +751,6 @@
"seed_language_korean": "Корейский",
"seed_language_chinese_traditional": "Китайский традиционный)",
"dfx_option_description": "Покупайте криптовалюту за EUR и CHF. До 990€ без дополнительного KYC. Для розничных и корпоративных клиентов в Европе",
"polygonscan_history": "История PolygonScan"
"polygonscan_history": "История PolygonScan",
"wallet_seed_legacy": "Наследие семя кошелька"
}

View file

@ -749,5 +749,6 @@
"seed_language_korean": "เกาหลี",
"seed_language_chinese_traditional": "จีน (ดั้งเดิม)",
"dfx_option_description": "ซื้อ crypto ด้วย EUR และ CHF สูงถึง 990€ โดยไม่มี KYC เพิ่มเติม สำหรับลูกค้ารายย่อยและลูกค้าองค์กรในยุโรป",
"polygonscan_history": "ประวัติ PolygonScan"
"polygonscan_history": "ประวัติ PolygonScan",
"wallet_seed_legacy": "เมล็ดกระเป๋าเงินมรดก"
}

View file

@ -745,5 +745,6 @@
"seed_language_korean": "Korean",
"seed_language_chinese_traditional": "Intsik (tradisyonal)",
"dfx_option_description": "Bumili ng crypto gamit ang EUR at CHF. Hanggang 990€ nang walang karagdagang KYC. Para sa retail at corporate na mga customer sa Europe",
"polygonscan_history": "Kasaysayan ng PolygonScan"
"polygonscan_history": "Kasaysayan ng PolygonScan",
"wallet_seed_legacy": "Legacy wallet seed"
}

View file

@ -749,5 +749,6 @@
"seed_language_korean": "Koreli",
"seed_language_chinese_traditional": "Çin geleneği)",
"dfx_option_description": "EUR ve CHF ile kripto satın alın. Ek KYC olmadan 990 €'ya kadar. Avrupa'daki perakende ve kurumsal müşteriler için",
"polygonscan_history": "PolygonScan geçmişi"
"polygonscan_history": "PolygonScan geçmişi",
"wallet_seed_legacy": "Eski cüzdan tohumu"
}

View file

@ -751,5 +751,6 @@
"seed_language_korean": "Корейський",
"dfx_option_description": "Купуйте криптовалюту за EUR і CHF. До 990 євро без додаткового KYC. Для роздрібних і корпоративних клієнтів у Європі",
"seed_language_chinese_traditional": "Китайський (традиційний)",
"polygonscan_history": "Історія PolygonScan"
"polygonscan_history": "Історія PolygonScan",
"wallet_seed_legacy": "Спадець насіння гаманця"
}

View file

@ -743,5 +743,6 @@
"seed_language_korean": "کورین",
"seed_language_chinese_traditional": "چینی (روایتی)",
"dfx_option_description": "EUR ﺭﻭﺍ CHF ﯽﻓﺎﺿﺍ ۔ﮟﯾﺪﯾﺮﺧ ﻮﭩﭘﺮﮐ ﮫﺗﺎﺳ ﮯﮐ KYC ﮯﯿﻟ ﮯﮐ ﻦﯿﻓﺭﺎﺻ ﭧﯾﺭﻮﭘﺭﺎﮐ ﺭﻭﺍ ﮦﺩﺭﻮﺧ ﮟ",
"polygonscan_history": "ﺦﯾﺭﺎﺗ ﯽﮐ ﻦﯿﮑﺳﺍ ﻥﻮﮔ ﯽﻟﻮﭘ"
"polygonscan_history": "ﺦﯾﺭﺎﺗ ﯽﮐ ﻦﯿﮑﺳﺍ ﻥﻮﮔ ﯽﻟﻮﭘ",
"wallet_seed_legacy": "میراثی پرس کا بیج"
}

View file

@ -745,5 +745,6 @@
"seed_language_korean": "Ara ẹni",
"seed_language_chinese_traditional": "Kannada (ibile)",
"dfx_option_description": "Ra crypto pẹlu EUR & CHF. Titi di 990 € laisi afikun KYC. Fun soobu ati awọn onibara ile-iṣẹ ni Yuroopu",
"polygonscan_history": "PolygonScan itan"
"polygonscan_history": "PolygonScan itan",
"wallet_seed_legacy": "Irugbin akole"
}

View file

@ -750,5 +750,6 @@
"seed_language_korean": "韩国人",
"seed_language_chinese_traditional": "中国传统的)",
"dfx_option_description": "用欧元和瑞士法郎购买加密货币。高达 990 欧元,无需额外 KYC。对于欧洲的零售和企业客户",
"polygonscan_history": "多边形扫描历史"
"polygonscan_history": "多边形扫描历史",
"wallet_seed_legacy": "旧的钱包种子"
}