diff --git a/pyth-rng/config.yaml b/pyth-rng/config.yaml new file mode 100644 index 000000000..e6d6ddfd6 --- /dev/null +++ b/pyth-rng/config.yaml @@ -0,0 +1,4 @@ +chains: + - chain_id: "optimism-goerli" + geth_rpc_addr: https://goerli.optimism.io + contract_addr: 0x28F16Af4D87523910b843a801454AEde5F9B0459 diff --git a/pyth-rng/src/api/chain_ids.rs b/pyth-rng/src/api/chain_ids.rs new file mode 100644 index 000000000..f29e1eda3 --- /dev/null +++ b/pyth-rng/src/api/chain_ids.rs @@ -0,0 +1,26 @@ +use { + crate::api::{ + ChainId, + RestError, + }, + anyhow::Result, + axum::{ + extract::State, + Json, + }, +}; + +/// Get the list of supported chain ids +#[utoipa::path( +get, +path = "/v1/chains", +responses( +(status = 200, description = "Successfully retrieved the list of chain ids", body = GetRandomValueResponse), +) +)] +pub async fn chain_ids( + State(state): State, +) -> Result>, RestError> { + let chain_ids = state.chains.iter().map(|(id, _)| id.clone()).collect(); + Ok(Json(chain_ids)) +}