forked from axiom-team/gecko
3 lasts received/sent transations + pending transactions
This commit is contained in:
parent
582e87f7e0
commit
7d13644c71
57
lib/api.dart
57
lib/api.dart
|
@ -111,7 +111,7 @@ Future getHistory(String pubkey) async {
|
|||
outputs
|
||||
writtenTime
|
||||
}
|
||||
receiving {
|
||||
sending {
|
||||
currency
|
||||
issuers
|
||||
comment
|
||||
|
@ -142,41 +142,44 @@ Future getHistory(String pubkey) async {
|
|||
final currentBase = res.data['currentUd']['base'];
|
||||
final currentUD = res.data['currentUd']['amount'] / 100;
|
||||
|
||||
// Get tx received
|
||||
// Get tx blockchain
|
||||
for (final trans in resBC) {
|
||||
// var direction = transBC[i]['direction'];
|
||||
var direction = trans['direction'];
|
||||
|
||||
print(trans);
|
||||
final transaction = trans['node'];
|
||||
var output = transaction['outputs'][0];
|
||||
// outPubkey = output.split("SIG(")[1].replaceAll(')', '');
|
||||
|
||||
print("DEBUG1 " + transaction['writtenTime'].toString());
|
||||
transBC.add(i);
|
||||
transBC[i] = [];
|
||||
transBC[i].add(transaction['writtenTime']);
|
||||
transBC[i].add(transaction['issuers'][0]);
|
||||
var amountBrut = int.parse(output.split(':')[0]);
|
||||
final base = int.parse(output.split(':')[1]);
|
||||
final applyBase = base - currentBase;
|
||||
final amount = amountBrut * pow(10, applyBase) / 100;
|
||||
transBC[i].add(amount);
|
||||
final amountUD = amount / currentUD;
|
||||
transBC[i].add(amountUD.toStringAsFixed(2));
|
||||
var amountUD = amount / currentUD;
|
||||
if (direction == "RECEIVED") {
|
||||
transBC[i].add(transaction['issuers'][0]);
|
||||
transBC[i].add(amount);
|
||||
transBC[i].add(amountUD.toStringAsFixed(2));
|
||||
} else if (direction == "SENT") {
|
||||
final outPubkey = output.split("SIG(")[1].replaceAll(')', '');
|
||||
transBC[i].add(outPubkey);
|
||||
transBC[i].add(-amount);
|
||||
transBC[i].add(amountUD.toStringAsFixed(2));
|
||||
}
|
||||
transBC[i].add(transaction['comment']);
|
||||
transBC[i].add(base);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
// Get tx receving
|
||||
// Get tx mempool
|
||||
var transMP = [];
|
||||
i = 0;
|
||||
|
||||
print('DEBUG2');
|
||||
print(resMP);
|
||||
|
||||
for (var transaction in resMP['receiving']) {
|
||||
if (transMP == null) {
|
||||
print("DEBUG3 " + resMP.toString());
|
||||
break;
|
||||
}
|
||||
var output = transaction['outputs'][0];
|
||||
|
@ -199,6 +202,32 @@ Future getHistory(String pubkey) async {
|
|||
i++;
|
||||
}
|
||||
|
||||
transMP = [];
|
||||
i = 0;
|
||||
for (var transaction in resMP['sending']) {
|
||||
if (transMP == null) {
|
||||
break;
|
||||
}
|
||||
var output = transaction['outputs'][0];
|
||||
var outPubkey = output.split("SIG(")[1].replaceAll(')', '');
|
||||
transMP.add(i);
|
||||
transMP[i] = [];
|
||||
transMP[i].add(transaction['writtenTime']);
|
||||
transMP[i].add(transaction['issuers'][0]);
|
||||
var amountBrut = int.parse(output.split(':')[0]);
|
||||
final base = int.parse(output.split(':')[1]);
|
||||
final applyBase = base - currentBase;
|
||||
final amount = amountBrut * pow(10, applyBase) / 100;
|
||||
transMP[i].add(-amount);
|
||||
final amountUD = amount / currentUD;
|
||||
transMP[i].add(amountUD.toStringAsFixed(2));
|
||||
transMP[i].add(transaction['comment']);
|
||||
transMP[i].add(base);
|
||||
transMP[i].add(outPubkey);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
// Order transactions by date
|
||||
transBC.sort((b, a) => Comparable.compare(a[0], b[0]));
|
||||
transMP.sort((b, a) => Comparable.compare(a[0], b[0]));
|
||||
|
|
|
@ -258,15 +258,14 @@ class _MyAppState extends State<MyApp> {
|
|||
final amount = i[2];
|
||||
// final amountUD = i[3];
|
||||
final comment = i[4];
|
||||
historyMP += "EN COURS DE RECEPTION\n" +
|
||||
dateBrut.toString() +
|
||||
historyMP += dateBrut.toString() +
|
||||
" \n " +
|
||||
issuer.toString() +
|
||||
" \n " +
|
||||
amount.toString() +
|
||||
" Ğ1\n " +
|
||||
comment.toString() +
|
||||
"\n---\n";
|
||||
"\n------------------\n";
|
||||
}
|
||||
|
||||
var history;
|
||||
|
@ -274,7 +273,8 @@ class _MyAppState extends State<MyApp> {
|
|||
if (historyMP == "") {
|
||||
history = historyBC;
|
||||
} else {
|
||||
history = historyMP + '\n' + historyBC;
|
||||
history =
|
||||
"EN COURS DE TRAITEMENT\n" + historyMP + "VALIDÉ\n" + historyBC;
|
||||
}
|
||||
this._outputHistory.text = history;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue