diff --git a/lib/providers/substrate_sdk.dart b/lib/providers/substrate_sdk.dart index 1a8236c..d56efd7 100644 --- a/lib/providers/substrate_sdk.dart +++ b/lib/providers/substrate_sdk.dart @@ -257,21 +257,24 @@ class SubstrateSdk with ChangeNotifier { return [certsReceiver['receivedCount'], certsReceiver['issuedCount']]; } - Future getCertData(String from, String to) async { + Future 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> getParameters() async { @@ -666,9 +669,8 @@ class SubstrateSdk with ChangeNotifier { Future> certState(String from, String to) async { Map 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 diff --git a/lib/screens/wallet_view.dart b/lib/screens/wallet_view.dart index 84a0d74..e2cebd9 100644 --- a/lib/screens/wallet_view.dart +++ b/lib/screens/wallet_view.dart @@ -129,6 +129,9 @@ class WalletViewScreen extends StatelessWidget { builder: (context, AsyncSnapshot> 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(