feat(tx-construction): expose tx-builder utils and add fluent minting#1686
Merged
Conversation
buildRedeemers, buildWitness and computeCollateral are defined in tx-builder/utils.ts but the tx-builder barrel never re-exported them, so they were absent from the package's public API. Consumers assembling Plutus transactions manually (mint / script-spend / withdrawal redeemers, collateral) had to reimplement buildRedeemers and could not use computeCollateral. Re-export ./utils from the barrel to expose them. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
b92758b to
6a6f296
Compare
aa81090 to
3737871
Compare
3f50970 to
fca0493
Compare
AngelCastilloB
previously approved these changes
Jun 17, 2026
Add `TxBuilder.addMint({ policy, assets, redeemer })` so consumers can mint or
burn assets under a policy without dropping to the lower-level `initializeTx`.
The policy script is attached to the witness set, the asset quantities are added
to the body, and (for Plutus policies) the redeemer is included and its execution
units evaluated during `build()`. Previously `GenericTxBuilder` had no minting
support — `mint` was never forwarded to `initializeTx`.
This also fixes redeemer index reconciliation for non-spend purposes: builder
redeemers are stamped with a sentinel index by `buildRedeemers`, but
`reorgRedeemers` only reindexed spend redeemers, so mint/withdrawal/certificate
redeemers reached `updateRedeemers` with an index the evaluator could not match.
Sentinel-indexed non-spend redeemers are now reindexed by their position within
their purpose; redeemers that already carry a concrete index are left untouched.
Coverage: unit tests for plutus mint, burn (negative quantity), native-script
mint without a redeemer, and multi-policy redeemer reindexing; plus an e2e test
that mints through the builder and submits. The `web-extension` remote-api
property map gains the new method.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
306b4c4 to
e0a82a1
Compare
GenericTxBuilder only merged extraSigners into the signing options when signingOptions were also set. Calling extraSigners() on its own therefore added the witnesses at sign() but not during fee estimation, producing an insufficient-fee transaction (e.g. minting under a native policy that requires an extra signature). Always include extra signers in the fee-estimation signing options. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
AngelCastilloB
approved these changes
Jun 18, 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.
Closes gaps in
@cardano-sdk/tx-constructionthat forced consumers (e.g. Lace's full-domain Cardano transaction builder) to reimplement SDK internals or drop to lower-level APIs.1. Export tx-builder utils
buildRedeemers,buildWitnessandcomputeCollateralare defined intx-builder/utils.tsbut the barrel never re-exported./utils, so they were absent from the public API. Fixed withexport * from './utils'(pure addition, no collisions).2. Fluent minting on the transaction builder
Add
TxBuilder.addMint({ policy, assets, redeemer }). The policy script is attached to the witness set, the asset quantities are added to the body, and for Plutus policies the redeemer is included and its execution units evaluated duringbuild(). PreviouslyGenericTxBuilderhad no minting support —mintwas never forwarded toinitializeTx.3. Canonical redeemer indexing (review follow-up)
Redeemer pointers must reference an item's position in the canonically-sorted transaction-body collection, not insertion order.
RedeemersByTypenow keys redeemers by on-chain identifier (mint →PolicyId, withdrawal →RewardAccount, vote →Voter), andcomputeMinimumCostderives each index from the body:The
@cardano-sdk/web-extensionremote-api property map gains the newaddMintmethod.Tests
TxBuilderPlutusScripts.test.ts): plutus mint with redeemer, burn (negative quantity), native-script mint without a redeemer, and multi-policy redeemer indexing.selectionConstraints.test.ts): withdrawal indices computed among script reward accounts by hash, with a key-hash withdrawal interleaved and the body out of canonical order. Full@cardano-sdk/tx-constructionsuite green (221).PersonalWallet/mint.test.ts): the mint scenario now builds throughcreateTxBuilder().addMint(...).build().sign()instead ofinitializeTx, validated on-chain by the e2e workflow (wallet_epoch_0, runs on PR).Open
Vote redeemer ordering is derived from the ledger Voter Ord (the cardano-c reference for votes was past the readable excerpt) and lacks a dedicated vector — flagged in-thread for confirmation against the reviewer's vote vectors. Withdrawal-with-redeemer is otherwise reachable via the documented
customizehook; a first-class "build unsigned tx for external signers" path remains a follow-up.🤖 Generated with Claude Code