Skip to content

fix(transaction): use arg.toObject() in Transaction#fromObject#29

Merged
exo-mv merged 1 commit into
masterfrom
neo/yvz5qa607plo/fix-transaction-toobject-undefined
Jun 4, 2026
Merged

fix(transaction): use arg.toObject() in Transaction#fromObject#29
exo-mv merged 1 commit into
masterfrom
neo/yvz5qa607plo/fix-transaction-toobject-undefined

Conversation

@exodus-neo

@exodus-neo exodus-neo Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Transaction.prototype.fromObject called transaction.toObject() while the local transaction variable was still undefined, so calling fromObject with a Transaction instance always threw TypeError: Cannot read properties of undefined (reading 'toObject').
  • Fixed by reading from the arg parameter (arg.toObject()), which holds the Transaction instance in that branch — consistent with the arg instanceof Transaction guard and upstream bitcore-lib behavior.
  • Added a regression test for fromObject with a Transaction instance, 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 fromObject is called directly with a Transaction instance (e.g. new Transaction().fromObject(otherTx)). The constructor routes Transaction instances to shallowCopy instead, which is why this went unnoticed. The bug is long-standing (inherited from the upstream fromObject history), not a recently introduced regression, so no Fixes regression from #N reference is included.

Verification

  • npm test: 451 passing (was 450; +1 new regression test), 0 failing.
  • The new test reproduces the exact TypeError before the fix (red) and passes after (green).
  • npm run lint could not run in this environment: gulp/jshint are not installed (absent from devDependencies). The change is a single-token edit consistent with the surrounding style, and both changed files pass node --check.

Origin: https://exodusio.slack.com/archives/C0B3VPDD5S9/p1780580205114779

…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 exo-mv merged commit f645588 into master Jun 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant