cardano-wasm demo: fee estimation, balance checks, signing, tx export - #1283
Open
palas wants to merge 2 commits into
Open
cardano-wasm demo: fee estimation, balance checks, signing, tx export#1283palas wants to merge 2 commits into
palas wants to merge 2 commits into
Conversation
palas
requested review from
CarlosLopezDeLara,
carbolymer and
disassembler
as code owners
August 8, 2026 00:01
- Conway/Dijkstra era toggle; estimateMinFee over the described tx - balance arithmetic in Elm: change = inputs - outputs - fee; explicit outputs and the change must meet the ADA-only min-UTxO, gating the sign button (insufficient/dust/too-small states) - the two numbers Elm needs come as init flags from web/pparams.js — the same pinned ledger-format object estimateMinFee consumes (single source) - signing returns the CBOR and the tx id (body hash, shown pre-submission) - export: cardano-cli TextEnvelope download (tx.signed) + copy CBOR, with an era-matched broadcast hint and the witness counts it was signed with - stale protection: shape edits reset the fee (invalidateShape), and the fee/sign replies are accepted only while their request is still live - live tx inspector mirrors the exact spec, including the implicit change
palas
force-pushed
the
wasm-demo-fee-sign-export
branch
from
August 8, 2026 00:03
0b56e1e to
cd8bdd5
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the cardano-wasm/demo transaction builder from “draft spec” into a workflow that can estimate fees, perform basic balance/min-UTxO checks, sign a transaction in-browser, and export the signed transaction (CBOR + cardano-cli TextEnvelope), with additional UX support such as era toggling and a live tx inspector.
Changes:
- Add pinned protocol parameters (
pparams.js) and pass fee-related values into Elm via init flags (single source of truth for fee estimation + Elm balance arithmetic). - Implement fee estimation + signing ports (JS) and corresponding Elm commands/decoders/state gates (fee state, tx state, staleness protection).
- Add UI for era selection, summary/balance display, signing/export actions, and a “live tx inspector”.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| cardano-wasm/demo/web/pparams.js | Introduces pinned ledger-format protocol parameters consumed by fee estimation and Elm flags. |
| cardano-wasm/demo/web/ports.js | Adds unsigned-tx builder plus fee estimation/signing port handlers; passes protocol flags into Elm. |
| cardano-wasm/demo/src/Wasm.elm | Adds ports-side commands for fee estimation/signing and encodes the tx “spec” JSON sent to JS. |
| cardano-wasm/demo/src/View.elm | Adds era toggle, builder summary, signing/export UI, and a live tx inspector panel. |
| cardano-wasm/demo/src/Update.elm | Adds fee/sign/export state machine, staleness handling, and cardano-cli TextEnvelope download. |
| cardano-wasm/demo/src/Types.elm | Adds era/fee/tx state types, signed payload types, and Protocol flags record. |
| cardano-wasm/demo/src/State.elm | Adds balance/min-UTxO logic, readiness gates, staleness helpers, witness counting, and Protocol-flag init. |
| cardano-wasm/demo/src/Ports.elm | Declares new fee-estimation and signing ports. |
| cardano-wasm/demo/src/Net.elm | Adds era tags and cardano-cli TextEnvelope type mapping per era. |
| cardano-wasm/demo/src/Main.elm | Switches Elm program flags from () to Protocol and wires new incoming ports. |
| .changes/20260718_cardano_wasm_demo_signing.yml | Changelog fragment documenting the demo feature addition. |
Files not reviewed (1)
- cardano-wasm/demo/web/pparams.js: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- finalOutputs doc states the estimate-size relation precisely: the real transaction is never larger than the estimated one (over-pay only) - the live tx inspector prints the fee exactly as the spec sends it (lovelace integer or null) instead of the display string
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.
This PR adds the following functionality to the
cardano-wasmdemo:Context
This is a follow up of: #1278
How to trust this PR
cardano-wasm/demo/+ a changelog fragment; CI already compiles it and checkselm-format.tx.signedand copied CBOR.Checklist
.changes/