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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use compiler::Compiler;
use diem_types::transaction::{Module, Script};
use move_binary_format::CompiledModule;
pub fn compile_module(file_name: &str, code: &str) -> (CompiledModule, Module) {
let compiled_module = Compiler {
deps: diem_framework_releases::current_modules().iter().collect(),
}
.into_compiled_module(file_name, code)
.expect("Module compilation failed");
let module = Module::new(
Compiler {
deps: diem_framework_releases::current_modules().iter().collect(),
}
.into_module_blob(file_name, code)
.expect("Module compilation failed"),
);
(compiled_module, module)
}
pub fn compile_script(file_name: &str, code: &str, extra_deps: Vec<CompiledModule>) -> Script {
let compiler = Compiler {
deps: diem_framework_releases::current_modules()
.iter()
.chain(extra_deps.iter())
.collect(),
};
Script::new(
compiler
.into_script_blob(file_name, code)
.expect("Script compilation failed"),
vec![],
vec![],
)
}