2023-07-22 02:59:38 +00:00
|
|
|
import 'dart:math';
|
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-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-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,
|
2023-04-28 02:02:49 +00:00
|
|
|
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
|
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
|
|
|
}
|