diff --git a/grpc/proto/gap_filler.proto b/grpc/proto/gap_filler.proto index 170b11fe9..b6eef740f 100644 --- a/grpc/proto/gap_filler.proto +++ b/grpc/proto/gap_filler.proto @@ -35,24 +35,44 @@ enum OwnerType { OWNER_TYPE_SINGLE = 2; } -message AssetLeaf { - bytes pubkey = 1; - bytes tree_id = 2; - bytes leaf = 3; - uint64 nonce = 4; - bytes data_hash = 5; - bytes creator_hash = 6; - uint64 leaf_seq = 7; - uint64 slot_updated = 8; +enum TokenStandard { + NON_FUNGIBLE = 0; + FUNGIBLE_ASSET = 1; + FUNGIBLE = 2; + NON_FUNGIBLE_EDITION = 3; + PROGRAMMABLE_NON_FUNGIBLE = 4; + PROGRAMMABLE_NON_FUNGIBLE_EDITION = 5; +} + +enum UseMethod { + BURN = 0; + MULTIPLE = 1; + SINGLE = 2; +} + +message Uses { + UseMethod use_method = 1; + uint64 remaining = 2; + uint64 total = 3; } message ChainDataV1 { string name = 1; string symbol = 2; - uint32 edition_nonce = 3; + uint32 edition_nonce = 3; // Changed from u8 to uint32 as Protobuf does not have a u8 type bool primary_sale_happened = 4; - string token_standard = 5; - string uses = 6; + TokenStandard token_standard = 5; + Uses uses = 6; + uint64 slot_updated = 7; +} + +message AssetLeaf { + bytes tree_id = 1; + bytes leaf = 2; + uint64 nonce = 3; + bytes data_hash = 4; + bytes creator_hash = 5; + uint64 leaf_seq = 6; uint64 slot_updated = 7; } @@ -123,17 +143,13 @@ message DynamicEnumField { uint64 slot_updated = 2; } -// SyncRequest and SyncResponse for data synchronization -message SyncRequest { - int64 start_slot = 1; - int64 end_slot = 2; -} - -message SyncResponse { - repeated AssetDetails assets = 1; +// RangeRequest and AssetDetailsResponse for data synchronization +message RangeRequest { + uint64 start_slot = 1; + uint64 end_slot = 2; } // Define the gRPC service service GapFillerService { - rpc SyncData(SyncRequest) returns (stream SyncResponse); + rpc GetAssetsUpdatedWithin(RangeRequest) returns (stream AssetDetails); } \ No newline at end of file diff --git a/grpc/src/gapfiller.rs b/grpc/src/gapfiller.rs index adf6b19ed..08b5e9e34 100644 --- a/grpc/src/gapfiller.rs +++ b/grpc/src/gapfiller.rs @@ -1,22 +1,12 @@ #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct AssetLeaf { - #[prost(bytes = "vec", tag = "1")] - pub pubkey: ::prost::alloc::vec::Vec, - #[prost(bytes = "vec", tag = "2")] - pub tree_id: ::prost::alloc::vec::Vec, - #[prost(bytes = "vec", tag = "3")] - pub leaf: ::prost::alloc::vec::Vec, - #[prost(uint64, tag = "4")] - pub nonce: u64, - #[prost(bytes = "vec", tag = "5")] - pub data_hash: ::prost::alloc::vec::Vec, - #[prost(bytes = "vec", tag = "6")] - pub creator_hash: ::prost::alloc::vec::Vec, - #[prost(uint64, tag = "7")] - pub leaf_seq: u64, - #[prost(uint64, tag = "8")] - pub slot_updated: u64, +pub struct Uses { + #[prost(enumeration = "UseMethod", tag = "1")] + pub use_method: i32, + #[prost(uint64, tag = "2")] + pub remaining: u64, + #[prost(uint64, tag = "3")] + pub total: u64, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -25,14 +15,33 @@ pub struct ChainDataV1 { pub name: ::prost::alloc::string::String, #[prost(string, tag = "2")] pub symbol: ::prost::alloc::string::String, + /// Changed from u8 to uint32 as Protobuf does not have a u8 type #[prost(uint32, tag = "3")] pub edition_nonce: u32, #[prost(bool, tag = "4")] pub primary_sale_happened: bool, - #[prost(string, tag = "5")] - pub token_standard: ::prost::alloc::string::String, - #[prost(string, tag = "6")] - pub uses: ::prost::alloc::string::String, + #[prost(enumeration = "TokenStandard", tag = "5")] + pub token_standard: i32, + #[prost(message, optional, tag = "6")] + pub uses: ::core::option::Option, + #[prost(uint64, tag = "7")] + pub slot_updated: u64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct AssetLeaf { + #[prost(bytes = "vec", tag = "1")] + pub tree_id: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", tag = "2")] + pub leaf: ::prost::alloc::vec::Vec, + #[prost(uint64, tag = "3")] + pub nonce: u64, + #[prost(bytes = "vec", tag = "4")] + pub data_hash: ::prost::alloc::vec::Vec, + #[prost(bytes = "vec", tag = "5")] + pub creator_hash: ::prost::alloc::vec::Vec, + #[prost(uint64, tag = "6")] + pub leaf_seq: u64, #[prost(uint64, tag = "7")] pub slot_updated: u64, } @@ -148,20 +157,14 @@ pub struct DynamicEnumField { #[prost(uint64, tag = "2")] pub slot_updated: u64, } -/// SyncRequest and SyncResponse for data synchronization -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, ::prost::Message)] -pub struct SyncRequest { - #[prost(int64, tag = "1")] - pub start_slot: i64, - #[prost(int64, tag = "2")] - pub end_slot: i64, -} +/// RangeRequest and AssetDetailsResponse for data synchronization #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct SyncResponse { - #[prost(message, repeated, tag = "1")] - pub assets: ::prost::alloc::vec::Vec, +pub struct RangeRequest { + #[prost(uint64, tag = "1")] + pub start_slot: u64, + #[prost(uint64, tag = "2")] + pub end_slot: u64, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] @@ -324,6 +327,77 @@ impl OwnerType { } } } +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum TokenStandard { + NonFungible = 0, + FungibleAsset = 1, + Fungible = 2, + NonFungibleEdition = 3, + ProgrammableNonFungible = 4, + ProgrammableNonFungibleEdition = 5, +} +impl TokenStandard { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + TokenStandard::NonFungible => "NON_FUNGIBLE", + TokenStandard::FungibleAsset => "FUNGIBLE_ASSET", + TokenStandard::Fungible => "FUNGIBLE", + TokenStandard::NonFungibleEdition => "NON_FUNGIBLE_EDITION", + TokenStandard::ProgrammableNonFungible => "PROGRAMMABLE_NON_FUNGIBLE", + TokenStandard::ProgrammableNonFungibleEdition => { + "PROGRAMMABLE_NON_FUNGIBLE_EDITION" + } + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "NON_FUNGIBLE" => Some(Self::NonFungible), + "FUNGIBLE_ASSET" => Some(Self::FungibleAsset), + "FUNGIBLE" => Some(Self::Fungible), + "NON_FUNGIBLE_EDITION" => Some(Self::NonFungibleEdition), + "PROGRAMMABLE_NON_FUNGIBLE" => Some(Self::ProgrammableNonFungible), + "PROGRAMMABLE_NON_FUNGIBLE_EDITION" => { + Some(Self::ProgrammableNonFungibleEdition) + } + _ => None, + } + } +} +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] +#[repr(i32)] +pub enum UseMethod { + Burn = 0, + Multiple = 1, + Single = 2, +} +impl UseMethod { + /// String value of the enum field names used in the ProtoBuf definition. + /// + /// The values are not transformed in any way and thus are considered stable + /// (if the ProtoBuf definition does not change) and safe for programmatic use. + pub fn as_str_name(&self) -> &'static str { + match self { + UseMethod::Burn => "BURN", + UseMethod::Multiple => "MULTIPLE", + UseMethod::Single => "SINGLE", + } + } + /// Creates an enum from field names used in the ProtoBuf definition. + pub fn from_str_name(value: &str) -> ::core::option::Option { + match value { + "BURN" => Some(Self::Burn), + "MULTIPLE" => Some(Self::Multiple), + "SINGLE" => Some(Self::Single), + _ => None, + } + } +} /// Generated client implementations. pub mod gap_filler_service_client { #![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)] @@ -410,11 +484,11 @@ pub mod gap_filler_service_client { self.inner = self.inner.max_encoding_message_size(limit); self } - pub async fn sync_data( + pub async fn get_assets_updated_within( &mut self, - request: impl tonic::IntoRequest, + request: impl tonic::IntoRequest, ) -> std::result::Result< - tonic::Response>, + tonic::Response>, tonic::Status, > { self.inner @@ -428,11 +502,16 @@ pub mod gap_filler_service_client { })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static( - "/gapfiller.GapFillerService/SyncData", + "/gapfiller.GapFillerService/GetAssetsUpdatedWithin", ); let mut req = request.into_request(); req.extensions_mut() - .insert(GrpcMethod::new("gapfiller.GapFillerService", "SyncData")); + .insert( + GrpcMethod::new( + "gapfiller.GapFillerService", + "GetAssetsUpdatedWithin", + ), + ); self.inner.server_streaming(req, path, codec).await } } @@ -444,16 +523,19 @@ pub mod gap_filler_service_server { /// Generated trait containing gRPC methods that should be implemented for use with GapFillerServiceServer. #[async_trait] pub trait GapFillerService: Send + Sync + 'static { - /// Server streaming response type for the SyncData method. - type SyncDataStream: tonic::codegen::tokio_stream::Stream< - Item = std::result::Result, + /// Server streaming response type for the GetAssetsUpdatedWithin method. + type GetAssetsUpdatedWithinStream: tonic::codegen::tokio_stream::Stream< + Item = std::result::Result, > + Send + 'static; - async fn sync_data( + async fn get_assets_updated_within( &self, - request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + request: tonic::Request, + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; } /// Define the gRPC service #[derive(Debug)] @@ -535,26 +617,30 @@ pub mod gap_filler_service_server { fn call(&mut self, req: http::Request) -> Self::Future { let inner = self.inner.clone(); match req.uri().path() { - "/gapfiller.GapFillerService/SyncData" => { + "/gapfiller.GapFillerService/GetAssetsUpdatedWithin" => { #[allow(non_camel_case_types)] - struct SyncDataSvc(pub Arc); + struct GetAssetsUpdatedWithinSvc(pub Arc); impl< T: GapFillerService, - > tonic::server::ServerStreamingService - for SyncDataSvc { - type Response = super::SyncResponse; - type ResponseStream = T::SyncDataStream; + > tonic::server::ServerStreamingService + for GetAssetsUpdatedWithinSvc { + type Response = super::AssetDetails; + type ResponseStream = T::GetAssetsUpdatedWithinStream; type Future = BoxFuture< tonic::Response, tonic::Status, >; fn call( &mut self, - request: tonic::Request, + request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::sync_data(&inner, request).await + ::get_assets_updated_within( + &inner, + request, + ) + .await }; Box::pin(fut) } @@ -566,7 +652,7 @@ pub mod gap_filler_service_server { let inner = self.inner.clone(); let fut = async move { let inner = inner.0; - let method = SyncDataSvc(inner); + let method = GetAssetsUpdatedWithinSvc(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec) .apply_compression_config(