Skip to content

Commit 3a65165

Browse files
lgalabruobycode
authored andcommitted
fix: iterate on integration
1 parent f22f164 commit 3a65165

File tree

5 files changed

+43
-14
lines changed

5 files changed

+43
-14
lines changed

src/frontend/cli.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,10 @@ pub fn main() {
321321
Err(e) => {
322322
println!("{}", e);
323323
}
324-
Ok((session, _)) => {
324+
Ok((session, _, output)) => {
325+
if let Some(message) = output {
326+
println!("{}", message);
327+
}
325328
println!(
326329
"{} Syntax of {} contract(s) successfully checked",
327330
green!("✔"),
@@ -338,7 +341,12 @@ pub fn main() {
338341
let start_repl = false;
339342
let res = load_session(manifest_path.clone(), start_repl, &Network::Devnet);
340343
let session = match res {
341-
Ok((session, _)) => session,
344+
Ok((session, _, output)) => {
345+
if let Some(message) = output {
346+
println!("{}", message);
347+
}
348+
session
349+
},
342350
Err(e) => {
343351
println!("{}", e);
344352
return;
@@ -363,7 +371,12 @@ pub fn main() {
363371
let start_repl = false;
364372
let res = load_session(manifest_path.clone(), start_repl, &Network::Devnet);
365373
let session = match res {
366-
Ok((session, _)) => session,
374+
Ok((session, _, output)) => {
375+
if let Some(message) = output {
376+
println!("{}", message);
377+
}
378+
session
379+
},
367380
Err(e) => {
368381
println!("{}", e);
369382
return;

src/integrate/events_observer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl EventObserverConfig {
7070
pub fn new(devnet_config: DevnetConfig, manifest_path: PathBuf) -> Self {
7171
info!("Checking contracts...");
7272
let (session, config) = match load_session(manifest_path.clone(), false, &Network::Devnet) {
73-
Ok((session, config)) => (session, config),
73+
Ok((session, config, _)) => (session, config),
7474
Err(e) => {
7575
println!("{}", e);
7676
std::process::exit(1);
@@ -202,7 +202,7 @@ pub async fn start_events_observer(
202202
.expect("Unable to terminate event observer");
203203

204204
let session = match load_session(manifest_path.clone(), false, &Network::Devnet) {
205-
Ok((session, _)) => session,
205+
Ok((session, _, _)) => session,
206206
Err(e) => {
207207
devnet_event_tx
208208
.send(DevnetEvent::error(format!("Contracts invalid: {}", e)))

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ extern crate lazy_static;
1616

1717
pub extern crate bip39;
1818

19+
#[macro_use]
1920
pub mod macros;
2021

2122
pub mod indexer;

src/poke/mod.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub fn load_session(
88
manifest_path: PathBuf,
99
start_repl: bool,
1010
env: &Network,
11-
) -> Result<(repl::Session, ChainConfig), String> {
11+
) -> Result<(repl::Session, ChainConfig, Option<String>), String> {
1212
let mut settings = repl::SessionSettings::default();
1313

1414
let mut project_path = manifest_path.clone();
@@ -106,20 +106,23 @@ pub fn load_session(
106106
settings.analysis = analysis_passes;
107107
}
108108

109-
let session = if start_repl {
109+
let (session, output) = if start_repl {
110110
let mut terminal = Terminal::new(settings.clone());
111111
terminal.start();
112-
terminal.session.clone()
112+
(terminal.session.clone(), None)
113113
} else {
114114
let mut session = repl::Session::new(settings.clone());
115-
match session.start() {
115+
let output = match session.start() {
116116
Err(message) => {
117117
println!("{}", message);
118118
std::process::exit(1);
119119
}
120-
_ => {}
120+
Ok((message, _)) => match message.is_empty() {
121+
true => None,
122+
false => Some(message)
123+
}
121124
};
122-
session
125+
(session, output)
123126
};
124-
Ok((session, chain_config))
127+
Ok((session, chain_config, output))
125128
}

src/publish/mod.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,22 @@ pub fn publish_all_contracts(
145145
network: Network,
146146
) -> Result<Vec<String>, Vec<String>> {
147147
let start_repl = false;
148-
let (session, chain) = match load_session(manifest_path, start_repl, &network) {
149-
Ok((session, chain)) => (session, chain),
148+
let (session, chain, output) = match load_session(manifest_path, start_repl, &network) {
149+
Ok((session, chain, output)) => (session, chain, output),
150150
Err(e) => return Err(vec![e]),
151151
};
152+
153+
if let Some(message) = output {
154+
println!("{}", message);
155+
println!("{}", yellow!("Would you like to continue [Y/n]:"));
156+
let mut buffer = String::new();
157+
std::io::stdin().read_line(&mut buffer).unwrap();
158+
if buffer == "n\n" {
159+
println!("{}", red!("Contracts deployment aborted"));
160+
std::process::exit(1);
161+
}
162+
}
163+
152164
let mut results = vec![];
153165
let mut deployers_nonces = BTreeMap::new();
154166
let mut deployers_lookup = BTreeMap::new();

0 commit comments

Comments
 (0)