CLI for relayer
This commit is contained in:
parent
4f6bcde865
commit
5f11d004b0
2 changed files with 25 additions and 5 deletions
10
utils/quartz-relayer/src/cli.rs
Normal file
10
utils/quartz-relayer/src/cli.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
use clap::Parser;
|
||||||
|
use tonic::transport::Endpoint;
|
||||||
|
|
||||||
|
#[derive(Debug, Parser)]
|
||||||
|
#[command(author, version, about, long_about = None)]
|
||||||
|
pub struct Cli {
|
||||||
|
/// RPC server address
|
||||||
|
#[clap(long, default_value = "http://localhost:11090")]
|
||||||
|
pub enclave_addr: Endpoint,
|
||||||
|
}
|
|
@ -1,13 +1,23 @@
|
||||||
use quartz_proto::quartz::{core_client::CoreClient, SessionCreateRequest};
|
mod cli;
|
||||||
|
|
||||||
|
use std::{fs::File, io::Write};
|
||||||
|
|
||||||
|
use clap::Parser;
|
||||||
|
use quartz_proto::quartz::{core_client::CoreClient, InstantiateRequest};
|
||||||
|
use quartz_relayer::types::InstantiateResponse;
|
||||||
|
|
||||||
|
use crate::{cli::Cli};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut client = CoreClient::connect("http://localhost:11090").await?;
|
let args = Cli::parse();
|
||||||
|
|
||||||
let request = tonic::Request::new(SessionCreateRequest {});
|
let mut client = CoreClient::connect(args.enclave_addr).await?;
|
||||||
|
let response = client.instantiate(InstantiateRequest {}).await?;
|
||||||
|
let response: InstantiateResponse = response.into_inner().try_into()?;
|
||||||
|
|
||||||
let response = client.session_create(request).await?;
|
let mut quote_file = File::create("test.quote")?;
|
||||||
println!("{:?}", response.into_inner());
|
quote_file.write_all(response.quote())?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue