cake_wallet/cw_nano/lib/pending_nano_transaction.dart

41 lines
1 KiB
Dart
Raw Normal View History

2023-07-31 13:10:33 +00:00
import 'package:cw_core/pending_transaction.dart';
import 'package:cw_nano/nano_client.dart';
import 'package:cw_nano/nano_util.dart';
class PendingNanoTransaction with PendingTransaction {
PendingNanoTransaction({
required this.nanoClient,
required this.amount,
required this.id,
2023-07-31 15:39:22 +00:00
required this.blocks,
2023-07-31 13:10:33 +00:00
});
final NanoClient nanoClient;
final BigInt amount;
final String id;
2023-07-31 15:39:22 +00:00
final List<Map<String, String>> blocks;
2023-07-31 13:10:33 +00:00
String hex = "unused";
@override
2023-07-31 15:39:22 +00:00
String get amountFormatted {
2023-08-21 20:10:22 +00:00
final String amt = NanoUtil.getRawAsUsableString(amount.toString(), NanoUtil.rawPerNano);
return amt;
}
String get accurateAmountFormatted {
2023-07-31 15:39:22 +00:00
final String amt = NanoUtil.getRawAsUsableString(amount.toString(), NanoUtil.rawPerNano);
final String acc = NanoUtil.getRawAccuracy(amount.toString(), NanoUtil.rawPerNano);
return "$acc$amt";
}
2023-07-31 13:10:33 +00:00
@override
String get feeFormatted => "0";
@override
Future<void> commit() async {
2023-07-31 15:39:22 +00:00
for (var block in blocks) {
await nanoClient.processBlock(block, "send");
}
2023-07-31 13:10:33 +00:00
}
}