From e9e185a6b02d14eba331f984c73f52b4d06497be Mon Sep 17 00:00:00 2001 From: armaniferrante Date: Wed, 23 Sep 2020 01:42:14 -0700 Subject: [PATCH] Switch to common crate for serialization --- solana-client-gen/codegen/src/lib.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/solana-client-gen/codegen/src/lib.rs b/solana-client-gen/codegen/src/lib.rs index 52da4db..694e1dd 100644 --- a/solana-client-gen/codegen/src/lib.rs +++ b/solana-client-gen/codegen/src/lib.rs @@ -684,15 +684,12 @@ fn enum_to_methods( pub struct _DefaultCoder; impl _DefaultCoder { pub fn to_bytes(i: #instruction_mod_ident::#instruction_enum_ident) -> Vec { - bincode::serialize(&(0u8, i)) + serum_common::pack::to_bytes(&i) .expect("instruction must be serializable") } - pub fn from_bytes(data: &[u8]) -> Result, ()> { - match data.split_first() { - None => Err(()), - Some((&0u8, rest)) => bincode::deserialize(rest).map_err(|_| ()), - Some((_, _rest)) => Err(()), - } + pub fn from_bytes(data: &[u8]) -> Result<#instruction_mod_ident::#instruction_enum_ident, ()> { + serum_common::pack::from_bytes(data) + .map_err(|_| ()) } } }