Skip to content

Commit bf461c3

Browse files
committed
move definition of public_tx/choice and public_tx/proof to the public_tx/vote mod
1 parent 6ed8202 commit bf461c3

File tree

4 files changed

+50
-53
lines changed

4 files changed

+50
-53
lines changed

rust/vote-tx-v2/src/public_tx/choice.rs

-22
This file was deleted.

rust/vote-tx-v2/src/public_tx/mod.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
//! A Catalyst public vote transaction v2 object, structured following this
22
//! [spec](https://input-output-hk.github.io/catalyst-libs/architecture/08_concepts/catalyst_voting/v2/#public-vote)
33
4-
mod choice;
5-
mod proof;
4+
mod vote;
65

76
use std::ops::{Deref, DerefMut};
87

9-
pub use choice::Choice;
108
use minicbor::{Decode, Encode};
11-
pub use proof::Proof;
9+
pub use vote::{Choice, Proof, PropId};
1210

13-
use crate::{gen_tx::GeneralizedTx, uuid::Uuid, Cbor};
14-
15-
/// A public voting proposal id struct.
16-
pub type PropId = Uuid;
11+
use crate::{gen_tx::GeneralizedTx, Cbor};
1712

1813
/// A public vote tx struct.
1914
#[derive(Debug, Clone, PartialEq)]

rust/vote-tx-v2/src/public_tx/proof.rs

-23
This file was deleted.

rust/vote-tx-v2/src/public_tx/vote.rs

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//! A public vote tx vote objects.
2+
3+
use minicbor::{Decode, Encode};
4+
5+
use crate::uuid::Uuid;
6+
7+
/// A public voting choice struct.
8+
#[derive(Debug, Clone, PartialEq)]
9+
pub struct Choice(pub u64);
10+
11+
/// A public voting proof struct, CBOR `undefined`.
12+
#[derive(Debug, Clone, PartialEq)]
13+
pub struct Proof;
14+
15+
/// A public voting proposal id struct.
16+
pub type PropId = Uuid;
17+
18+
impl Decode<'_, ()> for Choice {
19+
fn decode(d: &mut minicbor::Decoder<'_>, (): &mut ()) -> Result<Self, minicbor::decode::Error> {
20+
let choice = d.u64()?;
21+
Ok(Self(choice))
22+
}
23+
}
24+
25+
impl Encode<()> for Choice {
26+
fn encode<W: minicbor::encode::Write>(
27+
&self, e: &mut minicbor::Encoder<W>, (): &mut (),
28+
) -> Result<(), minicbor::encode::Error<W::Error>> {
29+
self.0.encode(e, &mut ())
30+
}
31+
}
32+
33+
impl Decode<'_, ()> for Proof {
34+
fn decode(d: &mut minicbor::Decoder<'_>, (): &mut ()) -> Result<Self, minicbor::decode::Error> {
35+
d.undefined()?;
36+
Ok(Self)
37+
}
38+
}
39+
40+
impl Encode<()> for Proof {
41+
fn encode<W: minicbor::encode::Write>(
42+
&self, e: &mut minicbor::Encoder<W>, (): &mut (),
43+
) -> Result<(), minicbor::encode::Error<W::Error>> {
44+
e.undefined()?;
45+
Ok(())
46+
}
47+
}

0 commit comments

Comments
 (0)