mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-22 10:34:32 +00:00
Merge branch 'wallets-refactor-epic' of https://github.com/cypherstack/stack_wallet into wallets-refactor-epic
This commit is contained in:
commit
89ca809d9f
2 changed files with 127 additions and 8 deletions
125
lib/models/isar/models/blockchain_data/epic_transaction.dart
Normal file
125
lib/models/isar/models/blockchain_data/epic_transaction.dart
Normal file
|
@ -0,0 +1,125 @@
|
|||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
||||
|
||||
class EpicTransaction {
|
||||
|
||||
@Index()
|
||||
late final String walletId;
|
||||
|
||||
@Index()
|
||||
final String parentKeyId;
|
||||
|
||||
@Index(unique: true, composite: [CompositeIndex("walletId")])
|
||||
late final int id;
|
||||
|
||||
final String? txSlateId;
|
||||
|
||||
@enumerated
|
||||
final TransactionType txType;
|
||||
|
||||
final String creationTs;
|
||||
final String confirmationTs;
|
||||
final bool confirmed;
|
||||
final int numInputs;
|
||||
final int numOutputs;
|
||||
final String amountCredited;
|
||||
final String amountDebited;
|
||||
final String? fee;
|
||||
final String? ttlCutoffHeight;
|
||||
final Messages? messages;
|
||||
final String? storedTx;
|
||||
final String? kernelExcess;
|
||||
final int? kernelLookupMinHeight;
|
||||
final String? paymentProof;
|
||||
|
||||
@Backlink(to: "transactions")
|
||||
final address = IsarLink<Address>();
|
||||
|
||||
EpicTransaction({
|
||||
required this.parentKeyId,
|
||||
required this.id,
|
||||
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,
|
||||
this.fee,
|
||||
this.ttlCutoffHeight,
|
||||
this.messages,
|
||||
this.storedTx,
|
||||
this.kernelExcess,
|
||||
this.kernelLookupMinHeight,
|
||||
this.paymentProof,
|
||||
});
|
||||
|
||||
factory EpicTransaction.fromJson(Map<String, dynamic> json) {
|
||||
return EpicTransaction(
|
||||
parentKeyId: json['parent_key_id'] as String,
|
||||
id: json['id'] as int,
|
||||
txSlateId: json['tx_slate_id'] as String,
|
||||
txType: json['tx_type'] as TransactionType,
|
||||
creationTs: json['creation_ts'] as String,
|
||||
confirmationTs: json['confirmation_ts'] as String,
|
||||
confirmed: json['confirmed'] as bool,
|
||||
numInputs: json['num_inputs'] as int,
|
||||
numOutputs: json['num_outputs'] as int,
|
||||
amountCredited: json['amount_credited'] as String,
|
||||
amountDebited: json['amount_debited'] as String,
|
||||
fee: json['fee'] as String,
|
||||
ttlCutoffHeight: json['ttl_cutoff_height'] as String,
|
||||
messages: json['messages'] != null ? Messages.fromJson(json['messages'] as Map<String, dynamic>) : null,
|
||||
storedTx: json['stored_tx'] as String,
|
||||
kernelExcess: json['kernel_excess'] as String,
|
||||
kernelLookupMinHeight: json['kernel_lookup_min_height'] as int,
|
||||
paymentProof: json['payment_proof'] as String,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Messages {
|
||||
final List<Message> messages;
|
||||
|
||||
Messages({required this.messages});
|
||||
|
||||
factory Messages.fromJson(Map<String, dynamic> json) {
|
||||
final messageList = json['messages'] as List<dynamic>;
|
||||
final messages = messageList.map((message) => Message.fromJson(message as Map<String, dynamic>)).toList();
|
||||
return Messages(messages: messages);
|
||||
}
|
||||
}
|
||||
|
||||
class Message {
|
||||
final String id;
|
||||
final String publicKey;
|
||||
final String? message;
|
||||
final String? messageSig;
|
||||
|
||||
Message({
|
||||
required this.id,
|
||||
required this.publicKey,
|
||||
this.message,
|
||||
this.messageSig,
|
||||
});
|
||||
|
||||
factory Message.fromJson(Map<String, dynamic> json) {
|
||||
return Message(
|
||||
id: json['id'] as String,
|
||||
publicKey: json['public_key'] as String,
|
||||
message: json['message'] as String,
|
||||
messageSig: json['message_sig'] as String,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum EpicTransactionType {
|
||||
//Use Epic transaction type here
|
||||
outgoing,
|
||||
incoming,
|
||||
sentToSelf, // should we keep this?
|
||||
unknown;
|
||||
}
|
|
@ -1277,13 +1277,6 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
Map<String, String> txAddressInfo) async {
|
||||
try {
|
||||
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 to = txAddressInfo['to'];
|
||||
slatesToCommits[slateData.slateId] = {
|
||||
|
@ -1530,6 +1523,8 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
});
|
||||
// return message;
|
||||
final String transactions = message['result'] as String;
|
||||
|
||||
print("RETURNED TRANSACTIONS IS $transactions");
|
||||
final jsonTransactions = json.decode(transactions) as List;
|
||||
|
||||
final List<Tuple2<isar_models.Transaction, isar_models.Address?>> txnsData =
|
||||
|
@ -1594,7 +1589,6 @@ class EpicCashWallet extends CoinServiceAPI
|
|||
isLelantus: false,
|
||||
slateId: slateId,
|
||||
nonce: null,
|
||||
// otherData: tx["id"].toString(),
|
||||
otherData: tx['onChainNote'].toString(),
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
|
|
Loading…
Reference in a new issue