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

Use certsByReceiver to gets certValidityPeriod instead of obsolete certsByReceiver call

parent 81772f92
No related branches found
No related tags found
1 merge request!26Features gdev2
Pipeline #16676 waiting for manual action
......@@ -257,21 +257,24 @@ class SubstrateSdk with ChangeNotifier {
return [certsReceiver['receivedCount'], certsReceiver['issuedCount']];
}
Future<Map> getCertData(String from, String to) async {
Future<int> getCertValidityPeriod(String from, String to) async {
final idtyIndexFrom = await getIdentityIndexOf(from);
final idtyIndexTo = await getIdentityIndexOf(to);
if (idtyIndexFrom == 0 || idtyIndexTo == 0) return {};
if (idtyIndexFrom == 0 || idtyIndexTo == 0) return 0;
final certData = await sdk.webView!.evalJavascript(
'api.query.cert.storageCertsByIssuer($idtyIndexFrom, $idtyIndexTo)') ??
'';
final List certData = await sdk.webView!
.evalJavascript('api.query.cert.certsByReceiver($idtyIndexTo)') ??
[];
if (certData == '') return {};
if (certData.isEmpty) return 0;
for (List certInfo in certData) {
if (certInfo[0] == idtyIndexFrom) {
return certInfo[1];
}
}
// log.d(_certData);
return certData;
return 0;
}
Future<Map<String, dynamic>> getParameters() async {
......@@ -666,9 +669,8 @@ class SubstrateSdk with ChangeNotifier {
Future<Map<String, int>> certState(String from, String to) async {
Map<String, int> result = {};
if (from != to && await isMemberGet(from)) {
final certData = await getCertData(from, to);
final removableOn = await getCertValidityPeriod(from, to);
final certMeta = await getCertMeta(from);
final int removableOn = certData['removableOn'] ?? 0;
final int nextIssuableOn = certMeta['nextIssuableOn'] ?? 0;
final certRemovableDuration = (removableOn - blocNumber) * 6;
const int renewDelay = 2 * 30 * 24 * 3600; // 2 months
......
......@@ -129,6 +129,9 @@ class WalletViewScreen extends StatelessWidget {
builder: (context, AsyncSnapshot<Map<String, int>> snapshot) {
if (snapshot.data == null) return const SizedBox();
String duration = '';
log.d(snapshot.data!['certDelay']);
log.d(snapshot.data!['certRenewable']);
if (snapshot.data!['certDelay'] != null ||
snapshot.data!['certRenewable'] != null) {
final Duration durationSeconds = Duration(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment