Skip to content

Commit c5b91df

Browse files
committed
f
1 parent 5389c39 commit c5b91df

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

libchisel/src/deployer.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use parity_wasm::builder;
2-
use parity_wasm::elements::{CustomSection, Module};
2+
use parity_wasm::elements::CustomSection;
33

4-
use super::{ChiselModule, ModuleError, ModuleKind, ModulePreset, ModuleTranslator};
4+
use super::{ChiselModule, ModuleError, ModuleKind, ModulePreset, ModuleTranslator, WasmModule};
55

66
/// Enum on which ModuleTranslator is implemented.
77
pub enum Deployer {
@@ -78,13 +78,13 @@ fn deployer_code() -> Vec<u8> {
7878
}
7979

8080
/// Returns a module which contains the deployable bytecode as a custom section.
81-
fn create_custom_deployer(payload: &[u8]) -> Result<Module, ModuleError> {
81+
fn create_custom_deployer(payload: &[u8]) -> Result<WasmModule, ModuleError> {
8282
// The standard deployer code, which expects a 32 bit little endian as the trailing content
8383
// immediately following the payload, placed in a custom section.
8484
let code = deployer_code();
8585

8686
// This is the pre-written deployer code.
87-
let mut module = Module::from_bytes(&code)?;
87+
let mut module = WasmModule::from_bytes(&code)?;
8888

8989
// Re-write memory to pre-allocate enough for code size
9090
let memory_initial = (payload.len() as u32 / 65536) + 1;
@@ -113,7 +113,7 @@ fn create_custom_deployer(payload: &[u8]) -> Result<Module, ModuleError> {
113113

114114
/// Returns a module which contains the deployable bytecode as a data segment.
115115
#[rustfmt::skip]
116-
fn create_memory_deployer(payload: &[u8]) -> Module {
116+
fn create_memory_deployer(payload: &[u8]) -> WasmModule {
117117
// Instructions calling finish(0, payload_len)
118118
let instructions = vec![
119119
parity_wasm::elements::Instruction::I32Const(0),
@@ -171,11 +171,11 @@ fn create_memory_deployer(payload: &[u8]) -> Module {
171171
}
172172

173173
impl ModuleTranslator for Deployer {
174-
fn translate_inplace(&self, _module: &mut Module) -> Result<bool, ModuleError> {
174+
fn translate_inplace(&self, _module: &mut WasmModule) -> Result<bool, ModuleError> {
175175
Err(ModuleError::NotSupported)
176176
}
177177

178-
fn translate(&self, module: &Module) -> Result<Option<Module>, ModuleError> {
178+
fn translate(&self, module: &WasmModule) -> Result<Option<WasmModule>, ModuleError> {
179179
let payload = module.clone().to_bytes()?;
180180
let output = match self {
181181
Deployer::Memory => create_memory_deployer(&payload),
@@ -290,7 +290,7 @@ mod tests {
290290

291291
#[test]
292292
fn customsection_interface_test() {
293-
let payload = Module::default();
293+
let payload = WasmModule::default();
294294
let module = Deployer::with_preset("customsection")
295295
.unwrap()
296296
.translate(&payload)
@@ -313,7 +313,7 @@ mod tests {
313313

314314
#[test]
315315
fn memory_interface_test() {
316-
let payload = Module::default();
316+
let payload = WasmModule::default();
317317
let module = Deployer::with_preset("memory")
318318
.unwrap()
319319
.translate(&payload)

0 commit comments

Comments
 (0)