feat(examples): dump_stake — emit StakeDatum CBOR hex for bootstrap
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.
This commit is contained in:
parent
ca2f69d28e
commit
6708d448d8
1 changed files with 33 additions and 0 deletions
33
crates/aldabra-dao/examples/dump_stake.rs
Normal file
33
crates/aldabra-dao/examples/dump_stake.rs
Normal file
|
|
@ -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::<ProposalLock>::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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue