Skip to content
This repository was archived by the owner on Aug 28, 2023. It is now read-only.

Move documentation to cargo doc #414

Merged
merged 21 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
aaff45e
Started doc generation script using cargo doc
jpalvarezl May 28, 2021
863f34e
Made the file executable
jpalvarezl May 28, 2021
a498b65
Made cargo doc call multiline
jpalvarezl May 28, 2021
f330207
Changed the command to the linux version
jpalvarezl May 31, 2021
69d1c01
Hid certain modules
jpalvarezl May 31, 2021
325ccdb
Added markdown comments and reference to struct in a separate module
jpalvarezl Jun 1, 2021
ec4041a
Added link to object in the right section
jpalvarezl Jun 1, 2021
d1040f1
Added json examples to transaction_details
jpalvarezl Jun 1, 2021
05d116b
hid the macros module from docs
jpalvarezl Jun 1, 2021
e8491eb
Added docs for TransactionSummary and history and queued endpoints
jpalvarezl Jun 1, 2021
2886c9c
Added docs for tx proposal and confirmation request endpoints and models
jpalvarezl Jun 1, 2021
e4bb264
Added documentation for about endpoint and models
jpalvarezl Jun 1, 2021
c6841cd
Transfered documentation for balances and collectibles
jpalvarezl Jun 1, 2021
9ec5373
Added more top level documentation
jpalvarezl Jun 1, 2021
4184db7
Richards suggestion
rmeissner Jun 2, 2021
79b53cf
Modified script and docs for balances and collectibles
jpalvarezl Jun 2, 2021
6a89ee8
Finished adjusting docs
jpalvarezl Jun 2, 2021
4d3e7f2
Removed excessive white space
jpalvarezl Jun 2, 2021
ead2b8e
Corrected casing
jpalvarezl Jun 2, 2021
4ffb74e
Added page reference and removed link to the transaction service
jpalvarezl Jun 2, 2021
871873e
Fixed how the link to structs are rendered
jpalvarezl Jun 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
dump.rdb

**/venv

*.DS_Store*
7 changes: 7 additions & 0 deletions scripts/generate_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

rm -rf ./target/doc

cargo doc --no-deps \
--workspace \
--open # TODO: remove
2 changes: 2 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ macro_rules! bail {
};
}

#[doc(hidden)]
#[macro_export]
macro_rules! api_error {
($msg:literal $(,)?) => {
Expand All @@ -47,6 +48,7 @@ macro_rules! api_error {
};
}

#[doc(hidden)]
#[macro_export]
macro_rules! client_error {
($status_code:expr, $message:expr) => {
Expand Down
18 changes: 18 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,33 @@ extern crate rocket_contrib;

extern crate dotenv;

#[doc(hidden)]
#[macro_use]
pub mod macros;

#[doc(hidden)]
mod cache;
#[doc(hidden)]
mod config;

/// Models exposed by this service
///
/// *Important:* Names, Enums and Polymorphism
///
/// Every field in the structs that you will see in this documentation is **camelCased** on serialisation.
///
/// Enums are **SCREAMING_SNAKE_CASED** on serialization and the variant is always put into a `type` json field for polymorphic cases.
mod models;
#[doc(hidden)]
mod monitoring;
#[doc(hidden)]
mod providers;

/// Collection of all endpoints all endpoints
mod routes;
#[doc(hidden)]
mod services;
#[doc(hidden)]
mod utils;

#[cfg(test)]
Expand All @@ -34,6 +51,7 @@ use routes::active_routes;
use std::time::Duration;
use utils::cors::CORS;

#[doc(hidden)]
#[launch]
fn rocket() -> _ {
dotenv().ok();
Expand Down
2 changes: 2 additions & 0 deletions src/models/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#[doc(hidden)]
pub mod backend;
pub mod commons;
#[doc(hidden)]
pub mod converters;
pub mod service;

Expand Down
18 changes: 18 additions & 0 deletions src/models/service/about.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
use serde::Serialize;

/// About
///
/// <details>
/// <summary>Sample</summary>
///
/// ```json
/// {
/// "transactionServiceBaseUrl": "https://safe-transaction.staging.gnosisdev.com/api/v1",
/// "name": "safe-client-gateway",
/// "version": "0.2.0-9-g17dcd40",
/// "buildNumber": "48"
/// }
/// ```
/// </details>
#[derive(Serialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct About {
/// base URL string used for backend requests
pub transaction_service_base_url: String,
/// crate name
pub name: String,
/// env variable `VERSION`, defaults to crate version
pub version: String,
/// Build number from github action
pub build_number: Option<String>,
}
2 changes: 2 additions & 0 deletions src/models/service/balances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub struct Balance {
#[derive(Serialize, Debug, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct Balances {
/// Aggregated fiat balance
pub fiat_total: String,
/// Individual [Balance] entries for each ERC20 in the Safe
pub items: Vec<Balance>,
}
123 changes: 123 additions & 0 deletions src/models/service/transactions/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,129 @@ use crate::providers::info::{SafeAppInfo, TokenInfo};
use serde::Serialize;
use std::collections::HashMap;

/// Top level object returned by the `/v1/transactions/<details_id>` endpoint
///
/// <details>
/// <summary>Sample 1: Multisig Transaction awaiting confirmation</summary>
///
/// ```json
/// {
/// "executedAt": null,
/// "txStatus": "AWAITING_CONFIRMATIONS",
/// "txInfo": {
/// "type": "SettingsChange",
/// "dataDecoded": {
/// "method": "changeThreshold",
/// "parameters": [
/// {
/// "name": "_threshold",
/// "type": "uint256",
/// "value": "2"
/// }
/// ]
/// }
/// },
/// "txData": {
/// "hexData": "0x694e80c30000000000000000000000000000000000000000000000000000000000000002",
/// "dataDecoded": {
/// "method": "changeThreshold",
/// "parameters": [
/// {
/// "name": "_threshold",
/// "type": "uint256",
/// "value": "2"
/// }
/// ]
/// },
/// "to": "0x1230B3d59858296A31053C1b8562Ecf89A2f888b",
/// "value": "0",
/// "operation": 0
/// },
/// "detailedExecutionInfo": {
/// "type": "MULTISIG",
/// "submittedAt": 1596792600322,
/// "nonce": 180,
/// "safeTxHash": "0x0ef685fb7984d7314c1368497e1b0c73016066bec41f966d32f18354b88fbd46",
/// "signers": [
/// "0xBEA2F9227230976d2813a2f8b922c22bE1DE1B23",
/// "0x37e9F140A9Df5DCBc783C6c220660a4E15CBFe72",
/// "0xA3DAa0d9Ae02dAA17a664c232aDa1B739eF5ae8D",
/// "0xF2CeA96575d6b10f51d9aF3b10e3e4E5738aa6bd",
/// "0x65F8236309e5A99Ff0d129d04E486EBCE20DC7B0"
/// ],
/// "confirmationsRequired": 3,
/// "confirmations": [
/// {
/// "signer": "0xBEA2F9227230976d2813a2f8b922c22bE1DE1B23",
/// "signature": "0x1b01f3d79a50576e82d1da31810c0313bed9b76b016e1d9c6216512b2c7e53bb70df8163e568ca8ec1b8c7e7ef0a8db52d6ab2b7f47dc51c31729dd064ce375b1c"
/// }
/// ]
/// },
/// "txHash": null
/// }
/// ```
/// </details>
///
///
/// <details>
/// <summary>Sample 2: Ethereum transaction</summary>
///
/// ```json
/// {
/// "executedAt": 1596719563000,
/// "txStatus": "SUCCESS",
/// "txInfo": {
/// "type": "Transfer",
/// "sender": "0x938bae50a210b80EA233112800Cd5Bc2e7644300",
/// "recipient": "0x1230B3d59858296A31053C1b8562Ecf89A2f888b",
/// "direction": "INCOMING",
/// "transferInfo": {
/// "type": "ETHER",
/// "value": "50000000000000"
/// }
/// },
/// "txData": null,
/// "detailedExecutionInfo": null,
/// "txHash": "0x70b3c7f81a49f270fe86673f6c08beecfee384a89ef8b0869e46584905d4ecc2"
/// }
/// ```
/// </details>
///
///
/// <details>
/// <summary>Sample 3: Settings change</summary>
///
/// ```json
/// {
/// "id": "multisig_0x57d94fe21bbee8f6646c420ee23126cd1ba1b9a53a6c9b10099a043da8f32eea",
/// "timestamp": 1595429831000,
/// "txStatus": "SUCCESS",
/// "txInfo": {
/// "type": "SettingsChange",
/// "dataDecoded": {
/// "method": "addOwnerWithThreshold",
/// "parameters": [
/// {
/// "name": "owner",
/// "type": "address",
/// "value": "0xA3DAa0d9Ae02dAA17a664c232aDa1B739eF5ae8D"
/// },
/// {
/// "name": "_threshold",
/// "type": "uint256",
/// "value": "2"
/// }
/// ]
/// }
/// },
/// "executionInfo": {
/// "nonce": 135,
/// "confirmationsRequired": 2,
/// "confirmationsSubmitted": 2
/// }
/// }
/// ```
/// </details>
#[derive(Serialize, Debug, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct TransactionDetails {
Expand Down
23 changes: 23 additions & 0 deletions src/models/service/transactions/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@ pub struct ConfirmationRequest {
pub signed_safe_tx_hash: String,
}

/// MultisigTransactionRequest
///
/// <details>
/// <summary>Example body of MultisigTransactionRequest for submitting a Cancellation Transaction</summary>
///
/// ```json
/// {
/// "to": "0xBe8C10Dbf4c6148f9834C56C3331f8191f355552",
/// "value": "0",
/// "data": "0x",
/// "nonce": "39",
/// "operation": 0,
/// "safeTxGas": "0",
/// "baseGas": "0",
/// "gasPrice": "0",
/// "gasToken": "0x0000000000000000000000000000000000000000",
/// "refundReceiver": "0x0000000000000000000000000000000000000000",
/// "safeTxHash": "61b0acaeae49e74306536c3371cd80bb46aeb5732859b6ffd776ad24e2d57f8e",
/// "sender": "0xBe8C10Dbf4c6148f9834C56C3331f8191f355552",
/// "signature": "a519dd9aa226a5f6f1816035af85d43d834c3284912574bef0c04aaff1f21004602a5339da424cf53de9aac068f67a3417f3cba40e3049637ae901b6f345b4ac1b"
/// }
/// ```
/// </details>
#[derive(Serialize, Deserialize, Debug, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct MultisigTransactionRequest {
Expand Down
Loading