Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #85 from MXCzkEVM/seed_detection_imprv
Browse files Browse the repository at this point in the history
Seed detection imprv
  • Loading branch information
reasje authored Oct 9, 2023
2 parents a9444b2 + bec4d65 commit 673c595
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 5 deletions.
Binary file modified assets/icons/mxc-icons.ttf
100644 → 100755
Binary file not shown.
3 changes: 3 additions & 0 deletions lib/common/assets.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Assets {
static const String mxcLogoUri = 'assets/svg/networks/mxc.svg';
}
1 change: 1 addition & 0 deletions lib/common/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export 'components/components.dart';
export 'dialogs/dialogs.dart';
export 'urls.dart';
export 'config.dart';
export 'assets.dart';
1 change: 0 additions & 1 deletion lib/common/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class Config {
static const int ethDecimals = 18;
static const String mxcSymbol = 'MXC';
static const String mxcName = 'MXC Token';
static const String mxcLogoUri = 'assets/svg/networks/mxc.svg';
static const String zeroAddress =
'0x0000000000000000000000000000000000000000';
static const String mxcAddressSepolia =
Expand Down
14 changes: 14 additions & 0 deletions lib/common/utils/formatter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,18 @@ class Formatter {
static String mergeUrlString(String first, String second) {
return Uri.parse(first).resolve(second).toString();
}

// Function to trim and remove extra spaces
static String trimAndRemoveExtraSpaces(String value) {
if (value.isEmpty) return '';
// Remove all new lines spaces
String trimmedValue = value.replaceAll('\n', '');
// String trimmedValue = value.trim();
List<String> words = trimmedValue.split(' '); // Split into individual words

// Remove extra spaces and new lines between words
words = words.where((word) => word.isNotEmpty).toList();

return words.join(' '); // Join words back with a single space between each
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class OpenDAppPresenter extends CompletePresenter<OpenDAppState> {
final chainId = state.network!.chainId;
final token = Token(
chainId: state.network!.chainId,
logoUri: Config.mxcLogoUri,
logoUri: Assets.mxcLogoUri,
name: Config.mxcName,
symbol: Config.mxcSymbol,
// can separate Sepolia & Ethereum
Expand Down
5 changes: 5 additions & 0 deletions lib/features/splash/import_wallet/import_wallet_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ class SplashImportWalletPage extends HookConsumerWidget {
autoFocus: true,
borderUnFocusColor: ColorsTheme.of(context).borderPrimary100,
borderFocusColor: ColorsTheme.of(context).borderPrimary200,
suffixButton: MxcTextFieldButton.icon(
icon: MxcIcons.clipboard,
onTap: () {
presenter.pastFromClipBoard();
}),
),
),
],
Expand Down
13 changes: 11 additions & 2 deletions lib/features/splash/import_wallet/import_wallet_presenter.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:clipboard/clipboard.dart';
import 'package:datadashwallet/common/utils/formatter.dart';
import 'package:datadashwallet/core/core.dart';
import 'package:datadashwallet/features/security/security.dart';
import 'package:flutter/material.dart';
Expand All @@ -14,7 +16,9 @@ class SplashImportWalletPresenter extends CompletePresenter<void> {
late final TextEditingController mnemonicController = TextEditingController();

String? validate(String? value) {
if (!_authUseCase.validateMnemonic(value ?? '')) {
final formattedMnemonic = Formatter.trimAndRemoveExtraSpaces(value ?? "");

if (!_authUseCase.validateMnemonic(formattedMnemonic)) {
return translate('recovery_phrase_limit')!;
}

Expand All @@ -26,7 +30,8 @@ class SplashImportWalletPresenter extends CompletePresenter<void> {
loading = true;

try {
final account = await _authUseCase.createWallet(value);
final formattedMnemonic = Formatter.trimAndRemoveExtraSpaces(value);
final account = await _authUseCase.createWallet(formattedMnemonic);
_accountUseCase.addAccount(account);
pushSetupEnableBiometricPage(context!);
} catch (e, s) {
Expand All @@ -35,4 +40,8 @@ class SplashImportWalletPresenter extends CompletePresenter<void> {
loading = false;
}
}

void pastFromClipBoard() async {
mnemonicController.text = await FlutterClipboard.paste();
}
}
2 changes: 1 addition & 1 deletion packages/shared

0 comments on commit 673c595

Please sign in to comment.