Skip to content

Commit ccf8a0b

Browse files
committed
migrate client wrapper
1 parent ef0e013 commit ccf8a0b

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
@@ -290,29 +290,16 @@ async fn print_messages_and_create_faucet(
290290

291291
eprintln!(
292292
"To use the admin wallet of this test network, you may set \
293-
the environment variables LINERA_WALLET, LINERA_KEYSTORE, \
294-
and LINERA_STORAGE as follows.\n"
293+
the environment variable LINERA_HOME as follows.\n"
295294
);
296295
println!(
297296
"{}",
298297
format!(
299-
"export LINERA_WALLET=\"{}\"",
300-
client.wallet_path().display()
298+
"export LINERA_HOME=\"{}\"",
299+
client.path_provider.path().display()
301300
)
302301
.bold()
303302
);
304-
println!(
305-
"{}",
306-
format!(
307-
"export LINERA_KEYSTORE=\"{}\"",
308-
client.keystore_path().display()
309-
)
310-
.bold()
311-
);
312-
println!(
313-
"{}",
314-
format!("export LINERA_STORAGE=\"{}\"\n", client.storage_path()).bold()
315-
);
316303

317304
let wallet = client.load_wallet()?;
318305
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
@@ -69,12 +69,10 @@ fn reqwest_client() -> reqwest::Client {
6969
pub struct ClientWrapper {
7070
binary_path: sync::Mutex<Option<PathBuf>>,
7171
testing_prng_seed: Option<u64>,
72-
storage: String,
73-
wallet: String,
74-
keystore: String,
7572
max_pending_message_bundles: usize,
7673
network: Network,
7774
pub path_provider: PathProvider,
75+
wallet_id: usize,
7876
on_drop: OnClientDrop,
7977
extra_args: Vec<String>,
8078
}
@@ -93,14 +91,14 @@ impl ClientWrapper {
9391
path_provider: PathProvider,
9492
network: Network,
9593
testing_prng_seed: Option<u64>,
96-
id: usize,
94+
wallet_id: usize,
9795
on_drop: OnClientDrop,
9896
) -> Self {
9997
Self::new_with_extra_args(
10098
path_provider,
10199
network,
102100
testing_prng_seed,
103-
id,
101+
wallet_id,
104102
on_drop,
105103
vec!["--wait-for-outgoing-messages".to_string()],
106104
)
@@ -110,26 +108,17 @@ impl ClientWrapper {
110108
path_provider: PathProvider,
111109
network: Network,
112110
testing_prng_seed: Option<u64>,
113-
id: usize,
111+
wallet_id: usize,
114112
on_drop: OnClientDrop,
115113
extra_args: Vec<String>,
116114
) -> Self {
117-
let storage = format!(
118-
"rocksdb:{}/client_{}.db",
119-
path_provider.path().display(),
120-
id
121-
);
122-
let wallet = format!("wallet_{}.json", id);
123-
let keystore = format!("keystore_{}.json", id);
124115
Self {
125116
binary_path: sync::Mutex::new(None),
126117
testing_prng_seed,
127-
storage,
128-
wallet,
129-
keystore,
130118
max_pending_message_bundles: 10_000,
131119
network,
132120
path_provider,
121+
wallet_id,
133122
on_drop,
134123
extra_args,
135124
}
@@ -235,12 +224,10 @@ impl ClientWrapper {
235224

236225
fn required_command_arguments(&self) -> impl Iterator<Item = Cow<'_, str>> + '_ {
237226
[
238-
"--wallet".into(),
239-
self.wallet.as_str().into(),
240-
"--keystore".into(),
241-
self.keystore.as_str().into(),
242-
"--storage".into(),
243-
self.storage.as_str().into(),
227+
"--home-directory".into(),
228+
self.path_provider.path().display().to_string().into(),
229+
"--with-wallet".into(),
230+
self.wallet_id.to_string().into(),
244231
"--send-timeout-ms".into(),
245232
"500000".into(),
246233
"--recv-timeout-ms".into(),
@@ -974,15 +961,17 @@ impl ClientWrapper {
974961
}
975962

976963
pub fn wallet_path(&self) -> PathBuf {
977-
self.path_provider.path().join(&self.wallet)
964+
self.path_provider
965+
.path()
966+
.join(self.wallet_id.to_string())
967+
.join("wallet.json")
978968
}
979969

980970
pub fn keystore_path(&self) -> PathBuf {
981-
self.path_provider.path().join(&self.keystore)
982-
}
983-
984-
pub fn storage_path(&self) -> &str {
985-
&self.storage
971+
self.path_provider
972+
.path()
973+
.join(self.wallet_id.to_string())
974+
.join("keystore.json")
986975
}
987976

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

0 commit comments

Comments
 (0)