Skip to content

feat: add certificate part builders and encode Conway stake (de)registration deposits - #856

Merged
twwu123 merged 2 commits into
feat/tx-parts-mint-withdrawal-scalarsfrom
feat/tx-parts-certificates
Oct 30, 2026
Merged

twwu123 merged 2 commits into
feat/tx-parts-mint-withdrawal-scalarsfrom
feat/tx-parts-certificates

Conversation

@lisicky

@lisicky lisicky commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

What

Adds part builders for every certificate the Conway ledger accepts. Also makes the TransactionPrototype encoder keep the deposit of Conway stake (de)registration certificates instead of dropping it.

Stacked on #855. Merge it first; this PR can then be retargeted to main. The part builders stay in packages/mesh-transaction/src/tx-builder/, not exported from the package root.

Contents

packages/mesh-transaction/src/tx-builder/parts/certificates.ts, one builder per CDDL certificate:

Builder Certificate
stakeRegistration, stakeDeregistration 7, 8: Conway, deposit stated
legacyStakeRegistration, legacyStakeDeregistration 0, 1
stakeDelegation 2
poolRegistration, poolRetirement 3, 4
voteDelegation, stakeAndVoteDelegation 9, 10
stakeRegistrationAndDelegation, voteRegistrationAndDelegation, stakeVoteRegistrationAndDelegation 11, 12, 13
committeeHotAuth, committeeColdResign 14, 15
drepRegistration, drepDeregistration, drepUpdate 16, 17, 18
  • Credentials, pools and DReps:
    • Stake and committee credentials are given as a bech32 reward address or as the credential itself.
    • DReps as a CIP-105/CIP-129 id, a credential, a DRepPrototype, "alwaysAbstain" or "alwaysNoConfidence".
    • Pools as a bech32 id or a key hash.
    • poolRegistration takes Mesh PoolParams. Margin, pledge and cost, VRF and owner hashes, the reward address, relays (IPv4, IPv6 with ::, DNS names, ports) and metadata are all checked.
  • Witnesses:
    • A key credential takes no witness argument.
    • A script credential needs witness: { native } or { plutus, redeemer }, checked against the credential's hash. A script referenced by out ref alone gets its hash from the credential.
    • Certificates introduced with governance can only be witnessed by a Plutus V3 script. The legacy deregistration and stake delegation accept any version.
    • The legacy stake registration takes no witness; pool certificates are signed by the keys they name.
  • Deposits and refunds. They can be given explicitly. When omitted, the part records the protocol parameter they come from (keyDeposit, drepDeposit), and unresolved reports it as a deposit gap.
  • Order. Certificates keep the order their parts are given in, as that order is part of the transaction.

mesh-core-cst:

  • Encoder fix. certificatePrototypeToCardano now encodes STAKE_REGISTRATION / STAKE_DEREGISTRATION with a coin as certificates 7/8, Registration / Unregistration with the deposit. Without a coin, the legacy 0/1 are produced as before. Previously the deposit was silently dropped, so these certificates did not round-trip.
  • The round-trip test that pinned the loss now checks both forms survive. The decoder comment and docs/design/tx-prototype.md are updated.

Validation

npm run build:mesh
cd packages/mesh-transaction && npx jest test/tx-builder
cd packages/mesh-core-cst && npm test
  • 16 new tests in certificates.test.ts:
    • every builder;
    • witness and Plutus V3 rules;
    • deposit gaps;
    • malformed pool parameters, anchors, ids and DReps;
    • a round trip of all 16 certificate forms through transactionPrototypeToHex / transactionPrototypeFromHex.
  • mesh-core-cst: 180 tests pass.
  • mesh-transaction (NODE_OPTIONS=--experimental-vm-modules npx jest): 224 tests pass. script-tx-fetcher and script-tx-fail fail to load under that flag on main too.

@twwu123
twwu123 merged commit 82cc3da into main Oct 30, 2026
1 check 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.

2 participants