2023-03-31 18:41:56 +00:00
|
|
|
import 'package:cw_core/amount_converter.dart';
|
|
|
|
import 'package:cw_core/crypto_currency.dart';
|
2023-03-16 17:24:21 +00:00
|
|
|
import 'package:cw_core/pending_transaction.dart';
|
|
|
|
import 'package:cw_ethereum/ethereum_client.dart';
|
|
|
|
import 'package:cw_ethereum/ethereum_transaction_credentials.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 {
|
|
|
|
final EthereumClient client;
|
|
|
|
final EthereumTransactionCredentials credentials;
|
2023-04-05 16:01:20 +00:00
|
|
|
final EthPrivateKey privateKey;
|
2023-03-31 18:41:56 +00:00
|
|
|
final int amount;
|
2023-03-16 17:24:21 +00:00
|
|
|
|
|
|
|
PendingEthereumTransaction({
|
|
|
|
required this.client,
|
|
|
|
required this.credentials,
|
|
|
|
required this.privateKey,
|
2023-03-31 18:41:56 +00:00
|
|
|
required this.amount,
|
2023-03-16 17:24:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
@override
|
2023-03-31 18:41:56 +00:00
|
|
|
String get amountFormatted => AmountConverter.amountIntToString(CryptoCurrency.eth, amount);
|
2023-03-16 17:24:21 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Future<void> commit() async {
|
|
|
|
for (var output in credentials.outputs) {
|
|
|
|
await client.sendTransaction(privateKey, output.address, output.cryptoAmount!);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
// TODO: implement feeFormatted
|
2023-03-31 18:41:56 +00:00
|
|
|
String get feeFormatted => "0.01";
|
2023-03-16 17:24:21 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
// TODO: implement hex
|
2023-03-31 18:41:56 +00:00
|
|
|
String get hex => "hex";
|
2023-03-16 17:24:21 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
// TODO: implement id
|
2023-03-31 18:41:56 +00:00
|
|
|
String get id => "id";
|
2023-03-16 17:24:21 +00:00
|
|
|
}
|