From 0befe1a40a790a3059b703f1b104975eafb3970b Mon Sep 17 00:00:00 2001 From: waalge Date: Wed, 1 Oct 2025 14:52:20 +0000 Subject: [PATCH] another stub: cardano value --- README.md | 11 +++++++++++ src/cardano_types.rs | 1 + src/cardano_types/value.rs | 17 +++++++++++++++++ src/utils.rs | 3 +-- 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 src/cardano_types/value.rs diff --git a/README.md b/README.md index 2ea63c2..ecc3bc3 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/cardano_types.rs b/src/cardano_types.rs index aa66da7..68b5603 100644 --- a/src/cardano_types.rs +++ b/src/cardano_types.rs @@ -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. /// diff --git a/src/cardano_types/value.rs b/src/cardano_types/value.rs new file mode 100644 index 0000000..cef215e --- /dev/null +++ b/src/cardano_types/value.rs @@ -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, HashMap, u64>>; + +#[derive(Debug)] +pub struct Value(u64, MultiAsset); + diff --git a/src/utils.rs b/src/utils.rs index 9f5c5d8..51a289b 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,8 +1,7 @@ use anyhow::{anyhow, Result}; pub fn v2a(v: Vec) -> Result<[T; N]> { - v.try_into() - .map_err(|v: Vec| anyhow!("Expected a Vec of length {}, but got {}", N, v.len())) + <[T;N]>::try_from(v).map_err(|v: Vec| anyhow!("Expected a Vec of length {}, but got {}", N, v.len())) } pub fn concat(l: &[T], r: &[T]) -> Vec {