From e4d7d616cd420d53a5fd8ae5c4bab7f5579e838d Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Thu, 23 Dec 2021 22:05:50 +0200 Subject: [PATCH] fix(create): infer contract from just contract name (#295) previously you had to specify the full path, and it'd panic if you only provided a name --- cli/src/cmd/create.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cli/src/cmd/create.rs b/cli/src/cmd/create.rs index 0793735ef2c7..8e7772e20889 100644 --- a/cli/src/cmd/create.rs +++ b/cli/src/cmd/create.rs @@ -108,7 +108,13 @@ impl CreateArgs { let mut contract_artifact = None; for (name, artifact) in compiled.into_artifacts() { - let artifact_contract_name = name.split(':').collect::>()[1]; + // if the contract name + let mut split = name.split(':'); + let mut artifact_contract_name = + split.next().ok_or_else(|| eyre::Error::msg("no contract name provided"))?; + if let Some(new_name) = split.next() { + artifact_contract_name = new_name; + }; if artifact_contract_name == self.contract.name { if has_found_contract {