Skip to content

Commit c5f18b6

Browse files
authored
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
1 parent 4ae7132 commit c5f18b6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cli/src/cmd/create.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,13 @@ impl CreateArgs {
108108
let mut contract_artifact = None;
109109

110110
for (name, artifact) in compiled.into_artifacts() {
111-
let artifact_contract_name = name.split(':').collect::<Vec<_>>()[1];
111+
// if the contract name
112+
let mut split = name.split(':');
113+
let mut artifact_contract_name =
114+
split.next().ok_or_else(|| eyre::Error::msg("no contract name provided"))?;
115+
if let Some(new_name) = split.next() {
116+
artifact_contract_name = new_name;
117+
};
112118

113119
if artifact_contract_name == self.contract.name {
114120
if has_found_contract {

0 commit comments

Comments
 (0)