fuel_core/schema/
da_compressed.rs1use super::scalars::HexString;
2use crate::{
3 fuel_core_graphql_api::{
4 IntoApiResult,
5 query_costs,
6 },
7 graphql_api::api_service::DaCompressionProvider,
8 schema::scalars::U32,
9};
10use async_graphql::{
11 Context,
12 Object,
13};
14
15pub struct DaCompressedBlock {
16 bytes: Vec<u8>,
17}
18
19impl From<Vec<u8>> for DaCompressedBlock {
20 fn from(bytes: Vec<u8>) -> Self {
21 Self { bytes }
22 }
23}
24
25#[Object]
26impl DaCompressedBlock {
27 async fn bytes(&self) -> HexString {
28 HexString(self.bytes.clone())
29 }
30}
31
32#[derive(Default)]
33pub struct DaCompressedBlockQuery;
34
35#[Object]
36impl DaCompressedBlockQuery {
37 #[graphql(complexity = "query_costs().da_compressed_block_read")]
38 async fn da_compressed_block(
39 &self,
40 ctx: &Context<'_>,
41 #[graphql(desc = "Height of the block")] height: U32,
42 ) -> async_graphql::Result<Option<DaCompressedBlock>> {
43 let da_compression_provider = ctx.data_unchecked::<DaCompressionProvider>();
44 da_compression_provider
45 .da_compressed_block(&height.0.into())
46 .into_api_result()
47 }
48}