Skip to content

Commit

Permalink
Minor cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
prasannavl committed Sep 5, 2023
1 parent c5e63e8 commit 499a8ec
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions lib/ain-contracts/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use std::env;
use std::fs;
use std::path::PathBuf;

use anyhow::format_err;
use anyhow::Result;
use anyhow::{bail, Context, Result};
use ethers_solc::{Project, ProjectPathsConfig, Solc};

fn main() -> Result<()> {
Expand All @@ -22,7 +21,7 @@ fn main() -> Result<()> {

let sol_project_root = PathBuf::from(sol_project_name);
if !sol_project_root.exists() {
return Err(format_err!("Solidity project missing: {sol_project_root:?}"));
bail!("Solidity project missing: {sol_project_root:?}");
}

let paths = ProjectPathsConfig::builder()
Expand All @@ -43,10 +42,8 @@ fn main() -> Result<()> {

for (id, artifact) in artifacts {
if id.name == contract_name {
let abi = artifact.abi.ok_or_else(|| format_err!("ABI not found"))?;
let bytecode = artifact
.deployed_bytecode
.ok_or_else(|| format_err!("Bytecode not found"))?;
let abi = artifact.abi.context("ABI not found")?;
let bytecode = artifact.deployed_bytecode.context("Bytecode not found")?;
let bytecode_out_path = sol_project_outdir.clone().join("bytecode.json");
let abi_out_path = sol_project_outdir.clone().join("abi.json");

Expand All @@ -55,10 +52,7 @@ fn main() -> Result<()> {
bytecode_out_path,
serde_json::to_string(&bytecode)?.as_bytes(),
)?;
fs::write(
abi_out_path,
serde_json::to_string(&abi)?.as_bytes(),
)?;
fs::write(abi_out_path, serde_json::to_string(&abi)?.as_bytes())?;
}
}

Expand Down

0 comments on commit 499a8ec

Please sign in to comment.