dev
dart 61 lines 1.92 KB
Raw
1 import 'package:cw_core/amount/money.dart';
2 import 'package:cw_core/transaction_direction.dart';
3 import 'package:cw_core/transaction_info.dart';
4 import 'package:cw_core/format_amount.dart';
5 import 'package:cw_zcash/cw_zcash.dart';
6 import 'package:cw_zcash/src/zkooltx.dart';
7
8 class ZcashTransactionInfo extends TransactionInfo {
9 ZcashTransactionInfo({
10 required final String id,
11 required final Money amount,
12 required final Money fee,
13 required final TransactionDirection direction,
14 required final bool isPending,
15 required final DateTime date,
16 required final int height,
17 required final int confirmations,
18 required final String to,
19 final String? memo,
20 final TxType? txType,
21 final bool isRotationReceive = false,
22 final bool isShieldAction = false,
23 final bool isIronwoodMigration = false,
24 }) {
25 this.id = id;
26 this.amount = amount;
27 this.fee = fee;
28 this.height = height;
29 this.direction = direction;
30 this.date = date;
31 this.isPending = isPending;
32 this.confirmations = confirmations;
33 this.to = to;
34 if (memo != null && memo.isNotEmpty) {
35 additionalInfo['memo'] = memo;
36 }
37 if (txType != null) {
38 additionalInfo['txType'] = txType.name;
39 }
40 additionalInfo['isRotationReceive'] = isRotationReceive;
41 additionalInfo['isAutoShield'] = isShieldAction || ZcashWalletService.isAutoshieldTx(txHash);
42 additionalInfo['isIronwoodMigration'] = isIronwoodMigration;
43
44 if (additionalInfo['isAutoShield'] == true) {
45 additionalInfo['memo'] ??= '';
46 additionalInfo['memo'] =
47 '${additionalInfo['memo']}\nThis is an auto-shielding transaction. Enjoy default privacy!.'
48 .trim();
49 }
50 }
51
52 String? _fiatAmount;
53
54 @override
55 String fiatAmount() => _fiatAmount ?? '';
56
57 @override
58 void changeFiatAmount(final String amount) => _fiatAmount = formatAmount(amount);
59
60 String? get memo => additionalInfo['memo'] as String?;
61 }