cake_wallet/cw_ethereum/lib/pending_ethereum_transaction.dart

36 lines
925 B
Dart
Raw Normal View History

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-04-05 16:01:20 +00:00
import 'package:web3dart/web3dart.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-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-03-16 17:24:21 +00:00
});
@override
2023-04-05 17:20:25 +00:00
String get amountFormatted =>
EtherAmount.inWei(BigInt.parse(amount)).getValueInUnit(EtherUnit.ether).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
String get feeFormatted => EtherAmount.inWei(fee).getValueInUnit(EtherUnit.ether).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
}