forked from axiom-team/gecko
Add tests, try to understand the problem ...
This commit is contained in:
parent
654281b34a
commit
e4558bf8ee
|
@ -296,7 +296,7 @@ List parseHistory(txs) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
transBC.sort((b, a) => Comparable.compare(a[0], b[0]));
|
// transBC.sort((b, a) => Comparable.compare(a[0], b[0]));
|
||||||
|
|
||||||
return transBC;
|
return transBC;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,35 +9,19 @@ import "package:dio/dio.dart";
|
||||||
import 'package:graphql_flutter/graphql_flutter.dart';
|
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||||
import 'query.dart';
|
import 'query.dart';
|
||||||
|
|
||||||
/// Integrates a list of articles with [ListPreferencesScreen].
|
//ignore: must_be_immutable
|
||||||
class HistoryListScreen extends StatefulWidget {
|
class HistoryListScreen extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
_HistoryListScreenState createState() => _HistoryListScreenState();
|
_HistoryListScreenState createState() => _HistoryListScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
// class HistoryListScreen extends StatefulWidget {
|
|
||||||
// // GeckoHome({Key key, this.title}) : super(key: key);
|
|
||||||
// // final String title;
|
|
||||||
|
|
||||||
// const HistoryListScreen({
|
|
||||||
// @required this.repository,
|
|
||||||
// final String title,
|
|
||||||
// Key key,
|
|
||||||
// }) : assert(repository != null),
|
|
||||||
// super(key: key);
|
|
||||||
|
|
||||||
// final Repository repository;
|
|
||||||
|
|
||||||
// @override
|
|
||||||
// _GeckoHomeState createState() => _GeckoHomeState();
|
|
||||||
// }
|
|
||||||
|
|
||||||
class _HistoryListScreenState extends State<HistoryListScreen> {
|
class _HistoryListScreenState extends State<HistoryListScreen> {
|
||||||
Uint8List bytes = Uint8List(0);
|
Uint8List bytes = Uint8List(0);
|
||||||
TextEditingController _outputPubkey;
|
TextEditingController _outputPubkey;
|
||||||
TextEditingController _outputBalance;
|
TextEditingController _outputBalance;
|
||||||
final nRepositories = 20;
|
final nRepositories = 3;
|
||||||
var pubkey = '';
|
var pubkey = '';
|
||||||
|
var titi = 'totooooooop';
|
||||||
ScrollController _scrollController = new ScrollController();
|
ScrollController _scrollController = new ScrollController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -54,10 +38,11 @@ class _HistoryListScreenState extends State<HistoryListScreen> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// final pubkey = 'D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU';
|
pubkey = 'D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU';
|
||||||
|
|
||||||
// var pubkey = '';
|
// var pubkey = '';
|
||||||
print('Build state : ' + pubkey);
|
print('Build state : ' + pubkey);
|
||||||
|
print(titi);
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
backgroundColor: Colors.grey[300],
|
backgroundColor: Colors.grey[300],
|
||||||
|
@ -68,9 +53,10 @@ class _HistoryListScreenState extends State<HistoryListScreen> {
|
||||||
TextField(
|
TextField(
|
||||||
// enabled: false,
|
// enabled: false,
|
||||||
onChanged: (text) {
|
onChanged: (text) {
|
||||||
print("Clé tappé: $text");
|
print("Clé tappxé: $text");
|
||||||
// pubkey = text;
|
pubkey = text;
|
||||||
pubkey = isPubkey(text);
|
// pubkey =
|
||||||
|
isPubkey(text);
|
||||||
},
|
},
|
||||||
controller: this._outputPubkey,
|
controller: this._outputPubkey,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
|
@ -114,10 +100,9 @@ class _HistoryListScreenState extends State<HistoryListScreen> {
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Query(
|
Query(
|
||||||
options: QueryOptions(
|
options: QueryOptions(
|
||||||
documentNode: gql(getMyRepositories),
|
documentNode: gql(getHistory),
|
||||||
variables: <String, dynamic>{
|
variables: <String, dynamic>{
|
||||||
'pubkey':
|
'pubkey': pubkey, // pubkey,
|
||||||
'D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU', // pubkey,
|
|
||||||
'number': nRepositories,
|
'number': nRepositories,
|
||||||
// set cursor to null so as to start at the beginning
|
// set cursor to null so as to start at the beginning
|
||||||
// 'cursor': 0
|
// 'cursor': 0
|
||||||
|
@ -138,8 +123,7 @@ class _HistoryListScreenState extends State<HistoryListScreen> {
|
||||||
|
|
||||||
if (result.data == null &&
|
if (result.data == null &&
|
||||||
result.exception.toString() == null) {
|
result.exception.toString() == null) {
|
||||||
return const Text(
|
return const Text('Both data and errors are null');
|
||||||
'Both data and errors are null, this is a known bug after refactoring, you might forget to set Github token');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<dynamic> blockchainTX =
|
final List<dynamic> blockchainTX =
|
||||||
|
@ -152,7 +136,9 @@ class _HistoryListScreenState extends State<HistoryListScreen> {
|
||||||
|
|
||||||
final Map pageInfo =
|
final Map pageInfo =
|
||||||
result.data['txsHistoryBc']['both']['pageInfo'];
|
result.data['txsHistoryBc']['both']['pageInfo'];
|
||||||
final String fetchMoreCursor = pageInfo['endCursor'];
|
|
||||||
|
final String fetchMoreCursor =
|
||||||
|
pageInfo['endCursor'] ?? 'cest null...';
|
||||||
|
|
||||||
FetchMoreOptions opts = FetchMoreOptions(
|
FetchMoreOptions opts = FetchMoreOptions(
|
||||||
variables: {'cursor': fetchMoreCursor},
|
variables: {'cursor': fetchMoreCursor},
|
||||||
|
@ -170,7 +156,9 @@ class _HistoryListScreenState extends State<HistoryListScreen> {
|
||||||
|
|
||||||
fetchMoreResultData['txsHistoryBc']['both']
|
fetchMoreResultData['txsHistoryBc']['both']
|
||||||
['edges'] = repos;
|
['edges'] = repos;
|
||||||
print('A: ' + fetchMoreCursor + ' B');
|
print('DEBUG NULL OPTION: ');
|
||||||
|
print(fetchMoreResultData);
|
||||||
|
print(fetchMoreCursor);
|
||||||
return fetchMoreResultData;
|
return fetchMoreResultData;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -180,13 +168,15 @@ class _HistoryListScreenState extends State<HistoryListScreen> {
|
||||||
if (_scrollController.position.pixels ==
|
if (_scrollController.position.pixels ==
|
||||||
_scrollController.position.maxScrollExtent) {
|
_scrollController.position.maxScrollExtent) {
|
||||||
if (!result.loading) {
|
if (!result.loading) {
|
||||||
print('B');
|
print('DEBUG NULL scrollController: ' +
|
||||||
print(opts);
|
fetchMoreCursor);
|
||||||
fetchMore(opts);
|
fetchMore(opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
print(
|
||||||
|
'DEBUG blockchainTX: ' + blockchainTX.toString());
|
||||||
List transBC = parseHistory(blockchainTX);
|
List transBC = parseHistory(blockchainTX);
|
||||||
// parseHistory(mempoolTX);
|
// parseHistory(mempoolTX);
|
||||||
|
|
||||||
|
@ -204,7 +194,7 @@ class _HistoryListScreenState extends State<HistoryListScreen> {
|
||||||
BorderRadius.circular(3.0)),
|
BorderRadius.circular(3.0)),
|
||||||
// 3
|
// 3
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(100.0),
|
||||||
// 4
|
// 4
|
||||||
child: Column(
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
@ -278,7 +268,6 @@ class _HistoryListScreenState extends State<HistoryListScreen> {
|
||||||
child: FittedBox(
|
child: FittedBox(
|
||||||
child: FloatingActionButton(
|
child: FloatingActionButton(
|
||||||
onPressed: () => _scan(),
|
onPressed: () => _scan(),
|
||||||
// label: Text('Scanner'),
|
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 40.0,
|
height: 40.0,
|
||||||
width: 40.0,
|
width: 40.0,
|
||||||
|
@ -319,15 +308,16 @@ class _HistoryListScreenState extends State<HistoryListScreen> {
|
||||||
print("C'est une pubkey !!!");
|
print("C'est une pubkey !!!");
|
||||||
showHistory(pubkey);
|
showHistory(pubkey);
|
||||||
|
|
||||||
// setState(() {});
|
// var tata = _scrollController;
|
||||||
|
|
||||||
|
// setState(() {
|
||||||
|
// print('setPubkey: ' + pubkey);
|
||||||
|
// pubkey = pubkey;
|
||||||
|
// // fetchMoreCursor = fetchMoreCursor;
|
||||||
|
// titi = 'lourd';
|
||||||
|
// });
|
||||||
|
|
||||||
return pubkey;
|
return pubkey;
|
||||||
|
|
||||||
// print(pubkey);
|
|
||||||
// setState(({pubkey = 'D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU'}) {
|
|
||||||
// pubkey = pubkey;
|
|
||||||
// print('setState : ' + pubkey);
|
|
||||||
// });
|
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,8 @@ class Gecko extends StatelessWidget {
|
||||||
);
|
);
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Ğecko',
|
title: 'Ğecko',
|
||||||
theme: ThemeData(primaryColor: Colors.white, accentColor: Colors.black),
|
theme:
|
||||||
|
ThemeData(primaryColor: Colors.blue[50], accentColor: Colors.black),
|
||||||
home: GraphQLProvider(
|
home: GraphQLProvider(
|
||||||
client: _client,
|
client: _client,
|
||||||
child: HistoryListScreen(),
|
child: HistoryListScreen(),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const String getMyRepositories = r'''
|
const String getHistory = r'''
|
||||||
query ($pubkey: String!, $number: Int!, $cursor: String) {
|
query ($pubkey: String!, $number: Int!, $cursor: String) {
|
||||||
txsHistoryBc(
|
txsHistoryBc(
|
||||||
pubkeyOrScript: $pubkey
|
pubkeyOrScript: $pubkey
|
||||||
|
@ -45,3 +45,11 @@ const String getMyRepositories = r'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
''';
|
''';
|
||||||
|
|
||||||
|
const String getxBalance = r'''
|
||||||
|
query ($pubkey: String!) {
|
||||||
|
balance(script: "$pubkey") {
|
||||||
|
amount
|
||||||
|
base
|
||||||
|
}
|
||||||
|
''';
|
||||||
|
|
Loading…
Reference in New Issue