Skip to content

Commit

Permalink
fix: make prover_root_url and auth_root_url more natural, replace…
Browse files Browse the repository at this point in the history
… placeholder for default `substrate_root_url`
  • Loading branch information
iajoiner committed Oct 29, 2024
1 parent bb8644d commit 1a0762c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
6 changes: 3 additions & 3 deletions scripts/count-ethereum-core/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ async fn main() {
dotenv::dotenv().unwrap();

let client = Arc::new(SxTClient::new(
env::var("PROVER_ROOT_URL").unwrap_or("api.spaceandtime.dev".to_string()),
env::var("AUTH_ROOT_URL").unwrap_or("api.spaceandtime.dev".to_string()),
env::var("SUBSTRATE_NODE_URL").unwrap_or("foo.bar.spaceandtime.dev".to_string()),
env::var("PROVER_ROOT_URL").unwrap_or("https://api.spaceandtime.dev".to_string()),
env::var("AUTH_ROOT_URL").unwrap_or("https://proxy.api.spaceandtime.dev".to_string()),
env::var("SUBSTRATE_NODE_URL").unwrap_or("https://rpc.testnet.sxt.network".to_string()),
env::var("SXT_API_KEY").expect("SXT_API_KEY is required"),
env::var("VERIFIER_SETUP").unwrap_or("verifier_setup.bin".to_string()),
));
Expand Down
8 changes: 4 additions & 4 deletions sdk/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ pub struct SdkArgs {
#[arg(
long,
value_name = "PROVER_ROOT_URL",
default_value = "api.spaceandtime.dev",
default_value = "https://api.spaceandtime.dev",
env = "PROVER_ROOT_URL"
)]
pub prover_root_url: String,

/// Root URL for the Auth service
///
/// Used for authentication requests. Generally the same as the Prover Root URL.
/// Used for authentication requests.
/// Can be set via AUTH_ROOT_URL environment variable.
#[arg(
long,
value_name = "AUTH_ROOT_URL",
default_value = "api.spaceandtime.dev",
default_value = "https://proxy.api.spaceandtime.dev",
env = "AUTH_ROOT_URL"
)]
pub auth_root_url: String,
Expand All @@ -44,7 +44,7 @@ pub struct SdkArgs {
#[arg(
long,
value_name = "SUBSTRATE_NODE_URL",
default_value = "foo.bar.spaceandtime.dev",
default_value = "https://rpc.testnet.sxt.network",
env = "SUBSTRATE_NODE_URL"
)]
pub substrate_node_url: String,
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub async fn get_access_token(
url: &str,
) -> Result<String, Box<dyn core::error::Error>> {
let client = Client::new();
let auth_url = format!("https://proxy.{}/auth/apikey", url);
let auth_url = format!("{}/auth/apikey", url);
let response = client
.post(auth_url)
.header("apikey", apikey)
Expand Down
13 changes: 3 additions & 10 deletions sdk/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,21 @@ mod prover {
#[derive(Debug, Clone)]
pub struct SxTClient {
/// Root URL for the Prover service
///
/// This URL is used for interacting with the prover service.
pub prover_root_url: String,

/// Root URL for the Auth service
///
/// Used for authentication requests. Generally the same as the Prover Root URL.
pub auth_root_url: String,

/// URL for the Substrate node service
///
/// Specifies the Substrate node endpoint used for accessing commitment data.
pub substrate_node_url: String,

/// API Key for Space and Time (SxT) services
///
/// The API key required for authorization with Space and Time services.
/// Please visit [Space and Time Studio](https://app.spaceandtime.ai/) to obtain an API key
/// if you do not have one.
pub sxt_api_key: String,

/// Path to the verifier setup binary file
///
/// Specifies the path to the `verifier_setup.bin` file required for verification.
pub verifier_setup: String,
}

Expand Down Expand Up @@ -101,7 +94,7 @@ impl SxTClient {
let client = Client::new();
let access_token = get_access_token(&self.sxt_api_key, &self.auth_root_url).await?;
let response = client
.post(format!("https://{}/v1/prove", &self.prover_root_url))
.post(format!("{}/v1/prove", &self.prover_root_url))
.bearer_auth(&access_token)
.json(&prover_query)
.send()
Expand Down

0 comments on commit 1a0762c

Please sign in to comment.