@@ -992,6 +992,20 @@ pub fn add_serialized_output(result: &mut serde_json::Value, value: Value) {
992
992
993
993
/// Returns (process-exit-code, Option<json-output>)
994
994
pub fn invoke_command ( invoked_by : & str , args : & [ String ] ) -> ( i32 , Option < serde_json:: Value > ) {
995
+ let mut store = MemoryBackingStore :: new ( ) ;
996
+ let mut analysis_db = store. as_analysis_db ( ) ;
997
+ analysis_db. begin ( ) ;
998
+
999
+ invoke_command_with_db ( invoked_by, args, & mut analysis_db)
1000
+ }
1001
+
1002
+ /// Returns (process-exit-code, Option<json-output>)
1003
+ /// Optionally accepts a shared analysis database for contract dependency resolution
1004
+ pub fn invoke_command_with_db (
1005
+ invoked_by : & str ,
1006
+ args : & [ String ] ,
1007
+ analysis_db : & mut AnalysisDatabase ,
1008
+ ) -> ( i32 , Option < serde_json:: Value > ) {
995
1009
if args. is_empty ( ) {
996
1010
print_usage ( invoked_by) ;
997
1011
return ( 1 , None ) ;
@@ -1662,12 +1676,14 @@ pub fn invoke_command(invoked_by: &str, args: &[String]) -> (i32, Option<serde_j
1662
1676
& mut marf,
1663
1677
coverage. as_mut ( ) ,
1664
1678
|vm_env| {
1665
- vm_env. initialize_versioned_contract (
1679
+ // Use the shared analysis database for contract initialization
1680
+ vm_env. initialize_versioned_contract_with_db (
1666
1681
contract_identifier,
1667
1682
ClarityVersion :: Clarity2 ,
1668
1683
& contract_content,
1669
1684
None ,
1670
1685
ASTRules :: PrecheckSize ,
1686
+ analysis_db,
1671
1687
)
1672
1688
} ,
1673
1689
) ;
@@ -2028,15 +2044,21 @@ mod test {
2028
2044
assert_eq ! ( exit, 0 ) ;
2029
2045
assert ! ( !result[ "message" ] . as_str( ) . unwrap( ) . is_empty( ) ) ;
2030
2046
2047
+ // Create a shared analysis database for contract dependency resolution
2048
+ let mut store = MemoryBackingStore :: new ( ) ;
2049
+ let mut analysis_db = store. as_analysis_db ( ) ;
2050
+ analysis_db. begin ( ) ;
2051
+
2031
2052
eprintln ! ( "launch tokens" ) ;
2032
- let invoked = invoke_command (
2053
+ let invoked = invoke_command_with_db (
2033
2054
"test" ,
2034
2055
& [
2035
2056
"launch" . to_string ( ) ,
2036
2057
"S1G2081040G2081040G2081040G208105NK8PE5.tokens" . to_string ( ) ,
2037
2058
cargo_workspace_as_string ( "sample/contracts/tokens.clar" ) ,
2038
2059
db_name. clone ( ) ,
2039
2060
] ,
2061
+ & mut analysis_db,
2040
2062
) ;
2041
2063
2042
2064
let exit = invoked. 0 ;
@@ -2117,7 +2139,7 @@ mod test {
2117
2139
assert ! ( result[ "assets" ] == json!( null) ) ;
2118
2140
2119
2141
eprintln ! ( "launch names with costs and assets" ) ;
2120
- let invoked = invoke_command (
2142
+ let invoked = invoke_command_with_db (
2121
2143
"test" ,
2122
2144
& [
2123
2145
"launch" . to_string ( ) ,
@@ -2127,6 +2149,7 @@ mod test {
2127
2149
"--assets" . to_string ( ) ,
2128
2150
db_name. clone ( ) ,
2129
2151
] ,
2152
+ & mut analysis_db,
2130
2153
) ;
2131
2154
2132
2155
let exit = invoked. 0 ;
0 commit comments