simulateWithEvents function
Simulate a full transaction (typically one built by a tx.* builder) and
return the events it would emit — the quote path: dry-run the real action,
decode the receipt. sender must be the acting owner so account auth
resolves. Throws the same typed errors the real execution would surface.
Implementation
Future<List<pb.Event>> simulateWithEvents(
ReadClient client,
Transaction tx,
String sender,
) async {
tx.setSender(sender);
final res = await _simulate(
client, tx, const ['transaction.effects.status', 'transaction.events']);
return res.transaction.events.events;
}