fix: don't override a transaction's recentBlockhash when calling simulate if it's already set (#24280)

* Update simulate to add blockhash if not exist

Simulate has been overriding the recentBlockhash of the passed
Transaction which can be considered destructive and with side effects.

Since the purpose of this function is to purely simulate, it should not
override recentBlockhash if it has already been set

Refs https://github.com/solana-labs/solana/issues/24279

* Apply prettier
This commit is contained in:
David Mohl 2022-04-13 11:15:50 +09:00 committed by GitHub
parent a43ff3bbcb
commit d8c45a69c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -3888,7 +3888,11 @@ export class Connection {
} else {
let disableCache = this._disableBlockhashCaching;
for (;;) {
transaction.recentBlockhash = await this._recentBlockhash(disableCache);
if (!transaction.recentBlockhash) {
transaction.recentBlockhash = await this._recentBlockhash(
disableCache,
);
}
if (!signers) break;