Skip to content

Commit cb97106

Browse files
author
Ludo Galabru
committed
fix: warnings
1 parent 9d71982 commit cb97106

File tree

15 files changed

+72
-79
lines changed

15 files changed

+72
-79
lines changed

src/bin.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ extern crate serde;
33
#[macro_use]
44
extern crate serde_derive;
55

6-
#[macro_use]
7-
extern crate lazy_static;
8-
96
#[macro_use]
107
extern crate rocket;
118

src/deployment/mod.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use clarity_repl::repl::SessionSettings;
4646
use clarity_repl::repl::{ExecutionResult, Session};
4747
use libsecp256k1::{PublicKey, SecretKey};
4848
use serde_yaml;
49-
use std::collections::{BTreeMap, HashMap, HashSet, VecDeque};
49+
use std::collections::{BTreeMap, HashMap, VecDeque};
5050
use std::fs::{self, File};
5151
use std::io::Write;
5252
use std::path::PathBuf;
@@ -68,14 +68,15 @@ pub struct DeploymentGenerationArtifacts {
6868
pub diags: HashMap<QualifiedContractIdentifier, Vec<Diagnostic>>,
6969
}
7070

71+
#[allow(dead_code)]
7172
pub fn encode_contract_call(
7273
_contract_name: &ContractName,
7374
_source: &str,
7475
_nonce: u64,
7576
_deployment_fee_rate: u64,
7677
_network: &StacksNetwork,
7778
) -> Result<(StacksTransaction, StacksAddress), String> {
78-
Err(format!("unimplemented"))
79+
Err(format!("encode_contract_call operations unimplemented"))
7980
}
8081

