@@ -8,8 +8,8 @@ use crate::{
88 commands:: call:: contract:: CallContractCommand ,
99 common:: {
1010 contracts:: {
11- check_contracts_node_and_prompt , has_contract_been_built, map_account,
12- normalize_call_args , request_contract_function_args, terminate_node ,
11+ check_ink_node_and_prompt , has_contract_been_built, map_account, normalize_call_args ,
12+ request_contract_function_args, terminate_nodes ,
1313 } ,
1414 rpc:: prompt_to_select_chain_rpc,
1515 urls,
@@ -19,12 +19,12 @@ use crate::{
1919} ;
2020use clap:: Args ;
2121use cliclack:: { ProgressBar , spinner} ;
22- use console:: { Emoji , Style } ;
22+ use console:: Emoji ;
2323use pop_contracts:: {
2424 Bytes , FunctionType , UpOpts , Verbosity , Weight , build_smart_contract,
2525 dry_run_gas_estimate_instantiate, dry_run_upload, extract_function, get_contract_code,
2626 get_instantiate_payload, get_upload_payload, instantiate_contract_signed,
27- instantiate_smart_contract, is_chain_alive, parse_hex_bytes, run_contracts_node ,
27+ instantiate_smart_contract, is_chain_alive, parse_hex_bytes, run_eth_rpc_node , run_ink_node ,
2828 set_up_deployment, set_up_upload, upload_contract_signed, upload_smart_contract,
2929} ;
3030use sp_core:: bytes:: to_hex;
@@ -34,6 +34,8 @@ use url::Url;
3434
3535const COMPLETE : & str = "🚀 Deployment complete" ;
3636const DEFAULT_PORT : u16 = 9944 ;
37+ const DEFAULT_ETH_RPC_PORT : u16 = 8545 ;
38+ const DEFAULT_INK_NODE_URL : & str = "ws://127.0.0.1:9944" ;
3739const FAILED : & str = "🚫 Deployment failed." ;
3840const HELP_HEADER : & str = "Smart contract deployment options" ;
3941
@@ -127,7 +129,7 @@ impl UpContractCommand {
127129 }
128130
129131 // Check if specified chain is accessible
130- let process = if !is_chain_alive ( self . url . clone ( ) ) . await ? {
132+ let processes = if !is_chain_alive ( self . url . clone ( ) ) . await ? {
131133 let local_url = Url :: parse ( urls:: LOCAL ) . expect ( "default url is valid" ) ;
132134 let start_local_node = if !self . skip_confirm {
133135 let msg = if self . url . as_str ( ) == urls:: LOCAL {
@@ -166,11 +168,12 @@ impl UpContractCommand {
166168 // Update url to that of the launched node
167169 self . url = local_url;
168170
169- let log = NamedTempFile :: new ( ) ?;
171+ let log_ink_node = NamedTempFile :: new ( ) ?;
172+ let log_eth_rpc = NamedTempFile :: new ( ) ?;
170173 let spinner = spinner ( ) ;
171174
172175 // uses the cache location
173- let binary_path = match check_contracts_node_and_prompt (
176+ let ( ink_node_binary_path , eth_rpc_binary_path ) = match check_ink_node_and_prompt (
174177 & mut Cli ,
175178 & spinner,
176179 & crate :: cache ( ) ?,
@@ -189,25 +192,40 @@ impl UpContractCommand {
189192
190193 spinner. start ( "Starting local node..." ) ;
191194
192- let process =
193- run_contracts_node ( binary_path, Some ( log. as_file ( ) ) , DEFAULT_PORT ) . await ?;
194- let bar = Style :: new ( ) . magenta ( ) . dim ( ) . apply_to ( Emoji ( "│" , "|" ) ) ;
195- spinner. stop ( format ! (
195+ let ink_node_process =
196+ run_ink_node ( & ink_node_binary_path, Some ( log_ink_node. as_file ( ) ) , DEFAULT_PORT )
197+ . await ?;
198+ let eth_rpc_node_process = run_eth_rpc_node (
199+ & eth_rpc_binary_path,
200+ Some ( log_eth_rpc. as_file ( ) ) ,
201+ DEFAULT_INK_NODE_URL ,
202+ DEFAULT_ETH_RPC_PORT ,
203+ )
204+ . await ?;
205+ spinner. clear ( ) ;
206+ Cli . info ( format ! (
196207 "Local node started successfully:{}" ,
197208 style( format!(
198- "
199- {bar} {}
200- {bar} {}" ,
209+ "\n {}\n {}" ,
201210 style( format!(
202211 "portal: https://polkadot.js.org/apps/?rpc={}#/explorer" ,
203212 self . url
204213 ) )
205214 . dim( ) ,
206- style( format!( "logs: tail -f {}" , log. path( ) . display( ) ) ) . dim( ) ,
215+ style( format!( "logs: tail -f {}" , log_ink_node. path( ) . display( ) ) ) . dim( ) ,
216+ ) )
217+ . dim( )
218+ ) ) ?;
219+ Cli . info ( format ! (
220+ "Ethereum RPC node started successfully:{}" ,
221+ style( format!(
222+ "\n {}\n {}" ,
223+ style( format!( "url: ws://localhost:{}" , DEFAULT_ETH_RPC_PORT ) ) . dim( ) ,
224+ style( format!( "logs: tail -f {}" , log_eth_rpc. path( ) . display( ) ) ) . dim( ) ,
207225 ) )
208226 . dim( )
209- ) ) ;
210- Some ( ( process , log ) )
227+ ) ) ? ;
228+ Some ( ( ( ink_node_process , log_ink_node ) , ( eth_rpc_node_process , log_eth_rpc ) ) )
211229 } else {
212230 None
213231 }
@@ -221,7 +239,7 @@ impl UpContractCommand {
221239 Ok ( data) => data,
222240 Err ( e) => {
223241 Cli . error ( format ! ( "An error occurred getting the call data: {e}" ) ) ?;
224- terminate_node ( & mut Cli , process ) . await ?;
242+ terminate_nodes ( & mut Cli , processes ) . await ?;
225243 Cli . outro_cancel ( FAILED ) ?;
226244 return Ok ( ( ) ) ;
227245 } ,
@@ -242,7 +260,7 @@ impl UpContractCommand {
242260 Err ( e) => {
243261 spinner
244262 . error ( format ! ( "An error occurred uploading your contract: {e}" ) ) ;
245- terminate_node ( & mut Cli , process ) . await ?;
263+ terminate_nodes ( & mut Cli , processes ) . await ?;
246264 Cli . outro_cancel ( FAILED ) ?;
247265 return Ok ( ( ) ) ;
248266 } ,
@@ -261,7 +279,7 @@ impl UpContractCommand {
261279 Cli . error ( format ! (
262280 "An error occurred instantiating the contract: {e}"
263281 ) ) ?;
264- terminate_node ( & mut Cli , process ) . await ?;
282+ terminate_nodes ( & mut Cli , processes ) . await ?;
265283 Cli . outro_cancel ( FAILED ) ?;
266284 return Ok ( ( ) ) ;
267285 } ,
@@ -279,7 +297,7 @@ impl UpContractCommand {
279297 Err ( e) => {
280298 spinner
281299 . error ( format ! ( "An error occurred uploading your contract: {e}" ) ) ;
282- terminate_node ( & mut Cli , process ) . await ?;
300+ terminate_nodes ( & mut Cli , processes ) . await ?;
283301 Cli . outro_cancel ( FAILED ) ?;
284302 return Ok ( ( ) ) ;
285303 } ,
@@ -299,19 +317,19 @@ impl UpContractCommand {
299317 }
300318 } else {
301319 Cli . outro_cancel ( "Signed payload doesn't exist." ) ?;
302- terminate_node ( & mut Cli , process ) . await ?;
320+ terminate_nodes ( & mut Cli , processes ) . await ?;
303321 return Ok ( ( ) ) ;
304322 }
305323
306324 Cli . outro ( COMPLETE ) ?;
307- terminate_node ( & mut Cli , process ) . await ?;
325+ terminate_nodes ( & mut Cli , processes ) . await ?;
308326 return Ok ( ( ) ) ;
309327 }
310328
311329 // Check for upload only.
312330 if self . upload_only {
313331 let result = self . upload_contract ( ) . await ;
314- terminate_node ( & mut Cli , process ) . await ?;
332+ terminate_nodes ( & mut Cli , processes ) . await ?;
315333 match result {
316334 Ok ( _) => {
317335 Cli . outro ( COMPLETE ) ?;
@@ -334,7 +352,7 @@ impl UpContractCommand {
334352 Ok ( i) => i,
335353 Err ( e) => {
336354 Cli . error ( format ! ( "An error occurred instantiating the contract: {e}" ) ) ?;
337- terminate_node ( & mut Cli , process ) . await ?;
355+ terminate_nodes ( & mut Cli , processes ) . await ?;
338356 Cli . outro_cancel ( FAILED ) ?;
339357 return Ok ( ( ) ) ;
340358 } ,
@@ -354,7 +372,7 @@ impl UpContractCommand {
354372 } ,
355373 Err ( e) => {
356374 spinner. error ( format ! ( "{e}" ) ) ;
357- terminate_node ( & mut Cli , process ) . await ?;
375+ terminate_nodes ( & mut Cli , processes ) . await ?;
358376 Cli . outro_cancel ( FAILED ) ?;
359377 return Ok ( ( ) ) ;
360378 } ,
@@ -371,7 +389,7 @@ impl UpContractCommand {
371389
372390 Cli . success ( COMPLETE ) ?;
373391 self . keep_interacting_with_node ( & mut Cli , contract_address) . await ?;
374- terminate_node ( & mut Cli , process ) . await ?;
392+ terminate_nodes ( & mut Cli , processes ) . await ?;
375393 }
376394
377395 Ok ( ( ) )
0 commit comments