From d38cabe1ebdf0be81d6d52a0d0041459b8b6eea5 Mon Sep 17 00:00:00 2001
From: poka <poka@p2p.legal>
Date: Tue, 14 Jun 2022 01:23:53 +0200
Subject: [PATCH] wip indexer

---
 lib/main.dart                     |  3 +-
 lib/models/queries_indexer.dart   | 69 +++++++++++++++++++++++++++++++
 lib/providers/wallet_options.dart |  3 ++
 pubspec.yaml                      |  2 +-
 4 files changed, 75 insertions(+), 2 deletions(-)

diff --git a/lib/main.dart b/lib/main.dart
index 63c9be46..3f348e40 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -80,7 +80,8 @@ Future<void> main() async {
   }
   // log.d(await configBox.get('endpoint'));
 
-  const indexerEndpoint = "http://192.168.1.72:8080/v1/graphql";
+  // const indexerEndpoint = "http://192.168.1.72:8080/v1/graphql";
+  const indexerEndpoint = "https://duniter-indexer.coinduf.eu/v1/graphql";
 
   HttpOverrides.global = MyHttpOverrides();
 
diff --git a/lib/models/queries_indexer.dart b/lib/models/queries_indexer.dart
index 439cd868..a59aa281 100644
--- a/lib/models/queries_indexer.dart
+++ b/lib/models/queries_indexer.dart
@@ -7,3 +7,72 @@ query ($address: String!) {
   }
 }
 ''';
+
+const String searchAddressByNameQ = r'''
+query ($name: String!) {
+  search_identity(args: {name: $name}) {
+    id
+    name
+  }
+}
+''';
+
+const String getHistoryByAddressQ = r'''
+query ($address: String!) {
+  account_by_pk(id: "5CQ8T4qpbYJq7uVsxGPQ5q2df7x3Wa4aRY6HUWMBYjfLZhnn") {
+    transactions_issued {
+      receiver_id
+      amount
+      created_at
+      created_on
+    }
+    transactions_received {
+      issuer_id
+      amount
+      created_at
+      created_on
+    }
+  }
+}
+''';
+
+const String getHistoryByAddressQ2 = r'''
+query ($address: String!) {
+  {
+    transaction(where: {_or: [{issuer_id: {_eq: $address}}, 
+      {receiver_id: {_eq: $address}}]}, order_by: {created_at: desc})
+  {
+      amount
+      created_at
+      issuer_id
+      receiver_id
+    }
+  }
+}
+''';
+
+const String getHistoryByAddressQ3 = r'''
+query ($address: String!) {
+  transaction_connection(where: 
+  {_or: [
+    {issuer_id: {_eq: $address}}, 
+    {receiver_id: {_eq: $address}}
+  ]}, 
+  order_by: {created_at: desc}) {
+    edges {
+      node {
+        amount
+        created_at
+        issuer_id
+        receiver_id
+      }
+    }
+    pageInfo {
+      endCursor
+      hasNextPage
+      hasPreviousPage
+      startCursor
+    }
+  }
+}
+''';
diff --git a/lib/providers/wallet_options.dart b/lib/providers/wallet_options.dart
index 54748368..748f6ab2 100644
--- a/lib/providers/wallet_options.dart
+++ b/lib/providers/wallet_options.dart
@@ -147,6 +147,9 @@ class WalletOptionsProvider with ChangeNotifier {
       );
     }
 
+    log.d('bbbbbbbbbbbb: ' +
+        DateTime.parse("2022-06-13T16:51:24.001+00:00").toString());
+
     return Consumer<SubstrateSdk>(builder: (context, _sub, _) {
       return FutureBuilder(
           future: _sub.idtyStatus(address),
diff --git a/pubspec.yaml b/pubspec.yaml
index fb66f41b..a74dd685 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.8+9
+version: 0.0.9+1
 
 environment:
   sdk: '>=2.12.0 <3.0.0'
-- 
GitLab