Skip to content

Commit

Permalink
Use package name instead of lib name for metadata dependency (#107)
Browse files Browse the repository at this point in the history
* Use package name instead of lib name for metadata dependency

* Fix ink_metadata error messages
  • Loading branch information
ascjones authored Nov 13, 2020
1 parent 68080d0 commit 69a9fae
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/workspace/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,25 +369,25 @@ impl Manifest {

fs::create_dir_all(&dir).context(format!("Creating directory '{}'", dir.display()))?;

let name = self
let contract_package_name = self
.toml
.get("lib")
.ok_or(anyhow::anyhow!("lib section not found"))?
.get("package")
.ok_or(anyhow::anyhow!("package section not found"))?
.get("name")
.ok_or(anyhow::anyhow!("[lib] name field not found"))?
.ok_or(anyhow::anyhow!("[package] name field not found"))?
.as_str()
.ok_or(anyhow::anyhow!("[lib] name should be a string"))?;
.ok_or(anyhow::anyhow!("[package] name should be a string"))?;

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

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

let updated_toml = toml::to_string(&self.toml)?;
Expand Down

0 comments on commit 69a9fae

Please sign in to comment.