diff --git a/src/config.rs b/src/config.rs deleted file mode 100644 index 97cef0c8b..000000000 --- a/src/config.rs +++ /dev/null @@ -1,74 +0,0 @@ -#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] -pub struct Config { - pub credentials_home_dir: std::path::PathBuf, - pub network_connection: linked_hash_map::LinkedHashMap, -} - -#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] -pub struct NetworkConfig { - pub network_name: String, - pub rpc_url: url::Url, - pub rpc_api_key: Option, - pub wallet_url: url::Url, - pub explorer_transaction_url: url::Url, - // https://github.com/near/near-cli-rs/issues/116 - pub linkdrop_account_id: Option, - pub faucet_url: Option, - pub meta_transaction_relayer_url: Option, -} - -impl Default for Config { - fn default() -> Self { - let home_dir = dirs::home_dir().expect("Impossible to get your home dir!"); - let mut credentials_home_dir = std::path::PathBuf::from(&home_dir); - credentials_home_dir.push(".near-credentials"); - - let mut network_connection = linked_hash_map::LinkedHashMap::new(); - network_connection.insert( - "mainnet".to_string(), - NetworkConfig { - network_name: "mainnet".to_string(), - rpc_url: "https://archival-rpc.mainnet.near.org".parse().unwrap(), - wallet_url: "https://app.mynearwallet.com/".parse().unwrap(), - explorer_transaction_url: "https://nearblocks.io/txns/" - .parse() - .unwrap(), - rpc_api_key: None, - linkdrop_account_id: Some("near".parse().unwrap()), - faucet_url: None, - meta_transaction_relayer_url: None, - }, - ); - network_connection.insert( - "testnet".to_string(), - NetworkConfig { - network_name: "testnet".to_string(), - rpc_url: "https://archival-rpc.testnet.near.org".parse().unwrap(), - wallet_url: "https://testnet.mynearwallet.com/".parse().unwrap(), - explorer_transaction_url: "https://testnet.nearblocks.io/txns/" - .parse() - .unwrap(), - rpc_api_key: None, - linkdrop_account_id: Some("testnet".parse().unwrap()), - faucet_url: Some("https://helper.nearprotocol.com/account".parse().unwrap()), - meta_transaction_relayer_url: None, - }, - ); - Self { - credentials_home_dir, - network_connection, - } - } -} - -impl NetworkConfig { - pub fn json_rpc_client(&self) -> near_jsonrpc_client::JsonRpcClient { - let mut json_rpc_client = - near_jsonrpc_client::JsonRpcClient::connect(self.rpc_url.as_ref()); - if let Some(rpc_api_key) = &self.rpc_api_key { - json_rpc_client = - json_rpc_client.header(near_jsonrpc_client::auth::ApiKey::from(rpc_api_key.clone())) - }; - json_rpc_client - } -} diff --git a/src/js_command_match/login.rs b/src/js_command_match/login.rs deleted file mode 100644 index 6ce269b16..000000000 --- a/src/js_command_match/login.rs +++ /dev/null @@ -1,20 +0,0 @@ -#[derive(Debug, Clone, clap::Parser)] -/// This is a legacy `legacy` command. Once you run it with the specified arguments, new syntax command will be suggested. -pub struct LoginArgs { - #[clap(long, aliases = ["wallet_url", "walletUrl"], default_value = "https://testnet.mynearwallet.com")] - wallet_url: String, - #[clap(allow_hyphen_values = true, num_args = 0..)] - _unknown_args: Vec, -} - -impl LoginArgs { - pub fn to_cli_args(&self, network_config: String) -> Vec { - vec![ - "account".to_owned(), - "import-account".to_owned(), - "using-web-wallet".to_owned(), - "network-config".to_owned(), - network_config, - ] - } -}