From 6708d448d88e27d03600780fc0a44981ed7ba8c0 Mon Sep 17 00:00:00 2001 From: Kayos Date: Thu, 7 May 2026 10:21:27 -0700 Subject: [PATCH] =?UTF-8?q?feat(examples):=20dump=5Fstake=20=E2=80=94=20em?= =?UTF-8?q?it=20StakeDatum=20CBOR=20hex=20for=20bootstrap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Companion to dump_governor (committed earlier this branch). Edit owner_pkh_hex + staked_amount in the source, then `cargo run` to print the inline datum CBOR for a wallet_plutus_mint_unsigned call that mints StakeST + sends to stakes_addr. No locks at bootstrap (locked_by = []) and no delegation (delegated_to = None). For a stake that's been used in proposals, locked_by would carry the ProposalLock entries; reuse this scaffold when reseeding a stake from a snapshot. --- crates/aldabra-dao/examples/dump_stake.rs | 33 +++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 crates/aldabra-dao/examples/dump_stake.rs diff --git a/crates/aldabra-dao/examples/dump_stake.rs b/crates/aldabra-dao/examples/dump_stake.rs new file mode 100644 index 0000000..6b62d03 --- /dev/null +++ b/crates/aldabra-dao/examples/dump_stake.rs @@ -0,0 +1,33 @@ +//! Print StakeDatum CBOR hex for a parametrized stake bootstrap. +//! +//! Usage: edit the values below, then +//! cargo run --example dump_stake -p aldabra-dao --release +//! +//! Used during preprod DAO bringup (Track B-fast) to construct the +//! inline datum for `wallet_plutus_mint_unsigned` calls that mint +//! StakeST and deposit at the stakes address. + +use aldabra_dao::agora::stake::{Credential, ProposalLock, StakeDatum}; +use pallas_codec::minicbor; + +fn main() { + // Edit per stake. + let owner_pkh_hex = "4cd61bd67ed72c1cec160bf7de6103c6bddb397da6a500dc4ff805f8"; + let staked_amount: i64 = 250; + + let owner_bytes = hex::decode(owner_pkh_hex).expect("decode pkh hex"); + assert_eq!(owner_bytes.len(), 28, "pkh must be 28 bytes"); + + let datum = StakeDatum { + staked_amount, + owner: Credential::PubKey(owner_bytes), + delegated_to: None, + locked_by: Vec::::new(), + }; + + let pd = datum.to_plutus_data().expect("encode"); + let mut buf = Vec::new(); + minicbor::encode(&pd, &mut buf).expect("cbor"); + let hex: String = buf.iter().map(|b| format!("{:02x}", b)).collect(); + println!("{}", hex); +}