another stub: cardano value
This commit is contained in:
parent
2d3e76a894
commit
0befe1a40a
11
README.md
11
README.md
|
@ -2,6 +2,17 @@
|
||||||
|
|
||||||
> A first stab at the konduit cli
|
> 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
|
## TODOs
|
||||||
|
|
||||||
- [x] serde for relevant data
|
- [x] serde for relevant data
|
||||||
|
|
|
@ -9,6 +9,7 @@ use uplc::PlutusData;
|
||||||
|
|
||||||
pub mod address;
|
pub mod address;
|
||||||
use address::Address;
|
use address::Address;
|
||||||
|
pub mod value;
|
||||||
|
|
||||||
/// This is a sad file: yet another set of wrapping.
|
/// This is a sad file: yet another set of wrapping.
|
||||||
///
|
///
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
|
|
||||||
pub fn v2a<T, const N: usize>(v: Vec<T>) -> Result<[T; N]> {
|
pub fn v2a<T, const N: usize>(v: Vec<T>) -> Result<[T; N]> {
|
||||||
v.try_into()
|
<[T;N]>::try_from(v).map_err(|v: Vec<T>| anyhow!("Expected a Vec of length {}, but got {}", N, v.len()))
|
||||||
.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> {
|
pub fn concat<T: Clone>(l: &[T], r: &[T]) -> Vec<T> {
|
||||||
|
|
Loading…
Reference in New Issue