diff --git a/clarity/src/vm/callables.rs b/clarity/src/vm/callables.rs index e6e9ae94d..8e7927a24 100644 --- a/clarity/src/vm/callables.rs +++ b/clarity/src/vm/callables.rs @@ -183,12 +183,23 @@ impl DefinedFunction { ( TypeSignature::TraitReferenceType(trait_identifier), Value::Principal(PrincipalData::Contract(callee_contract_id)), - ) + ) if *env.epoch() < StacksEpochId::Epoch21 => { + // Argument is a trait reference, probably leading to a dynamic contract call + // We keep a reference of the mapping (var-name: (callee_contract_id, trait_id)) in the context. + // The code fetching and checking the trait is implemented in the contract_call eval function. + context.callable_contracts.insert( + name.clone(), + CallableData { + contract_identifier: callee_contract_id.clone(), + trait_identifier: Some(trait_identifier.clone()), + }, + ); + } // Epoch >= 2.1 uses CallableType - | ( + ( TypeSignature::CallableType(CallableSubtype::Trait(trait_identifier)), Value::Principal(PrincipalData::Contract(callee_contract_id)), - ) => { + ) if *env.epoch() >= StacksEpochId::Epoch21 => { // Argument is a trait reference, probably leading to a dynamic contract call // We keep a reference of the mapping (var-name: (callee_contract_id, trait_id)) in the context. // The code fetching and checking the trait is implemented in the contract_call eval function. diff --git a/clarity/src/vm/types/signatures.rs b/clarity/src/vm/types/signatures.rs index c29e268cf..b818e0121 100644 --- a/clarity/src/vm/types/signatures.rs +++ b/clarity/src/vm/types/signatures.rs @@ -641,6 +641,9 @@ impl TypeSignature { } } NoType => Err(CheckErrors::CouldNotDetermineType), + TraitReferenceType(_) => { + unreachable!("TraitReferenceType should not be used in epoch v2.1") + } _ => Ok(&other == self), } }