Skip to content

Commit

Permalink
structs renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed Dec 11, 2024
1 parent 1303193 commit 9cc0db7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cairo_vm_hints/src/provider/indexer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub mod types;

use reqwest::Client;
use types::{IndexerError, IndexerHeadersProofResponse, IndexerQuery, MMRFromNewIndexer};
use types::{IndexerError, IndexerHeadersProofResponse, IndexerQuery, MMRResponse};

pub const HERODOTUS_RS_INDEXER_URL: &str = "https://rs-indexer.api.herodotus.cloud/accumulators/proofs";

Expand Down Expand Up @@ -32,7 +32,7 @@ impl Indexer {
.map_err(IndexerError::ReqwestError)?;

if response.status().is_success() {
let parsed_mmr: MMRFromNewIndexer =
let parsed_mmr: MMRResponse =
serde_json::from_value(response.json().await.map_err(IndexerError::ReqwestError)?).map_err(IndexerError::SerdeJsonError)?;

if parsed_mmr.data.is_empty() {
Expand Down
20 changes: 10 additions & 10 deletions cairo_vm_hints/src/provider/indexer/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,18 @@ impl IndexerQuery {
/// MMR metadata and proof returned from indexer
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct MMRFromNewIndexer {
pub data: Vec<MMRDataFromNewIndexer>,
pub struct MMRResponse {
pub data: Vec<MMRData>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct MMRDataFromNewIndexer {
pub meta: MMRMetaFromNewIndexer,
pub proofs: Vec<MMRProofFromNewIndexer>,
pub struct MMRData {
pub meta: MMRMetadata,
pub proofs: Vec<MMRProof>,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct MMRMetaFromNewIndexer {
pub struct MMRMetadata {
pub mmr_id: String,
pub mmr_peaks: Vec<String>,
pub mmr_root: String,
Expand All @@ -101,7 +101,7 @@ pub struct MMRMetaFromNewIndexer {

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde_as]
pub struct MMRProofFromNewIndexer {
pub struct MMRProof {
pub block_number: u64,
pub element_hash: String,
pub element_index: u64,
Expand All @@ -118,12 +118,12 @@ pub enum BlockHeader {

#[derive(Debug)]
pub struct IndexerHeadersProofResponse {
pub mmr_meta: MMRMetaFromNewIndexer,
pub headers: HashMap<BlockNumber, MMRProofFromNewIndexer>,
pub mmr_meta: MMRMetadata,
pub headers: HashMap<BlockNumber, MMRProof>,
}

impl IndexerHeadersProofResponse {
pub fn new(mmr_data: MMRDataFromNewIndexer) -> Self {
pub fn new(mmr_data: MMRData) -> Self {
let mmr_meta = mmr_data.meta;
let headers = mmr_data.proofs.into_iter().map(|block| (block.block_number, block)).collect();
Self { mmr_meta, headers }
Expand Down

0 comments on commit 9cc0db7

Please sign in to comment.