Add infos about current scan in last import screen

This commit is contained in:
poka 2022-08-15 12:58:47 +02:00
parent edb8735109
commit 3fad0f03f0
5 changed files with 45 additions and 25 deletions

View File

@ -173,6 +173,6 @@
"contactsManagement": "My contacts",
"noContacts": "You don't have any contact",
"addContact": "Add\nto contacts",
"removeContact": "Remove\nthis contact"
"removeContact": "Remove\nthis contact",
"derivationsScanProgress": "Scan address {}/{}"
}

View File

@ -173,5 +173,6 @@
"contactsManagement": "My contacts",
"noContacts": "You don't have any contact",
"addContact": "Add\nto contacts",
"removeContact": "Remove\nthis contact"
"removeContact": "Remove\nthis contact",
"derivationsScanProgress": "Scan address {}/{}"
}

View File

@ -174,6 +174,6 @@
"contactsManagement": "Mes contacts",
"noContacts": "Vous n'avez aucun contact",
"addContact": "Ajouter\naux contacts",
"removeContact": "Supprimer\nce contact"
"removeContact": "Supprimer\nce contact",
"derivationsScanProgress": "Scan de l'adresse {}/{}"
}

View File

@ -23,7 +23,9 @@ class GenerateWalletsProvider with ChangeNotifier {
FocusNode walletNameFocus = FocusNode();
Color? askedWordColor = Colors.black;
bool isAskedWordValid = false;
int scanedValidWalletNumber = -1;
int scanedWalletNumber = -1;
int numberScan = 20;
late int nbrWord;
String? nbrWordAlpha;
@ -366,11 +368,11 @@ class GenerateWalletsProvider with ChangeNotifier {
notifyListeners();
}
Future<bool> scanDerivations(BuildContext context,
{int numberScan = 20}) async {
Future<bool> scanDerivations(BuildContext context) async {
SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false);
final currentChestNumber = configBox.get('currentChest');
bool isAlive = false;
scanedValidWalletNumber = 0;
scanedWalletNumber = 0;
notifyListeners();
@ -379,8 +381,10 @@ class GenerateWalletsProvider with ChangeNotifier {
}
final hasRoot = await scanRootBalance(sub, currentChestNumber);
scanedWalletNumber = 1;
notifyListeners();
if (hasRoot) {
scanedWalletNumber = 1;
scanedValidWalletNumber = 1;
isAlive = true;
}
@ -401,9 +405,9 @@ class GenerateWalletsProvider with ChangeNotifier {
"${addressData.address!}: ${balance['transferableBalance']} $currencyName");
if (balance['transferableBalance'] != 0) {
isAlive = true;
String walletName = scanedWalletNumber == 0
String walletName = scanedValidWalletNumber == 0
? 'currentWallet'.tr()
: '${'wallet'.tr()} ${scanedWalletNumber + 1}';
: '${'wallet'.tr()} ${scanedValidWalletNumber + 1}';
await sub.importAccount(
mnemonic: '',
fromMnemonic: true,
@ -414,15 +418,19 @@ class GenerateWalletsProvider with ChangeNotifier {
version: dataVersion,
chest: currentChestNumber,
address: addressData.address!,
number: scanedWalletNumber,
number: scanedValidWalletNumber,
name: walletName,
derivation: derivationNbr,
imageDefaultPath: '${scanedWalletNumber % 4}.png');
imageDefaultPath: '${scanedValidWalletNumber % 4}.png');
await walletBox.add(myWallet);
scanedWalletNumber = scanedWalletNumber + 1;
scanedValidWalletNumber = scanedValidWalletNumber + 1;
}
scanedWalletNumber = scanedWalletNumber + 1;
notifyListeners();
}
log.d(scanedWalletNumber);
scanedWalletNumber = -1;
scanedValidWalletNumber = -1;
notifyListeners();
return isAlive;
}
@ -436,8 +444,9 @@ class GenerateWalletsProvider with ChangeNotifier {
onTimeout: () => {},
);
log.d(balance);
if (balance != {}) {
log.d(
"${addressData.address!}: ${balance['transferableBalance']} $currencyName");
if (balance['transferableBalance'] != 0) {
String walletName = 'myRootWallet'.tr();
await sub.importAccount(
mnemonic: '', fromMnemonic: true, password: pin.text);

View File

@ -56,16 +56,26 @@ class OnboardingStepTen extends StatelessWidget {
common.buildText("geckoWillCheckPassword".tr()),
SizedBox(height: isTall ? 80 : 20),
Visibility(
visible: generateWalletProvider.scanedWalletNumber != -1,
visible: generateWalletProvider.scanedValidWalletNumber != -1,
child: Padding(
padding: const EdgeInsets.only(bottom: 15),
child: SizedBox(
height: 22,
width: 22,
child: CircularProgressIndicator(
color: orangeC,
strokeWidth: 3,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("derivationsScanProgress".tr(args: [
'${generateWalletProvider.scanedWalletNumber}',
'${generateWalletProvider.numberScan + 1}'
])),
const SizedBox(width: 10),
SizedBox(
height: 22,
width: 22,
child: CircularProgressIndicator(
color: orangeC,
strokeWidth: 3,
),
),
],
),
),
),
@ -188,8 +198,8 @@ class OnboardingStepTen extends StatelessWidget {
await generateWalletProvider.storeHDWChest(context);
bool isAlive = false;
if (scanDerivation) {
isAlive = await generateWalletProvider
.scanDerivations(context, numberScan: 20);
isAlive =
await generateWalletProvider.scanDerivations(context);
}
if (!isAlive) {
final address = await sub.importAccount(