Skip to content
Snippets Groups Projects
Commit 3fad0f03 authored by poka's avatar poka
Browse files

Add infos about current scan in last import screen

parent edb87351
No related branches found
No related tags found
No related merge requests found
Pipeline #16759 failed
...@@ -173,6 +173,6 @@ ...@@ -173,6 +173,6 @@
"contactsManagement": "My contacts", "contactsManagement": "My contacts",
"noContacts": "You don't have any contact", "noContacts": "You don't have any contact",
"addContact": "Add\nto contacts", "addContact": "Add\nto contacts",
"removeContact": "Remove\nthis contact" "removeContact": "Remove\nthis contact",
"derivationsScanProgress": "Scan address {}/{}"
} }
\ No newline at end of file
...@@ -173,5 +173,6 @@ ...@@ -173,5 +173,6 @@
"contactsManagement": "My contacts", "contactsManagement": "My contacts",
"noContacts": "You don't have any contact", "noContacts": "You don't have any contact",
"addContact": "Add\nto contacts", "addContact": "Add\nto contacts",
"removeContact": "Remove\nthis contact" "removeContact": "Remove\nthis contact",
"derivationsScanProgress": "Scan address {}/{}"
} }
\ No newline at end of file
...@@ -174,6 +174,6 @@ ...@@ -174,6 +174,6 @@
"contactsManagement": "Mes contacts", "contactsManagement": "Mes contacts",
"noContacts": "Vous n'avez aucun contact", "noContacts": "Vous n'avez aucun contact",
"addContact": "Ajouter\naux contacts", "addContact": "Ajouter\naux contacts",
"removeContact": "Supprimer\nce contact" "removeContact": "Supprimer\nce contact",
"derivationsScanProgress": "Scan de l'adresse {}/{}"
} }
\ No newline at end of file
...@@ -23,7 +23,9 @@ class GenerateWalletsProvider with ChangeNotifier { ...@@ -23,7 +23,9 @@ class GenerateWalletsProvider with ChangeNotifier {
FocusNode walletNameFocus = FocusNode(); FocusNode walletNameFocus = FocusNode();
Color? askedWordColor = Colors.black; Color? askedWordColor = Colors.black;
bool isAskedWordValid = false; bool isAskedWordValid = false;
int scanedValidWalletNumber = -1;
int scanedWalletNumber = -1; int scanedWalletNumber = -1;
int numberScan = 20;
late int nbrWord; late int nbrWord;
String? nbrWordAlpha; String? nbrWordAlpha;
...@@ -366,11 +368,11 @@ class GenerateWalletsProvider with ChangeNotifier { ...@@ -366,11 +368,11 @@ class GenerateWalletsProvider with ChangeNotifier {
notifyListeners(); notifyListeners();
} }
Future<bool> scanDerivations(BuildContext context, Future<bool> scanDerivations(BuildContext context) async {
{int numberScan = 20}) async {
SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false); SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false);
final currentChestNumber = configBox.get('currentChest'); final currentChestNumber = configBox.get('currentChest');
bool isAlive = false; bool isAlive = false;
scanedValidWalletNumber = 0;
scanedWalletNumber = 0; scanedWalletNumber = 0;
notifyListeners(); notifyListeners();
...@@ -379,8 +381,10 @@ class GenerateWalletsProvider with ChangeNotifier { ...@@ -379,8 +381,10 @@ class GenerateWalletsProvider with ChangeNotifier {
} }
final hasRoot = await scanRootBalance(sub, currentChestNumber); final hasRoot = await scanRootBalance(sub, currentChestNumber);
if (hasRoot) {
scanedWalletNumber = 1; scanedWalletNumber = 1;
notifyListeners();
if (hasRoot) {
scanedValidWalletNumber = 1;
isAlive = true; isAlive = true;
} }
...@@ -401,9 +405,9 @@ class GenerateWalletsProvider with ChangeNotifier { ...@@ -401,9 +405,9 @@ class GenerateWalletsProvider with ChangeNotifier {
"${addressData.address!}: ${balance['transferableBalance']} $currencyName"); "${addressData.address!}: ${balance['transferableBalance']} $currencyName");
if (balance['transferableBalance'] != 0) { if (balance['transferableBalance'] != 0) {
isAlive = true; isAlive = true;
String walletName = scanedWalletNumber == 0 String walletName = scanedValidWalletNumber == 0
? 'currentWallet'.tr() ? 'currentWallet'.tr()
: '${'wallet'.tr()} ${scanedWalletNumber + 1}'; : '${'wallet'.tr()} ${scanedValidWalletNumber + 1}';
await sub.importAccount( await sub.importAccount(
mnemonic: '', mnemonic: '',
fromMnemonic: true, fromMnemonic: true,
...@@ -414,15 +418,19 @@ class GenerateWalletsProvider with ChangeNotifier { ...@@ -414,15 +418,19 @@ class GenerateWalletsProvider with ChangeNotifier {
version: dataVersion, version: dataVersion,
chest: currentChestNumber, chest: currentChestNumber,
address: addressData.address!, address: addressData.address!,
number: scanedWalletNumber, number: scanedValidWalletNumber,
name: walletName, name: walletName,
derivation: derivationNbr, derivation: derivationNbr,
imageDefaultPath: '${scanedWalletNumber % 4}.png'); imageDefaultPath: '${scanedValidWalletNumber % 4}.png');
await walletBox.add(myWallet); await walletBox.add(myWallet);
scanedWalletNumber = scanedWalletNumber + 1; scanedValidWalletNumber = scanedValidWalletNumber + 1;
} }
scanedWalletNumber = scanedWalletNumber + 1;
notifyListeners();
} }
log.d(scanedWalletNumber);
scanedWalletNumber = -1; scanedWalletNumber = -1;
scanedValidWalletNumber = -1;
notifyListeners(); notifyListeners();
return isAlive; return isAlive;
} }
...@@ -436,8 +444,9 @@ class GenerateWalletsProvider with ChangeNotifier { ...@@ -436,8 +444,9 @@ class GenerateWalletsProvider with ChangeNotifier {
onTimeout: () => {}, onTimeout: () => {},
); );
log.d(balance); log.d(
if (balance != {}) { "${addressData.address!}: ${balance['transferableBalance']} $currencyName");
if (balance['transferableBalance'] != 0) {
String walletName = 'myRootWallet'.tr(); String walletName = 'myRootWallet'.tr();
await sub.importAccount( await sub.importAccount(
mnemonic: '', fromMnemonic: true, password: pin.text); mnemonic: '', fromMnemonic: true, password: pin.text);
......
...@@ -56,10 +56,18 @@ class OnboardingStepTen extends StatelessWidget { ...@@ -56,10 +56,18 @@ class OnboardingStepTen extends StatelessWidget {
common.buildText("geckoWillCheckPassword".tr()), common.buildText("geckoWillCheckPassword".tr()),
SizedBox(height: isTall ? 80 : 20), SizedBox(height: isTall ? 80 : 20),
Visibility( Visibility(
visible: generateWalletProvider.scanedWalletNumber != -1, visible: generateWalletProvider.scanedValidWalletNumber != -1,
child: Padding( child: Padding(
padding: const EdgeInsets.only(bottom: 15), padding: const EdgeInsets.only(bottom: 15),
child: SizedBox( child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("derivationsScanProgress".tr(args: [
'${generateWalletProvider.scanedWalletNumber}',
'${generateWalletProvider.numberScan + 1}'
])),
const SizedBox(width: 10),
SizedBox(
height: 22, height: 22,
width: 22, width: 22,
child: CircularProgressIndicator( child: CircularProgressIndicator(
...@@ -67,6 +75,8 @@ class OnboardingStepTen extends StatelessWidget { ...@@ -67,6 +75,8 @@ class OnboardingStepTen extends StatelessWidget {
strokeWidth: 3, strokeWidth: 3,
), ),
), ),
],
),
), ),
), ),
Consumer<SubstrateSdk>(builder: (context, sub, _) { Consumer<SubstrateSdk>(builder: (context, sub, _) {
...@@ -188,8 +198,8 @@ class OnboardingStepTen extends StatelessWidget { ...@@ -188,8 +198,8 @@ class OnboardingStepTen extends StatelessWidget {
await generateWalletProvider.storeHDWChest(context); await generateWalletProvider.storeHDWChest(context);
bool isAlive = false; bool isAlive = false;
if (scanDerivation) { if (scanDerivation) {
isAlive = await generateWalletProvider isAlive =
.scanDerivations(context, numberScan: 20); await generateWalletProvider.scanDerivations(context);
} }
if (!isAlive) { if (!isAlive) {
final address = await sub.importAccount( final address = await sub.importAccount(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment