From 9c41e1fcb8a39a176ff16aad092fd9e5ff243ef9 Mon Sep 17 00:00:00 2001 From: reasje Date: Mon, 9 Oct 2023 17:33:04 +0330 Subject: [PATCH 1/4] feat: Add clipboard icon --- assets/icons/mxc-icons.ttf | Bin 11032 -> 11224 bytes 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 assets/icons/mxc-icons.ttf diff --git a/assets/icons/mxc-icons.ttf b/assets/icons/mxc-icons.ttf old mode 100644 new mode 100755 index 0933983eb1392dd8c382c5f265d7ea2681938a18..8a4ae69dcd77d572af93ed7ce082a7105b9a8717 GIT binary patch delta 755 zcmZ9IO-K}B7{~wb%J}J8klQo6E=2F}<9Yx8_y0We&fFS( zf9iV2{MU^uCjjmaV6jccE>ApC7p?)K9jIHGiYk%T;O!p(J`tfQGK$|?-_U-YXquXt zO+TE-{sGt*(~D`U^5o<5?|`sI`s|F7PO#%xrt=!o^>Jk;+O6Du1+?4)cqFt`*{q~~ z=m*-!-~u<+-ADaklqK|U&If1Y!#`2N8|2{g!2Q)i&Hl;8gav+tbP+hyrDgW{GcIi*S~ zEG$MnCvkfB(M5jT>Z5^zeu4j`U*${WQZvc*?B;!$v_<6HgEW&c?`16JK|9r@JfIQ! ziZEtflb^~jGuy%o*F1ej_8DK#ZJ`Fu2+%u%Rn?tA7pp9H2=0c)mP6%TeJsrSSaqW) zxL9W})E)9Mu~BeTg;_Av)#7H`{$YFA>2vmab`qXmb0ZH2_Ekt??VhqKQ4(sGCD~T; zTasmo+v@RBV5ig*?mfu1os~YPwT!=8EEJjU9G(&~V!#Zx2E z$+?)4EXYC~jV4pmTD(5s>mW<-Kd{+3gfvtP5E|l0VFXc3Vh%AVNaFv~oYs%EHdyn! s^R27QuUE8{3fdLv?-^<-gH}eqe zCGK8X`}&~$#u3ixk`4}kzq1>hoFq=>sa~LNhNfJGn#;#ou^^VjJ|)3037r@wjMPXZr1nKzyO;LpGkfJS}qLVK7yG6& zWP_({KbZC0?$P`Rt>~!#;OaO+1ein-9$aPx*eIh82Nrz%Urlv%JkVpFW!b@Pk&pHU ZXX4(W*P^4j Date: Mon, 9 Oct 2023 17:33:49 +0330 Subject: [PATCH 2/4] feat: Added seed phase space & new line trimmer --- lib/common/utils/formatter.dart | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/common/utils/formatter.dart b/lib/common/utils/formatter.dart index d98b6f38..83fbef8b 100644 --- a/lib/common/utils/formatter.dart +++ b/lib/common/utils/formatter.dart @@ -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 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 + } } From fd8a57bc3d6a45391d862e92a5f08549bc699a12 Mon Sep 17 00:00:00 2001 From: reasje Date: Mon, 9 Oct 2023 17:35:01 +0330 Subject: [PATCH 3/4] feat: Allow paste & trim seed phase --- .../splash/import_wallet/import_wallet_page.dart | 5 +++++ .../import_wallet/import_wallet_presenter.dart | 13 +++++++++++-- packages/shared | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/features/splash/import_wallet/import_wallet_page.dart b/lib/features/splash/import_wallet/import_wallet_page.dart index 3f36ad56..6f12f960 100644 --- a/lib/features/splash/import_wallet/import_wallet_page.dart +++ b/lib/features/splash/import_wallet/import_wallet_page.dart @@ -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(); + }), ), ), ], diff --git a/lib/features/splash/import_wallet/import_wallet_presenter.dart b/lib/features/splash/import_wallet/import_wallet_presenter.dart index 9fe12d7c..d7c86c68 100644 --- a/lib/features/splash/import_wallet/import_wallet_presenter.dart +++ b/lib/features/splash/import_wallet/import_wallet_presenter.dart @@ -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'; @@ -14,7 +16,9 @@ class SplashImportWalletPresenter extends CompletePresenter { 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')!; } @@ -26,7 +30,8 @@ class SplashImportWalletPresenter extends CompletePresenter { 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) { @@ -35,4 +40,8 @@ class SplashImportWalletPresenter extends CompletePresenter { loading = false; } } + + void pastFromClipBoard() async { + mnemonicController.text = await FlutterClipboard.paste(); + } } diff --git a/packages/shared b/packages/shared index fa47c77f..4fba1d93 160000 --- a/packages/shared +++ b/packages/shared @@ -1 +1 @@ -Subproject commit fa47c77f004e248e94a3f498e793d5805d7e5a6d +Subproject commit 4fba1d935c9fc525ef88318ab10999b384c08ba1 From bec4d6519270835c5077ab0375fa678b2205dd1b Mon Sep 17 00:00:00 2001 From: reasje Date: Mon, 9 Oct 2023 17:59:17 +0330 Subject: [PATCH 4/4] fix: Add assets as const --- lib/common/assets.dart | 3 +++ lib/common/common.dart | 1 + lib/common/config.dart | 1 - .../dapps/subfeatures/open_dapp/open_dapp_presenter.dart | 2 +- packages/shared | 2 +- 5 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 lib/common/assets.dart diff --git a/lib/common/assets.dart b/lib/common/assets.dart new file mode 100644 index 00000000..c031c5c4 --- /dev/null +++ b/lib/common/assets.dart @@ -0,0 +1,3 @@ +class Assets { + static const String mxcLogoUri = 'assets/svg/networks/mxc.svg'; +} diff --git a/lib/common/common.dart b/lib/common/common.dart index d18cde47..340faac2 100644 --- a/lib/common/common.dart +++ b/lib/common/common.dart @@ -12,3 +12,4 @@ export 'components/components.dart'; export 'dialogs/dialogs.dart'; export 'urls.dart'; export 'config.dart'; +export 'assets.dart'; diff --git a/lib/common/config.dart b/lib/common/config.dart index e4225421..09558729 100644 --- a/lib/common/config.dart +++ b/lib/common/config.dart @@ -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 = diff --git a/lib/features/dapps/subfeatures/open_dapp/open_dapp_presenter.dart b/lib/features/dapps/subfeatures/open_dapp/open_dapp_presenter.dart index 943573b5..0ba1d327 100644 --- a/lib/features/dapps/subfeatures/open_dapp/open_dapp_presenter.dart +++ b/lib/features/dapps/subfeatures/open_dapp/open_dapp_presenter.dart @@ -143,7 +143,7 @@ class OpenDAppPresenter extends CompletePresenter { 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 diff --git a/packages/shared b/packages/shared index 4fba1d93..8023be01 160000 --- a/packages/shared +++ b/packages/shared @@ -1 +1 @@ -Subproject commit 4fba1d935c9fc525ef88318ab10999b384c08ba1 +Subproject commit 8023be019dd4e18de970c9a546494eed2647dae9