Skip to content

Commit

Permalink
Chores for doc comments, Cargo.toml and copyright date (use-ink#437)
Browse files Browse the repository at this point in the history
* Update copyright date to 2022

* Remove outdated `rust-version` entries from `Cargo.toml`

* Tune doc comments

* Streamline `keywords` in `Cargo.toml`

* Write Wasm consistent in doc comments
  • Loading branch information
cmichi authored Feb 18, 2022
1 parent 438b31d commit e3ea3f4
Show file tree
Hide file tree
Showing 24 changed files with 51 additions and 55 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ version = "0.17.0"
authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs"
edition = "2021"
rust-version = "1.56.1"

license = "GPL-3.0"
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 Parity Technologies (UK) Ltd.
// Copyright 2018-2022 Parity Technologies (UK) Ltd.
// This file is part of cargo-contract.
//
// cargo-contract is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -95,7 +95,7 @@ fn zip_dir(src_dir: &Path, dst_file: &Path, method: CompressionMethod) -> Result
let path = entry.path();
let mut name = path.strip_prefix(&src_dir)?.to_path_buf();

// Cargo.toml files cause the folder to excluded from `cargo package` so need to be renamed
// `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");
}
Expand Down
3 changes: 1 addition & 2 deletions metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ name = "contract-metadata"
version = "0.5.1"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
rust-version = "1.56.1"

license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/paritytech/cargo-contract"
documentation = "https://docs.rs/contract-metadata"
homepage = "https://www.substrate.io/"
description = "Library defining metadata for smart contracts on substrate"
keywords = ["parity", "blockchain"]
keywords = ["wasm", "parity", "webassembly", "blockchain", "edsl"]
include = ["Cargo.toml", "*.rs", "LICENSE"]

[lib]
Expand Down
2 changes: 1 addition & 1 deletion metadata/byte_str.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 Parity Technologies (UK) Ltd.
// Copyright 2018-2022 Parity Technologies (UK) Ltd.
// This file is part of cargo-contract.
//
// cargo-contract is free software: you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion metadata/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 Parity Technologies (UK) Ltd.
// Copyright 2018-2022 Parity Technologies (UK) Ltd.
// This file is part of cargo-contract.
//
// cargo-contract is free software: you can redistribute it and/or modify
Expand Down
32 changes: 16 additions & 16 deletions src/cmd/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 Parity Technologies (UK) Ltd.
// Copyright 2018-2022 Parity Technologies (UK) Ltd.
// This file is part of cargo-contract.
//
// cargo-contract is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -54,13 +54,13 @@ pub(crate) struct ExecuteArgs {
output_type: OutputType,
}

