waitForTransaction method
Poll getTransaction until digest is available or timeout elapses.
Implementation
Future<ExecutedTransaction> waitForTransaction(
String digest, {
Duration timeout = const Duration(seconds: 60),
Duration pollInterval = const Duration(milliseconds: 500),
List<String>? readMask,
}) async {
final deadline = DateTime.now().add(timeout);
while (true) {
try {
final tx = await getTransaction(digest, readMask: readMask);
if (tx.digest.isNotEmpty) return tx;
} catch (_) {
// not yet available; keep polling
}
if (DateTime.now().isAfter(deadline)) {
throw TimeoutException(
'waitForTransaction($digest) timed out', timeout);
}
await Future.delayed(pollInterval);
}
}