From c487749f52a54e06c0ae2518a764cfe646ac3dd4 Mon Sep 17 00:00:00 2001
From: poka <poka@p2p.legal>
Date: Wed, 10 Aug 2022 07:18:04 +0200
Subject: [PATCH] improve batch meca

---
 lib/providers/substrate_sdk.dart | 21 +++++++--------------
 pubspec.yaml                     |  2 +-
 2 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/lib/providers/substrate_sdk.dart b/lib/providers/substrate_sdk.dart
index 0f2f9ad9..a6c6be5a 100644
--- a/lib/providers/substrate_sdk.dart
+++ b/lib/providers/substrate_sdk.dart
@@ -506,6 +506,7 @@ class SubstrateSdk with ChangeNotifier {
       keyring.current.pubKey,
     );
     TxInfoData txInfo;
+    List txOptions = [];
 
     if (toIdtyStatus == 'noid') {
       txInfo = TxInfoData(
@@ -513,6 +514,7 @@ class SubstrateSdk with ChangeNotifier {
         'createIdentity',
         sender,
       );
+      txOptions = [toAddress];
     } else if (toIdtyStatus == 'Validated' ||
         toIdtyStatus == 'ConfirmedByOwner') {
       if (toCerts[0] >= currencyParameters['wotMinCertForMembership'] &&
@@ -523,12 +525,17 @@ class SubstrateSdk with ChangeNotifier {
           'batchAll',
           sender,
         );
+        txOptions = [
+          'cert.addCert($fromIndex, $toIndex)',
+          'identity.validateIdentity($toIndex)'
+        ];
       } else {
         txInfo = TxInfoData(
           'cert',
           'addCert',
           sender,
         );
+        txOptions = [fromIndex, toIndex];
       }
     } else {
       transactionStatus = 'cantBeCert';
@@ -539,20 +546,6 @@ class SubstrateSdk with ChangeNotifier {
     log.d('Cert action: ${txInfo.call!}');
 
     try {
-      List txOptions = [];
-      if (txInfo.call == 'batchAll') {
-        txOptions = [
-          'cert.addCert($fromIndex, $toIndex)',
-          'identity.validateIdentity($toIndex)'
-        ];
-      } else if (txInfo.call == 'createIdentity') {
-        txOptions = [toAddress];
-      } else if (txInfo.call == 'addCert') {
-        txOptions = [fromIndex, toIndex];
-      } else {
-        log.e('TX call is unexpected');
-        return 'Ğecko says: TX call is unexpected';
-      }
       final hash = await sdk.api.tx
           .signAndSend(
             txInfo,
diff --git a/pubspec.yaml b/pubspec.yaml
index 1f0d806d..fad4eda4 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -5,7 +5,7 @@ description: Pay with G1.
 # pub.dev using `pub publish`. This is preferred for private packages.
 publish_to: 'none' # Remove this line if you wish to publish to pub.dev
 
-version: 0.0.9+16
+version: 0.0.9+17
 
 environment:
   sdk: '>=2.12.0 <3.0.0'
-- 
GitLab