Skip to content

Commit

Permalink
fix: do not modify transaction during simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry authored and steveluscher committed Apr 13, 2022
1 parent e707c2b commit f9175dd
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3878,7 +3878,14 @@ export class Connection {
): Promise<RpcResponseAndContext<SimulatedTransactionResponse>> {
let transaction;
if (transactionOrMessage instanceof Transaction) {
transaction = transactionOrMessage;
let originalTx: Transaction = transactionOrMessage;
transaction = new Transaction({
recentBlockhash: originalTx.recentBlockhash,
nonceInfo: originalTx.nonceInfo,
feePayer: originalTx.feePayer,
signatures: [...originalTx.signatures],
});
transaction.instructions = transactionOrMessage.instructions;
} else {
transaction = Transaction.populate(transactionOrMessage);
}
Expand All @@ -3888,11 +3895,7 @@ export class Connection {
} else {
let disableCache = this._disableBlockhashCaching;
for (;;) {
if (!transaction.recentBlockhash) {
transaction.recentBlockhash = await this._recentBlockhash(
disableCache,
);
}
transaction.recentBlockhash = await this._recentBlockhash(disableCache);

if (!signers) break;

Expand Down

0 comments on commit f9175dd

Please sign in to comment.