Skip to content

Commit e7ff966

Browse files
authored
Merge pull request #184 from Emurgo/develop-alonzo
[breaking] Alonzo changes
2 parents 1d343dd + 39f8439 commit e7ff966

File tree

9 files changed

+2517
-446
lines changed

9 files changed

+2517
-446
lines changed

rust/Cargo.lock

Lines changed: 46 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ hex = "0.4.0"
2727
cfg-if = "1"
2828
linked-hash-map = "0.5.3"
2929
serde_json = "1.0.57"
30+
num-bigint = "0.4.0"
3031
# The default can't be compiled to wasm, so it's necessary to use either the 'nightly'
3132
# feature or this one
3233
clear_on_drop = { version = "0.2", features = ["no_cc"] }

rust/src/crypto.rs

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,57 @@ impl Deserialize for Vkey {
338338
}
339339
}
340340

341+
#[wasm_bindgen]
342+
#[derive(Clone)]
343+
pub struct Vkeys(Vec<Vkey>);
344+
345+
#[wasm_bindgen]
346+
impl Vkeys {
347+
pub fn new() -> Self {
348+
Self(Vec::new())
349+
}
350+
351+
pub fn len(&self) -> usize {
352+
self.0.len()
353+
}
354+
355+
pub fn get(&self, index: usize) -> Vkey {
356+
self.0[index].clone()
357+
}
358+
359+
pub fn add(&mut self, elem: &Vkey) {
360+
self.0.push(elem.clone());
361+
}
362+
}
363+
364+
impl cbor_event::se::Serialize for Vkeys {
365+
fn serialize<'se, W: Write>(&self, serializer: &'se mut Serializer<W>) -> cbor_event::Result<&'se mut Serializer<W>> {
366+
serializer.write_array(cbor_event::Len::Len(self.0.len() as u64))?;
367+
for element in &self.0 {
368+
element.serialize(serializer)?;
369+
}
370+
Ok(serializer)
371+
}
372+
}
373+
374+
impl Deserialize for Vkeys {
375+
fn deserialize<R: BufRead + Seek>(raw: &mut Deserializer<R>) -> Result<Self, DeserializeError> {
376+
let mut arr = Vec::new();
377+
(|| -> Result<_, DeserializeError> {
378+
let len = raw.array()?;
379+
while match len { cbor_event::Len::Len(n) => arr.len() < n as usize, cbor_event::Len::Indefinite => true, } {
380+
if raw.cbor_type()? == CBORType::Special {
381+
assert_eq!(raw.special()?, CBORSpecial::Break);
382+
break;
383+
}
384+
arr.push(Vkey::deserialize(raw)?);
385+
}
386+
Ok(())
387+
})().map_err(|e| e.annotate("Vkeys"))?;
388+
Ok(Self(arr))
389+
}
390+
}
391+
341392
#[wasm_bindgen]
342393
#[derive(Clone)]
343394
pub struct Vkeywitness {
@@ -769,9 +820,12 @@ impl_hash_type!(ScriptHash, 28);
769820
impl_hash_type!(TransactionHash, 32);
770821
impl_hash_type!(GenesisDelegateHash, 28);
771822
impl_hash_type!(GenesisHash, 28);
772-
impl_hash_type!(MetadataHash, 32);
823+
impl_hash_type!(AuxiliaryDataHash, 32);
824+
impl_hash_type!(PoolMetadataHash, 32);
773825
impl_hash_type!(VRFKeyHash, 32);
774826
impl_hash_type!(BlockHash, 32);
827+
impl_hash_type!(DataHash, 32);
828+
impl_hash_type!(ScriptDataHash, 32);
775829
// We might want to make these two vkeys normal classes later but for now it's just arbitrary bytes for us (used in block parsing)
776830
impl_hash_type!(VRFVKey, 32);
777831
impl_hash_type!(KESVKey, 32);

0 commit comments

Comments
 (0)