@@ -17,11 +17,6 @@ const VOTE_CAST_TAG: u8 = 11;
17
17
/// INPUT-ACCOUNT = %xff VALUE UNTAG-ACCOUNT-ID
18
18
const INPUT_ACCOUNT : u8 = 255 ;
19
19
20
- /// Block epoch + slot
21
- /// This is redundant as time checks have been removed
22
- const EPOCH : u32 = 0 ;
23
- const SLOT : u32 = 0 ;
24
-
25
20
/// Only 1 input (subsequently 1 witness), no output
26
21
/// VoteCast TX should have only 1 input, 0 output and 1 witness (signature).
27
22
const INPUT : u8 = 1 ;
@@ -51,6 +46,8 @@ pub fn generate_vote_fragment(
51
46
proof : Vec < u8 > ,
52
47
proposal : u8 ,
53
48
vote_plan_id : & [ u8 ] ,
49
+ epoch : u32 ,
50
+ slot : u32 ,
54
51
) -> Result < Vec < u8 > , Box < dyn error:: Error > > {
55
52
let mut vote_cast = Codec :: new ( Vec :: new ( ) ) ;
56
53
@@ -62,7 +59,8 @@ pub fn generate_vote_fragment(
62
59
63
60
let data_to_sign = vote_cast. into_inner ( ) . clone ( ) ;
64
61
65
- let ( inputs, witness) = compose_inputs_and_witnesses ( keypair, data_to_sign. clone ( ) ) ?;
62
+ let ( inputs, witness) =
63
+ compose_inputs_and_witnesses ( keypair, data_to_sign. clone ( ) , epoch, slot) ?;
66
64
67
65
let mut vote_cast = Codec :: new ( Vec :: new ( ) ) ;
68
66
vote_cast. put_bytes ( & data_to_sign) ?;
@@ -85,11 +83,13 @@ pub fn generate_vote_fragment(
85
83
fn compose_inputs_and_witnesses (
86
84
keypair : Keypair ,
87
85
data_to_sign : Vec < u8 > ,
86
+ epoch : u32 ,
87
+ slot : u32 ,
88
88
) -> Result < ( Vec < u8 > , Vec < u8 > ) , Box < dyn error:: Error > > {
89
89
let mut inputs = Codec :: new ( Vec :: new ( ) ) ;
90
90
91
- inputs. put_be_u32 ( EPOCH ) ?;
92
- inputs. put_be_u32 ( SLOT ) ?;
91
+ inputs. put_be_u32 ( epoch ) ?;
92
+ inputs. put_be_u32 ( slot ) ?;
93
93
inputs. put_u8 ( INPUT ) ?;
94
94
inputs. put_u8 ( OUTPUT ) ?;
95
95
@@ -219,6 +219,8 @@ mod tests {
219
219
proof,
220
220
5 ,
221
221
& hex:: decode ( vote_plan_id. clone ( ) ) . unwrap ( ) ,
222
+ 0 ,
223
+ 0 ,
222
224
)
223
225
. unwrap ( ) ;
224
226
0 commit comments