Skip to content

Commit

Permalink
fix wallet file naming, update to WRS 0.8.1 to fix clipboard paste wh…
Browse files Browse the repository at this point in the history
…en prompting for use input (mnemonic)
  • Loading branch information
aspect committed Nov 1, 2023
1 parent 204398e commit 0a2008e
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 55 deletions.
106 changes: 66 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ serde-wasm-bindgen = "0.6.1"
sha1 = "0.10.6"
sha2 = "0.10.8"
sha3 = "0.10.8"
slugify-rs = "0.0.3"
smallvec = { version = "1.11.1", features = ["serde"] }
sorted-insert = "0.2.3"
statest = "0.2.2"
Expand Down Expand Up @@ -230,16 +231,16 @@ zeroize = { version = "1.6.0", default-features = false, features = ["alloc"] }
workflow-perf-monitor = { version = "0.0.2" }

# workflow dependencies
workflow-d3 = { version = "0.8.0" }
workflow-nw = { version = "0.8.0" }
workflow-log = { version = "0.8.0" }
workflow-core = { version = "0.8.0" }
workflow-wasm = { version = "0.8.0" }
workflow-dom = { version = "0.8.0" }
workflow-rpc = { version = "0.8.0" }
workflow-node = { version = "0.8.0" }
workflow-store = { version = "0.8.0" }
workflow-terminal = { version = "0.8.0" }
workflow-d3 = { version = "0.8.1" }
workflow-nw = { version = "0.8.1" }
workflow-log = { version = "0.8.1" }
workflow-core = { version = "0.8.1" }
workflow-wasm = { version = "0.8.1" }
workflow-dom = { version = "0.8.1" }
workflow-rpc = { version = "0.8.1" }
workflow-node = { version = "0.8.1" }
workflow-store = { version = "0.8.1" }
workflow-terminal = { version = "0.8.1" }
nw-sys = "0.1.6"

# if below is enabled, this means that there is an ongoing work
Expand Down
7 changes: 5 additions & 2 deletions cli/src/modules/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ impl Wallet {
} else {
let name = argv.remove(0);
let name = name.trim().to_string();
if name.as_str() == "wallet" {
let name_check = name.to_lowercase();
if name_check.as_str() == "wallet" {
return Err(Error::custom("Wallet name cannot be 'wallet'"));
}
Some(name)
Expand All @@ -49,7 +50,9 @@ impl Wallet {
}
"open" => {
let name = if let Some(name) = argv.first().cloned() {
if name.as_str() == "wallet" {
let name_check = name.to_lowercase();

if name_check.as_str() == "wallet" {
tprintln!(ctx, "you can not have a wallet named 'wallet'...");
tprintln!(ctx, "perhaps you are looking to use 'open <name>'");
return Ok(());
Expand Down
1 change: 1 addition & 0 deletions wallet/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ serde-wasm-bindgen.workspace = true
serde.workspace = true
sha1.workspace = true
sha2.workspace = true
slugify-rs.workspace = true
sorted-insert.workspace = true
thiserror.workspace = true
wasm-bindgen-futures.workspace = true
Expand Down
16 changes: 13 additions & 3 deletions wallet/core/src/storage/local/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,22 @@ use crate::storage::local::wallet::Wallet;
use crate::storage::local::Payload;
use crate::storage::local::Storage;
use crate::storage::*;
use slugify_rs::slugify;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
use workflow_core::runtime::is_web;
use workflow_store::fs;

fn make_filename(title: &Option<String>, filename: &Option<String>) -> String {
if let Some(filename) = filename {
filename.to_string()
} else if let Some(title) = title {
slugify!(title)
} else {
super::DEFAULT_WALLET_FILE.to_string()
}
}

pub enum Store {
Resident,
Storage(Storage),
Expand All @@ -38,8 +49,7 @@ impl LocalStoreInner {
// log_info!("LocalStoreInner::try_create: folder: {}, args: {:?}, is_resident: {}", folder, args, is_resident);

let title = args.title.clone();

let filename = args.filename.clone().unwrap_or(super::DEFAULT_WALLET_FILE.to_string());
let filename = make_filename(&title, &args.filename);

let storage = Storage::try_new_with_folder(folder, &format!("{filename}.wallet"))?;
if storage.exists().await? && !args.overwrite_wallet {
Expand All @@ -62,7 +72,7 @@ impl LocalStoreInner {
}

pub async fn try_load(ctx: &Arc<dyn AccessContextT>, folder: &str, args: OpenArgs) -> Result<Self> {
let filename = args.filename.unwrap_or(super::DEFAULT_WALLET_FILE.to_string());
let filename = make_filename(&None, &args.filename);
let storage = Storage::try_new_with_folder(folder, &format!("{filename}.wallet"))?;

let secret = ctx.wallet_secret().await;
Expand Down

0 comments on commit 0a2008e

Please sign in to comment.