handleTransaction method
EIP-1193: eth_sendTransaction must return hash immediately, not wait for mining.
waitForConfirmation is opt-in for callers that need blocking behavior.
Implementation
Future<String> handleTransaction(
/// Public member.
Map<String, dynamic> txParams, {
/// waitForConfirmation.
bool waitForConfirmation = false,
}) async {
try {
_validateTransaction(txParams);
final tx = await _prepareTransaction(txParams);
final signedTx = await _signTransaction(tx);
final txHash = await _sendTransaction(signedTx);
if (waitForConfirmation) {
await _monitorTransaction(txHash);
} else {
// Fire-and-forget monitoring – log but don't block
// ignore: unawaited_futures
_monitorTransaction(txHash).catchError((_) {});
}
return txHash;
} catch (e) {
if (e is WalletException) rethrow;
throw WalletException('Transaction failed: $e');
}
}