Skip to content

Commit

Permalink
feat: support clarity 3 (#1465)
Browse files Browse the repository at this point in the history
* feat: handle clarity 3

* chore: handle clarity 3 keywords

* refactor: improve manifest parsing

* chore: update cargo.lock

* chore: update cargo.lock

* chore: update stacks core dependencies

* chore: update stacks core dependencies
  • Loading branch information
hugocaillard authored Jun 7, 2024
1 parent 343a01a commit 2c92bef
Show file tree
Hide file tree
Showing 15 changed files with 276 additions and 267 deletions.
98 changes: 70 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions components/clarinet-deployments/src/requirements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ pub async fn retrieve_contract(
let clarity_version = match contract.clarity_version {
Some(1) => ClarityVersion::Clarity1,
Some(2) => ClarityVersion::Clarity2,
Some(3) => ClarityVersion::Clarity3,
Some(_) => {
return Err("unable to parse clarity_version (can either be '1' or '2'".to_string())
}
Expand Down
26 changes: 23 additions & 3 deletions components/clarinet-deployments/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,13 @@ impl ContractPublishSpecification {
Ok(ClarityVersion::Clarity1)
} else if clarity_version.eq(&2) {
Ok(ClarityVersion::Clarity2)
} else if clarity_version.eq(&3) {
Ok(ClarityVersion::Clarity3)
} else {
Err("unable to parse clarity_version (can either be '1' or '2'".to_string())
Err(
"unable to parse clarity_version, it can either be '1', '2', or '3'"
.to_string(),
)
}
}
_ => Ok(DEFAULT_CLARITY_VERSION),
Expand Down Expand Up @@ -661,6 +666,7 @@ pub mod clarity_version_serde {
match clarity_version {
ClarityVersion::Clarity1 => s.serialize_i64(1),
ClarityVersion::Clarity2 => s.serialize_i64(2),
ClarityVersion::Clarity3 => s.serialize_i64(3),
}
}

Expand All @@ -672,6 +678,7 @@ pub mod clarity_version_serde {
match cv {
1 => Ok(ClarityVersion::Clarity1),
2 => Ok(ClarityVersion::Clarity2),
3 => Ok(ClarityVersion::Clarity3),
_ => Err(serde::de::Error::custom(INVALID_CLARITY_VERSION)),
}
}
Expand Down Expand Up @@ -743,8 +750,13 @@ impl RequirementPublishSpecification {
Ok(ClarityVersion::Clarity1)
} else if clarity_version.eq(&2) {
Ok(ClarityVersion::Clarity2)
} else if clarity_version.eq(&3) {
Ok(ClarityVersion::Clarity3)
} else {
Err("unable to parse clarity_version (can either be '1' or '2'".to_string())
Err(
"unable to parse clarity_version, it can either be '1', '2', or '3'"
.to_string(),
)
}
}
_ => Ok(DEFAULT_CLARITY_VERSION),
Expand Down Expand Up @@ -867,8 +879,13 @@ impl EmulatedContractPublishSpecification {
Ok(ClarityVersion::Clarity1)
} else if clarity_version.eq(&2) {
Ok(ClarityVersion::Clarity2)
} else if clarity_version.eq(&3) {
Ok(ClarityVersion::Clarity3)
} else {
Err("unable to parse clarity_version (can either be '1' or '2'".to_string())
Err(
"unable to parse clarity_version, it can either be '1', '2', or '3'"
.to_string(),
)
}
}
_ => Ok(DEFAULT_CLARITY_VERSION),
Expand Down Expand Up @@ -1380,6 +1397,7 @@ impl TransactionPlanSpecification {
clarity_version: match tx.clarity_version {
ClarityVersion::Clarity1 => Some(1),
ClarityVersion::Clarity2 => Some(2),
ClarityVersion::Clarity3 => Some(3),
},
},
)
Expand All @@ -1405,6 +1423,7 @@ impl TransactionPlanSpecification {
clarity_version: match tx.clarity_version {
ClarityVersion::Clarity1 => Some(1),
ClarityVersion::Clarity2 => Some(2),
ClarityVersion::Clarity3 => Some(3),
},
},
)
Expand All @@ -1426,6 +1445,7 @@ impl TransactionPlanSpecification {
clarity_version: match tx.clarity_version {
ClarityVersion::Clarity1 => Some(1),
ClarityVersion::Clarity2 => Some(2),
ClarityVersion::Clarity3 => Some(3),
},
},
)
Expand Down
Loading

0 comments on commit 2c92bef

Please sign in to comment.