Remove trace of gva search adapter

This commit is contained in:
poka 2021-11-27 07:48:35 +01:00
parent 48a04866b5
commit 012cd31daf
5 changed files with 0 additions and 447 deletions

View File

@ -2,7 +2,6 @@ import 'dart:io';
import 'package:flutter/material.dart';
import 'package:gecko/models/chest_data.dart';
import 'package:gecko/models/g1_wallets_list.dart';
import 'package:gecko/models/g1_wallets_list_live.dart';
import 'package:gecko/models/wallet_data.dart';
import 'package:hive/hive.dart';
import 'package:logger/logger.dart';
@ -19,7 +18,6 @@ Box<WalletData> walletBox;
Box<ChestData> chestBox;
Box configBox;
Box<G1WalletsList> g1WalletsBox;
Box<G1WalletsListLive> g1WalletsBoxLive;
String cesiumPod = "https://g1.data.le-sou.org";
// String cesiumPod = "https://g1.data.e-is.pro";

View File

@ -24,7 +24,6 @@ import 'package:gecko/models/change_pin.dart';
import 'package:gecko/models/chest_data.dart';
import 'package:gecko/models/chest_provider.dart';
import 'package:gecko/models/g1_wallets_list.dart';
import 'package:gecko/models/g1_wallets_list_live.dart';
import 'package:gecko/models/generate_wallets.dart';
import 'package:gecko/models/history.dart';
import 'package:gecko/models/home.dart';
@ -62,19 +61,10 @@ Future<void> main() async {
Hive.registerAdapter(ChestDataAdapter());
Hive.registerAdapter(G1WalletsListAdapter());
Hive.registerAdapter(IdAdapter());
Hive.registerAdapter(G1WalletsListLiveAdapter());
Hive.registerAdapter(DataAdapter());
Hive.registerAdapter(WalletsAdapter());
Hive.registerAdapter(EdgesAdapter());
Hive.registerAdapter(NodeAdapter());
Hive.registerAdapter(BalanceAdapter());
Hive.registerAdapter(IdtyAdapter());
Hive.registerAdapter(PageInfoAdapter());
walletBox = await Hive.openBox<WalletData>("walletBox");
chestBox = await Hive.openBox<ChestData>("chestBox");
configBox = await Hive.openBox("configBox");
g1WalletsBox = await Hive.openBox<G1WalletsList>("g1WalletsBox");
g1WalletsBoxLive = await Hive.openBox<G1WalletsListLive>("g1WalletsBoxLive");
// final HiveStore _store =
// await HiveStore.open(path: '${appPath.path}/gqlCache');

View File

@ -1,179 +0,0 @@
import 'package:hive_flutter/hive_flutter.dart';
part 'g1_wallets_list_live.g.dart';
@HiveType(typeId: 4)
class G1WalletsListLive {
@HiveField(0)
Data data;
G1WalletsListLive({this.data});
G1WalletsListLive.fromJson(Map<String, dynamic> json) {
data = json['data'] != null ? Data.fromJson(json['data']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
if (this.data != null) {
data['data'] = this.data.toJson();
}
return data;
}
}
@HiveType(typeId: 5)
class Data {
Wallets wallets;
Data({this.wallets});
Data.fromJson(Map<String, dynamic> json) {
wallets =
json['wallets'] != null ? Wallets.fromJson(json['wallets']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
if (wallets != null) {
data['wallets'] = wallets.toJson();
}
return data;
}
}
@HiveType(typeId: 6)
class Wallets {
List<Edges> edges;
PageInfo pageInfo;
Wallets({this.edges, this.pageInfo});
Wallets.fromJson(Map<String, dynamic> json) {
if (json['edges'] != null) {
edges = <Edges>[];
json['edges'].forEach((v) {
edges.add(Edges.fromJson(v));
});
}
pageInfo =
json['pageInfo'] != null ? PageInfo.fromJson(json['pageInfo']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
if (edges != null) {
data['edges'] = edges.map((v) => v.toJson()).toList();
}
if (pageInfo != null) {
data['pageInfo'] = pageInfo.toJson();
}
return data;
}
}
@HiveType(typeId: 7)
class Edges {
Node node;
Edges({this.node});
Edges.fromJson(Map<String, dynamic> json) {
node = json['node'] != null ? Node.fromJson(json['node']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
if (node != null) {
data['node'] = node.toJson();
}
return data;
}
}
@HiveType(typeId: 8)
class Node {
Balance balance;
Idty idty;
String script;
Node({this.balance, this.idty, this.script});
Node.fromJson(Map<String, dynamic> json) {
balance =
json['balance'] != null ? Balance.fromJson(json['balance']) : null;
idty = json['idty'] != null ? Idty.fromJson(json['idty']) : null;
script = json['script'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
if (balance != null) {
data['balance'] = balance.toJson();
}
if (idty != null) {
data['idty'] = idty.toJson();
}
data['script'] = script;
return data;
}
}
@HiveType(typeId: 9)
class Balance {
int amount;
int base;
Balance({this.amount, this.base});
Balance.fromJson(Map<String, dynamic> json) {
amount = json['amount'];
base = json['base'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['amount'] = amount;
data['base'] = base;
return data;
}
}
@HiveType(typeId: 10)
class Idty {
bool isMember;
String username;
Idty({this.isMember, this.username});
Idty.fromJson(Map<String, dynamic> json) {
isMember = json['isMember'];
username = json['username'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['isMember'] = isMember;
data['username'] = username;
return data;
}
}
@HiveType(typeId: 11)
class PageInfo {
String endCursor;
bool hasNextPage;
PageInfo({this.endCursor, this.hasNextPage});
PageInfo.fromJson(Map<String, dynamic> json) {
endCursor = json['endCursor'];
hasNextPage = json['hasNextPage'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['endCursor'] = endCursor;
data['hasNextPage'] = hasNextPage;
return data;
}
}

View File

@ -1,216 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'g1_wallets_list_live.dart';
// **************************************************************************
// TypeAdapterGenerator
// **************************************************************************
class G1WalletsListLiveAdapter extends TypeAdapter<G1WalletsListLive> {
@override
final int typeId = 4;
@override
G1WalletsListLive read(BinaryReader reader) {
final numOfFields = reader.readByte();
final fields = <int, dynamic>{
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
};
return G1WalletsListLive(
data: fields[0] as Data,
);
}
@override
void write(BinaryWriter writer, G1WalletsListLive obj) {
writer
..writeByte(1)
..writeByte(0)
..write(obj.data);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is G1WalletsListLiveAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
class DataAdapter extends TypeAdapter<Data> {
@override
final int typeId = 5;
@override
Data read(BinaryReader reader) {
return Data();
}
@override
void write(BinaryWriter writer, Data obj) {
writer.writeByte(0);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is DataAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
class WalletsAdapter extends TypeAdapter<Wallets> {
@override
final int typeId = 6;
@override
Wallets read(BinaryReader reader) {
return Wallets();
}
@override
void write(BinaryWriter writer, Wallets obj) {
writer.writeByte(0);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is WalletsAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
class EdgesAdapter extends TypeAdapter<Edges> {
@override
final int typeId = 7;
@override
Edges read(BinaryReader reader) {
return Edges();
}
@override
void write(BinaryWriter writer, Edges obj) {
writer.writeByte(0);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is EdgesAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
class NodeAdapter extends TypeAdapter<Node> {
@override
final int typeId = 8;
@override
Node read(BinaryReader reader) {
return Node();
}
@override
void write(BinaryWriter writer, Node obj) {
writer.writeByte(0);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is NodeAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
class BalanceAdapter extends TypeAdapter<Balance> {
@override
final int typeId = 9;
@override
Balance read(BinaryReader reader) {
return Balance();
}
@override
void write(BinaryWriter writer, Balance obj) {
writer.writeByte(0);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is BalanceAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
class IdtyAdapter extends TypeAdapter<Idty> {
@override
final int typeId = 10;
@override
Idty read(BinaryReader reader) {
return Idty();
}
@override
void write(BinaryWriter writer, Idty obj) {
writer.writeByte(0);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is IdtyAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}
class PageInfoAdapter extends TypeAdapter<PageInfo> {
@override
final int typeId = 11;
@override
PageInfo read(BinaryReader reader) {
return PageInfo();
}
@override
void write(BinaryWriter writer, PageInfo obj) {
writer.writeByte(0);
}
@override
int get hashCode => typeId.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is PageInfoAdapter &&
runtimeType == other.runtimeType &&
typeId == other.typeId;
}

View File

@ -3,7 +3,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
import 'package:gecko/models/g1_wallets_list.dart';
import 'package:gecko/models/g1_wallets_list_live.dart';
import 'package:http/http.dart' as http;
class SearchProvider with ChangeNotifier {
@ -43,45 +42,6 @@ class SearchProvider with ChangeNotifier {
return searchResult;
}
Future<List> searchBlockchainLive() async {
searchResult.clear();
int searchTime = DateTime.now().millisecondsSinceEpoch;
if (cacheTime + cacheDuring <= searchTime) {
g1WalletsBox.clear();
final url = Uri.parse(
'https://g1.librelois.fr/gva?query={%20wallets(pagination:%20{%20ord:%20ASC,%20pageSize:%20999%20})%20{%20pageInfo%20{%20hasNextPage%20endCursor%20}%20edges%20{%20node%20{%20script%20balance%20{%20amount%20base%20}%20idty%20{%20isMember%20username%20}%20}%20}%20}%20}');
final response = await http.get(url);
// log.d(response.body);
G1WalletsListLive _jsonResponse =
G1WalletsListLive.fromJson(json.decode(response.body));
while (_jsonResponse.data.wallets.pageInfo.hasNextPage) {
var cursor = _jsonResponse.data.wallets.pageInfo.endCursor;
final url = Uri.parse(
'https://g1.librelois.fr/gva?query={%20wallets(pagination:%20{%20ord:%20ASC,%20pageSize:%20999%20})%20{%20pageInfo%20{%20hasNextPage%20endCursor%20}%20edges%20{%20node%20{%20script%20balance%20{%20amount%20base%20}%20idty%20{%20isMember%20username%20}%20}%20}%20}%20}');
final response = await http.get(url);
}
await configBox.put('g1WalletCache', _jsonResponse);
cacheTime = DateTime.now().millisecondsSinceEpoch;
}
for (var value in configBox.get('g1WalletCache').data.wallets.edges) {
if ((value.node.idty != null &&
value.node.idty.username != null &&
value.node.idty.username.contains(searchController.text)) ||
value.node.script.contains(searchController.text)) {
searchResult.add(value);
}
}
// log.d(configBox.get('g1WalletCache').data.wallets.edges.toString());
return searchResult;
}
}
List<G1WalletsList> _parseG1Wallets(String responseBody) {