Skip to content

Commit

Permalink
feat(theoros_handlers): Pragma feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
akhercha committed Sep 10, 2024
1 parent 5437380 commit f94e250
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 11 deletions.
6 changes: 5 additions & 1 deletion monorepo.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@
"path": "rust/pragma-utils",
"name": "pragma-utils",
},
{
"path": "rust/pragma-feeds",
"name": "pragma-feeds",
},
{
"path": "solidity",
"name": "===== SOLIDITY =====",
},
],
"settings": {},
}
}
20 changes: 20 additions & 0 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "2"
members = ["pragma-cli", "theoros", "pragma-utils"]
members = ["pragma-cli", "theoros", "pragma-utils", "pragma-feeds"]

[workspace.package]
version = "0.1.0"
Expand Down Expand Up @@ -75,11 +75,16 @@ rusoto_s3 = "0.48.0"
rusoto_core = "0.48.0"
lazy_static = "1.5.0"


# Apibara DNA (indexing)
apibara-core = { git = "https://github.com/apibara/dna", rev = "9caa385" }
apibara-sdk = { git = "https://github.com/apibara/dna", rev = "9caa385" }

# Pragma packages
pragma-utils = { path = "pragma-utils" }
pragma-feeds = { path = "pragma-feeds" }
pragma-cli = { path = "pragma-cli" }
theoros = { path = "theoros" }

# Tests dependencies
tracing-test = "0.2.5"

Expand Down
19 changes: 19 additions & 0 deletions rust/pragma-feeds/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "pragma-feeds"
version = "0.1.0"
edition = "2021"

[dependencies]
anyhow = { workspace = true }
apibara-core = { workspace = true }
async-trait = { workspace = true }
starknet = { workspace = true }
tokio = { workspace = true, features = ["signal"] }
tracing = { workspace = true }
tracing-axiom = { workspace = true }
tracing-subscriber = { workspace = true }
rusoto_core = { workspace = true }
hex = { workspace = true }
strum = { workspace = true }
strum_macros = { workspace = true }
serde = { workspace = true, features = ["derive"] }
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ use std::convert::TryFrom;
use std::str::FromStr;

use anyhow::{anyhow, bail, Context};
use hex;
use serde::{Deserialize, Serialize};
use strum_macros::{Display, EnumString};

Expand Down
1 change: 0 additions & 1 deletion rust/pragma-utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod conversions;
pub mod feeds;
pub mod http;
pub mod services;
pub mod tracing;
3 changes: 2 additions & 1 deletion rust/theoros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ rusoto_core = { workspace = true }
alloy = { workspace = true }
lazy_static = { workspace = true }

pragma-utils = { path = "../pragma-utils" }
pragma-utils = { workspace = true }
pragma-feeds = { workspace = true }
3 changes: 2 additions & 1 deletion rust/theoros/src/handlers/get_data_feeds.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use axum::extract::State;
use axum::Json;
use pragma_utils::feeds::Feed;
use serde::{Deserialize, Serialize};
use utoipa::{ToResponse, ToSchema};

use pragma_feeds::Feed;

use crate::errors::GetDataFeedsError;
use crate::AppState;

Expand Down
2 changes: 1 addition & 1 deletion rust/theoros/src/services/api/docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use serde_json::to_string_pretty;
use utoipa::OpenApi;
use utoipauto::utoipauto;

#[utoipauto(paths = "./theoros/src, ./pragma-utils/src")]
#[utoipauto(paths = "./theoros/src, ./pragma-feeds/src")]
#[derive(OpenApi)]
#[openapi(
tags(
Expand Down
6 changes: 3 additions & 3 deletions rust/theoros/src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ impl TheorosStorage {
// TODO: remove this later, only used for now for tests
pub fn testing_state() -> Self {
let constants_data_feeds: HashSet<String> = HashSet::from([
"0x01534d4254432f555344".into(), // BTC/USD
"0x01534d4554482f555344".into(), // ETH/USD
"0x01534d454b55424f2f555344".into(), // EKUBO/USD
"0x01534d4254432f555344".into(), // SPOT MEDIAN: BTC/USD
"0x01534d4554482f555344".into(), // SPOT MEDIAN: ETH/USD
"0x014F50454b55424f2f555344".into(), // OPTIONS: EKUBO/USD
]);
Self { data_feeds: constants_data_feeds, ..Default::default() }
}
Expand Down

0 comments on commit f94e250

Please sign in to comment.