fix(transaction): use arg.toObject() in Transaction#fromObject#29
Merged
exo-mv merged 1 commit intoJun 4, 2026
Merged
Conversation
…stances fromObject called transaction.toObject() while the transaction variable was still undefined, so passing a Transaction instance threw "TypeError: Cannot read properties of undefined (reading 'toObject')". Read from the arg parameter, which holds the Transaction instance. Add a regression test for this previously uncovered path. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Co-authored-by: Claude Code (claude-opus-4-8[1m]) <noreply@anthropic.com>
exo-mv
approved these changes
Jun 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Transaction.prototype.fromObjectcalledtransaction.toObject()while the localtransactionvariable was stillundefined, so callingfromObjectwith aTransactioninstance always threwTypeError: Cannot read properties of undefined (reading 'toObject').argparameter (arg.toObject()), which holds theTransactioninstance in that branch — consistent with thearg instanceof Transactionguard and upstream bitcore-lib behavior.fromObjectwith aTransactioninstance, a path that had no coverage in the active test suite (which is why the typo shipped).Details
The buggy branch is only reachable when
fromObjectis called directly with aTransactioninstance (e.g.new Transaction().fromObject(otherTx)). The constructor routesTransactioninstances toshallowCopyinstead, which is why this went unnoticed. The bug is long-standing (inherited from the upstreamfromObjecthistory), not a recently introduced regression, so noFixes regression from #Nreference is included.Verification
npm test: 451 passing (was 450; +1 new regression test), 0 failing.TypeErrorbefore the fix (red) and passes after (green).npm run lintcould not run in this environment:gulp/jshintare not installed (absent fromdevDependencies). The change is a single-token edit consistent with the surrounding style, and both changed files passnode --check.Origin: https://exodusio.slack.com/archives/C0B3VPDD5S9/p1780580205114779