Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Vlad Frolov <[email protected]>
  • Loading branch information
gagdiez and frol authored Jul 5, 2024
1 parent e544418 commit 8900733
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
10 changes: 3 additions & 7 deletions src/js_command_match/contract/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,10 @@ impl CallArgs {
command.push("sign-with-ledger".to_string());
command.push("--seed-phrase-hd-path".to_string());
command.push(self.ledger_path.to_owned().unwrap_or_default());
}

if self.private_key.is_some() {
} else if let Some(private_key) = self.private_key {
command.push("sign-with-plaintext-private-key".to_string());
command.push(self.private_key.clone().unwrap());
}

if !self.sign_with_ledger && self.private_key.is_none() {
command.push(private_key.clone());
} else {
command.push("sign-with-keychain".to_string());
}

Expand Down
2 changes: 1 addition & 1 deletion src/js_command_match/keys/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ mod tests {
let result = AddKeyArgs::to_cli_args(&add_key_args, "testnet".to_string());
assert_eq!(
result.join(" "),
format!("account add-key {} grant-function-call-access --allowance unlimited --contract-account-id {} --function-names {} use-manually-provided-public-key {} network-config testnet sign-with-keychain send", account_id, contract_id, method_names, access_key)
format!("account add-key {account_id} grant-function-call-access --allowance unlimited --contract-account-id {contract_id} --function-names {method_names} use-manually-provided-public-key {access_key} network-config testnet sign-with-keychain send")
)
}
}
Expand Down
1 change: 0 additions & 1 deletion src/js_command_match/keys/list.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::js_command_match::constants::NETWORK_ID_ALIASES;

#[derive(Debug, Clone, clap::Parser)]
#[clap(alias("list-keys"))]
/// This is a legacy `keys` command. Once you run it with the specified arguments, new syntax command will be suggested.
pub struct KeysArgs {
account_id: String,
Expand Down
9 changes: 4 additions & 5 deletions src/js_command_match/transactions/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use crate::js_command_match::constants::NETWORK_ID_ALIASES;
#[derive(Debug, Clone, clap::Parser)]
pub struct TxStatusArgs {
hash: String,
#[clap(allow_hyphen_values = true, num_args = 0..)]
_unknown_args: Vec<String>,
#[clap(long, aliases = NETWORK_ID_ALIASES, default_value=None)]
network_id: Option<String>,
#[clap(allow_hyphen_values = true, num_args = 0..)]
_unknown_args: Vec<String>,
}

impl TxStatusArgs {
Expand Down Expand Up @@ -49,12 +49,11 @@ mod tests {
let transaction_hash = "4HxfV69Brk7fJd3NC63ti2H3QCgwiUiMAPvwNmGWbVXo";
let network_id = "mainnet";

for i in 0..NETWORK_ID_ALIASES.len() {
let network_id_parameter_alias = &format!("--{}", &NETWORK_ID_ALIASES[i]);
for network_id_alias in NETWORK_ID_ALIASES {
let state_args = TxStatusArgs::parse_from(&[
"near",
transaction_hash,
network_id_parameter_alias,
&format!("--{}", &network_id_alias),
network_id,
]);
let result = TxStatusArgs::to_cli_args(&state_args, "testnet".to_string());
Expand Down

0 comments on commit 8900733

Please sign in to comment.