Skip to content

Commit a95fd03

Browse files
committed
migrate client wrapper
1 parent 74bbde4 commit a95fd03

File tree

2 files changed

+20
-44
lines changed

2 files changed

+20
-44
lines changed

linera-service/src/cli/net_up_utils.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -311,29 +311,16 @@ async fn print_messages_and_create_faucet(
311311

312312
eprintln!(
313313
"To use the admin wallet of this test network, you may set \
314-
the environment variables LINERA_WALLET, LINERA_KEYSTORE, \
315-
and LINERA_STORAGE as follows.\n"
314+
the environment variable LINERA_HOME as follows.\n"
316315
);
317316
println!(
318317
"{}",
319318
format!(
320-
"export LINERA_WALLET=\"{}\"",
321-
client.wallet_path().display(),
319+
"export LINERA_HOME=\"{}\"",
320+
client.path_provider.path().display()
322321
)
323322
.bold(),
324323
);
325-
println!(
326-
"{}",
327-
format!(
328-
"export LINERA_KEYSTORE=\"{}\"",
329-
client.keystore_path().display(),
330-
)
331-
.bold()
332-
);
333-
println!(
334-
"{}",
335-
format!("export LINERA_STORAGE=\"{}\"", client.storage_path()).bold(),
336-
);
337324

338325
let wallet = client.load_wallet()?;
339326
let chains = wallet.chain_ids();

linera-service/src/cli_wrappers/wallet.rs

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,10 @@ fn reqwest_client() -> reqwest::Client {
6868
pub struct ClientWrapper {
6969
binary_path: sync::Mutex<Option<PathBuf>>,
7070
testing_prng_seed: Option<u64>,
71-
storage: String,
72-
wallet: String,
73-
keystore: String,
7471
max_pending_message_bundles: usize,
7572
network: Network,
7673
pub path_provider: PathProvider,
74+
wallet_id: usize,
7775
on_drop: OnClientDrop,
7876
extra_args: Vec<String>,
7977
}
@@ -92,14 +90,14 @@ impl ClientWrapper {
9290
path_provider: PathProvider,
9391
network: Network,
9492
testing_prng_seed: Option<u64>,
95-
id: usize,
93+
wallet_id: usize,
9694
on_drop: OnClientDrop,
9795
) -> Self {
9896
Self::new_with_extra_args(
9997
path_provider,
10098
network,
10199
testing_prng_seed,
102-
id,
100+
wallet_id,
103101
on_drop,
104102
vec!["--wait-for-outgoing-messages".to_string()],
105103
)
@@ -109,26 +107,17 @@ impl ClientWrapper {
109107
path_provider: PathProvider,
110108
network: Network,
111109
testing_prng_seed: Option<u64>,
112-
id: usize,
110+
wallet_id: usize,
113111
on_drop: OnClientDrop,
114112
extra_args: Vec<String>,
115113
) -> Self {
116-
let storage = format!(
117-
"rocksdb:{}/client_{}.db",
118-
path_provider.path().display(),
119-
id
120-
);
121-
let wallet = format!("wallet_{}.json", id);
122-
let keystore = format!("keystore_{}.json", id);
123114
Self {
124115
binary_path: sync::Mutex::new(None),
125116
testing_prng_seed,
126-
storage,
127-
wallet,
128-
keystore,
129117
max_pending_message_bundles: 10_000,
130118
network,
131119
path_provider,
120+
wallet_id,
132121
on_drop,
133122
extra_args,
134123
}
@@ -234,12 +223,10 @@ impl ClientWrapper {
234223

235224
fn required_command_arguments(&self) -> impl Iterator<Item = Cow<'_, str>> + '_ {
236225
[
237-
"--wallet".into(),
238-
self.wallet.as_str().into(),
239-
"--keystore".into(),
240-
self.keystore.as_str().into(),
241-
"--storage".into(),
242-
self.storage.as_str().into(),
226+
"--home-directory".into(),
227+
self.path_provider.path().display().to_string().into(),
228+
"--with-wallet".into(),
229+
self.wallet_id.to_string().into(),
243230
"--send-timeout-ms".into(),
244231
"500000".into(),
245232
"--recv-timeout-ms".into(),
@@ -982,15 +969,17 @@ impl ClientWrapper {
982969
}
983970

984971
pub fn wallet_path(&self) -> PathBuf {
985-
self.path_provider.path().join(&self.wallet)
972+
self.path_provider
973+
.path()
974+
.join(self.wallet_id.to_string())
975+
.join("wallet.json")
986976
}
987977

988978
pub fn keystore_path(&self) -> PathBuf {
989-
self.path_provider.path().join(&self.keystore)
990-
}
991-
992-
pub fn storage_path(&self) -> &str {
993-
&self.storage
979+
self.path_provider
980+
.path()
981+
.join(self.wallet_id.to_string())
982+
.join("keystore.json")
994983
}
995984

996985
pub fn get_owner(&self) -> Option<AccountOwner> {

0 commit comments

Comments
 (0)