cake_wallet/cw_ethereum/lib/pending_ethereum_transaction.dart

37 lines
910 B
Dart
Raw Normal View History

2023-07-22 02:59:38 +00:00
import 'dart:math';
import 'dart:typed_data';
2023-03-16 17:24:21 +00:00
import 'package:cw_core/pending_transaction.dart';
import 'package:web3dart/crypto.dart';
2023-03-16 17:24:21 +00:00
class PendingEthereumTransaction with PendingTransaction {
2023-04-05 17:20:25 +00:00
final Function sendTransaction;
final Uint8List signedTransaction;
final BigInt fee;
final String amount;
2023-07-22 02:59:38 +00:00
final int exponent;
2023-03-16 17:24:21 +00:00
PendingEthereumTransaction({
2023-04-05 17:20:25 +00:00
required this.sendTransaction,
required this.signedTransaction,
required this.fee,
required this.amount,
2023-07-22 02:59:38 +00:00
required this.exponent,
2023-03-16 17:24:21 +00:00
});
@override
2023-07-22 02:59:38 +00:00
String get amountFormatted => (BigInt.parse(amount) / BigInt.from(pow(10, exponent))).toString();
2023-03-16 17:24:21 +00:00
@override
2023-06-06 01:34:11 +00:00
Future<void> commit() async => await sendTransaction();
2023-03-16 17:24:21 +00:00
@override
2023-07-22 02:59:38 +00:00
String get feeFormatted => (fee / BigInt.from(pow(10, 18))).toString();
2023-03-16 17:24:21 +00:00
@override
String get hex => bytesToHex(signedTransaction, include0x: true);
2023-03-16 17:24:21 +00:00
@override
String get id => '';
2023-03-16 17:24:21 +00:00
}