1
1
use anyhow:: { anyhow, Result } ;
2
2
use prism_keys:: { Signature , SigningKey , VerifyingKey } ;
3
+ use prism_serde:: raw_or_b64;
3
4
use serde:: { Deserialize , Serialize } ;
4
5
5
6
use crate :: {
6
7
operation:: { Operation , ServiceChallenge } ,
7
8
transaction:: Transaction ,
8
9
} ;
9
10
11
+ #[ derive( Clone , Serialize , Deserialize , Debug , PartialEq ) ]
12
+ pub struct SignedData ( pub VerifyingKey , #[ serde( with = "raw_or_b64" ) ] pub Vec < u8 > ) ;
13
+
10
14
#[ derive( Clone , Serialize , Deserialize , Debug , PartialEq , Default ) ]
11
15
/// Represents an account or service on prism, making up the values of our state
12
16
/// tree.
@@ -23,7 +27,7 @@ pub struct Account {
23
27
24
28
/// Arbitrary signed data associated with the account, used for bookkeeping
25
29
/// externally signed data from keys that don't live on Prism.
26
- signed_data : Vec < ( VerifyingKey , Vec < u8 > ) > ,
30
+ signed_data : Vec < SignedData > ,
27
31
28
32
/// The service challenge for the account, if it is a service.
29
33
service_challenge : Option < ServiceChallenge > ,
@@ -42,7 +46,7 @@ impl Account {
42
46
& self . valid_keys
43
47
}
44
48
45
- pub fn signed_data ( & self ) -> & [ ( VerifyingKey , Vec < u8 > ) ] {
49
+ pub fn signed_data ( & self ) -> & [ SignedData ] {
46
50
& self . signed_data
47
51
}
48
52
@@ -161,7 +165,10 @@ impl Account {
161
165
data,
162
166
data_signature,
163
167
} => {
164
- self . signed_data . push ( ( data_signature. verifying_key . clone ( ) , data. clone ( ) ) ) ;
168
+ self . signed_data . push ( SignedData (
169
+ data_signature. verifying_key . clone ( ) ,
170
+ data. clone ( ) ,
171
+ ) ) ;
165
172
}
166
173
Operation :: CreateAccount { id, key, .. } => {
167
174
self . id = id. clone ( ) ;
0 commit comments