Repository navigation
Conversation
This branch has not been deployed
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.
Stacked on #858 (which is stacked on #864): merge those first.
What
A new transaction builder in
@meshsdk/transaction,TxBuilder. A transaction is a list of parts —output(...),spend.plutus(...),mint.native(...),certificate.stakeDelegation(...), ... — given to the builder with a payer; the builder selects inputs, adds change, works out the fee, collateral and execution units, and returns the transaction as an object that signs, submits and waits for itself. Several transactions that depend on each other are built at once as a plan, sent in order and followed to the chain. The fluentMeshTxBuilderkeeps working, deprecated, on top of the new builder.Contents
Building
{ changeAddress, utxos }; UTxOs are taken in any of three forms (the builder'sUtxo, a MeshUTxO, the CBOR of a transaction unspent output).paramsandcostModels; a builder with a network alone reads and signs.TxBuildError,TxPartError,TxPlanError) with codes and details;TxError.is(error, code)checks them.One transaction:
BuiltTxbuild()returns aBuiltTx: the data of the build,sign()(a wallet, a private key throughkeySigner, or a signer of transaction hashes),addWitnesses(),submit(),awaitInclusion(), and JSON withbuilder.restore().builder.fromCbor(tx, { knownUtxos })makes the same object of a transaction built elsewhere, to read its outputs, fee, collateral and missing signers before signing;{ blind: true }signs without reading its inputs.requiredSigners(tx, spent)lists who must sign.Several transactions:
TxPlanbuilder.plan(steps, { payer })builds a group of transactions at once;run()signs, sends and waits for each in order, with statuses frombuilttofinal, deadlines,stop(),replan()andplan.add().Reading CBOR
CborReader, bounded in size, depth and work; reference scripts are not decoded. CBOR the application gives (data, datums, redeemers, native scripts) is kept byte for byte unless it breaks the transaction's structure.NATIVE_SCRIPT_UNREAD).Other packages
@meshsdk/core-cst: reading aTransactionPrototypefrom CBOR, adding witnesses to a transaction in its own form,@cardano-sdk/core0.47.1.@meshsdk/wallet: wallets write witnesses in the transaction's form.@meshsdk/common: types the builder takes.Editor support
Docs
packages/mesh-transaction/README.md: the guide, with examples type-checked in CI.docs/design/tx-builder.md: the design.MeshTxBuilder@deprecated, running onTxBuilder. Where it used to return a transaction the ledger refuses, it now throws the new builder's error; the README lists every difference and the members removed.Validation
Run locally on the head of this branch, as CI runs them:
turbo build:mesh,build:docs,build:apps,build:scripts,lint@meshsdk/transactiontscand the typecheck of every package's tests; the README's TypeScript examples compiletest:packageof@meshsdk/core-cstand@meshsdk/scalus-emulator, andtest:scalus-packages