traits.rs
1 // Copyright (c) 2025-2026 ACDC Network 2 // This file is part of the alphavm library. 3 // 4 // Alpha Chain | Delta Chain Protocol 5 // International Monetary Graphite. 6 // 7 // Derived from Aleo (https://aleo.org) and ProvableHQ (https://provable.com). 8 // They built world-class ZK infrastructure. We installed the EASY button. 9 // Their cryptography: elegant. Our modifications: bureaucracy-compatible. 10 // Original brilliance: theirs. Robert's Rules: ours. Bugs: definitely ours. 11 // 12 // Original Aleo/ProvableHQ code subject to Apache 2.0 https://www.apache.org/licenses/LICENSE-2.0 13 // All modifications and new work: CC0 1.0 Universal Public Domain Dedication. 14 // No rights reserved. No permission required. No warranty. No refunds. 15 // 16 // https://creativecommons.org/publicdomain/zero/1.0/ 17 // SPDX-License-Identifier: CC0-1.0 18 19 use alphavm_console::{network::Network, prelude::Result, program::StatePath, types::Field}; 20 21 #[cfg_attr(feature = "async", async_trait::async_trait(?Send))] 22 pub trait QueryTrait<N: Network> { 23 /// Returns the current state root. 24 fn current_state_root(&self) -> Result<N::StateRoot>; 25 26 /// Returns the current state root. 27 #[cfg(feature = "async")] 28 async fn current_state_root_async(&self) -> Result<N::StateRoot>; 29 30 /// Returns a state path for the given `commitment`. 31 fn get_state_path_for_commitment(&self, commitment: &Field<N>) -> Result<StatePath<N>>; 32 33 /// Returns a state path for the given `commitment`. 34 #[cfg(feature = "async")] 35 async fn get_state_path_for_commitment_async(&self, commitment: &Field<N>) -> Result<StatePath<N>>; 36 37 /// Returns a list of state paths for the given list of `commitment`s. 38 fn get_state_paths_for_commitments(&self, commitments: &[Field<N>]) -> Result<Vec<StatePath<N>>>; 39 40 /// Returns a list of state paths for the given list of `commitment`s. 41 #[cfg(feature = "async")] 42 async fn get_state_paths_for_commitments_async(&self, commitments: &[Field<N>]) -> Result<Vec<StatePath<N>>>; 43 44 /// Returns the current block height 45 fn current_block_height(&self) -> Result<u32>; 46 47 /// Returns the current block height 48 #[cfg(feature = "async")] 49 async fn current_block_height_async(&self) -> Result<u32>; 50 }