Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/escrow_with_delay.simf
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn timeout_spend(sender_sig: Signature) {
let sender_pk: Pubkey = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798; // 1 * G
checksig(sender_pk, sender_sig);
let timeout: Distance = 1000;
jet::check_lock_distance(timeout);
jet::broken_do_not_use_check_lock_distance(timeout);
}

fn main() {
Expand Down
11 changes: 9 additions & 2 deletions src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::sync::Arc;

use either::Either;
use miniscript::iter::{Tree, TreeLike};
use simplicity::jet::Elements;
use simplicity::jet::{Elements, Jet};

use crate::debug::{CallTracker, DebugSymbols, TrackedCallName};
use crate::error::{Error, RichError, Span, WithSpan};
Expand Down Expand Up @@ -1294,7 +1294,14 @@ impl AbstractSyntaxTree for CallName {
Ok(Elements::CheckSigVerify | Elements::Verify) | Err(_) => {
Err(Error::JetDoesNotExist(name.clone())).with_span(from)
}
Ok(jet) => Ok(Self::Jet(jet)),
Ok(jet) => {
// TODO: in future, we will want this to be a warning, but that would mean that
// you need to change all methods to return warnings.
if jet.is_deprecated() {
return Err(Error::JetIsDeprecated(name.clone())).with_span(from);
}
Ok(Self::Jet(jet))
}
},
parse::CallName::UnwrapLeft(right_ty) => scope
.resolve(right_ty)
Expand Down
5 changes: 5 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ pub enum Error {
ModuleRedefined(ModuleName),
ArgumentMissing(WitnessName),
ArgumentTypeMismatch(WitnessName, ResolvedType, ResolvedType),
JetIsDeprecated(JetName),
}

#[rustfmt::skip]
Expand Down Expand Up @@ -490,6 +491,10 @@ impl fmt::Display for Error {
f,
"Jet `{name}` does not exist"
),
Error::JetIsDeprecated(name) => write!(
f,
"Jet `{name}` has been deprecrated."
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Jet `{name}` has been deprecrated."
"Jet `{name}` has been deprecated."

),
Error::InvalidCast(source, target) => write!(
f,
"Cannot cast values of type `{source}` as values of type `{target}`"
Expand Down
16 changes: 8 additions & 8 deletions src/jet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,12 @@ pub fn source_type(jet: Elements) -> Vec<AliasedType> {
* Time locks
*/
Elements::CheckLockTime => vec![Time.into()],
Elements::CheckLockDistance => vec![Distance.into()],
Elements::CheckLockDuration => vec![Duration.into()],
Elements::BrokenDoNotUseCheckLockDistance => vec![Distance.into()],
Elements::BrokenDoNotUseCheckLockDuration => vec![Duration.into()],
Elements::CheckLockHeight => vec![Height.into()],
Elements::TxLockTime
| Elements::TxLockDistance
| Elements::TxLockDuration
| Elements::BrokenDoNotUseTxLockDistance
| Elements::BrokenDoNotUseTxLockDuration
| Elements::TxLockHeight
| Elements::TxIsFinal => vec![],
/*
Expand Down Expand Up @@ -956,13 +956,13 @@ pub fn target_type(jet: Elements) -> AliasedType {
* Time locks
*/
Elements::CheckLockTime
| Elements::CheckLockDistance
| Elements::CheckLockDuration
| Elements::BrokenDoNotUseCheckLockDistance
| Elements::BrokenDoNotUseCheckLockDuration
| Elements::CheckLockHeight => AliasedType::unit(),
Elements::TxIsFinal => bool(),
Elements::TxLockTime => Time.into(),
Elements::TxLockDistance => Distance.into(),
Elements::TxLockDuration => Duration.into(),
Elements::BrokenDoNotUseTxLockDistance => Distance.into(),
Elements::BrokenDoNotUseTxLockDuration => Duration.into(),
Elements::TxLockHeight => Height.into(),
/*
* Issuance
Expand Down
Loading