simulateTransactionRaw method
Future<JsonRpcContextResponse<TransactionStatus> >
simulateTransactionRaw(
- Transaction transaction, {
- bool includeAccounts = false,
- Commitment? commitment,
Simulates sending a Transaction.
Implementation
Future<JsonRpcContextResponse<TransactionStatus>> simulateTransactionRaw(
Transaction transaction, {
final bool includeAccounts = false,
final Commitment? commitment,
}) async {
// if (nonceInfo != null && signers != null) {
// transaction.sign(signers);
// } else {
// bool disableCache = false;
// for (;;) {
// final latestBlockhash = await _blockhashCache.get(this, disabled: disableCache);
// transaction = transaction.copyWith(
// recentBlockhash: latestBlockhash.blockhash,
// lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
// );
// if (signers == null) {
// break;
// }
// transaction.sign(signers);
// final Uint8List? payerSignature = transaction.signature;
// if (payerSignature == null) {
// throw const TransactionException('No signature.'); // should never happen
// }
// final String signature = base64.encode(payerSignature);
// if (!_blockhashCache.simulatedSignatures.contains(signature) &&
// !_blockhashCache.transactionSignatures.contains(signature)) {
// // The signature of this transaction has not been seen before with the current
// // [latestBlockhash.blockhash], all done. Let's break
// _blockhashCache.simulatedSignatures.add(signature);
// break;
// } else {
// // This transaction would be treated as duplicate (its derived signature matched to one of
// // the already recorded signatures). So, we must fetch a new blockhash for a different
// // signature by disabling our cache not to wait for the cache expiration
// // [BlockhashCache.timeout].
// disableCache = true;
// }
// }
// }
final SimulateTransactionConfig config = SimulateTransactionConfig(
commitment: commitment,
encoding: TransactionEncoding.base64,
accounts: includeAccounts
? AccountsFilter(
addresses:
transaction.message.nonProgramIds().toList(growable: false))
: null,
);
final String signedTransaction =
transaction.serialize().getString(BufferEncoding.base64);
return send(SimulateTransaction(signedTransaction, config: config));
}