1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use parity_wasm::{builder, elements::Module};
use casper_types::contracts::DEFAULT_ENTRY_POINT_NAME;
use crate::shared::wasm_prep::{PreprocessingError, Preprocessor};
pub fn do_nothing_bytes() -> Vec<u8> {
let module = builder::module()
.function()
.signature()
.build()
.body()
.build()
.build()
.export()
.field(DEFAULT_ENTRY_POINT_NAME)
.build()
.memory()
.build()
.build();
parity_wasm::serialize(module).expect("should serialize")
}
pub fn do_nothing_module(preprocessor: &Preprocessor) -> Result<Module, PreprocessingError> {
let do_nothing_bytes = do_nothing_bytes();
preprocessor.preprocess(&do_nothing_bytes)
}