2023-04-28 02:02:49 +00:00
|
|
|
import 'dart:typed_data';
|
|
|
|
|
2023-03-16 17:24:21 +00:00
|
|
|
import 'package:cw_core/pending_transaction.dart';
|
2023-04-28 02:02:49 +00:00
|
|
|
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;
|
2023-04-28 02:02:49 +00:00
|
|
|
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,
|
2023-04-28 02:02:49 +00:00
|
|
|
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 =>
|
2023-04-28 02:02:49 +00:00
|
|
|
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
|
2023-04-28 02:02:49 +00:00
|
|
|
String get feeFormatted => EtherAmount.inWei(fee).getValueInUnit(EtherUnit.ether).toString();
|
2023-03-16 17:24:21 +00:00
|
|
|
|
|
|
|
@override
|
2023-04-28 02:02:49 +00:00
|
|
|
String get hex => bytesToHex(signedTransaction, include0x: true);
|
2023-03-16 17:24:21 +00:00
|
|
|
|
|
|
|
@override
|
2023-04-28 02:02:49 +00:00
|
|
|
String get id => '';
|
2023-03-16 17:24:21 +00:00
|
|
|
}
|