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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
Ğecko
Commits
36267865
Commit
36267865
authored
1 month ago
by
poka
Browse files
Options
Downloads
Patches
Plain Diff
fix Valid value range is empty for certs cache
parent
74a81de6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/providers/substrate_sdk.dart
+12
-11
12 additions, 11 deletions
lib/providers/substrate_sdk.dart
lib/widgets/certifications.dart
+20
-7
20 additions, 7 deletions
lib/widgets/certifications.dart
with
32 additions
and
18 deletions
lib/providers/substrate_sdk.dart
+
12
−
11
View file @
36267865
...
...
@@ -30,6 +30,7 @@ import 'package:provider/provider.dart';
import
'package:pointycastle/pointycastle.dart'
as
pc
;
import
"package:hex/hex.dart"
;
import
'package:uuid/uuid.dart'
show
Uuid
;
import
'package:gecko/widgets/certifications.dart'
;
class
SubstrateSdk
with
ChangeNotifier
{
final
WalletSDK
sdk
=
WalletSDK
();
...
...
@@ -51,7 +52,7 @@ class SubstrateSdk with ChangeNotifier {
bool
isCesiumIDVisible
=
false
;
bool
isCesiumAddresLoading
=
false
;
late
int
udValue
;
Map
<
String
,
List
<
int
>
>
certsCounterCache
=
{};
final
Map
<
String
,
CertificationData
>
certsCounterCache
=
{};
Map
<
String
,
List
>
oldOwnerKeys
=
{};
// Cache pour idtyStatus
...
...
@@ -210,13 +211,13 @@ class SubstrateSdk with ChangeNotifier {
return
List
<
int
?
>
.
from
(
await
_getStorage
(
'identity.identityIndexOf.multi(
$jsonString
)'
));
}
Future
<
List
<
int
>
>
getCertsCounter
(
String
address
)
async
{
Future
<
CertificationData
>
getCertsCounter
(
String
address
)
async
{
// On fait toujours la requête en background
final
idtyIndex
=
await
_getIdentityIndexOf
(
address
);
if
(
idtyIndex
==
null
)
{
final
emptyList
=
<
int
>[]
;
final
emptyList
=
CertificationData
(
receivedCount:
0
,
sentCount:
0
)
;
// Si le compteur a changé (était non vide avant), on notifie
if
(
certsCounterCache
[
address
]
?.
isNotEmpty
==
true
)
{
if
(
certsCounterCache
[
address
]
?.
receivedCount
!=
0
||
certsCounterCache
[
address
]
?.
sentCount
!=
0
)
{
certsCounterCache
[
address
]
=
emptyList
;
notifyListeners
();
}
...
...
@@ -227,12 +228,12 @@ class SubstrateSdk with ChangeNotifier {
final
List
<
int
>
newCerts
=
[
certsReceiver
[
'receivedCount'
]
as
int
,
certsReceiver
[
'issuedCount'
]
as
int
];
// Si le compteur a changé, on met à jour le cache et on notifie
if
(
certsCounterCache
[
address
]
?.
length
!=
2
||
certsCounterCache
[
address
]
!
[
0
]
!=
newCerts
[
0
]
||
certsCounterCache
[
address
]
!
[
1
]
!=
newCerts
[
1
])
{
certsCounterCache
[
address
]
=
newCerts
;
if
(
certsCounterCache
[
address
]
?.
receivedCount
!=
newCerts
[
0
]
||
certsCounterCache
[
address
]
?.
sentCount
!=
newCerts
[
1
])
{
certsCounterCache
[
address
]
=
CertificationData
(
receivedCount:
newCerts
[
0
],
sentCount:
newCerts
[
1
])
;
notifyListeners
();
}
return
certsCounterCache
[
address
]
??
newCerts
;
return
certsCounterCache
[
address
]
!
;
}
Future
<
DateTime
?
>
membershipExpireIn
(
String
address
)
async
{
...
...
@@ -1069,10 +1070,10 @@ class SubstrateSdk with ChangeNotifier {
String
?
rawParams
;
var
toCerts
=
await
getCertsCounter
(
destAddress
);
if
(
toCerts
.
isEmpty
)
{
toCerts
=
[
0
,
0
]
;
if
(
toCerts
.
receivedCount
==
0
&&
toCerts
.
sentCount
==
0
)
{
toCerts
=
CertificationData
(
receivedCount:
0
,
sentCount:
0
)
;
}
log
.
d
(
"debug toCert:
${toCerts
[0]
}
---
${currencyParameters['minCertForMembership']!}
---
$toIdtyStatus
"
);
log
.
d
(
"debug toCert:
${toCerts
.receivedCount
}
---
${currencyParameters['minCertForMembership']!}
---
$toIdtyStatus
"
);
if
(
toIdtyStatus
==
IdtyStatus
.
none
)
{
txInfo
=
TxInfoData
(
...
...
@@ -1082,7 +1083,7 @@ class SubstrateSdk with ChangeNotifier {
);
txOptions
=
[
destAddress
];
}
else
if
(
toIdtyStatus
==
IdtyStatus
.
member
||
toIdtyStatus
==
IdtyStatus
.
unvalidated
)
{
if
(
toCerts
[
0
]
>
=
currencyParameters
[
'minCertForMembership'
]
!
-
1
&&
toIdtyStatus
!=
IdtyStatus
.
member
)
{
if
(
toCerts
.
receivedCount
>
=
currencyParameters
[
'minCertForMembership'
]
!
-
1
&&
toIdtyStatus
!=
IdtyStatus
.
member
)
{
log
.
d
(
'Batch cert and membership validation'
);
txInfo
=
TxInfoData
(
'utility'
,
...
...
This diff is collapsed.
Click to expand it.
lib/widgets/certifications.dart
+
20
−
7
View file @
36267865
...
...
@@ -3,6 +3,19 @@ import 'package:gecko/models/scale_functions.dart';
import
'package:gecko/providers/substrate_sdk.dart'
;
import
'package:provider/provider.dart'
;
// Add a class to store certification data
class
CertificationData
{
final
int
receivedCount
;
final
int
sentCount
;
CertificationData
({
required
this
.
receivedCount
,
required
this
.
sentCount
});
bool
equals
(
CertificationData
?
other
)
{
if
(
other
==
null
)
return
false
;
return
receivedCount
==
other
.
receivedCount
&&
sentCount
==
other
.
sentCount
;
}
}
class
Certifications
extends
StatefulWidget
{
const
Certifications
({
super
.
key
,
required
this
.
address
,
required
this
.
size
,
this
.
color
=
Colors
.
black
});
final
String
address
;
...
...
@@ -25,7 +38,7 @@ class _CertificationsState extends State<Certifications> {
if
(
!
mounted
)
return
;
final
cachedData
=
sdk
.
certsCounterCache
[
widget
.
address
];
if
(
cachedData
==
null
||
cachedData
.
isEmpty
||
networkData
[
0
]
!=
cachedData
[
0
]
||
networkData
[
1
]
!=
cachedData
[
1
]
)
{
if
(
cachedData
==
null
||
!
cachedData
.
equals
(
networkData
)
)
{
sdk
.
certsCounterCache
[
widget
.
address
]
=
networkData
;
setState
(()
{});
}
...
...
@@ -38,21 +51,21 @@ class _CertificationsState extends State<Certifications> {
Widget
build
(
BuildContext
context
)
{
return
Consumer
<
SubstrateSdk
>(
builder:
(
context
,
sdk
,
_
)
{
//
Afficher les données du cache
imm
é
diate
ment si disponi
ble
s
//
Display cached data
imm
e
diate
ly if availa
ble
final
cachedCerts
=
sdk
.
certsCounterCache
[
widget
.
address
];
//
Vérifier les données réseau en arrière-plan
//
Check network data in the background
if
(
!
_isLoading
)
{
Future
.
microtask
(()
=
>
_checkNetworkData
(
sdk
));
}
//
Si pas de données en cache, on affiche rien en attendant
if
(
cachedCerts
==
null
||
cachedCerts
.
isEmpty
)
{
//
If no cached data, show nothing while waiting
if
(
cachedCerts
==
null
)
{
return
const
SizedBox
.
shrink
();
}
//
Afficher les données du cache
return
_buildContent
(
cachedCerts
[
0
]
,
cachedCerts
[
1
]
);
//
Display cached data
return
_buildContent
(
cachedCerts
.
receivedCount
,
cachedCerts
.
sentCount
);
},
);
}
...
...
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