diff --git a/Cargo.toml b/Cargo.toml index 47b9c03..cd5277c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-liquid" -version = "1.0.0-rc1" +version = "1.0.0-rc2" authors = ["vita-dounai "] build = "build.rs" edition = "2018" @@ -21,6 +21,7 @@ pwasm-utils = "0.14.0" which = "4.0.2" indicatif = { version = "0.15.0", features = ["rayon", "improved_unicode"] } console = { version = "0.13.0" } +crossterm = "0.19.0" [build-dependencies] anyhow = "1.0.32" diff --git a/build.rs b/build.rs index e6e23e7..64a0598 100644 --- a/build.rs +++ b/build.rs @@ -16,7 +16,7 @@ use std::{ ffi::OsStr, fs::File, io::{Read, Write}, - path::PathBuf, + path::{Path, PathBuf}, }; use walkdir::WalkDir; use zip::{write::FileOptions, CompressionMethod, ZipWriter}; @@ -52,13 +52,13 @@ fn main() { }); } -fn zip_dir(src_dir: &PathBuf, dst_file: &PathBuf) -> Result<()> { +fn zip_dir(src_dir: &Path, dst_file: &Path) -> Result<()> { if !src_dir.exists() { - anyhow::bail!("src_dir '{}' does not exist", src_dir.display()); + anyhow::bail!("src_dir `{}` does not exist", src_dir.display()); } if !src_dir.is_dir() { - anyhow::bail!("src_dir '{}' is not a directory"); + anyhow::bail!("src_dir `{}` is not a directory"); } let file = File::create(dst_file)?; @@ -77,20 +77,21 @@ fn zip_dir(src_dir: &PathBuf, dst_file: &PathBuf) -> Result<()> { // Cargo.toml files cause the folder to excluded from `cargo package` so need to be renamed if name.file_name() == Some(OsStr::new("_Cargo.toml")) { - name.set_file_name("Cargo.toml") + name.set_file_name("Cargo.toml"); } - if path.is_file() { - #[allow(deprecated)] - zip.start_file_from_path(name.as_path(), options)?; - let mut f = File::open(path)?; - - f.read_to_end(&mut buffer)?; - zip.write_all(&*buffer)?; - buffer.clear(); - } else if name.as_os_str().len() != 0 { - #[allow(deprecated)] - zip.add_directory_from_path(name.as_path(), options)?; + if let Some(name) = name.to_str() { + if path.is_file() { + zip.start_file(name, options)?; + let mut f = File::open(path)?; + f.read_to_end(&mut buffer)?; + zip.write_all(&*buffer)?; + buffer.clear(); + } else if !name.is_empty() { + zip.add_directory(name, options)?; + } + } else { + anyhow::bail!("the path contains invalid UTF-8 characters: `{:?}` ", name); } } zip.finish()?; diff --git a/src/cmd/build.rs b/src/cmd/build.rs index 3f78486..db2fec6 100644 --- a/src/cmd/build.rs +++ b/src/cmd/build.rs @@ -18,13 +18,20 @@ use crate::{ use anyhow::{Context, Result}; use colored::Colorize; use console::Emoji; +use crossterm::{ + cursor::{self, DisableBlinking, EnableBlinking, MoveTo}, + execute, terminal, +}; use indicatif::HumanDuration; use parity_wasm::elements::{Module, Section}; +use std::sync::mpsc::channel; use std::{ - io::{self, Write}, + io::{self, stderr, Write}, path::{Path, PathBuf}, process::Command, - time::Instant, + sync::Arc, + thread, + time::{Duration, Instant}, }; struct CrateMetadata { @@ -88,14 +95,17 @@ fn collect_crate_metadata(manifest_path: &ManifestPath) -> Result fn build_cargo_project( crate_metadata: &CrateMetadata, use_gm: bool, - verbosity: &Option, + verbosity: Verbosity, ) -> Result<()> { utils::check_channel()?; - std::env::set_var("RUSTFLAGS", "-C link-arg=-z -C link-arg=stack-size=65536"); + std::env::set_var( + "RUSTFLAGS", + "--emit mir -C link-arg=-z -C link-arg=stack-size=65536", + ); let verbosity = Some(match verbosity { - Some(Verbosity::Verbose) => xargo_lib::Verbosity::Verbose, - Some(Verbosity::Quiet) | None => xargo_lib::Verbosity::Quiet, + Verbosity::Verbose => xargo_lib::Verbosity::Verbose, + Verbosity::Quiet => xargo_lib::Verbosity::Quiet, }); let xbuild = |manifest_path: &ManifestPath| { @@ -144,11 +154,11 @@ fn build_cargo_project( /// /// Presently all custom sections are not required so they can be stripped safely. fn strip_custom_sections(module: &mut Module) { - module.sections_mut().retain(|section| match section { - Section::Custom(_) => false, - Section::Name(_) => false, - Section::Reloc(_) => false, - _ => true, + module.sections_mut().retain(|section| { + !matches!( + section, + Section::Custom(_) | Section::Name(_) | Section::Reloc(_) + ) }); } @@ -185,7 +195,7 @@ fn optimize_wasm(crate_metadata: &CrateMetadata) -> Result<()> { // check `wasm-opt` installed if which::which("wasm-opt").is_err() { - println!( + eprintln!( "{}", "wasm-opt is not installed. Install this tool on your system in order to \n\ reduce the size of your Wasm binary. \n\ @@ -218,12 +228,12 @@ fn optimize_wasm(crate_metadata: &CrateMetadata) -> Result<()> { Ok(()) } -fn generate_abi(crate_meta: &CrateMetadata, verbosity: &Option) -> Result<()> { +fn generate_abi(crate_meta: &CrateMetadata, verbosity: Verbosity) -> Result<()> { utils::check_channel()?; std::env::set_var("RUSTFLAGS", ""); let build = |manifest_path: &ManifestPath| -> Result<()> { - let cargo = std::env::var("CARGO").unwrap_or("cargo".to_string()); + let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".to_string()); let mut cmd = Command::new(cargo); let origin_manifest_path = crate_meta.manifest_path.as_ref().canonicalize()?; @@ -243,8 +253,8 @@ fn generate_abi(crate_meta: &CrateMetadata, verbosity: &Option) -> Re .as_str(), format!("--target-dir={}", crate_meta.target_dir().to_string_lossy()).as_str(), match verbosity { - Some(Verbosity::Quiet) | None => "--quiet", - Some(Verbosity::Verbose) => "--verbose", + Verbosity::Quiet => "--quiet", + Verbosity::Verbose => "--verbose", }, ] .iter() @@ -274,53 +284,185 @@ fn generate_abi(crate_meta: &CrateMetadata, verbosity: &Option) -> Re Ok(()) } -static LOOKING_GLASS: Emoji<'_, '_> = Emoji("🔍 ", ":-D"); -static TRUCK: Emoji<'_, '_> = Emoji("🚚 ", ";-)"); -static CLIP: Emoji<'_, '_> = Emoji("🔗 ", "âˆĐˍâˆĐ"); -static PAPER: Emoji<'_, '_> = Emoji("📃 ", "^_^"); -static SPARKLE: Emoji<'_, '_> = Emoji("âœĻ ", ":-) "); +static LOOKING_GLASS: Emoji<'_, '_> = Emoji("🔍 ", "d(ãƒŧωãƒŧd)"); +static TRUCK: Emoji<'_, '_> = Emoji("🚚 ", "(âˆŦãƒŧωãƒŧ)âˆŦ"); +static CLIP: Emoji<'_, '_> = Emoji("🔗 ", "∇(ãƒŧωãƒŧ∇)"); +static PAPER: Emoji<'_, '_> = Emoji("📃 ", "∂(ãƒŧωãƒŧ∂)"); +static SPARKLE: Emoji<'_, '_> = Emoji("âœĻ ", "(˘â€Ēωâ€Ē˘)āļ‡ "); + +struct FormattedDuration(Duration); + +impl std::fmt::Display for FormattedDuration { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut t = self.0.as_millis(); + let millis = t % 1000; + t /= 1000; + let seconds = t % 60; + t /= 60; + let minutes = t % 60; + t /= 60; + let hours = t % 24; + t /= 24; + if t > 0 { + let days = t; + write!( + f, + "{}d {:02}:{:02}:{:02}.{:03}", + days, hours, minutes, seconds, millis + ) + } else { + write!( + f, + "{:02}:{:02}:{:02}.{:03}", + hours, minutes, seconds, millis + ) + } + } +} + +fn execute_task( + stage: &str, + emoji: Emoji<'_, '_>, + message: &str, + f: F, + show_animation: bool, +) -> Result +where + F: FnOnce() -> Result + Send + 'static, + T: Send + 'static, + E: Send + 'static, +{ + const INDICATES: [char; 4] = ['|', '/', '-', '\\']; + let stage = stage.bold().dimmed(); + let message = message.bold().bright_green(); + let started = Instant::now(); + + if show_animation { + let origin_pos = cursor::position().unwrap(); + eprintln!(); + + let (tx, rx) = channel(); + let t = thread::spawn(move || { + let result = f(); + tx.send(matches!(result, Ok(_))).unwrap(); + result + }); + + let mut i = 0; + let mut stderr = stderr(); + let success = loop { + if let Ok(success) = rx.try_recv() { + break success; + } + + let elapsed = format!("[{}]", FormattedDuration(started.elapsed())).cyan(); + let info = format!( + "{} {} {} {: <25} {}\r", + INDICATES[i], stage, emoji, message, elapsed + ); + i = (i + 1) % INDICATES.len(); + + { + let mut handle = stderr.lock(); + let cursor_pos = cursor::position().unwrap(); + if cursor_pos.1 - origin_pos.1 > 8 { + break false; + } + + execute!(handle, DisableBlinking, MoveTo(origin_pos.0, origin_pos.1)).unwrap(); + handle.write_all(info.as_bytes()).unwrap(); + handle.flush().unwrap(); + execute!(handle, EnableBlinking, MoveTo(cursor_pos.0, cursor_pos.1),).unwrap(); + } + + thread::sleep(Duration::from_millis(50)); + }; + + if success { + let elapsed = format!("[{}]", FormattedDuration(started.elapsed())).cyan(); + let info = format!( + "{} {} {} {: <25} {}\n", + "√".green(), + stage, + emoji, + message, + elapsed, + ); + let cursor_pos = cursor::position().unwrap(); + execute!(stderr, MoveTo(origin_pos.0, origin_pos.1)).unwrap(); + stderr.write_all(info.as_bytes()).unwrap(); + execute!(stderr, MoveTo(cursor_pos.0, cursor_pos.1)).unwrap(); + } + t.join().unwrap() + } else { + eprintln!("{}", format!("* {} {} {}", stage, emoji, message)); + f() + } +} pub(crate) fn execute_build( manifest_path: ManifestPath, use_gm: bool, - verbosity: Option, + verbosity: Verbosity, ) -> Result { let started = Instant::now(); + let terminal_size = terminal::size(); + let current_pos = cursor::position(); + let show_animation = matches!(verbosity, Verbosity::Quiet) + && match (terminal_size, current_pos) { + (Ok(terminal_size), Ok(current_pos)) => { + !(terminal_size.1 < 16 || terminal_size.1 - current_pos.1 < 16) + } + _ => false, + }; + let crate_metadata; - println!( - "{} {} {}", - "[1/4]".bold().dimmed(), - LOOKING_GLASS, - "Collecting crate metadata".bright_green().bold() - ); - let crate_metadata = collect_crate_metadata(&manifest_path)?; + { + let result = execute_task( + "[1/4]", + LOOKING_GLASS, + "Collecting crate metadata", + move || collect_crate_metadata(&manifest_path), + show_animation, + ); + crate_metadata = Arc::new(result?); + } - println!( - "{} {} {}", - "[2/4]".bold().dimmed(), - TRUCK, - "Building cargo project".bright_green().bold() - ); - build_cargo_project(&crate_metadata, use_gm, &verbosity)?; + { + let crate_metadata = crate_metadata.clone(); + execute_task( + "[2/4]", + TRUCK, + "Building cargo project", + move || build_cargo_project(crate_metadata.as_ref(), use_gm, verbosity), + show_animation, + )?; + } - println!( - "{} {} {}", - "[3/4]".bold().dimmed(), - CLIP, - "Optimizing wasm file".bright_green().bold() - ); - optimize_wasm(&crate_metadata)?; + { + let crate_metadata = crate_metadata.clone(); + execute_task( + "[3/4]", + CLIP, + "Optimizing Wasm bytecode", + move || optimize_wasm(crate_metadata.as_ref()), + show_animation, + )?; + } - println!( - "{} {} {}", - "[4/4]".bold().dimmed(), - PAPER, - "Generating ABI file".bright_green().bold() - ); - generate_abi(&crate_metadata, &verbosity)?; + { + let crate_metadata = crate_metadata.clone(); + execute_task( + "[4/4]", + PAPER, + "Generating ABI file", + move || generate_abi(crate_metadata.as_ref(), verbosity), + show_animation, + )?; + } Ok(format!( - "\n{}Done in {}, your project is ready now:\n{}: {}\n{}: {}", + "\n{}Done in {}, your project is ready now:\n{: >6}: {}\n{: >6}: {}", SPARKLE, HumanDuration(started.elapsed()), "Binary".green().bold(), diff --git a/src/cmd/new.rs b/src/cmd/new.rs index 34a7f03..b5adcc8 100644 --- a/src/cmd/new.rs +++ b/src/cmd/new.rs @@ -55,8 +55,9 @@ pub(crate) fn execute_new(ty: &str, name: &str, dir: Option<&PathBuf>) -> Result let contents = contents .replace("{{name}}", name) .replace("{{camel_name}}", &name.to_camel_case()); - #[allow(deprecated)] - let out_path = out_dir.join(file.sanitized_name().strip_prefix(ty).unwrap()); + let mangled_name = file.mangled_name(); + let sanitized_name = mangled_name.strip_prefix(ty)?; + let out_path = out_dir.join(sanitized_name); if file.name().ends_with('/') { fs::create_dir_all(&out_path)?; @@ -72,9 +73,6 @@ pub(crate) fn execute_new(ty: &str, name: &str, dir: Option<&PathBuf>) -> Result .create_new(true) .open(out_path.clone()) .map_err(|e| { - #[allow(deprecated)] - let sanitized_name = file.sanitized_name(); - let sanitized_name = sanitized_name.strip_prefix(ty).unwrap(); if e.kind() == std::io::ErrorKind::AlreadyExists { anyhow::anyhow!( "New contract file {} already exists", diff --git a/src/main.rs b/src/main.rs index b653726..5b732b9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,19 +47,20 @@ struct VerbosityFlags { verbose: bool, } +#[derive(Copy, Clone)] enum Verbosity { Quiet, Verbose, } -impl TryFrom<&VerbosityFlags> for Option { +impl TryFrom<&VerbosityFlags> for Verbosity { type Error = Error; fn try_from(value: &VerbosityFlags) -> Result { match (value.quiet, value.verbose) { - (true, false) => Ok(Some(Verbosity::Quiet)), - (false, false) => Ok(Some(Verbosity::Quiet)), - (false, true) => Ok(Some(Verbosity::Verbose)), + (true, false) => Ok(Verbosity::Quiet), + (false, false) => Ok(Verbosity::Quiet), + (false, true) => Ok(Verbosity::Verbose), (true, true) => anyhow::bail!("Cannot pass both --quiet and --verbose flags"), } } diff --git a/src/workspace.rs b/src/workspace.rs index b461c59..c6d7d31 100644 --- a/src/workspace.rs +++ b/src/workspace.rs @@ -16,7 +16,7 @@ use std::{ collections::{HashMap, HashSet}, convert::{TryFrom, TryInto}, fs, - path::{Path, PathBuf}, + path::{Path, PathBuf, MAIN_SEPARATOR}, }; use toml::value; @@ -56,9 +56,9 @@ impl Default for ManifestPath { } } -impl Into for &ManifestPath { - fn into(self) -> PathBuf { - self.path.clone() +impl From<&ManifestPath> for PathBuf { + fn from(manifest_path: &ManifestPath) -> Self { + manifest_path.path.clone() } } @@ -122,12 +122,12 @@ impl Manifest { .or_insert(value::Value::Table(Default::default())); let release = profile .as_table_mut() - .ok_or(anyhow::anyhow!("profile should be a table"))? + .ok_or_else(|| anyhow::anyhow!("profile should be a table"))? .entry("release") .or_insert(value::Value::Table(Default::default())); let lto = release .as_table_mut() - .ok_or(anyhow::anyhow!("release should be a table"))? + .ok_or_else(|| anyhow::anyhow!("release should be a table"))? .entry("lto") .or_insert(enabled.into()); *lto = enabled.into(); @@ -139,14 +139,14 @@ impl Manifest { let lib = self .toml .get_mut("lib") - .ok_or(anyhow::anyhow!("lib section not found"))?; + .ok_or_else(|| anyhow::anyhow!("lib section not found"))?; let crate_types = lib .get_mut("crate-type") - .ok_or(anyhow::anyhow!("crate-type section not found"))?; + .ok_or_else(|| anyhow::anyhow!("crate-type section not found"))?; crate_types .as_array_mut() - .ok_or(anyhow::anyhow!("crate-types should be an Array")) + .ok_or_else(|| anyhow::anyhow!("crate-types should be an Array")) } /// Writes the amended manifest to the given path. @@ -185,7 +185,7 @@ impl Manifest { let to_absolute = |value_id: String, existing_path: &mut value::Value| -> Result<()> { let path_str = existing_path .as_str() - .ok_or(anyhow::anyhow!("{} should be a string", value_id))?; + .ok_or_else(|| anyhow::anyhow!("{} should be a string", value_id))?; let path = PathBuf::from(path_str); if path.is_relative() { let lib_abs = abs_dir.join(path); @@ -195,10 +195,9 @@ impl Manifest { }; let rewrite_path = |table_value: &mut value::Value, table_section: &str, default: &str| { - let table = table_value.as_table_mut().ok_or(anyhow::anyhow!( - "'[{}]' section should be a table", - table_section - ))?; + let table = table_value.as_table_mut().ok_or_else(|| { + anyhow::anyhow!("'[{}]' section should be a table", table_section) + })?; match table.get_mut("path") { Some(existing_path) => { @@ -224,18 +223,26 @@ impl Manifest { // Rewrite `[lib] path = /path/to/lib.rs` if let Some(lib) = self.toml.get_mut("lib") { - rewrite_path(lib, "lib", "src/lib.rs")?; + rewrite_path( + lib, + "lib", + &["src", "lib.rs"].join(&MAIN_SEPARATOR.to_string()), + )?; } // Rewrite `[[bin]] path = /path/to/main.rs` if let Some(bin) = self.toml.get_mut("bin") { let bins = bin .as_array_mut() - .ok_or(anyhow::anyhow!("'[[bin]]' section should be a table array"))?; + .ok_or_else(|| anyhow::anyhow!("'[[bin]]' section should be a table array"))?; // Rewrite `[[bin]] path =` value to an absolute path. for bin in bins { - rewrite_path(bin, "[bin]", "src/main.rs")?; + rewrite_path( + bin, + "[bin]", + &["src", "main.rs"].join(&MAIN_SEPARATOR.to_string()), + )?; } } @@ -247,7 +254,7 @@ impl Manifest { .collect::>(); let table = dependencies .as_table_mut() - .ok_or(anyhow::anyhow!("dependencies should be a table"))?; + .ok_or_else(|| anyhow::anyhow!("dependencies should be a table"))?; for (name, value) in table { let package_name = { let package = value.get("package"); @@ -269,6 +276,7 @@ impl Manifest { } } +#[allow(clippy::ptr_arg)] fn crate_type_exists(crate_type: &str, crate_types: &value::Array) -> bool { crate_types .iter() @@ -295,10 +303,12 @@ impl Workspace { .packages .iter() .find(|p| p.id == *package_id) - .expect(&format!( - "Package '{}' is a member and should be in the packages list", - package_id - )); + .unwrap_or_else(|| { + panic!( + "Package '{}' is a member and should be in the packages list", + package_id + ) + }); let manifest = Manifest::new(&package.manifest_path)?; Ok((package_id.clone(), (package.clone(), manifest))) }; diff --git a/template/collaboration/.liquid/abi_gen/_Cargo.toml b/template/collaboration/.liquid/abi_gen/_Cargo.toml index 3e1750e..dc76c77 100644 --- a/template/collaboration/.liquid/abi_gen/_Cargo.toml +++ b/template/collaboration/.liquid/abi_gen/_Cargo.toml @@ -1,6 +1,6 @@ [package] name = "abi-gen" -version = "1.0.0-rc1" +version = "1.0.0-rc2" authors = ["vita-dounai "] edition = "2018" publish = false @@ -17,7 +17,7 @@ features = ["liquid-abi-gen"] [dependencies.liquid_lang] git = "https://github.com/WeBankBlockchain/liquid" -tag= "v1.0.0-rc1" +branch = "dev" package = "liquid_lang" default-features = false features = ["collaboration-abi-gen"] diff --git a/template/collaboration/_Cargo.toml b/template/collaboration/_Cargo.toml index a151506..1bfb899 100644 --- a/template/collaboration/_Cargo.toml +++ b/template/collaboration/_Cargo.toml @@ -10,20 +10,17 @@ edition = "2018" scale = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive", "full"] } spin = "0.7.0" -liquid_lang = { version = "1.0.0-rc1", git = "https://github.com/WeBankBlockchain/liquid", tag= "v1.0.0-rc1", package = "liquid_lang", default-features = false, features = ["collaboration"] } -liquid_primitives = { version = "1.0.0-rc1", git = "https://github.com/WeBankBlockchain/liquid", tag= "v1.0.0-rc1", package = "liquid_primitives", default-features = false } -liquid_prelude = { version = "1.0.0-rc1", git = "https://github.com/WeBankBlockchain/liquid", tag= "v1.0.0-rc1", package = "liquid_prelude", default-features = false } -liquid_abi_codec = { version = "1.0.0-rc1", git = "https://github.com/WeBankBlockchain/liquid", tag= "v1.0.0-rc1", package = "liquid_abi_codec", default-features = false } -liquid_macro = { version = "1.0.0-rc1", git = "https://github.com/WeBankBlockchain/liquid", tag= "v1.0.0-rc1", package = "liquid_macro", default-features = false, features = ["collaboration"] } -liquid_abi_gen = { version = "1.0.0-rc1", git = "https://github.com/WeBankBlockchain/liquid", tag= "v1.0.0-rc1", package = "liquid_abi_gen", default-features = false, optional = true } -liquid_ty_mapping = { version = "1.0.0-rc1", git = "https://github.com/WeBankBlockchain/liquid", tag= "v1.0.0-rc1", package = "liquid_ty_mapping", default-features = false } +liquid_lang = { version = "1.0.0-rc2", git = "https://github.com/WeBankBlockchain/liquid", branch = "dev", package = "liquid_lang", default-features = false, features = ["collaboration"] } +liquid_primitives = { version = "1.0.0-rc2", git = "https://github.com/WeBankBlockchain/liquid", branch = "dev", package = "liquid_primitives", default-features = false } +liquid_prelude = { version = "1.0.0-rc2", git = "https://github.com/WeBankBlockchain/liquid", branch = "dev", package = "liquid_prelude", default-features = false } +liquid_macro = { version = "1.0.0-rc2", git = "https://github.com/WeBankBlockchain/liquid", branch = "dev", package = "liquid_macro", default-features = false } +liquid_abi_gen = { version = "1.0.0-rc2", git = "https://github.com/WeBankBlockchain/liquid", branch = "dev", package = "liquid_abi_gen", default-features = false, optional = true } [dev-dependencies] predicates = "1.0.5" [lib] name = "{{name}}" -path = "lib.rs" crate-type = [ # Used for normal contract Wasm blobs. "cdylib", diff --git a/template/collaboration/lib.rs b/template/collaboration/src/lib.rs similarity index 100% rename from template/collaboration/lib.rs rename to template/collaboration/src/lib.rs diff --git a/template/contract/.liquid/abi_gen/_Cargo.toml b/template/contract/.liquid/abi_gen/_Cargo.toml index aa0c603..258c78b 100644 --- a/template/contract/.liquid/abi_gen/_Cargo.toml +++ b/template/contract/.liquid/abi_gen/_Cargo.toml @@ -1,6 +1,6 @@ [package] name = "abi-gen" -version = "1.0.0-rc1" +version = "1.0.0-rc2" authors = ["vita-dounai "] edition = "2018" publish = false @@ -17,7 +17,7 @@ features = ["liquid-abi-gen"] [dependencies.liquid_lang] git = "https://github.com/WeBankBlockchain/liquid" -tag= "v1.0.0-rc1" +branch = "dev" package = "liquid_lang" default-features = false features = ["contract-abi-gen"] diff --git a/template/contract/_Cargo.toml b/template/contract/_Cargo.toml index 0fbe31c..ab46fcb 100644 --- a/template/contract/_Cargo.toml +++ b/template/contract/_Cargo.toml @@ -9,20 +9,17 @@ edition = "2018" [dependencies] scale = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive", "full"] } -liquid_lang = { version = "1.0.0-rc1", git = "https://github.com/WeBankBlockchain/liquid", tag= "v1.0.0-rc1", package = "liquid_lang", default-features = false, features = ["contract", "solidity-compatible"] } -liquid_primitives = { version = "1.0.0-rc1", git = "https://github.com/WeBankBlockchain/liquid", tag= "v1.0.0-rc1", package = "liquid_primitives", default-features = false } -liquid_prelude = { version = "1.0.0-rc1", git = "https://github.com/WeBankBlockchain/liquid", tag= "v1.0.0-rc1", package = "liquid_prelude", default-features = false } -liquid_abi_codec = { version = "1.0.0-rc1", git = "https://github.com/WeBankBlockchain/liquid", tag= "v1.0.0-rc1", package = "liquid_abi_codec", default-features = false } -liquid_macro = { version = "1.0.0-rc1", git = "https://github.com/WeBankBlockchain/liquid", tag= "v1.0.0-rc1", package = "liquid_macro", default-features = false } -liquid_abi_gen = { version = "1.0.0-rc1", git = "https://github.com/WeBankBlockchain/liquid", tag= "v1.0.0-rc1", package = "liquid_abi_gen", default-features = false, optional = true } -liquid_ty_mapping = { version = "1.0.0-rc1", git = "https://github.com/WeBankBlockchain/liquid", tag= "v1.0.0-rc1", package = "liquid_ty_mapping", default-features = false } +liquid_lang = { version = "1.0.0-rc2", git = "https://github.com/WeBankBlockchain/liquid", branch = "dev", package = "liquid_lang", default-features = false, features = ["contract"] } +liquid_primitives = { version = "1.0.0-rc2", git = "https://github.com/WeBankBlockchain/liquid", branch = "dev", package = "liquid_primitives", default-features = false } +liquid_prelude = { version = "1.0.0-rc2", git = "https://github.com/WeBankBlockchain/liquid", branch = "dev", package = "liquid_prelude", default-features = false } +liquid_macro = { version = "1.0.0-rc2", git = "https://github.com/WeBankBlockchain/liquid", branch = "dev", package = "liquid_macro", default-features = false } +liquid_abi_gen = { version = "1.0.0-rc2", git = "https://github.com/WeBankBlockchain/liquid", branch = "dev", package = "liquid_abi_gen", default-features = false, optional = true } [dev-dependencies] predicates = "1.0.5" [lib] name = "{{name}}" -path = "lib.rs" crate-type = [ # Used for normal contract Wasm blobs. "cdylib", @@ -37,9 +34,7 @@ std = [ "scale/std", "liquid_primitives/std", "liquid_prelude/std", - "liquid_abi_codec/std", "liquid_macro/std", - "liquid_ty_mapping/std", ] liquid-abi-gen = [ "std", diff --git a/template/contract/lib.rs b/template/contract/src/lib.rs similarity index 100% rename from template/contract/lib.rs rename to template/contract/src/lib.rs