@ -15,6 +15,7 @@ indexmap = "1.1.0"
|
||||
libc = "0.2.65"
|
||||
log = "0.4.8"
|
||||
serde = "1.0.101"
|
||||
serde_bytes = "0.11"
|
||||
serde_derive = "1.0.101"
|
||||
serde_json = "1.0.41"
|
||||
solana-logger = { path = "../../logger", version = "0.20.0" }
|
||||
|
@ -34,6 +34,12 @@ fn to_array_32(array: &[u8]) -> &[u8; 32] {
|
||||
array.try_into().expect("slice with incorrect length")
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
pub struct ModuleBytes {
|
||||
#[serde(with = "serde_bytes")]
|
||||
pub bytes: Vec<u8>,
|
||||
}
|
||||
|
||||
/// Type of Libra account held by a Solana account
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
pub enum LibraAccountState {
|
||||
@ -43,8 +49,9 @@ pub enum LibraAccountState {
|
||||
CompiledProgram(String),
|
||||
/// Serialized verified program bytes
|
||||
VerifiedProgram {
|
||||
#[serde(with = "serde_bytes")]
|
||||
script_bytes: Vec<u8>,
|
||||
modules_bytes: Vec<Vec<u8>>,
|
||||
modules_bytes: Vec<ModuleBytes>,
|
||||
},
|
||||
/// Associated genesis account and the write set containing the Libra account data
|
||||
User(Pubkey, WriteSet),
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::account_state::{pubkey_to_address, LibraAccountState};
|
||||
use crate::account_state::{pubkey_to_address, LibraAccountState, ModuleBytes};
|
||||
use crate::data_store::DataStore;
|
||||
use crate::error_mappers::*;
|
||||
use crate::id;
|
||||
@ -127,7 +127,7 @@ impl MoveProcessor {
|
||||
.as_inner()
|
||||
.serialize(&mut buf)
|
||||
.map_err(map_failure_error)?;
|
||||
modules_bytes.push(buf);
|
||||
modules_bytes.push(ModuleBytes { bytes: buf });
|
||||
}
|
||||
Ok(LibraAccountState::VerifiedProgram {
|
||||
script_bytes,
|
||||
@ -172,7 +172,7 @@ impl MoveProcessor {
|
||||
VerifiedScript::deserialize(&script_bytes).map_err(map_vm_binary_error)?;
|
||||
let modules = modules_bytes
|
||||
.iter()
|
||||
.map(|bytes| VerifiedModule::deserialize(&bytes))
|
||||
.map(|module_bytes| VerifiedModule::deserialize(&module_bytes.bytes))
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.map_err(map_vm_binary_error)?;
|
||||
|
||||
|
Reference in New Issue
Block a user