diff --git a/examples/escrow_with_delay.simf b/examples/escrow_with_delay.simf index 67dd3d3e..8a11a54a 100644 --- a/examples/escrow_with_delay.simf +++ b/examples/escrow_with_delay.simf @@ -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() { diff --git a/src/ast.rs b/src/ast.rs index 6cda4851..1701dece 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -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}; @@ -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) diff --git a/src/error.rs b/src/error.rs index c06cc90b..b283e4ea 100644 --- a/src/error.rs +++ b/src/error.rs @@ -437,6 +437,7 @@ pub enum Error { ModuleRedefined(ModuleName), ArgumentMissing(WitnessName), ArgumentTypeMismatch(WitnessName, ResolvedType, ResolvedType), + JetIsDeprecated(JetName), } #[rustfmt::skip] @@ -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." + ), Error::InvalidCast(source, target) => write!( f, "Cannot cast values of type `{source}` as values of type `{target}`" diff --git a/src/jet.rs b/src/jet.rs index cf6a1fcb..724b73a2 100644 --- a/src/jet.rs +++ b/src/jet.rs @@ -450,12 +450,12 @@ pub fn source_type(jet: Elements) -> Vec { * 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![], /* @@ -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