From 6f6e5172d3f443882d9128303da6a4ee916d62f4 Mon Sep 17 00:00:00 2001 From: steveluscher Date: Tue, 7 Jun 2022 20:08:52 -0700 Subject: [PATCH] fix: ingest only the relevant properties when constructing `Transactions` --- web3.js/src/transaction.ts | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/web3.js/src/transaction.ts b/web3.js/src/transaction.ts index 4a9c842f11..686dd587a3 100644 --- a/web3.js/src/transaction.ts +++ b/web3.js/src/transaction.ts @@ -258,17 +258,25 @@ export class Transaction { ) { if (!opts) { return; - } else if ( - Object.prototype.hasOwnProperty.call(opts, 'lastValidBlockHeight') - ) { - const newOpts = opts as TransactionBlockhashCtor; - Object.assign(this, newOpts); - this.recentBlockhash = newOpts.blockhash; - this.lastValidBlockHeight = newOpts.lastValidBlockHeight; + } + if (opts.feePayer) { + this.feePayer = opts.feePayer; + } + if (opts.signatures) { + this.signatures = opts.signatures; + } + if (Object.prototype.hasOwnProperty.call(opts, 'lastValidBlockHeight')) { + const {blockhash, lastValidBlockHeight} = + opts as TransactionBlockhashCtor; + this.recentBlockhash = blockhash; + this.lastValidBlockHeight = lastValidBlockHeight; } else { - const oldOpts = opts as TransactionCtorFields_DEPRECATED; - Object.assign(this, oldOpts); - this.recentBlockhash = oldOpts.recentBlockhash; + const {recentBlockhash, nonceInfo} = + opts as TransactionCtorFields_DEPRECATED; + if (nonceInfo) { + this.nonceInfo = nonceInfo; + } + this.recentBlockhash = recentBlockhash; } }