Skip to content

cardano-wasm demo: staking (certificates, pool picker, stake witnesses) - #1290

Open
palas wants to merge 2 commits into
masterfrom
wasm-demo-staking
Open

cardano-wasm demo: staking (certificates, pool picker, stake witnesses)#1290
palas wants to merge 2 commits into
masterfrom
wasm-demo-staking

Conversation

@palas

@palas palas commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

This PR adds the following functionality to the cardano-wasm demo:

  • per-wallet certificate menu: register / register+delegate / delegate-only / unregister; key deposit and refund reflected in the balance
  • live pool picker from Blockfrost /pools/extended, one page at a time (prev/next; no duplicates possible from shifting offsets)
  • delegation uses Blockfrost's hex pool id, with a golden-tested pure-Elm bech32 fallback decoder
  • signing attaches payment witnesses per input wallet and a stake witness (alsoSignWithStakeKey) per certificate wallet
  • README: full feature list

Context

This is a follow up of: #1287

How to trust this PR

  • Only the elm code, ports javascript, and the readme are modified and elm code compiles.
  • You can test this version by downloading the artifact from the WASM CI action and serving it with a simple web-server.
  • Tests will be added in the next PR.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff
  • Changelog fragment added in .changes/

- per-wallet certificate menu: register / register+delegate / delegate-only /
  unregister; key deposit and refund reflected in the balance
- live pool picker from Blockfrost /pools/extended, one page at a time
  (prev/next; no duplicates possible from shifting offsets)
- delegation uses Blockfrost's hex pool id, with a golden-tested pure-Elm
  bech32 fallback decoder
- signing attaches payment witnesses per input wallet and a stake witness
  (alsoSignWithStakeKey) per certificate wallet
- README: full feature list
@palas palas self-assigned this Aug 12, 2026
@palas
palas requested a review from Jimbo4350 as a code owner August 12, 2026 00:21
Copilot AI lite review requested due to automatic review settings August 12, 2026 00:21
@palas
palas marked this pull request as draft August 12, 2026 00:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extends the cardano-wasm demo to support staking certificate flows and stake-pool selection, wiring the new functionality through Elm state/update/view and the JS cardano-wasm port boundary, with Blockfrost providing pool data.

Changes:

  • Add certificate selection per wallet (register / delegate / unregister), include certificates in tx building, and account for key deposits/refunds in balance/change.
  • Add a Blockfrost-backed, paginated pool picker modal and use pool hex ids for delegation.
  • Update signing/fee estimation to include stake witnesses when certificates are present, and expand demo documentation.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
cardano-wasm/demo/web/ports.js Build txs with certificates; include stake witnesses; improve top-level docs; adjust boot error handling.
cardano-wasm/demo/src/Wasm.elm Encode certificates + stake witnesses into port requests; rebalance module layout.
cardano-wasm/demo/src/View.elm Add certificate UI + certificate list; add pool picker modal + paging UI; show deposits in summary.
cardano-wasm/demo/src/Update.elm Add certificate/pool-picker message handling; clear network-specific state on network switch.
cardano-wasm/demo/src/Types.elm Introduce certificate/pool/picker types; extend model/msg for new flows.
cardano-wasm/demo/src/State.elm Add deposit arithmetic, stake-witness accounting, certificate helpers, pool helpers, and small utilities.
cardano-wasm/demo/src/Ports.elm Minor cleanup (doc removal).
cardano-wasm/demo/src/Net.elm Minor doc tweak.
cardano-wasm/demo/src/Main.elm Update module overview comment for Blockfrost/Bech32/Hex additions.
cardano-wasm/demo/src/Blockfrost.elm Add /pools/extended fetch + decoding for pool picker.
cardano-wasm/demo/src/Bech32.elm Add provisional bech32→hex decoder fallback for pool ids.
cardano-wasm/demo/README.md Document the expanded demo feature set, including staking and pool picker.
.changes/20260718_cardano_wasm_demo_staking.yml Add changelog fragment for the new demo feature.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cardano-wasm/demo/src/Types.elm
Comment thread cardano-wasm/demo/src/Blockfrost.elm Outdated
Comment thread cardano-wasm/demo/src/View.elm
Comment thread cardano-wasm/demo/web/ports.js Outdated
- pin the pool's Blockfrost hex (and ticker) into the certificate at pick
  time instead of re-resolving it from the currently loaded picker page at
  estimate/sign time; drop the poolHex fallback path
- stamp GotPools with the network and page it answers and drop stale replies,
  matching the GotUtxos landing-guard idiom
- validate fully in Bech32.bech32ToHex (BIP-173 checksum, pool prefix,
  28-byte payload, no mixed case); fix the fetchPools docstring (pages
  replace, not append)
- show the pending menu choice while the pool picker is open and replace the
  wallet's certificate only on a confirmed pick, so cancelling rolls back and
  the DOM select stays in sync
- decode and show metadata.ticker in the pool picker; search matches it
- compute the pager's has-more flag at the fetch boundary; toast on retry
  without a project id; log pool fetches like other Blockfrost calls; use
  LogInfo for cert edits
- ports.js: build the boot error message from DOM nodes/textContent instead
  of innerHTML; fail loudly on an empty payment-key list instead of wedging
  the wasm instance
- docs: restore the Types/Ports module docstrings, pparams.js (not .json),
  certificate building in the Wasm module doc, the real stake-witness rule,
  and an honest certMenu comment
@palas
palas marked this pull request as ready for review August 12, 2026 02:29
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