forked from arne-fuchs/edcas-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.rs
74 lines (63 loc) · 2.18 KB
/
cli.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use std::any::Any;
use crate::edcas::{
self,
backend::evm::journal_uploader,
settings::{self, Settings},
EliteRustClient,
};
use ethers::prelude::*;
pub fn upload_journal(client: EliteRustClient) {
let journal_path = client
.settings
.lock()
.unwrap()
.journal_reader_settings
.journal_directory
.clone();
let evm_settings = &client.settings.lock().unwrap().evm_settings;
// start evm uploader thread
let (mut progress_bus_reader, total) = journal_uploader::initialize(evm_settings, journal_path);
println!("Uploading {} logs", total);
// loop until uploading is done
loop {
match progress_bus_reader.recv() {
Ok(index) => {
if index <= 0 {
println!("done uploading");
break;
}
print!("{} ", total - index);
}
Err(err) => {
println!("\npanicked: {}", err);
break;
}
}
}
}
pub fn set_sc_address(smart_contract_address: String, client: EliteRustClient) {
let _ = smart_contract_address
.parse::<Address>()
.unwrap_or_else(|_| panic!("Address is incorrect"));
let mut settings = client.settings.lock().unwrap();
settings.evm_settings.smart_contract_address = smart_contract_address;
settings.save_settings_to_file();
}
pub fn set_journal_path(journal_path: String) {
let mut settings = edcas::settings::Settings::default();
settings.journal_reader_settings.journal_directory = journal_path;
settings.save_settings_to_file();
}
pub fn set_settings_path(new_settings_path: String) {
let mut settings = edcas::settings::Settings {
settings_path: new_settings_path,
..Default::default() // did that becaouse clippy was angry i reassigned a field later
};
//settings.settings_path = new_settings_path;
settings.save_settings_to_file();
}
pub fn set_graphics_path(new_graphics_path: String) {
let mut settings = edcas::settings::Settings::default();
settings.graphic_editor_settings.graphics_directory = new_graphics_path;
settings.save_settings_to_file();
}