@@ -23,14 +23,15 @@ use dapi_grpc::platform::v0::{
2323 GetCurrentQuorumsInfoRequest , GetEpochsInfoRequest , GetEvonodesProposedEpochBlocksByIdsRequest ,
2424 GetEvonodesProposedEpochBlocksByRangeRequest , GetIdentityKeysRequest , GetPathElementsRequest ,
2525 GetProtocolVersionUpgradeStateRequest , GetProtocolVersionUpgradeVoteStatusRequest ,
26- GetTotalCreditsInPlatformRequest , KeyRequestType ,
26+ GetTotalCreditsInPlatformRequest , KeyRequestType , SpecificKeys ,
2727} ;
2828use dapi_grpc:: platform:: v0:: {
2929 get_status_request, GetContestedResourceIdentityVotesRequest ,
3030 GetPrefundedSpecializedBalanceRequest , GetStatusRequest , GetTokenDirectPurchasePricesRequest ,
3131 GetTokenPerpetualDistributionLastClaimRequest , GetVotePollsByEndDateRequest ,
3232} ;
3333use dpp:: dashcore_rpc:: dashcore:: { hashes:: Hash , ProTxHash } ;
34+ use dpp:: identity:: KeyID ;
3435use dpp:: version:: PlatformVersionError ;
3536use dpp:: { block:: epoch:: EpochIndex , prelude:: Identifier } ;
3637use drive:: query:: contested_resource_votes_given_by_identity_query:: ContestedResourceVotesGivenByIdentityQuery ;
@@ -183,6 +184,85 @@ impl Query<proto::GetIdentityKeysRequest> for Identifier {
183184 }
184185}
185186
187+ /// Query for specific identity keys by their IDs
188+ #[ derive( Debug , Clone ) ]
189+ pub struct IdentityKeysQuery {
190+ /// Identity ID to fetch keys from
191+ pub identity_id : Identifier ,
192+ /// Specific key IDs to fetch
193+ pub key_ids : Vec < KeyID > ,
194+ /// Optional limit for the number of keys to return
195+ pub limit : Option < u32 > ,
196+ /// Optional offset for pagination
197+ pub offset : Option < u32 > ,
198+ }
199+
200+ impl IdentityKeysQuery {
201+ /// Create a new query for specific identity keys
202+ ///
203+ /// # Arguments
204+ ///
205+ /// * `identity_id` - The identity to fetch keys from
206+ /// * `key_ids` - The specific key IDs to fetch
207+ ///
208+ /// # Example
209+ ///
210+ /// ```rust
211+ /// use dash_sdk::platform::{Identifier, IdentityKeysQuery};
212+ ///
213+ /// let identity_id = Identifier::new([1; 32]);
214+ /// let key_ids = vec![0, 1, 2]; // Fetch keys with IDs 0, 1, and 2
215+ /// let query = IdentityKeysQuery::new(identity_id, key_ids);
216+ /// ```
217+ pub fn new ( identity_id : Identifier , key_ids : Vec < KeyID > ) -> Self {
218+ Self {
219+ identity_id,
220+ key_ids,
221+ limit : None ,
222+ offset : None ,
223+ }
224+ }
225+
226+ /// Set a limit on the number of keys to return
227+ pub fn with_limit ( mut self , limit : u32 ) -> Self {
228+ self . limit = Some ( limit) ;
229+ self
230+ }
231+
232+ /// Set an offset for pagination
233+ pub fn with_offset ( mut self , offset : u32 ) -> Self {
234+ self . offset = Some ( offset) ;
235+ self
236+ }
237+ }
238+
239+ impl Query < proto:: GetIdentityKeysRequest > for IdentityKeysQuery {
240+ /// Get specific keys for an identity.
241+ fn query ( self , prove : bool ) -> Result < proto:: GetIdentityKeysRequest , Error > {
242+ if !prove {
243+ unimplemented ! ( "queries without proofs are not supported yet" ) ;
244+ }
245+
246+ Ok ( GetIdentityKeysRequest {
247+ version : Some ( get_identity_keys_request:: Version :: V0 (
248+ GetIdentityKeysRequestV0 {
249+ identity_id : self . identity_id . to_vec ( ) ,
250+ prove,
251+ limit : self . limit ,
252+ offset : self . offset ,
253+ request_type : Some ( KeyRequestType {
254+ request : Some ( proto:: key_request_type:: Request :: SpecificKeys (
255+ SpecificKeys {
256+ key_ids : self . key_ids . into_iter ( ) . collect ( ) ,
257+ } ,
258+ ) ) ,
259+ } ) ,
260+ } ,
261+ ) ) ,
262+ } )
263+ }
264+ }
265+
186266impl Query < DocumentQuery > for DriveDocumentQuery < ' _ > {
187267 fn query ( self , prove : bool ) -> Result < DocumentQuery , Error > {
188268 if !prove {
0 commit comments