Commit 509cf65f authored by Andrew Jones's avatar Andrew Jones Committed by Hero Bird

[cli] rename generate-abi to generate-metadata (#239)

* [cli] rename generate-abi to generate-metadata

* [cli] rename abi.json to metadata.json
parent 80984939
Pipeline #56991 failed with stages
in 41 seconds
......@@ -25,13 +25,13 @@ Install the latest ink! CLI using the following command:
cargo install --git https://github.com/paritytech/ink cargo-contract --force
```
There is a new contract ABI format you need to use. You can generate the ABI using:
There is a new contract metadata format you need to use. You can generate the metadata using:
```bash
cargo contract generate-abi
cargo contract generate-metadata
```
This will generate a file `abi.json` you should upload when deploying or interacting with a
This will generate a file `metadata.json` you should upload when deploying or interacting with a
contract.
## Declaring a Contract
......
......@@ -21,8 +21,8 @@ use std::path::PathBuf;
/// Executes build of the smart-contract which produces a wasm binary that is ready for deploying.
///
/// It does so by invoking build by cargo and then post processing the final binary.
pub(crate) fn execute_generate_abi(dir: Option<&PathBuf>) -> Result<String> {
println!(" Generating abi");
pub(crate) fn execute_generate_metadata(dir: Option<&PathBuf>) -> Result<String> {
println!(" Generating metadata");
super::exec_cargo(
"run",
......@@ -36,13 +36,13 @@ pub(crate) fn execute_generate_abi(dir: Option<&PathBuf>) -> Result<String> {
dir,
)?;
let metadata = MetadataCommand::new().exec()?;
let mut abi_path = metadata.target_directory.clone();
abi_path.push("abi.json");
let cargo_metadata = MetadataCommand::new().exec()?;
let mut out_path = cargo_metadata.target_directory.clone();
out_path.push("metadata.json");
Ok(format!(
"Your abi file is ready.\nYou can find it here:\n{}",
abi_path.display()
"Your metadata file is ready.\nYou can find it here:\n{}",
out_path.display()
))
}
......@@ -50,8 +50,8 @@ pub(crate) fn execute_generate_abi(dir: Option<&PathBuf>) -> Result<String> {
mod tests {
use crate::{
cmd::{
execute_generate_abi,
execute_new,
execute_generate_metadata,
tests::with_tmp_dir,
},
AbstractionLayer,
......@@ -59,16 +59,16 @@ mod tests {
#[cfg(feature = "test-ci-only")]
#[test]
fn generate_abi() {
fn generate_metadata() {
with_tmp_dir(|path| {
execute_new(AbstractionLayer::Lang, "new_project", Some(path))
.expect("new project creation failed");
let working_dir = path.join("new_project");
super::execute_generate_abi(Some(&working_dir)).expect("generate abi failed");
super::execute_generate_metadata(Some(&working_dir)).expect("generate metadata failed");
let mut abi_file = working_dir.clone();
abi_file.push("target");
abi_file.push("abi.json");
abi_file.push("metadata.json");
assert!(abi_file.exists())
});
}
......
......@@ -23,14 +23,14 @@ use std::{
process::Command,
};
mod abi;
mod metadata;
mod build;
mod deploy;
mod error;
mod new;
pub(crate) use self::{
abi::execute_generate_abi,
metadata::execute_generate_metadata,
build::execute_build,
deploy::execute_deploy,
error::{
......
......@@ -94,9 +94,9 @@ enum Command {
/// Builds the smart contract.
#[structopt(name = "build")]
Build {},
/// Generate abi artifacts
#[structopt(name = "generate-abi")]
GenerateAbi {},
/// Generate contract metadata artifacts
#[structopt(name = "generate-metadata")]
GenerateMetadata {},
/// Test the smart contract off-chain.
#[structopt(name = "test")]
Test {},
......@@ -145,7 +145,7 @@ fn exec(cmd: Command) -> cmd::Result<String> {
target_dir,
} => cmd::execute_new(*layer, name, target_dir.as_ref()),
Command::Build {} => cmd::execute_build(None),
Command::GenerateAbi {} => cmd::execute_generate_abi(None),
Command::GenerateMetadata {} => cmd::execute_generate_metadata(None),
Command::Test {} => Err(CommandError::UnimplementedCommand),
Command::Deploy {
url,
......
......@@ -2,6 +2,6 @@ fn main() -> Result<(), std::io::Error> {
let abi = <contract::{{camel_name}} as ink_lang2::GenerateAbi>::generate_abi();
let contents = serde_json::to_string_pretty(&abi)?;
std::fs::create_dir("target").ok();
std::fs::write("target/abi.json", contents)?;
std::fs::write("target/metadata.json", contents)?;
Ok(())
}
......@@ -2,6 +2,6 @@ fn main() -> Result<(), std::io::Error> {
let abi = contract::ink_generate_abi();
let contents = serde_json::to_string_pretty(&abi)?;
std::fs::create_dir("target").ok();
std::fs::write("target/abi.json", contents)?;
std::fs::write("target/metadata.json", contents)?;
Ok(())
}
......@@ -2,6 +2,6 @@ fn main() -> Result<(), std::io::Error> {
let abi = contract::ink_generate_abi();
let contents = serde_json::to_string_pretty(&abi)?;
std::fs::create_dir("target").ok();
std::fs::write("target/abi.json", contents)?;
std::fs::write("target/metadata.json", contents)?;
Ok(())
}
......@@ -2,6 +2,6 @@ fn main() -> Result<(), std::io::Error> {
let abi = contract::ink_generate_abi();
let contents = serde_json::to_string_pretty(&abi)?;
std::fs::create_dir("target").ok();
std::fs::write("target/abi.json", contents)?;
std::fs::write("target/metadata.json", contents)?;
Ok(())
}
......@@ -3,6 +3,6 @@ fn main() -> Result<(), std::io::Error> {
let abi = contract::ink_generate_abi();
let contents = serde_json::to_string_pretty(&abi)?;
std::fs::create_dir("target").ok();
std::fs::write("target/abi.json", contents)?;
std::fs::write("target/metadata.json", contents)?;
Ok(())
}
......@@ -3,6 +3,6 @@ fn main() -> Result<(), std::io::Error> {
let abi = contract::ink_generate_abi();
let contents = serde_json::to_string_pretty(&abi)?;
std::fs::create_dir("target").ok();
std::fs::write("target/abi.json", contents)?;
std::fs::write("target/metadata.json", contents)?;
Ok(())
}
......@@ -3,6 +3,6 @@ fn main() -> Result<(), std::io::Error> {
let abi = contract::ink_generate_abi();
let contents = serde_json::to_string_pretty(&abi)?;
std::fs::create_dir("target").ok();
std::fs::write("target/abi.json", contents)?;
std::fs::write("target/metadata.json", contents)?;
Ok(())
}
......@@ -3,6 +3,6 @@ fn main() -> Result<(), std::io::Error> {
let abi = contract::ink_generate_abi();
let contents = serde_json::to_string_pretty(&abi)?;
std::fs::create_dir("target").ok();
std::fs::write("target/abi.json", contents)?;
std::fs::write("target/metadata.json", contents)?;
Ok(())
}
......@@ -2,6 +2,6 @@ fn main() -> Result<(), std::io::Error> {
let abi = <contract::Delegator as ink_lang2::GenerateAbi>::generate_abi();
let contents = serde_json::to_string_pretty(&abi)?;
std::fs::create_dir("target").ok();
std::fs::write("target/abi.json", contents)?;
std::fs::write("target/metadata.json", contents)?;
Ok(())
}
......@@ -2,6 +2,6 @@ fn main() -> Result<(), std::io::Error> {
let abi = <contract::Erc20 as ink_lang2::GenerateAbi>::generate_abi();
let contents = serde_json::to_string_pretty(&abi)?;
std::fs::create_dir("target").ok();
std::fs::write("target/abi.json", contents)?;
std::fs::write("target/metadata.json", contents)?;
Ok(())
}
......@@ -3,6 +3,6 @@ fn main() -> Result<(), std::io::Error> {
let abi = <contract::Flipper as ink_lang2::GenerateAbi>::generate_abi();
let contents = serde_json::to_string_pretty(&abi)?;
std::fs::create_dir("target").ok();
std::fs::write("target/abi.json", contents)?;
std::fs::write("target/metadata.json", contents)?;
Ok(())
}
......@@ -3,6 +3,6 @@ fn main() -> Result<(), std::io::Error> {
let abi = <contract::Incrementer as ink_lang2::GenerateAbi>::generate_abi();
let contents = serde_json::to_string_pretty(&abi)?;
std::fs::create_dir("target").ok();
std::fs::write("target/abi.json", contents)?;
std::fs::write("target/metadata.json", contents)?;
Ok(())
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment