Skip to content

Commit 6fb0e3d

Browse files
committed
Better API docs
1 parent 78ba9da commit 6fb0e3d

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

apps/fortuna/src/api/explorer.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub struct ExplorerQueryParams {
2020
#[param(value_type = Option<String>, example = "2023-10-01T00:00:00Z")]
2121
pub min_timestamp: Option<DateTime<Utc>>,
2222
/// Only return logs that are older or equal to this timestamp.
23-
#[param(value_type = Option<String>, example = "2023-10-01T00:00:00Z")]
23+
#[param(value_type = Option<String>, example = "2033-10-01T00:00:00Z")]
2424
pub max_timestamp: Option<DateTime<Utc>>,
2525
/// The query string to search for. This can be a transaction hash, sender address, or sequence number.
2626
pub query: Option<String>,
@@ -31,12 +31,14 @@ pub struct ExplorerQueryParams {
3131

3232
const LOG_RETURN_LIMIT: u64 = 1000;
3333

34+
/// Returns the logs of all requests captured by the keeper.
35+
///
36+
/// This endpoint allows you to filter the logs by a specific chain ID, a query string (which can be a transaction hash, sender address, or sequence number), and a time range.
37+
/// This is useful for debugging and monitoring the requests made to the Entropy contracts on various chains.
3438
#[utoipa::path(
3539
get,
3640
path = "/v1/logs",
37-
responses(
38-
(status = 200, description = "Entropy request logs", body = Vec<RequestStatus>)
39-
),
41+
responses((status = 200, description = "A list of Entropy request logs", body = Vec<RequestStatus>)),
4042
params(ExplorerQueryParams)
4143
)]
4244
pub async fn explorer(

apps/fortuna/src/command/run.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ pub async fn run_api(
4141
schemas(
4242
crate::api::GetRandomValueResponse,
4343
crate::history::RequestStatus,
44+
crate::history::RequestEntryState,
4445
crate::api::Blob,
4546
crate::api::BinaryEncoding,
4647
)
@@ -242,7 +243,6 @@ async fn setup_chain_state(
242243
{
243244
return Err(anyhow!("The current hash chain for chain id {} has configured commitments for sequence numbers greater than the current on-chain sequence number. Are the commitments configured correctly?", &chain_id));
244245
}
245-
tracing::info!("latest metadata: {:?}", latest_metadata);
246246

247247
provider_commitments.push(Commitment {
248248
seed: latest_metadata.seed,

apps/fortuna/src/history.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ use {
1111
};
1212

1313
#[derive(Clone, Debug, Serialize, ToSchema, PartialEq)]
14+
#[serde(tag = "state", rename_all = "kebab-case")]
1415
pub enum RequestEntryState {
1516
Pending,
1617
Completed {
1718
reveal_block_number: u64,
19+
/// The transaction hash of the reveal transaction.
20+
#[schema(example = "0xfe5f880ac10c0aae43f910b5a17f98a93cdd2eb2dce3a5ae34e5827a3a071a32", value_type = String)]
1821
reveal_tx_hash: TxHash,
1922
},
2023
Failed {
@@ -24,13 +27,22 @@ pub enum RequestEntryState {
2427

2528
#[derive(Clone, Debug, Serialize, ToSchema, PartialEq)]
2629
pub struct RequestStatus {
30+
/// The chain ID of the request.
31+
#[schema(example = "ethereum", value_type = String)]
2732
pub chain_id: ChainId,
33+
#[schema(example = "0x6cc14824ea2918f5de5c2f75a9da968ad4bd6344", value_type = String)]
2834
pub provider: Address,
2935
pub sequence: u64,
36+
#[schema(example = "2023-10-01T00:00:00Z", value_type = String)]
3037
pub created_at: DateTime<chrono::Utc>,
38+
#[schema(example = "2023-10-01T00:00:05Z", value_type = String)]
3139
pub last_updated_at: DateTime<chrono::Utc>,
3240
pub request_block_number: u64,
41+
/// The transaction hash of the request transaction.
42+
#[schema(example = "0x5a3a984f41bb5443f5efa6070ed59ccb25edd8dbe6ce7f9294cf5caa64ed00ae", value_type = String)]
3343
pub request_tx_hash: TxHash,
44+
/// This is the address that initiated the request.
45+
#[schema(example = "0x78357316239040e19fc823372cc179ca75e64b81", value_type = String)]
3446
pub sender: Address,
3547
pub state: RequestEntryState,
3648
}

apps/fortuna/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pub mod chain;
33
pub mod command;
44
pub mod config;
55
pub mod eth_utils;
6+
pub mod history;
67
pub mod keeper;
78
pub mod state;
8-
9-
pub mod history;

0 commit comments

Comments
 (0)