@@ -44,6 +44,7 @@ mod sessions {
4444 use std:: fs;
4545 use std:: env;
4646 use std:: collections:: HashMap ;
47+ use clarity_repl:: clarity:: analysis:: ContractAnalysis ;
4748 use deno_core:: error:: AnyError ;
4849 use clarity_repl:: repl:: { self , Session } ;
4950 use clarity_repl:: repl:: settings:: Account ;
@@ -54,7 +55,7 @@ mod sessions {
5455 pub static ref SESSIONS : Mutex <HashMap <u32 , ( String , Session ) >> = Mutex :: new( HashMap :: new( ) ) ;
5556 }
5657
57- pub fn handle_setup_chain ( name : String , transactions : Vec < TransactionArgs > ) -> Result < ( u32 , Vec < Account > ) , AnyError > {
58+ pub fn handle_setup_chain ( name : String , transactions : Vec < TransactionArgs > ) -> Result < ( u32 , Vec < Account > , Vec < ( ContractAnalysis , String ) > ) , AnyError > {
5859 let mut sessions = SESSIONS . lock ( ) . unwrap ( ) ;
5960 let session_id = sessions. len ( ) as u32 ;
6061
@@ -133,10 +134,10 @@ mod sessions {
133134 settings. initial_deployer = initial_deployer;
134135 settings. include_boot_contracts = vec ! [ "pox" . to_string( ) , "costs" . to_string( ) , "bns" . to_string( ) ] ;
135136 let mut session = Session :: new ( settings. clone ( ) ) ;
136- session. start ( ) ;
137+ let ( _ , contracts ) = session. start ( ) ;
137138 session. advance_chain_tip ( 1 ) ;
138139 sessions. insert ( session_id, ( name, session) ) ;
139- Ok ( ( session_id, settings. initial_accounts ) )
140+ Ok ( ( session_id, settings. initial_accounts , contracts ) )
140141 }
141142
142143 pub fn perform_block < F , R > ( session_id : u32 , handler : F ) -> Result < R , AnyError > where F : FnOnce ( & str , & mut Session ) -> Result < R , AnyError > {
@@ -702,11 +703,17 @@ struct SetupChainArgs {
702703fn setup_chain ( state : & mut OpState , args : Value , _: ( ) ) -> Result < String , AnyError > {
703704 let args: SetupChainArgs = serde_json:: from_value ( args)
704705 . expect ( "Invalid request from JavaScript for \" op_load\" ." ) ;
705- let ( session_id, accounts) = sessions:: handle_setup_chain ( args. name , args. transactions ) ?;
706+ let ( session_id, accounts, contracts) = sessions:: handle_setup_chain ( args. name , args. transactions ) ?;
707+ let serialized_contracts = contracts. iter ( ) . map ( |( a, s) | json ! ( {
708+ "contract_id" : a. contract_identifier. to_string( ) ,
709+ "contract_interface" : a. contract_interface. clone( ) ,
710+ "source" : s
711+ } ) ) . collect :: < Vec < _ > > ( ) ;
706712
707713 Ok ( json ! ( {
708714 "session_id" : session_id,
709715 "accounts" : accounts,
716+ "contracts" : serialized_contracts,
710717 } ) . to_string ( ) )
711718}
712719
0 commit comments