2023-11-06 21:37:18 +00:00
|
|
|
import 'package:cw_wownero/pending_wownero_transaction.dart';
|
2024-01-05 18:59:01 +00:00
|
|
|
import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart';
|
2023-11-20 15:15:36 +00:00
|
|
|
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
2023-11-03 19:46:55 +00:00
|
|
|
import 'package:stackwallet/models/paynym/paynym_account_lite.dart';
|
2023-09-14 23:34:01 +00:00
|
|
|
import 'package:stackwallet/utilities/amount/amount.dart';
|
|
|
|
import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart';
|
2023-11-20 19:55:22 +00:00
|
|
|
import 'package:tezart/tezart.dart' as tezart;
|
2023-11-03 19:46:55 +00:00
|
|
|
import 'package:web3dart/web3dart.dart' as web3dart;
|
2023-09-14 23:34:01 +00:00
|
|
|
|
|
|
|
class TxData {
|
|
|
|
final FeeRateType? feeRateType;
|
|
|
|
final int? feeRateAmount;
|
|
|
|
final int? satsPerVByte;
|
|
|
|
|
|
|
|
final Amount? fee;
|
|
|
|
final int? vSize;
|
|
|
|
|
|
|
|
final String? raw;
|
|
|
|
|
|
|
|
final String? txid;
|
|
|
|
final String? txHash;
|
|
|
|
|
|
|
|
final String? note;
|
|
|
|
final String? noteOnChain;
|
|
|
|
|
2023-11-03 19:46:55 +00:00
|
|
|
final String? memo;
|
|
|
|
|
2023-09-14 23:34:01 +00:00
|
|
|
final List<({String address, Amount amount})>? recipients;
|
|
|
|
final Set<UTXO>? utxos;
|
2023-11-08 19:57:38 +00:00
|
|
|
final List<UTXO>? usedUTXOs;
|
2023-09-14 23:34:01 +00:00
|
|
|
|
|
|
|
final String? changeAddress;
|
|
|
|
|
|
|
|
final String? frostMSConfig;
|
|
|
|
|
2023-11-03 19:46:55 +00:00
|
|
|
// paynym specific
|
|
|
|
final PaynymAccountLite? paynymAccountLite;
|
|
|
|
|
|
|
|
// eth token specific
|
|
|
|
final web3dart.Transaction? web3dartTransaction;
|
|
|
|
final int? nonce;
|
|
|
|
final BigInt? chainId;
|
|
|
|
final BigInt? feeInWei;
|
|
|
|
|
2023-11-06 21:37:18 +00:00
|
|
|
// wownero specific
|
|
|
|
final PendingWowneroTransaction? pendingWowneroTransaction;
|
|
|
|
|
2023-11-20 15:15:36 +00:00
|
|
|
// firo lelantus specific
|
|
|
|
final int? jMintValue;
|
|
|
|
final List<int>? spendCoinIndexes;
|
|
|
|
final int? height;
|
|
|
|
final TransactionType? txType;
|
|
|
|
final TransactionSubType? txSubType;
|
|
|
|
final List<Map<String, dynamic>>? mintsMapLelantus;
|
|
|
|
|
2023-11-20 19:55:22 +00:00
|
|
|
// tezos specific
|
|
|
|
final tezart.OperationsList? tezosOperationsList;
|
|
|
|
|
2023-12-13 17:26:30 +00:00
|
|
|
// firo spark specific
|
|
|
|
final List<
|
|
|
|
({
|
|
|
|
String address,
|
|
|
|
Amount amount,
|
|
|
|
String memo,
|
|
|
|
})>? sparkRecipients;
|
2023-12-27 16:01:13 +00:00
|
|
|
final List<TxData>? sparkMints;
|
2023-12-13 17:26:30 +00:00
|
|
|
|
2024-01-05 18:59:01 +00:00
|
|
|
final TransactionV2? tempTx;
|
|
|
|
|
2023-09-14 23:34:01 +00:00
|
|
|
TxData({
|
|
|
|
this.feeRateType,
|
|
|
|
this.feeRateAmount,
|
|
|
|
this.satsPerVByte,
|
|
|
|
this.fee,
|
|
|
|
this.vSize,
|
|
|
|
this.raw,
|
|
|
|
this.txid,
|
|
|
|
this.txHash,
|
|
|
|
this.note,
|
|
|
|
this.noteOnChain,
|
2023-11-03 19:46:55 +00:00
|
|
|
this.memo,
|
2023-09-14 23:34:01 +00:00
|
|
|
this.recipients,
|
|
|
|
this.utxos,
|
2023-11-08 19:57:38 +00:00
|
|
|
this.usedUTXOs,
|
2023-09-14 23:34:01 +00:00
|
|
|
this.changeAddress,
|
|
|
|
this.frostMSConfig,
|
2023-11-03 19:46:55 +00:00
|
|
|
this.paynymAccountLite,
|
|
|
|
this.web3dartTransaction,
|
|
|
|
this.nonce,
|
|
|
|
this.chainId,
|
|
|
|
this.feeInWei,
|
2023-11-06 21:37:18 +00:00
|
|
|
this.pendingWowneroTransaction,
|
2023-11-20 15:15:36 +00:00
|
|
|
this.jMintValue,
|
|
|
|
this.spendCoinIndexes,
|
|
|
|
this.height,
|
|
|
|
this.txType,
|
|
|
|
this.txSubType,
|
|
|
|
this.mintsMapLelantus,
|
2023-11-20 19:55:22 +00:00
|
|
|
this.tezosOperationsList,
|
2023-12-13 17:26:30 +00:00
|
|
|
this.sparkRecipients,
|
2023-12-27 16:01:13 +00:00
|
|
|
this.sparkMints,
|
2024-01-05 18:59:01 +00:00
|
|
|
this.tempTx,
|
2023-09-14 23:34:01 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
Amount? get amount => recipients != null && recipients!.isNotEmpty
|
|
|
|
? recipients!
|
|
|
|
.map((e) => e.amount)
|
|
|
|
.reduce((total, amount) => total += amount)
|
|
|
|
: null;
|
|
|
|
|
2023-12-21 00:00:02 +00:00
|
|
|
Amount? get amountSpark =>
|
|
|
|
sparkRecipients != null && sparkRecipients!.isNotEmpty
|
|
|
|
? sparkRecipients!
|
|
|
|
.map((e) => e.amount)
|
|
|
|
.reduce((total, amount) => total += amount)
|
|
|
|
: null;
|
|
|
|
|
2023-09-14 23:34:01 +00:00
|
|
|
int? get estimatedSatsPerVByte => fee != null && vSize != null
|
|
|
|
? (fee!.raw ~/ BigInt.from(vSize!)).toInt()
|
|
|
|
: null;
|
|
|
|
|
|
|
|
TxData copyWith({
|
|
|
|
FeeRateType? feeRateType,
|
|
|
|
int? feeRateAmount,
|
|
|
|
int? satsPerVByte,
|
|
|
|
Amount? fee,
|
|
|
|
int? vSize,
|
|
|
|
String? raw,
|
|
|
|
String? txid,
|
|
|
|
String? txHash,
|
|
|
|
String? note,
|
|
|
|
String? noteOnChain,
|
2023-11-03 19:46:55 +00:00
|
|
|
String? memo,
|
2023-09-14 23:34:01 +00:00
|
|
|
Set<UTXO>? utxos,
|
2023-11-08 19:57:38 +00:00
|
|
|
List<UTXO>? usedUTXOs,
|
2023-09-14 23:34:01 +00:00
|
|
|
List<({String address, Amount amount})>? recipients,
|
|
|
|
String? frostMSConfig,
|
|
|
|
String? changeAddress,
|
2023-11-03 19:46:55 +00:00
|
|
|
PaynymAccountLite? paynymAccountLite,
|
|
|
|
web3dart.Transaction? web3dartTransaction,
|
|
|
|
int? nonce,
|
|
|
|
BigInt? chainId,
|
|
|
|
BigInt? feeInWei,
|
2023-11-06 21:37:18 +00:00
|
|
|
PendingWowneroTransaction? pendingWowneroTransaction,
|
2023-11-20 15:15:36 +00:00
|
|
|
int? jMintValue,
|
|
|
|
List<int>? spendCoinIndexes,
|
|
|
|
int? height,
|
|
|
|
TransactionType? txType,
|
|
|
|
TransactionSubType? txSubType,
|
|
|
|
List<Map<String, dynamic>>? mintsMapLelantus,
|
2023-11-20 19:55:22 +00:00
|
|
|
tezart.OperationsList? tezosOperationsList,
|
2023-12-13 17:26:30 +00:00
|
|
|
List<
|
|
|
|
({
|
|
|
|
String address,
|
|
|
|
Amount amount,
|
|
|
|
String memo,
|
|
|
|
})>?
|
|
|
|
sparkRecipients,
|
2023-12-27 16:01:13 +00:00
|
|
|
List<TxData>? sparkMints,
|
2024-01-05 18:59:01 +00:00
|
|
|
TransactionV2? tempTx,
|
2023-09-14 23:34:01 +00:00
|
|
|
}) {
|
|
|
|
return TxData(
|
|
|
|
feeRateType: feeRateType ?? this.feeRateType,
|
|
|
|
feeRateAmount: feeRateAmount ?? this.feeRateAmount,
|
|
|
|
satsPerVByte: satsPerVByte ?? this.satsPerVByte,
|
|
|
|
fee: fee ?? this.fee,
|
|
|
|
vSize: vSize ?? this.vSize,
|
|
|
|
raw: raw ?? this.raw,
|
|
|
|
txid: txid ?? this.txid,
|
|
|
|
txHash: txHash ?? this.txHash,
|
|
|
|
note: note ?? this.note,
|
|
|
|
noteOnChain: noteOnChain ?? this.noteOnChain,
|
2023-11-03 19:46:55 +00:00
|
|
|
memo: memo ?? this.memo,
|
2023-09-14 23:34:01 +00:00
|
|
|
utxos: utxos ?? this.utxos,
|
2023-11-08 19:57:38 +00:00
|
|
|
usedUTXOs: usedUTXOs ?? this.usedUTXOs,
|
2023-09-14 23:34:01 +00:00
|
|
|
recipients: recipients ?? this.recipients,
|
|
|
|
frostMSConfig: frostMSConfig ?? this.frostMSConfig,
|
|
|
|
changeAddress: changeAddress ?? this.changeAddress,
|
2023-11-03 19:46:55 +00:00
|
|
|
paynymAccountLite: paynymAccountLite ?? this.paynymAccountLite,
|
|
|
|
web3dartTransaction: web3dartTransaction ?? this.web3dartTransaction,
|
|
|
|
nonce: nonce ?? this.nonce,
|
|
|
|
chainId: chainId ?? this.chainId,
|
|
|
|
feeInWei: feeInWei ?? this.feeInWei,
|
2023-11-06 21:37:18 +00:00
|
|
|
pendingWowneroTransaction:
|
|
|
|
pendingWowneroTransaction ?? this.pendingWowneroTransaction,
|
2023-11-20 15:15:36 +00:00
|
|
|
jMintValue: jMintValue ?? this.jMintValue,
|
|
|
|
spendCoinIndexes: spendCoinIndexes ?? this.spendCoinIndexes,
|
|
|
|
height: height ?? this.height,
|
|
|
|
txType: txType ?? this.txType,
|
|
|
|
txSubType: txSubType ?? this.txSubType,
|
|
|
|
mintsMapLelantus: mintsMapLelantus ?? this.mintsMapLelantus,
|
2023-11-20 19:55:22 +00:00
|
|
|
tezosOperationsList: tezosOperationsList ?? this.tezosOperationsList,
|
2023-12-13 17:26:30 +00:00
|
|
|
sparkRecipients: sparkRecipients ?? this.sparkRecipients,
|
2023-12-27 16:01:13 +00:00
|
|
|
sparkMints: sparkMints ?? this.sparkMints,
|
2024-01-05 18:59:01 +00:00
|
|
|
tempTx: tempTx ?? this.tempTx,
|
2023-09-14 23:34:01 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() => 'TxData{'
|
|
|
|
'feeRateType: $feeRateType, '
|
|
|
|
'feeRateAmount: $feeRateAmount, '
|
|
|
|
'satsPerVByte: $satsPerVByte, '
|
|
|
|
'fee: $fee, '
|
|
|
|
'vSize: $vSize, '
|
|
|
|
'raw: $raw, '
|
|
|
|
'txid: $txid, '
|
|
|
|
'txHash: $txHash, '
|
|
|
|
'note: $note, '
|
|
|
|
'noteOnChain: $noteOnChain, '
|
2023-11-03 19:46:55 +00:00
|
|
|
'memo: $memo, '
|
2023-09-14 23:34:01 +00:00
|
|
|
'recipients: $recipients, '
|
|
|
|
'utxos: $utxos, '
|
2023-11-08 19:57:38 +00:00
|
|
|
'usedUTXOs: $usedUTXOs, '
|
2023-09-14 23:34:01 +00:00
|
|
|
'frostMSConfig: $frostMSConfig, '
|
2023-11-03 19:46:55 +00:00
|
|
|
'changeAddress: $changeAddress, '
|
|
|
|
'paynymAccountLite: $paynymAccountLite, '
|
|
|
|
'web3dartTransaction: $web3dartTransaction, '
|
|
|
|
'nonce: $nonce, '
|
|
|
|
'chainId: $chainId, '
|
|
|
|
'feeInWei: $feeInWei, '
|
2023-11-06 21:37:18 +00:00
|
|
|
'pendingWowneroTransaction: $pendingWowneroTransaction, '
|
2023-11-20 15:15:36 +00:00
|
|
|
'jMintValue: $jMintValue, '
|
|
|
|
'spendCoinIndexes: $spendCoinIndexes, '
|
|
|
|
'height: $height, '
|
|
|
|
'txType: $txType, '
|
|
|
|
'txSubType: $txSubType, '
|
|
|
|
'mintsMapLelantus: $mintsMapLelantus, '
|
2023-11-20 19:55:22 +00:00
|
|
|
'tezosOperationsList: $tezosOperationsList, '
|
2023-12-13 17:26:30 +00:00
|
|
|
'sparkRecipients: $sparkRecipients, '
|
2023-12-27 16:01:13 +00:00
|
|
|
'sparkMints: $sparkMints, '
|
2024-01-05 18:59:01 +00:00
|
|
|
'tempTx: $tempTx, '
|
2023-09-14 23:34:01 +00:00
|
|
|
'}';
|
|
|
|
}
|