@@ -65,9 +65,28 @@ impl Display for ProvingSystemId {
6565#[ derive( Debug , Serialize , Deserialize , Clone ) ]
6666pub struct VerificationData {
6767 pub proving_system : ProvingSystemId ,
68+ #[ serde( with = "serde_bytes" ) ]
6869 pub proof : Vec < u8 > ,
70+ #[ serde(
71+ default ,
72+ skip_serializing_if = "Option::is_none" ,
73+ deserialize_with = "deserialize_option_bytes" ,
74+ serialize_with = "serialize_option_bytes"
75+ ) ]
6976 pub pub_input : Option < Vec < u8 > > ,
77+ #[ serde(
78+ default ,
79+ skip_serializing_if = "Option::is_none" ,
80+ deserialize_with = "deserialize_option_bytes" ,
81+ serialize_with = "serialize_option_bytes"
82+ ) ]
7083 pub verification_key : Option < Vec < u8 > > ,
84+ #[ serde(
85+ default ,
86+ skip_serializing_if = "Option::is_none" ,
87+ deserialize_with = "deserialize_option_bytes" ,
88+ serialize_with = "serialize_option_bytes"
89+ ) ]
7190 pub vm_program_code : Option < Vec < u8 > > ,
7291 pub proof_generator_addr : Address ,
7392}
@@ -429,15 +448,13 @@ pub enum SubmitProofResponseMessage {
429448 EthRpcError ,
430449 InvalidPaymentServiceAddress ( Address , Address ) ,
431450 UnderpricedProof ,
432- ServerBusy ,
433451}
434452
435453#[ derive( Debug , Clone , Serialize , Deserialize ) ]
436454pub enum GetNonceResponseMessage {
437455 Nonce ( U256 ) ,
438456 EthRpcError ( String ) ,
439457 InvalidRequest ( String ) ,
440- ServerBusy ,
441458}
442459
443460#[ derive( Debug , Clone ) ]
@@ -504,6 +521,25 @@ impl Network {
504521 }
505522}
506523
524+ // Helper functions for serializing Option<Vec<u8>> with serde_bytes
525+ fn serialize_option_bytes < S > ( value : & Option < Vec < u8 > > , serializer : S ) -> Result < S :: Ok , S :: Error >
526+ where
527+ S : serde:: Serializer ,
528+ {
529+ match value {
530+ Some ( bytes) => serde_bytes:: serialize ( bytes, serializer) ,
531+ None => serializer. serialize_none ( ) ,
532+ }
533+ }
534+
535+ fn deserialize_option_bytes < ' de , D > ( deserializer : D ) -> Result < Option < Vec < u8 > > , D :: Error >
536+ where
537+ D : serde:: Deserializer < ' de > ,
538+ {
539+ let opt: Option < serde_bytes:: ByteBuf > = Option :: deserialize ( deserializer) ?;
540+ Ok ( opt. map ( |buf| buf. into_vec ( ) ) )
541+ }
542+
507543#[ cfg( test) ]
508544mod tests {
509545 use ethers:: signers:: LocalWallet ;
0 commit comments