8182
pub fn encode_contract_publish(
@@ -323,7 +324,7 @@ pub fn get_absolute_deployment_path(
323324
manifest: &ProjectManifest,
324325
relative_deployment_path: &str,
325326
) -> PathBuf {
326-
let mut base_path = manifest.get_project_root_dir();
327+
let base_path = manifest.get_project_root_dir();
327328
let path = match PathBuf::from_str(relative_deployment_path) {
328329
Ok(path) => path,
329330
Err(_e) => {
@@ -481,7 +482,7 @@ pub fn apply_on_chain_deployment(
481482
let _ =
482483
deployment_event_tx.send(DeploymentEvent::ContractUpdate(ContractUpdate {
483484
contract_id: format!("{}.{}", issuer_address, tx.contract_name),
484-
status: ContractStatus::Queued,
485+
status: ContractStatus::Encoded,
485486
comment: None,
486487
}));
487488
}
@@ -522,7 +523,17 @@ pub fn apply_on_chain_deployment(
522523
(sender, contract_name, TransactionStatus::Broadcasted),
523524
);
524525
}
525-
Err(_e) => return,
526+
Err(e) => {
527+
let message = format!("{:?}", e);
528+
let _ =
529+
deployment_event_tx.send(DeploymentEvent::ContractUpdate(ContractUpdate {
530+
contract_id: format!("{}.{}", sender.to_address(), contract_name),
531+
status: ContractStatus::Error,
532+
comment: Some(message.clone()),
533+
}));
534+
let _ = deployment_event_tx.send(DeploymentEvent::Interrupted(message));
535+
return;
536+
}
526537
};
527538
}
528539

@@ -578,7 +589,7 @@ pub fn apply_on_chain_deployment(
578589
}
579590

580591
pub fn check_deployments(manifest: &ProjectManifest) -> Result<(), String> {
581-
let mut base_path = manifest.get_project_root_dir();
592+
let base_path = manifest.get_project_root_dir();
582593
let files = get_deployments_files(manifest)?;
583594
for (path, relative_path) in files.into_iter() {
584595
let _spec = match DeploymentSpecification::from_config_file(&path, &base_path) {
@@ -764,7 +775,7 @@ pub fn generate_default_deployment(
764775
let mut boot_contracts_asts = session.get_boot_contracts_asts();
765776
let boot_contracts_ids = boot_contracts_asts
766777
.iter()
767-
.map(|(k, v)| k.clone())
778+
.map(|(k, _)| k.clone())
768779
.collect::<Vec<QualifiedContractIdentifier>>();
769780
requirements_asts.append(&mut boot_contracts_asts);
770781

src/deployment/requirements.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ pub fn retrieve_contract(
5454
Ok((code, file_path))
5555
}
5656

57+
#[allow(dead_code)]
5758
#[derive(Deserialize, Debug, Default, Clone)]
5859
struct Contract {
5960
source: String,
60-
publish_height: u32,
61+
_publish_height: u32,
6162
}
6263

6364
async fn fetch_contract(request_url: String) -> Result<Contract, String> {

src/deployment/ui/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use crossterm::{
99
execute,
1010
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
1111
};
12+
use std::io::stdout;
1213
use std::sync::mpsc::Receiver;
13-
use std::{error::Error, io::stdout};
1414
use tui::{backend::CrosstermBackend, Terminal};
1515

1616
pub fn start_ui(

src/frontend/cli.rs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::deployment::{
22
self, apply_on_chain_deployment, check_deployments, generate_default_deployment,
33
get_absolute_deployment_path, get_default_deployment_path, load_deployment,
4-
load_deployment_if_exists, read_deployment_or_generate_default, setup_session_with_deployment,
5-
write_deployment, DeploymentCommand, DeploymentEvent,
4+
load_deployment_if_exists, setup_session_with_deployment, write_deployment, DeploymentCommand,
5+
DeploymentEvent,
66
};
77
use crate::generate::{
88
self,
@@ -528,6 +528,18 @@ pub fn main() {
528528
let (command_tx, command_rx) = std::sync::mpsc::channel();
529529
let (event_tx, event_rx) = std::sync::mpsc::channel();
530530
let manifest_moved = manifest.clone();
531+
532+
if manifest.project.telemetry {
533+
#[cfg(feature = "telemetry")]
534+
telemetry_report_event(DeveloperUsageEvent::ProtocolPublished(
535+
DeveloperUsageDigest::new(
536+
&manifest.project.name,
537+
&manifest.project.authors,
538+
),
539+
deployment.network.clone(),
540+
));
541+
}
542+
531543
std::thread::spawn(move || {
532544
let manifest = manifest_moved;
533545
apply_on_chain_deployment(&manifest, deployment, event_tx, command_rx, true);
@@ -539,7 +551,7 @@ pub fn main() {
539551
loop {
540552
let cmd = match event_rx.recv() {
541553
Ok(cmd) => cmd,
542-
Err(e) => break,
554+
Err(_e) => break,
543555
};
544556
match cmd {
545557
DeploymentEvent::Interrupted(message) => {
@@ -583,13 +595,8 @@ pub fn main() {
583595
Contracts::NewContract(cmd) => {
584596
let manifest = load_manifest_or_exit(cmd.manifest_path);
585597

586-
let changes = generate::get_changes_for_new_contract(
587-
&manifest.path,
588-
cmd.name,
589-
None,
590-
true,
591-
vec![],
592-
);
598+
let changes =
599+
generate::get_changes_for_new_contract(&manifest.path, cmd.name, None, true);
593600
if !execute_changes(changes) {
594601
std::process::exit(1);
595602
}
@@ -676,6 +683,10 @@ pub fn main() {
676683
let mut terminal = Terminal::load(session);
677684
terminal.start();
678685

686+
if hints_enabled {
687+
display_post_console_hint();
688+
}
689+
679690
// Report telemetry
680691
if manifest.project.telemetry {
681692
#[cfg(feature = "telemetry")]

src/frontend/dap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ pub fn run_dap() -> Result<(), String> {
4545
false,
4646
None,
4747
) {
48-
Ok(result) => Ok(()),
49-
Err(diagnostics) => Err("unable to interpret expression".to_string()),
48+
Ok(_result) => Ok(()),
49+
Err(_diagnostics) => Err("unable to interpret expression".to_string()),
5050
}
5151
}
5252
Err(e) => Err(format!("dap_init: {}", e)),

src/frontend/telemetry.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub enum DeveloperUsageEvent {
1313
CheckExecuted(DeveloperUsageDigest),
1414
TestSuiteExecuted(DeveloperUsageDigest, bool, u32),
1515
DevnetExecuted(DeveloperUsageDigest),
16-
ContractPublished(DeveloperUsageDigest, StacksNetwork),
16+
ProtocolPublished(DeveloperUsageDigest, StacksNetwork),
1717
DebugStarted(DeveloperUsageDigest, u32),
1818
DAPDebugStarted(DeveloperUsageDigest),
1919
UnknownCommand(DeveloperUsageDigest, String),
@@ -84,8 +84,8 @@ async fn send_event(event: DeveloperUsageEvent) {
8484
"ci_mode": ci_mode,
8585
}),
8686
),
87-
DeveloperUsageEvent::ContractPublished(digest, network) => (
88-
"ContractPublished",
87+
DeveloperUsageEvent::ProtocolPublished(digest, network) => (
88+
"ProtocolPublished",
8989
json!({
9090
"project_id": digest.project_id,
9191
"team_id": digest.team_id,

src/generate/contract.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ impl GetChangesForNewContract {
1919
}
2020
}
2121

22-
pub fn run(&mut self, include_test: bool, deps: Vec<String>) -> Vec<Changes> {
22+
pub fn run(&mut self, include_test: bool) -> Vec<Changes> {
2323
self.create_template_contract();
2424
if include_test {
2525
self.create_template_test();
2626
}
27-
self.index_contract_in_clarinet_toml(deps);
27+
self.index_contract_in_clarinet_toml();
2828
self.changes.clone()
2929
}
3030

@@ -115,7 +115,7 @@ Clarinet.test({{
115115
self.changes.push(Changes::AddFile(change));
116116
}
117117

118-
fn index_contract_in_clarinet_toml(&mut self, deps: Vec<String>) {
118+
fn index_contract_in_clarinet_toml(&mut self) {
119119
let contract_file_name = format!("{}.clar", self.contract_name);
120120
let manifest_path = self.manifest_path.clone();
121121

src/generate/mod.rs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ mod contract;
33
mod notebook;
44
mod project;
55

6-
use crate::types::RequirementConfig;
76
pub use changes::{Changes, DirectoryCreation, FileCreation, TOMLEdition};
87
use contract::GetChangesForNewContract;
98
use notebook::GetChangesForNewNotebook;
109
use project::GetChangesForNewProject;
11-
use std::{collections::HashMap, path::PathBuf};
10+
use std::path::PathBuf;
1211

1312
pub fn get_changes_for_new_project(
1413
project_path: String,
@@ -24,26 +23,9 @@ pub fn get_changes_for_new_contract(
2423
contract_name: String,
2524
source: Option<String>,
2625
include_test: bool,
27-
deps: Vec<String>,
2826
) -> Vec<Changes> {
2927
let mut command = GetChangesForNewContract::new(manifest_path.clone(), contract_name, source);
30-
command.run(include_test, deps)
31-
}
32-
33-
pub fn get_changes_for_new_link(
34-
manifest_path: PathBuf,
35-
contract_id: String,
36-
_source: Option<String>,
37-
) -> Vec<Changes> {
38-
let change = TOMLEdition {
39-
comment: format!("Adding {} as a requirement in Clarinet.toml", contract_id),
40-
manifest_path,
41-
contracts_to_add: HashMap::new(),
42-
requirements_to_add: vec![RequirementConfig {
43-
contract_id: contract_id.clone(),
44-
}],
45-
};
46-
vec![Changes::EditTOML(change)]
28+
command.run(include_test)
4729
}
4830

4931
#[allow(dead_code)]

src/integrate/chains_coordinator.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
use super::DevnetEvent;
22
use crate::deployment::types::DeploymentSpecification;
3-
use crate::deployment::{
4-
apply_on_chain_deployment, read_deployment_or_generate_default, setup_session_with_deployment,
5-
DeploymentCommand, DeploymentEvent,
6-
};
3+
use crate::deployment::{apply_on_chain_deployment, DeploymentCommand, DeploymentEvent};
74
use crate::indexer::{chains, Indexer, IndexerConfig};
85
use crate::integrate::{MempoolAdmissionData, ServiceStatusData, Status};
96
use crate::types::{self, AccountConfig, ChainConfig, DevnetConfig, ProjectManifest};
@@ -15,18 +12,17 @@ use clarity_repl::clarity::representations::ClarityName;
1512
use clarity_repl::clarity::types::{BuffData, SequenceData, TupleData, Value as ClarityValue};
1613
use clarity_repl::clarity::util::address::AddressHashMode;
1714
use clarity_repl::clarity::util::hash::{hex_bytes, Hash160};
18-
use clarity_repl::repl::settings::InitialContract;
19-
use clarity_repl::repl::Session;
15+
2016
use rocket::config::{Config, LogLevel};
2117
use rocket::serde::json::{json, Json, Value as JsonValue};
2218
use rocket::serde::Deserialize;
2319
use rocket::State;
24-
use std::collections::VecDeque;
20+
2521
use std::convert::TryFrom;
2622
use std::error::Error;
27-
use std::iter::FromIterator;
23+
2824
use std::net::{IpAddr, Ipv4Addr};
29-
use std::path::PathBuf;
25+
3026
use std::str;
3127
use std::sync::atomic::{AtomicBool, Ordering};
3228
use std::sync::mpsc::{channel, Receiver, Sender};
@@ -289,7 +285,6 @@ pub fn handle_new_bitcoin_block(
289285
indexer_rw_lock: &State<Arc<RwLock<Indexer>>>,
290286
devnet_events_tx: &State<Arc<Mutex<Sender<DevnetEvent>>>>,
291287
marshalled_block: Json<JsonValue>,
292-
background_job_tx_mutex: &State<Arc<Mutex<Sender<ChainsCoordinatorCommand>>>>,
293288
) -> Json<JsonValue> {
294289
let devnet_events_tx = devnet_events_tx.inner();
295290

@@ -622,7 +617,7 @@ pub fn perform_protocol_deployment(
622617
loop {
623618
let event = match deployment_events_rx.recv() {
624619
Ok(event) => event,
625-
Err(e) => break,
620+
Err(_e) => break,
626621
};
627622
match event {
628623
DeploymentEvent::ContractUpdate(_) => {}

0 commit comments

Comments
 (0)