From b546078c8fed02e3e4e00ef8d62a1c1e46aa0cae Mon Sep 17 00:00:00 2001
From: poka <poka@p2p.legal>
Date: Mon, 15 Aug 2022 17:41:12 +0200
Subject: [PATCH] fix: sentry 3334937784

---
 lib/providers/generate_wallets.dart |  8 ++----
 lib/providers/substrate_sdk.dart    | 41 +++++------------------------
 lib/screens/onBoarding/10.dart      |  1 -
 3 files changed, 9 insertions(+), 41 deletions(-)

diff --git a/lib/providers/generate_wallets.dart b/lib/providers/generate_wallets.dart
index b4e80683..c9880e6e 100644
--- a/lib/providers/generate_wallets.dart
+++ b/lib/providers/generate_wallets.dart
@@ -409,10 +409,7 @@ class GenerateWalletsProvider with ChangeNotifier {
             ? 'currentWallet'.tr()
             : '${'wallet'.tr()} ${scanedValidWalletNumber + 1}';
         await sub.importAccount(
-            mnemonic: '',
-            fromMnemonic: true,
-            derivePath: '//$derivationNbr',
-            password: pin.text);
+            derivePath: '//$derivationNbr', password: pin.text);
 
         WalletData myWallet = WalletData(
             version: dataVersion,
@@ -448,8 +445,7 @@ class GenerateWalletsProvider with ChangeNotifier {
         "${addressData.address!}: ${balance['transferableBalance']} $currencyName");
     if (balance['transferableBalance'] != 0) {
       String walletName = 'myRootWallet'.tr();
-      await sub.importAccount(
-          mnemonic: '', fromMnemonic: true, password: pin.text);
+      await sub.importAccount(password: pin.text);
 
       WalletData myWallet = WalletData(
           version: dataVersion,
diff --git a/lib/providers/substrate_sdk.dart b/lib/providers/substrate_sdk.dart
index 677088ab..ec416b51 100644
--- a/lib/providers/substrate_sdk.dart
+++ b/lib/providers/substrate_sdk.dart
@@ -1,6 +1,5 @@
 import 'package:easy_localization/easy_localization.dart';
 import 'package:flutter/material.dart';
-import 'package:flutter/services.dart';
 import 'package:gecko/globals.dart';
 import 'package:gecko/models/chest_data.dart';
 import 'package:gecko/models/wallet_data.dart';
@@ -30,9 +29,6 @@ class SubstrateSdk with ChangeNotifier {
   String transactionStatus = '';
   int ss58 = 42;
 
-  TextEditingController jsonKeystore = TextEditingController();
-  TextEditingController keystorePassword = TextEditingController();
-
   /////////////////////////////////////
   ////////// 1: API METHODS ///////////
   /////////////////////////////////////
@@ -374,40 +370,18 @@ class SubstrateSdk with ChangeNotifier {
 
   Future<String> importAccount(
       {String mnemonic = '',
-      bool fromMnemonic = false,
       String derivePath = '',
-      String password = ''}) async {
-    // toy exercise immense month enter answer table prefer speed cycle gold phone
-    final clipboardData = await Clipboard.getData(Clipboard.kTextPlain);
-    if (mnemonic != '') {
-      fromMnemonic = true;
-      generatedMnemonic = mnemonic;
-    } else if (clipboardData!.text!.split(' ').length == 12) {
-      fromMnemonic = true;
-      generatedMnemonic = clipboardData.text!;
-    }
-
-    if (password == '') {
-      password = keystorePassword.text;
-    }
-
-    final KeyType keytype;
-    final String keyToImport;
-    if (fromMnemonic) {
-      keytype = KeyType.mnemonic;
-      keyToImport = generatedMnemonic;
-    } else {
-      keytype = KeyType.keystore;
-      keyToImport = jsonKeystore.text.replaceAll("'", "\\'");
-    }
+      required String password}) async {
+    const keytype = KeyType.mnemonic;
+    if (mnemonic != '') generatedMnemonic = mnemonic;
 
     importIsLoading = true;
     notifyListeners();
-    if (clipboardData?.text != null) jsonKeystore.text = clipboardData!.text!;
-    var json = await sdk.api.keyring
+
+    final json = await sdk.api.keyring
         .importAccount(keyring,
             keyType: keytype,
-            key: keyToImport,
+            key: generatedMnemonic,
             name: derivePath,
             password: password,
             derivePath: derivePath,
@@ -543,7 +517,6 @@ class SubstrateSdk with ChangeNotifier {
 
     return await importAccount(
         mnemonic: generatedMnemonic,
-        fromMnemonic: true,
         derivePath: '//$number',
         password: password);
   }
@@ -558,7 +531,7 @@ class SubstrateSdk with ChangeNotifier {
     final List seedList = seedMap!['seed'].split('//');
     generatedMnemonic = seedList[0];
 
-    return await importAccount(fromMnemonic: true, password: password);
+    return await importAccount(password: password);
   }
 
   Future<bool> isMnemonicValid(String mnemonic) async {
diff --git a/lib/screens/onBoarding/10.dart b/lib/screens/onBoarding/10.dart
index d2a5f2a7..ad58bace 100644
--- a/lib/screens/onBoarding/10.dart
+++ b/lib/screens/onBoarding/10.dart
@@ -203,7 +203,6 @@ class OnboardingStepTen extends StatelessWidget {
                 }
                 if (!isAlive) {
                   final address = await sub.importAccount(
-                      fromMnemonic: true,
                       mnemonic: generateWalletProvider.generatedMnemonic!,
                       derivePath: '//2',
                       password: generateWalletProvider.pin.text);
-- 
GitLab