another stub: cardano value

This commit is contained in:
waalge 2025-10-01 14:52:20 +00:00
parent 2d3e76a894
commit 0befe1a40a
4 changed files with 30 additions and 2 deletions

View File

@ -2,6 +2,17 @@
> A first stab at the konduit cli
## Workspace
- [ ] cardano-tx-builder - Pure cardano transaction builder utils
- [ ] cardano-connect - Traits for cardano connector
- [ ] cardano-connect-blockfrost - Impl for blockfrost
- [ ] konduit-core - Pure konduit transaction builders.
Depends only on cardano-tx-builder.
- [ ] test round trip data
- [ ] compiles to wasm
- [ ] konduit-cli - cli wrapping of core
## TODOs
- [x] serde for relevant data

View File

@ -9,6 +9,7 @@ use uplc::PlutusData;
pub mod address;
use address::Address;
pub mod value;
/// This is a sad file: yet another set of wrapping.
///

View File

@ -0,0 +1,17 @@
// TODO: Write some sane value handling fuctions:
// - add
// - sub
// - prune
// - split (negative, positive)
// - is_positive
use std::collections::HashMap;
use pallas_crypto::hash::Hash;
/// Naive version of value
pub type MultiAsset = HashMap<Hash<28>, HashMap<Vec<u8>, u64>>;
#[derive(Debug)]
pub struct Value(u64, MultiAsset);

View File

@ -1,8 +1,7 @@
use anyhow::{anyhow, Result};
pub fn v2a<T, const N: usize>(v: Vec<T>) -> Result<[T; N]> {
v.try_into()
.map_err(|v: Vec<T>| anyhow!("Expected a Vec of length {}, but got {}", N, v.len()))
<[T;N]>::try_from(v).map_err(|v: Vec<T>| anyhow!("Expected a Vec of length {}, but got {}", N, v.len()))
}
pub fn concat<T: Clone>(l: &[T], r: &[T]) -> Vec<T> {