Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
qedric committed May 26, 2024
2 parents 9d1ae1d + 742c35f commit d74c31d
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sp1_prover/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[workspace]
exclude = ["zkpoex", "ecdh"]
members = ["zkpoex-script", "ecdh-script", "evm-runner"]
members = ["zkpoex-script", "ecdh-script", "evm-runner", "bid-server"]
resolver = "2"
14 changes: 14 additions & 0 deletions sp1_prover/bid-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
version = "0.1.0"
name = "bid-server"
edition = "2021"


[dependencies]
rocket = { version = "0.5.1", features = ["json"] }
cli-batteries = "0.5"
clap = { version = "4.5.4", features = ["derive"] }
rocket_cors = "0.6.0"

[build-dependencies]
cli-batteries = "0.5"
3 changes: 3 additions & 0 deletions sp1_prover/bid-server/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
cli_batteries::build_rs().unwrap()
}
61 changes: 61 additions & 0 deletions sp1_prover/bid-server/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#[macro_use] extern crate rocket;

use rocket::{Rocket, Build, State};
use rocket::http::Method;

use rocket::serde::Serialize;

use rocket::serde::json::Json;
use rocket_cors::{AllowedHeaders, AllowedOrigins, Guard, Responder};
use clap::Parser;

#[derive(Debug, Serialize)]
#[serde(crate = "rocket::serde")]
struct Resp {
proof: String,
address: String,
}

// return contets of proof
#[get("/proof")]
async fn proof(cors: Guard<'_>, args: &State<Args>) -> Responder<Json<Resp>> {
let resp = Resp {
proof: args.proof.clone(),
address: args.address.clone(),
};
cors.responder(Json(resp))
}

/// Simple program to serve proof files
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
/// path to proof
#[arg(short, long)]
proof: String,

/// redemption address
#[arg(short, long, default_value_t = (&"0x..").to_string())]
address: String,
}

#[launch]
fn rocket() -> Rocket<Build> {

let allowed_origins = AllowedOrigins::some_exact(&["https://zktripster.pages.dev"]);
let cors = rocket_cors::CorsOptions {
allowed_origins,
allowed_methods: vec![Method::Get].into_iter().map(From::from).collect(),
allowed_headers: AllowedHeaders::some(&["Authorization", "Accept"]),
allow_credentials: true,
..Default::default()
}
.to_cors().unwrap();

let args = Args::parse();
rocket::build()
.mount("/", routes![proof])
.mount("/", rocket_cors::catch_all_options_routes())
.manage(args)
.manage(cors)
}

0 comments on commit d74c31d

Please sign in to comment.