Skip to content

Commit

Permalink
fix: ingest only the relevant properties when constructing `Transacti…
Browse files Browse the repository at this point in the history
…ons`
  • Loading branch information
steveluscher committed Jul 2, 2022
1 parent 5f3b7bd commit 6f6e517
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions web3.js/src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 6f6e517

Please sign in to comment.