fix: do not modify transaction during simulation

This commit is contained in:
Justin Starry 2022-04-13 12:54:46 +08:00 committed by Steven Luscher
parent aea17c35ae
commit e13efa0883
1 changed files with 9 additions and 6 deletions

View File

@ -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);
}
@ -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;