/// Executes build of the smart-contract which produces a wasm binary that is ready for deploying.
/// Executes build of the smart contract which produces a Wasm binary that is ready for deploying.
///
/// It does so by invoking `cargo build` and then post processing the final binary.
#[derive(Debug, StructOpt)]
#[structopt(name = "build")]
pub struct BuildCommand {
/// Path to the Cargo.toml of the contract to build
/// Path to the `Cargo.toml` of the contract to build
#[structopt(long, parse(from_os_str))]
manifest_path: Option<PathBuf>,
/// By default the contract is compiled with debug functionality
Expand Down Expand Up @@ -91,7 +91,7 @@ pub struct BuildCommand {
verbosity: VerbosityFlags,
#[structopt(flatten)]
unstable_options: UnstableOptions,
/// Number of optimization passes, passed as an argument to wasm-opt.
/// Number of optimization passes, passed as an argument to `wasm-opt`.
///
/// - `0`: execute no optimization passes
///
Expand Down Expand Up @@ -187,7 +187,7 @@ impl BuildCommand {
#[derive(Debug, StructOpt)]
#[structopt(name = "check")]
pub struct CheckCommand {
/// Path to the Cargo.toml of the contract to build
/// Path to the `Cargo.toml` of the contract to build
#[structopt(long, parse(from_os_str))]
manifest_path: Option<PathBuf>,
#[structopt(flatten)]
Expand Down Expand Up @@ -226,9 +226,9 @@ impl CheckCommand {
/// to build the standard library with [`panic_immediate_abort`](https://github.com/johnthagen/min-sized-rust#remove-panic-string-formatting-with-panic_immediate_abort)
/// which reduces the size of the Wasm binary by not including panic strings and formatting code.
///
/// # Cargo.toml optimizations
/// # `Cargo.toml` optimizations
///
/// The original Cargo.toml will be amended to remove the `rlib` crate type in order to minimize
/// The original `Cargo.toml` will be amended to remove the `rlib` crate type in order to minimize
/// the final Wasm binary size.
///
/// Preferred default `[profile.release]` settings will be added if they are missing, existing
Expand Down Expand Up @@ -304,7 +304,7 @@ fn exec_cargo_for_wasm_target(
Ok(())
}

/// Ensures the wasm memory import of a given module has the maximum number of pages.
/// Ensures the Wasm memory import of a given module has the maximum number of pages.
///
/// Iterates over the import section, finds the memory import entry if any and adjusts the maximum
/// limit.
Expand Down Expand Up @@ -363,7 +363,7 @@ fn strip_exports(module: &mut Module) {
}
}

/// Load and parse a wasm file from disk.
/// Load and parse a Wasm file from disk.
fn load_module<P: AsRef<Path>>(path: P) -> Result<Module> {
let path = path.as_ref();
parity_wasm::deserialize_file(path).context(format!(
Expand All @@ -372,9 +372,9 @@ fn load_module<P: AsRef<Path>>(path: P) -> Result<Module> {
))
}

/// Performs required post-processing steps on the wasm artifact.
/// Performs required post-processing steps on the Wasm artifact.
fn post_process_wasm(crate_metadata: &CrateMetadata) -> Result<()> {
// Deserialize wasm module from a file.
// Deserialize Wasm module from a file.
let mut module =
load_module(&crate_metadata.original_wasm).context("Loading of original wasm failed")?;

Expand All @@ -393,9 +393,9 @@ fn post_process_wasm(crate_metadata: &CrateMetadata) -> Result<()> {
Ok(())
}

/// Attempts to perform optional wasm optimization using `binaryen`.
/// Attempts to perform optional Wasm optimization using `binaryen`.
///
/// The intention is to reduce the size of bloated wasm binaries as a result of missing
/// The intention is to reduce the size of bloated Wasm binaries as a result of missing
/// optimizations (or bugs?) between Rust and Wasm.
fn optimize_wasm(
crate_metadata: &CrateMetadata,
Expand Down Expand Up @@ -439,7 +439,7 @@ fn optimize_wasm(
/// The supplied `optimization_level` denotes the number of optimization passes,
/// resulting in potentially a lot of time spent optimizing.
///
/// If successful, the optimized wasm is written to `dest_optimized`.
/// If successful, the optimized Wasm is written to `dest_optimized`.
fn do_optimization(
dest_wasm: &OsStr,
dest_optimized: &OsStr,
Expand Down Expand Up @@ -510,7 +510,7 @@ fn do_optimization(
Ok(())
}

/// Checks if the wasm-opt binary under `wasm_opt_path` returns a version
/// Checks if the `wasm-opt` binary under `wasm_opt_path` returns a version
/// compatible with `cargo-contract`.
///
/// Currently this must be a version >= 99.
Expand Down Expand Up @@ -643,7 +643,7 @@ pub fn assert_debug_mode_supported(ink_version: &Version) -> anyhow::Result<()>
Ok(())
}

/// Executes build of the smart-contract which produces a wasm binary that is ready for deploying.
/// Executes build of the smart contract which produces a Wasm binary that is ready for deploying.
///
/// It does so by invoking `cargo build` and then post processing the final binary.
pub(crate) fn execute(args: ExecuteArgs) -> Result<BuildResult> {
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/extrinsics/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ impl CallCommand {
}
}

/// A struct that encodes RPC parameters required for a call to a smart-contract.
/// A struct that encodes RPC parameters required for a call to a smart contract.
///
/// Copied from pallet-contracts-rpc
/// Copied from `pallet-contracts-rpc`.
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
pub struct RpcCallRequest {
Expand Down
10 changes: 5 additions & 5 deletions src/cmd/extrinsics/instantiate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type ContractInstantiateResult =

#[derive(Debug, StructOpt)]
pub struct InstantiateCommand {
/// Path to wasm contract code, defaults to `./target/ink/<name>.wasm`.
/// Path to Wasm contract code, defaults to `./target/ink/<name>.wasm`.
/// Use to instantiate contracts which have not yet been uploaded.
/// If the contract has already been uploaded use `--code-hash` instead.
#[structopt(parse(from_os_str))]
Expand Down Expand Up @@ -302,7 +302,7 @@ impl<'a> Exec<'a> {
}
}

/// A struct that encodes RPC parameters required to instantiate a new smart-contract.
/// A struct that encodes RPC parameters required to instantiate a new smart contract.
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct InstantiateRequest {
Expand All @@ -315,13 +315,13 @@ struct InstantiateRequest {
salt: Bytes,
}

/// Reference to an existing code hash or a new wasm module.
/// Reference to an existing code hash or a new Wasm module.
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
enum Code {
/// A wasm module as raw bytes.
/// A Wasm module as raw bytes.
Upload(Bytes),
/// The code hash of an on-chain wasm blob.
/// The code hash of an on-chain Wasm blob.
Existing(<DefaultConfig as Config>::Hash),
}

Expand Down
8 changes: 4 additions & 4 deletions src/cmd/extrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ type PairSigner = subxt::PairSigner<DefaultConfig, SignedExtra, sp_core::sr25519
type SignedExtra = subxt::DefaultExtra<DefaultConfig>;
type RuntimeApi = runtime_api::api::RuntimeApi<DefaultConfig, SignedExtra>;

/// Arguments required for creating and sending an extrinsic to a substrate node
/// Arguments required for creating and sending an extrinsic to a substrate node.
#[derive(Clone, Debug, StructOpt)]
pub struct ExtrinsicOpts {
/// Path to the Cargo.toml of the contract
/// Path to the `Cargo.toml` of the contract.
#[structopt(long, parse(from_os_str))]
manifest_path: Option<PathBuf>,
/// Websockets url of a substrate node
/// Websockets url of a substrate node.
#[structopt(
name = "url",
long,
Expand All @@ -66,7 +66,7 @@ pub struct ExtrinsicOpts {
/// Secret key URI for the account deploying the contract.
#[structopt(name = "suri", long, short)]
suri: String,
/// Password for the secret key
/// Password for the secret key.
#[structopt(name = "password", long, short)]
password: Option<String>,
#[structopt(flatten)]
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/extrinsics/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type CodeUploadReturnValue = pallet_contracts_primitives::CodeUploadReturnValue<
#[derive(Debug, StructOpt)]
#[structopt(name = "upload", about = "Upload a contract's code")]
pub struct UploadCommand {
/// Path to wasm contract code, defaults to `./target/ink/<name>.wasm`.
/// Path to Wasm contract code, defaults to `./target/ink/<name>.wasm`.
#[structopt(parse(from_os_str))]
wasm_path: Option<PathBuf>,
#[structopt(flatten)]
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 Parity Technologies (UK) Ltd.
// Copyright 2018-2022 Parity Technologies (UK) Ltd.
// This file is part of cargo-contract.
//
// cargo-contract is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -53,7 +53,7 @@ struct ExtendedMetadataResult {
user: Option<User>,
}

/// Generates a file with metadata describing the ABI of the smart-contract.
/// Generates a file with metadata describing the ABI of the smart contract.
///
/// It does so by generating and invoking a temporary workspace member.
pub(crate) fn execute(
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 Parity Technologies (UK) Ltd.
// Copyright 2018-2022 Parity Technologies (UK) Ltd.
// This file is part of cargo-contract.
//
// cargo-contract is free software: you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/new.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 Parity Technologies (UK) Ltd.
// Copyright 2018-2022 Parity Technologies (UK) Ltd.
// This file is part of cargo-contract.
//
// cargo-contract is free software: you can redistribute it and/or modify
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 Parity Technologies (UK) Ltd.
// Copyright 2018-2022 Parity Technologies (UK) Ltd.
// This file is part of cargo-contract.
//
// cargo-contract is free software: you can redistribute it and/or modify
Expand All @@ -20,7 +20,7 @@ use colored::Colorize;
use std::{convert::TryFrom, path::PathBuf};
use structopt::StructOpt;

/// Executes smart-contract tests off-chain by delegating to `cargo test`.
/// Executes smart contract tests off-chain by delegating to `cargo test`.
#[derive(Debug, StructOpt)]
#[structopt(name = "test")]
pub struct TestCommand {
Expand Down
2 changes: 1 addition & 1 deletion src/crate_metadata.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 Parity Technologies (UK) Ltd.
// Copyright 2018-2022 Parity Technologies (UK) Ltd.
// This file is part of cargo-contract.
//
// cargo-contract is free software: you can redistribute it and/or modify
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 Parity Technologies (UK) Ltd.
// Copyright 2018-2022 Parity Technologies (UK) Ltd.
// This file is part of cargo-contract.
//
// cargo-contract is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -339,7 +339,7 @@ pub struct BuildResult {
/// Result of the optimization process.
#[derive(serde::Serialize)]
pub struct OptimizationResult {
/// The path of the optimized wasm file.
/// The path of the optimized Wasm file.
pub dest_wasm: PathBuf,
/// The original Wasm size.
pub original_size: f64,
Expand Down
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 Parity Technologies (UK) Ltd.
// Copyright 2018-2022 Parity Technologies (UK) Ltd.
// This file is part of cargo-contract.
//
// cargo-contract is free software: you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion src/validate_wasm.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 Parity Technologies (UK) Ltd.
// Copyright 2018-2022 Parity Technologies (UK) Ltd.
// This file is part of cargo-contract.
//
// cargo-contract is free software: you can redistribute it and/or modify
Expand Down
6 changes: 3 additions & 3 deletions src/workspace/manifest.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 Parity Technologies (UK) Ltd.
// Copyright 2018-2022 Parity Technologies (UK) Ltd.
// This file is part of cargo-contract.
//
// cargo-contract is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -31,14 +31,14 @@ const MANIFEST_FILE: &str = "Cargo.toml";
const LEGACY_METADATA_PACKAGE_PATH: &str = ".ink/abi_gen";
const METADATA_PACKAGE_PATH: &str = ".ink/metadata_gen";

/// Path to a Cargo.toml file
/// Path to a `Cargo.toml` file
#[derive(Clone, Debug)]
pub struct ManifestPath {
path: PathBuf,
}

impl ManifestPath {
/// Create a new ManifestPath, errors if not path to `Cargo.toml`
/// Create a new [`ManifestPath`], errors if not path to `Cargo.toml`
pub fn new<P: AsRef<Path>>(path: P) -> Result<Self> {
let manifest = path.as_ref();
if let Some(file_name) = manifest.file_name() {
Expand Down
2 changes: 1 addition & 1 deletion src/workspace/metadata.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 Parity Technologies (UK) Ltd.
// Copyright 2018-2022 Parity Technologies (UK) Ltd.
// This file is part of cargo-contract.
//
// cargo-contract is free software: you can redistribute it and/or modify
Expand Down
4 changes: 2 additions & 2 deletions src/workspace/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 Parity Technologies (UK) Ltd.
// Copyright 2018-2022 Parity Technologies (UK) Ltd.
// This file is part of cargo-contract.
//
// cargo-contract is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -85,7 +85,7 @@ impl Workspace {
/// # Note
///
/// The root package is the current workspace package being built, not to be confused with
/// the workspace root (where the top level workspace Cargo.toml is defined).
/// the workspace root (where the top level workspace `Cargo.toml` is defined).
pub fn with_root_package_manifest<F>(&mut self, f: F) -> Result<&mut Self>
where
F: FnOnce(&mut Manifest) -> Result<()>,
Expand Down
2 changes: 1 addition & 1 deletion src/workspace/profile.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018-2021 Parity Technologies (UK) Ltd.
// Copyright 2018-2022 Parity Technologies (UK) Ltd.
// This file is part of cargo-contract.
//
// cargo-contract is free software: you can redistribute it and/or modify
Expand Down
1 change: 0 additions & 1 deletion templates/new/_Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name = "{{name}}"
version = "0.1.0"
authors = ["[your_name] <[your_email]>"]
edition = "2021"
rust-version = "1.56.1"

[dependencies]
ink_primitives = { version = "3.0.0-rc8", default-features = false }
Expand Down
1 change: 0 additions & 1 deletion templates/tools/generate-metadata/_Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name = "metadata-gen"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
rust-version = "1.56.1"
publish = false

[[bin]]
Expand Down

0 comments on commit e3ea3f4

Please sign in to comment.