From a9b8329e6bf6cadf1aa965421507da22a72cc73c Mon Sep 17 00:00:00 2001 From: Jayant Krishnamurthy Date: Wed, 18 Oct 2023 16:17:05 -0700 Subject: [PATCH] missing files --- pyth-rng/config.yaml | 4 ++++ pyth-rng/src/api/chain_ids.rs | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 pyth-rng/config.yaml create mode 100644 pyth-rng/src/api/chain_ids.rs 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)) +}