Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ğecko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
Ğecko
Commits
a751b1eb
Commit
a751b1eb
authored
1 year ago
by
poka
Browse files
Options
Downloads
Patches
Plain Diff
feat: big improvement on wallet scan at safe import
parent
fadc3c0c
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/providers/generate_wallets.dart
+16
-15
16 additions, 15 deletions
lib/providers/generate_wallets.dart
lib/providers/substrate_sdk.dart
+0
-4
0 additions, 4 deletions
lib/providers/substrate_sdk.dart
lib/screens/myWallets/wallets_home.dart
+2
-1
2 additions, 1 deletion
lib/screens/myWallets/wallets_home.dart
with
18 additions
and
20 deletions
lib/providers/generate_wallets.dart
+
16
−
15
View file @
a751b1eb
...
...
@@ -23,7 +23,7 @@ class GenerateWalletsProvider with ChangeNotifier {
bool
isAskedWordValid
=
false
;
int
scanedValidWalletNumber
=
-
1
;
int
scanedWalletNumber
=
-
1
;
int
numberScan
=
2
0
;
int
numberScan
=
6
0
;
late
int
nbrWord
;
String
?
nbrWordAlpha
;
...
...
@@ -301,6 +301,7 @@ class GenerateWalletsProvider with ChangeNotifier {
bool
isAlive
=
false
;
scanedValidWalletNumber
=
0
;
scanedWalletNumber
=
0
;
Map
<
String
,
int
>
addressToScan
=
{};
notifyListeners
();
if
(
!
sub
.
nodeConnected
)
{
...
...
@@ -315,37 +316,38 @@ class GenerateWalletsProvider with ChangeNotifier {
isAlive
=
true
;
}
for
(
var
derivationNbr
in
[
for
(
var
i
=
0
;
i
<
numberScan
;
i
+=
1
)
i
])
{
for
(
int
derivationNbr
in
[
for
(
var
i
=
0
;
i
<
numberScan
;
i
+=
1
)
i
])
{
final
addressData
=
await
sub
.
sdk
.
api
.
keyring
.
addressFromMnemonic
(
sub
.
currencyParameters
[
'ss58'
]
!
,
cryptoType:
CryptoType
.
sr25519
,
mnemonic:
generatedMnemonic
!
,
derivePath:
'//
$derivationNbr
'
);
addressToScan
.
putIfAbsent
(
addressData
.
address
!
,
()
=
>
derivationNbr
);
}
final
Map
balance
=
await
sub
.
getBalance
(
addressData
.
address
!
)
.
timeout
(
const
Duration
(
seconds:
1
),
onTimeout:
()
=
>
{
'transferableBalance'
:
0
},
final
balanceList
=
await
sub
.
getBalanceMulti
(
addressToScan
.
keys
.
toList
())
.
timeout
(
const
Duration
(
seconds:
20
),
onTimeout:
()
=
>
{},
);
// const balance = 0;
log
.
d
(
"
${addressData.address!}
:
${balance['transferableBalance']}
$currencyName
"
);
if
(
balance
[
'transferableBalance'
]
!=
0
)
{
for
(
String
scannedWallet
in
balanceList
.
keys
)
{
if
(
balanceList
[
scannedWallet
]
!
[
'transferableBalance'
]
!=
0
)
{
isAlive
=
true
;
String
walletName
=
scanedValidWalletNumber
==
0
?
'currentWallet'
.
tr
()
:
'
${'wallet'.tr()}
${scanedValidWalletNumber + 1}
'
;
await
sub
.
importAccount
(
mnemonic:
generatedMnemonic
!
,
derivePath:
'
//
$
derivationNbr
'
,
derivePath:
"
//
$
{addressToScan[scannedWallet]}
"
,
password:
pin
.
text
);
WalletData
myWallet
=
WalletData
(
chest:
currentChestNumber
,
address:
addressData
.
address
!
,
address:
scannedWallet
,
number:
scanedValidWalletNumber
,
name:
walletName
,
derivation:
derivationNbr
,
derivation:
addressToScan
[
scannedWallet
]
,
imageDefaultPath:
'
${scanedValidWalletNumber % 4}
.png'
,
isOwned:
true
);
await
walletBox
.
put
(
myWallet
.
address
,
myWallet
);
...
...
@@ -354,6 +356,7 @@ class GenerateWalletsProvider with ChangeNotifier {
scanedWalletNumber
=
scanedWalletNumber
+
1
;
notifyListeners
();
}
log
.
d
(
scanedWalletNumber
);
scanedWalletNumber
=
-
1
;
scanedValidWalletNumber
=
-
1
;
...
...
@@ -372,8 +375,6 @@ class GenerateWalletsProvider with ChangeNotifier {
onTimeout:
()
=
>
{},
);
log
.
d
(
balance
);
log
.
d
(
"
${addressData.address!}
:
${balance['transferableBalance']}
$currencyName
"
);
if
(
balance
[
'transferableBalance'
]
!=
0
)
{
...
...
This diff is collapsed.
Click to expand it.
lib/providers/substrate_sdk.dart
+
0
−
4
View file @
a751b1eb
...
...
@@ -236,8 +236,6 @@ class SubstrateSdk with ChangeNotifier {
nbr
++
;
}
log
.
i
(
finalBalancesList
);
return
finalBalancesList
;
}
...
...
@@ -275,8 +273,6 @@ class SubstrateSdk with ChangeNotifier {
final
int
transferableBalance
=
(
balanceGlobal
[
'data'
][
'free'
]
+
unclaimedUds
);
// log.d('udValue: $udValue');
return
{
'transferableBalance'
:
round
((
transferableBalance
/
balanceRatio
)
/
100
),
'free'
:
round
((
balanceGlobal
[
'data'
][
'free'
]
/
balanceRatio
)
/
100
),
...
...
This diff is collapsed.
Click to expand it.
lib/screens/myWallets/wallets_home.dart
+
2
−
1
View file @
a751b1eb
...
...
@@ -467,7 +467,8 @@ class _WalletsHomeState extends State<WalletsHome> {
}),
),
Consumer
<
SubstrateSdk
>(
builder:
(
context
,
sub
,
_
)
{
return
sub
.
nodeConnected
return
sub
.
nodeConnected
&&
myWalletProvider
.
listWallets
.
length
<
30
?
addNewDerivation
(
context
)
:
const
Text
(
''
);
}),
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment