Skip to content

Commit

Permalink
chore: reorganize config into separate module (#1479)
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal authored Jul 25, 2024
1 parent 91f95de commit d0c077b
Show file tree
Hide file tree
Showing 38 changed files with 269 additions and 247 deletions.
3 changes: 2 additions & 1 deletion cmd/crates/soroban-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ use assert_fs::{fixture::FixtureError, prelude::PathChild, TempDir};
use fs_extra::dir::CopyOptions;

use soroban_cli::{
commands::{config, contract::invoke, global, keys, network, NetworkRunnable},
commands::{contract::invoke, global, keys, NetworkRunnable},
config::{self, network},
CommandParser,
};

Expand Down
3 changes: 2 additions & 1 deletion cmd/crates/soroban-test/tests/it/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use soroban_test::{AssertExt, TestEnv};
use std::{fs, path::Path};

use crate::util::{add_key, add_test_id, SecretKind, DEFAULT_SEED_PHRASE};
use soroban_cli::commands::network::{self, LOCAL_NETWORK_PASSPHRASE};
use soroban_cli::commands::network;
use soroban_cli::config::network::passphrase::LOCAL as LOCAL_NETWORK_PASSPHRASE;

fn ls(sandbox: &TestEnv) -> Vec<String> {
sandbox
Expand Down
8 changes: 5 additions & 3 deletions cmd/crates/soroban-test/tests/it/integration/hello_world.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use predicates::boolean::PredicateBooleanExt;
use soroban_cli::commands::{
use soroban_cli::{
commands::{
contract::{self, fetch},
txn_result::TxnResult,
},
config::{locator, secret},
contract::{self, fetch},
txn_result::TxnResult,
};
use soroban_rpc::GetLatestLedgerResponse;
use soroban_test::{AssertExt, TestEnv, LOCAL_NETWORK_PASSPHRASE};
Expand Down
4 changes: 2 additions & 2 deletions cmd/crates/soroban-test/tests/it/util.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::path::Path;

use soroban_cli::commands::{
use soroban_cli::{
commands::contract,
config::{locator::KeyType, secret::Secret},
contract,
};
use soroban_test::{TestEnv, Wasm, TEST_ACCOUNT};

Expand Down
3 changes: 1 addition & 2 deletions cmd/soroban-cli/src/commands/cache/actionlog/ls.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use clap::command;

use super::super::super::config::locator;
use crate::commands::config::data;
use crate::config::{data, locator};

#[derive(thiserror::Error, Debug)]
pub enum Error {
Expand Down
3 changes: 1 addition & 2 deletions cmd/soroban-cli/src/commands/cache/actionlog/read.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::{fs, io, path::PathBuf};

use super::super::super::config::locator;
use crate::commands::config::data;
use crate::config::{data, locator};

#[derive(thiserror::Error, Debug)]
pub enum Error {
Expand Down
3 changes: 1 addition & 2 deletions cmd/soroban-cli/src/commands/cache/clean.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::{fs, io::ErrorKind};

use super::super::config::locator;
use crate::commands::config::data;
use crate::config::{data, locator};

#[derive(thiserror::Error, Debug)]
pub enum Error {
Expand Down
3 changes: 1 addition & 2 deletions cmd/soroban-cli/src/commands/cache/path.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use super::super::config::locator;
use crate::commands::config::data;
use crate::config::{data, locator};

#[derive(thiserror::Error, Debug)]
pub enum Error {
Expand Down
8 changes: 3 additions & 5 deletions cmd/soroban-cli/src/commands/contract/bindings/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ use stellar_strkey::DecodeError;

use crate::wasm;
use crate::{
commands::{
config::{self, locator},
contract::fetch,
global,
commands::{contract::fetch, global, NetworkRunnable},
config::{
self, locator,
network::{self, Network},
NetworkRunnable,
},
get_spec::{self, get_remote_contract_spec},
};
Expand Down
4 changes: 2 additions & 2 deletions cmd/soroban-cli/src/commands/contract/deploy/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ use std::{array::TryFromSliceError, fmt::Debug, num::ParseIntError};

use crate::{
commands::{
config::{self, data},
global, network,
global,
txn_result::{TxnEnvelopeResult, TxnResult},
NetworkRunnable,
},
config::{self, data, network},
rpc::{Client, Error as SorobanRpcError},
utils::{contract_id_hash_from_asset, parsing::parse_asset},
};
Expand Down
6 changes: 3 additions & 3 deletions cmd/soroban-cli/src/commands/contract/deploy/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ use soroban_env_host::{
};

use crate::commands::{
config::{data, locator},
contract::{self, id::wasm::get_contract_id},
global, network,
global,
txn_result::{TxnEnvelopeResult, TxnResult},
NetworkRunnable,
};
use crate::{
commands::{config, contract::install, HEADING_RPC},
commands::{contract::install, HEADING_RPC},
config::{self, data, locator, network},
rpc::{self, Client},
utils, wasm,
};
Expand Down
4 changes: 2 additions & 2 deletions cmd/soroban-cli/src/commands/contract/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use soroban_env_host::xdr::{

use crate::{
commands::{
config::{self, data, locator},
global, network,
global,
txn_result::{TxnEnvelopeResult, TxnResult},
NetworkRunnable,
},
config::{self, data, locator, network},
key,
rpc::{self, Client},
wasm, Pwd,
Expand Down
6 changes: 4 additions & 2 deletions cmd/soroban-cli/src/commands/contract/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ use soroban_env_host::{
use soroban_spec::read::FromWasmError;
use stellar_strkey::DecodeError;

use super::super::config::{self, locator};
use crate::commands::network::{self, Network};
use crate::commands::{global, NetworkRunnable};
use crate::config::{
self, locator,
network::{self, Network},
};
use crate::{
rpc::{self, Client},
Pwd,
Expand Down
4 changes: 2 additions & 2 deletions cmd/soroban-cli/src/commands/contract/id/asset.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::{arg, command, Parser};

use crate::commands::config;
use crate::config;

use crate::utils::contract_id_hash_from_asset;
use crate::utils::parsing::parse_asset;
Expand All @@ -20,7 +20,7 @@ pub enum Error {
#[error(transparent)]
ParseError(#[from] crate::utils::parsing::Error),
#[error(transparent)]
ConfigError(#[from] crate::commands::config::Error),
ConfigError(#[from] config::Error),
#[error(transparent)]
Xdr(#[from] soroban_env_host::xdr::Error),
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/soroban-cli/src/commands/contract/id/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use soroban_env_host::xdr::{
HashIdPreimageContractId, Limits, PublicKey, ScAddress, Uint256, WriteXdr,
};

use crate::commands::config;
use crate::config;

#[derive(Parser, Debug, Clone)]
#[group(skip)]
Expand All @@ -22,7 +22,7 @@ pub enum Error {
#[error(transparent)]
ParseError(#[from] crate::utils::parsing::Error),
#[error(transparent)]
ConfigError(#[from] crate::commands::config::Error),
ConfigError(#[from] config::Error),
#[error(transparent)]
Xdr(#[from] xdr::Error),
#[error("cannot parse salt {0}")]
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/contract/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{fmt::Debug, path::PathBuf};
use tracing::debug;

use super::SpecOutput;
use crate::{commands::config::locator, wasm};
use crate::{config::locator, wasm};

#[derive(Parser, Debug, Clone)]
#[group(skip)]
Expand Down
6 changes: 3 additions & 3 deletions cmd/soroban-cli/src/commands/contract/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ use soroban_env_host::xdr::{
};

use super::restore;
use crate::commands::network;
use crate::commands::txn_result::{TxnEnvelopeResult, TxnResult};
use crate::commands::{config::data, global, NetworkRunnable};
use crate::commands::{global, NetworkRunnable};
use crate::config::{self, data, network};
use crate::key;
use crate::rpc::{self, Client};
use crate::{commands::config, utils, wasm};
use crate::{utils, wasm};

const CONTRACT_META_SDK_KEY: &str = "rssdkver";
const PUBLIC_NETWORK_PASSPHRASE: &str = "Public Global Stellar Network ; September 2015";
Expand Down
8 changes: 3 additions & 5 deletions cmd/soroban-cli/src/commands/contract/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ use soroban_env_host::{

use soroban_spec::read::FromWasmError;

use super::super::{
config::{self, locator},
events,
};
use super::super::events;
use crate::commands::txn_result::{TxnEnvelopeResult, TxnResult};
use crate::commands::NetworkRunnable;
use crate::get_spec::{self, get_remote_contract_spec};
use crate::{
commands::{config::data, global, network},
commands::global,
config::{self, data, locator, network},
rpc, Pwd,
};
use soroban_spec_tools::{contract, Spec};
Expand Down
6 changes: 2 additions & 4 deletions cmd/soroban-cli/src/commands/contract/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ use soroban_env_host::{
};

use crate::{
commands::{
config::{self, locator},
global, NetworkRunnable,
},
commands::{global, NetworkRunnable},
config::{self, locator},
key,
rpc::{self, Client, FullLedgerEntries, FullLedgerEntry},
};
Expand Down
4 changes: 2 additions & 2 deletions cmd/soroban-cli/src/commands/contract/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ use stellar_strkey::DecodeError;

use crate::{
commands::{
config::{self, data, locator},
contract::extend,
global, network,
global,
txn_result::{TxnEnvelopeResult, TxnResult},
NetworkRunnable,
},
config::{self, data, locator, network},
key,
rpc::{self, Client},
wasm, Pwd,
Expand Down
6 changes: 2 additions & 4 deletions cmd/soroban-cli/src/commands/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ use std::io;

use soroban_env_host::xdr::{self, Limits, ReadXdr};

use super::{
config::{self, locator},
global, network, NetworkRunnable,
};
use super::{global, NetworkRunnable};
use crate::config::{self, locator, network};
use crate::rpc;

#[derive(Parser, Debug, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/keys/add.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::command;

use super::super::config::{locator, secret};
use crate::config::{locator, secret};

#[derive(thiserror::Error, Debug)]
pub enum Error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/keys/fund.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::command;

use crate::commands::network;
use crate::config::network;

use super::address;

Expand Down
4 changes: 1 addition & 3 deletions cmd/soroban-cli/src/commands/keys/generate.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use clap::{arg, command};

use crate::commands::network;

use super::super::config::{
locator,
locator, network,
secret::{self, Secret},
};

Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/keys/show.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::arg;

use super::super::config::{locator, secret};
use crate::config::{locator, secret};

#[derive(thiserror::Error, Debug)]
pub enum Error {
Expand Down
3 changes: 2 additions & 1 deletion cmd/soroban-cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ use std::str::FromStr;
use async_trait::async_trait;
use clap::{command, error::ErrorKind, CommandFactory, FromArgMatches, Parser};

use crate::config;

pub mod cache;
pub mod completion;
pub mod config;
pub mod contract;
pub mod events;
pub mod global;
Expand Down
4 changes: 2 additions & 2 deletions cmd/soroban-cli/src/commands/network/add.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::super::config::{locator, secret};
use crate::config::{locator, network, secret};
use clap::command;

#[derive(thiserror::Error, Debug)]
Expand All @@ -17,7 +17,7 @@ pub struct Cmd {
pub name: String,

#[command(flatten)]
pub network: super::Network,
pub network: network::Network,

#[command(flatten)]
pub config_locator: locator::Args,
Expand Down
Loading

0 comments on commit d0c077b

Please sign in to comment.