Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new ink entrance crate #728

Merged
merged 20 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
- `--output-json` support for `call`, `instantiate` and `upload` commands - [#722](https://github.com/paritytech/cargo-contract/pull/722)
- Use new ink entrance crate - [#728](https://github.com/paritytech/cargo-contract/pull/728)

## [2.0.0-alpha.2] - 2022-09-02

Expand Down
150 changes: 81 additions & 69 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/cargo-contract/src/cmd/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ fn exec_cargo_for_wasm_target(
args.push("--offline");
}
if build_mode == BuildMode::Debug {
args.push("--features=ink_env/ink-debug");
args.push("--features=ink/ink-debug");
} else {
args.push("-Zbuild-std-features=panic_immediate_abort");
}
Expand Down
2 changes: 1 addition & 1 deletion crates/cargo-contract/src/cmd/extrinsics/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl From<subxt::Error> for ErrorVariant {

impl From<anyhow::Error> for ErrorVariant {
fn from(error: anyhow::Error) -> Self {
Self::Generic(GenericError::from_message(format!("{}", error)))
Self::Generic(GenericError::from_message(format!("{:?}", error)))
}
}

Expand Down
6 changes: 3 additions & 3 deletions crates/cargo-contract/src/crate_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,16 @@ impl CrateMetadata {
.packages
.iter()
.find_map(|package| {
if package.name == "ink_lang" {
if package.name == "ink" {
Some(
Version::parse(&package.version.to_string())
.expect("Invalid ink_lang version string"),
.expect("Invalid ink crate version string"),
)
} else {
None
}
})
.ok_or_else(|| anyhow::anyhow!("No 'ink_lang' dependency found"))?;
.ok_or_else(|| anyhow::anyhow!("No 'ink' dependency found"))?;

let ExtraMetadata {
documentation,
Expand Down
12 changes: 5 additions & 7 deletions crates/cargo-contract/src/workspace/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,18 +462,16 @@ impl Manifest {
.as_str()
.ok_or_else(|| anyhow::anyhow!("[package] name should be a string"))?;

let ink_metadata = self
let ink_crate = self
.toml
.get("dependencies")
.ok_or_else(|| anyhow::anyhow!("[dependencies] section not found"))?
.get("ink_metadata")
.ok_or_else(|| anyhow::anyhow!("ink_metadata dependency not found"))?
.get("ink")
.ok_or_else(|| anyhow::anyhow!("ink dependency not found"))?
.as_table()
.ok_or_else(|| {
anyhow::anyhow!("ink_metadata dependency should be a table")
})?;
.ok_or_else(|| anyhow::anyhow!("ink dependency should be a table"))?;

metadata::generate_package(dir, contract_package_name, ink_metadata.clone())?;
metadata::generate_package(dir, contract_package_name, ink_crate.clone())?;
}

let updated_toml = toml::to_string(&self.toml)?;
Expand Down
10 changes: 5 additions & 5 deletions crates/cargo-contract/src/workspace/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use toml::value;
pub(super) fn generate_package<P: AsRef<Path>>(
target_dir: P,
contract_package_name: &str,
mut ink_metadata_dependency: value::Table,
mut ink_crate_dependency: value::Table,
) -> Result<()> {
let dir = target_dir.as_ref();
tracing::debug!(
Expand Down Expand Up @@ -59,12 +59,12 @@ pub(super) fn generate_package<P: AsRef<Path>>(
contract.insert("package".into(), contract_package_name.into());

// make ink_metadata dependency use default features
ink_metadata_dependency.remove("default-features");
ink_metadata_dependency.remove("features");
ink_metadata_dependency.remove("optional");
ink_crate_dependency.remove("default-features");
ink_crate_dependency.remove("features");
ink_crate_dependency.remove("optional");

// add ink dependencies copied from contract manifest
deps.insert("ink_metadata".into(), ink_metadata_dependency.into());
deps.insert("ink".into(), ink_crate_dependency.into());
let cargo_toml = toml::to_string(&cargo_toml)?;

fs::write(dir.join("Cargo.toml"), cargo_toml)?;
Expand Down
11 changes: 2 additions & 9 deletions crates/cargo-contract/templates/new/_Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ authors = ["[your_name] <[your_email]>"]
edition = "2021"

[dependencies]
ink_primitives = { version = "4.0.0-alpha.1", default-features = false }
ink_metadata = { version = "4.0.0-alpha.1", default-features = false, features = ["derive"], optional = true }
ink_env = { version = "4.0.0-alpha.1", default-features = false }
ink_storage = { version = "4.0.0-alpha.1", default-features = false }
ink_lang = { version = "4.0.0-alpha.1", default-features = false }
ink = { version = "4.0.0-alpha.3", default-features = false }

scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"], optional = true }
Expand All @@ -25,10 +21,7 @@ crate-type = [
[features]
default = ["std"]
std = [
"ink_metadata/std",
"ink_env/std",
"ink_storage/std",
"ink_primitives/std",
"ink/std",
"scale/std",
"scale-info/std",
]
Expand Down
Loading