mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-18 02:07:43 +00:00
WIP: GET Transactions
This commit is contained in:
parent
c7608b0ad7
commit
8705340880
2 changed files with 118 additions and 7 deletions
118
lib/models/isar/models/blockchain_data/epic_transaction.dart
Normal file
118
lib/models/isar/models/blockchain_data/epic_transaction.dart
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Stack Wallet.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Cypher Stack
|
||||||
|
* All Rights Reserved.
|
||||||
|
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
||||||
|
* Generated by Cypher Stack on 2023-05-26
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:isar/isar.dart';
|
||||||
|
import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
|
||||||
|
import 'package:stackwallet/models/isar/models/blockchain_data/input.dart';
|
||||||
|
import 'package:stackwallet/models/isar/models/blockchain_data/output.dart';
|
||||||
|
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||||
|
import 'package:tuple/tuple.dart';
|
||||||
|
|
||||||
|
@Collection()
|
||||||
|
class EpicTransaction {
|
||||||
|
String parentKeyId;
|
||||||
|
int id;
|
||||||
|
String txSlateId;
|
||||||
|
String txType;
|
||||||
|
String creationTs;
|
||||||
|
String confirmationTs;
|
||||||
|
bool confirmed;
|
||||||
|
int numInputs;
|
||||||
|
int numOutputs;
|
||||||
|
String amountCredited;
|
||||||
|
String amountDebited;
|
||||||
|
String fee;
|
||||||
|
int? ttlCutoffHeight; // Use int? for nullable fields
|
||||||
|
List<MessageDto> messages;
|
||||||
|
String storedTx;
|
||||||
|
String kernelExcess;
|
||||||
|
int kernelLookupMinHeight;
|
||||||
|
String? paymentProof; // Use String? for nullable fields
|
||||||
|
|
||||||
|
EpicTransaction({
|
||||||
|
required this.parentKeyId,
|
||||||
|
required this.id,
|
||||||
|
required this.txSlateId,
|
||||||
|
required this.txType,
|
||||||
|
required this.creationTs,
|
||||||
|
required this.confirmationTs,
|
||||||
|
required this.confirmed,
|
||||||
|
required this.numInputs,
|
||||||
|
required this.numOutputs,
|
||||||
|
required this.amountCredited,
|
||||||
|
required this.amountDebited,
|
||||||
|
required this.fee,
|
||||||
|
this.ttlCutoffHeight,
|
||||||
|
required this.messages,
|
||||||
|
required this.storedTx,
|
||||||
|
required this.kernelExcess,
|
||||||
|
required this.kernelLookupMinHeight,
|
||||||
|
this.paymentProof,
|
||||||
|
});
|
||||||
|
|
||||||
|
Tuple2
|
||||||
|
|
||||||
|
factory EpicTransaction.fromJson(Map<String, dynamic> json) {
|
||||||
|
final messagesJson = json['messages']['messages'] as List;
|
||||||
|
final messagesList = messagesJson
|
||||||
|
.map((messageJson) => MessageDto.fromJson(messageJson))
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
return EpicTransaction(
|
||||||
|
parentKeyId: json['parent_key_id'] as String,
|
||||||
|
id: int.parse(json['id'] as String),
|
||||||
|
txSlateId: json['tx_slate_id'] as String,
|
||||||
|
txType: json['tx_type'] as String,
|
||||||
|
creationTs: json['creation_ts'] as String,
|
||||||
|
confirmationTs: json['confirmation_ts'] as String,
|
||||||
|
confirmed: json['confirmed'] as bool,
|
||||||
|
numInputs: int.parse(json['num_inputs'] as String),
|
||||||
|
numOutputs: int.parse(json['num_outputs'] as String),
|
||||||
|
amountCredited: json['amount_credited'] as String,
|
||||||
|
amountDebited: json['amount_debited'] as String,
|
||||||
|
fee: json['fee'] as String,
|
||||||
|
ttlCutoffHeight: int.parse(json['ttl_cutoff_height'] as String),
|
||||||
|
messages: messagesList,
|
||||||
|
storedTx: json['stored_tx'] as String,
|
||||||
|
kernelExcess: json['kernel_excess'] as String,
|
||||||
|
kernelLookupMinHeight: int.parse(json['kernel_lookup_min_height'] as String),
|
||||||
|
paymentProof: json['payment_proof'] as String,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MessageDto {
|
||||||
|
String id;
|
||||||
|
String publicKey;
|
||||||
|
String message;
|
||||||
|
String messageSig;
|
||||||
|
|
||||||
|
MessageDto({
|
||||||
|
required this.id,
|
||||||
|
required this.publicKey,
|
||||||
|
required this.message,
|
||||||
|
required this.messageSig,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory MessageDto.fromJson(Map<String, dynamic> json) {
|
||||||
|
return MessageDto(
|
||||||
|
id: json['id'] as String,
|
||||||
|
publicKey: json['public_key'] as String,
|
||||||
|
message: json['message'] as String,
|
||||||
|
messageSig: json['message_sig'] as String,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1162,13 +1162,6 @@ class EpicCashWallet extends CoinServiceAPI
|
||||||
Map<String, String> txAddressInfo) async {
|
Map<String, String> txAddressInfo) async {
|
||||||
try {
|
try {
|
||||||
var slatesToCommits = await getSlatesToCommits();
|
var slatesToCommits = await getSlatesToCommits();
|
||||||
// final slate0 = jsonDecode(slateMessage);
|
|
||||||
// final slate = jsonDecode(slate0[0] as String);
|
|
||||||
// final part1 = jsonDecode(slate[0] as String);
|
|
||||||
// final part2 = jsonDecode(slate[1] as String);
|
|
||||||
// final slateId = part1[0]['tx_slate_id'];
|
|
||||||
// final commitId = part2['tx']['body']['outputs'][0]['commit'];
|
|
||||||
|
|
||||||
final from = txAddressInfo['from'];
|
final from = txAddressInfo['from'];
|
||||||
final to = txAddressInfo['to'];
|
final to = txAddressInfo['to'];
|
||||||
slatesToCommits[slateData.slateId] = {
|
slatesToCommits[slateData.slateId] = {
|
||||||
|
|
Loading…
Reference in a new issue