From 3a7f8836dd2316b3b97dbf883ef8cfda22231c3c Mon Sep 17 00:00:00 2001 From: fro Date: Mon, 6 Aug 2018 15:16:54 +0300 Subject: [PATCH] the constructor arg removed from --- cli/build/main.rs | 12 +++++++----- src/build.rs | 8 +------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/cli/build/main.rs b/cli/build/main.rs index 38df600..df0eb63 100644 --- a/cli/build/main.rs +++ b/cli/build/main.rs @@ -160,7 +160,6 @@ fn do_main() -> Result<(), Error> { let (module, ctor_module) = build( module, - true, source_input.target(), runtime_type_version, &public_api_entries, @@ -174,10 +173,13 @@ fn do_main() -> Result<(), Error> { parity_wasm::serialize_to_file(save_raw_path, module.clone()).map_err(Error::Encoding)?; } - parity_wasm::serialize_to_file( - &path, - ctor_module.expect("ctor_module can't be None, because 'constructor' argument is set to true in build"), - ).map_err(Error::Encoding)?; + if let Some(ctor_module) = ctor_module { + parity_wasm::serialize_to_file( + &path, + ctor_module, + ).map_err(Error::Encoding)?; + } + Ok(()) } diff --git a/src/build.rs b/src/build.rs index 80c644b..0f4809e 100644 --- a/src/build.rs +++ b/src/build.rs @@ -18,7 +18,6 @@ use parity_wasm::elements; pub enum Error { Encoding(elements::Error), Packing(PackingError), - NoCreateSymbolFound, Optimizer, } @@ -47,7 +46,6 @@ impl std::fmt::Display for Error { Encoding(ref err) => write!(f, "Encoding error ({})", err), Optimizer => write!(f, "Optimization error due to missing export section. Pointed wrong file?"), Packing(ref e) => write!(f, "Packing failed due to module structure error: {}. Sure used correct libraries for building contracts?", e), - NoCreateSymbolFound => write!(f, "Packing failed: no \"{}\" symbol found?", CREATE_SYMBOL), } } } @@ -62,7 +60,6 @@ fn has_ctor(module: &elements::Module) -> bool { pub fn build( mut module: elements::Module, - constructor: bool, source_target: SourceTarget, runtime_type_version: Option<([u8; 4], u32)>, public_api_entries: &[&str], @@ -105,10 +102,7 @@ pub fn build( )?; } - if constructor { - if !has_ctor(&ctor_module) { - Err(Error::NoCreateSymbolFound)? - } + if has_ctor(&ctor_module) { if !skip_optimization { optimize(&mut ctor_module, vec![CREATE_SYMBOL])?; }