snarkvm_ledger_query/traits.rs
1// Copyright 2024 Aleo Network Foundation
2// This file is part of the snarkVM library.
3
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at:
7
8// http://www.apache.org/licenses/LICENSE-2.0
9
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16use console::{network::Network, prelude::Result, program::StatePath, types::Field};
17
18#[cfg_attr(feature = "async", async_trait(?Send))]
19pub trait QueryTrait<N: Network> {
20 /// Returns the current state root.
21 fn current_state_root(&self) -> Result<N::StateRoot>;
22
23 /// Returns the current state root.
24 #[cfg(feature = "async")]
25 async fn current_state_root_async(&self) -> Result<N::StateRoot>;
26
27 /// Returns a state path for the given `commitment`.
28 fn get_state_path_for_commitment(&self, commitment: &Field<N>) -> Result<StatePath<N>>;
29
30 /// Returns a state path for the given `commitment`.
31 #[cfg(feature = "async")]
32 async fn get_state_path_for_commitment_async(&self, commitment: &Field<N>) -> Result<StatePath<N>>;
33
34 /// Returns the current block height
35 fn current_block_height(&self) -> Result<u32>;
36
37 /// Returns the current block height
38 #[cfg(feature = "async")]
39 async fn current_block_height_async(&self) -> Result<u32>;
40}