Repository navigation
Conversation
…xecute() Outputs were distributed to parties by splicing the transaction's own outputs array. When the transaction was passed as an EIP-12 object, the caller's object lost every output that matched a party (typically all of them), so inspecting or reusing it after execution saw a truncated transaction. Distribute over a copy instead.
🦋 Changeset detectedLatest commit: e77bd0c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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
MockChain.execute()distributed a transaction's outputs to the parties by splicing the transaction's ownoutputsarray:That is invisible when the transaction is passed as an
ErgoUnsignedTransaction(a fresh EIP-12 object is built internally), butexecute()also accepts a plainEIP12UnsignedTransaction— and thentxObjectis the caller's object. After execution, the caller's transaction had lost every output that matched a party — typically all of them — so inspecting the transaction afterwards, asserting on its outputs, or reusing the object operated on a truncated transaction.Reproduced with a payment + change transaction passed via
.toEIP12Object():tx.outputs.lengthwent from 3 beforeexecute()to 1 after it (only the fee output, which matched no party in that setup, survived).Fix
Distribute over a copy (
const outputs = [...txObject.outputs]). Delivery semantics are unchanged: same parties, same order, each output still goes to at most one party.Tests
mockChain.spec.ts: executes an EIP-12 transaction and asserts the caller'soutputs(length, contents, and element identity) andinputsare unchanged, while the payment and change balances are still delivered correctly. It fails on master with exactly the mutation above (expected length 3, got 1) and passes with the fix.Includes a patch changeset for
@fleet-sdk/mock-chain.Built by Kyle Cox (@Kshot9000) — https://x.com/kshot9000
Tips (ERG): 9fcM5RWnAjmP4vx5bnW6yohB6H9bLq8sJbaPLHtwZLtQPB32Pvy