1use crate::{
4 proof::PathProof,
5 trie::{KeyPath, ValueHash},
6 trie_pos::TriePosition,
7};
8
9#[cfg(not(feature = "std"))]
10use alloc::vec::Vec;
11
12#[cfg_attr(
16 feature = "borsh",
17 derive(borsh::BorshDeserialize, borsh::BorshSerialize)
18)]
19#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
20pub struct Witness {
21 pub path_proofs: Vec<WitnessedPath>,
24 pub operations: WitnessedOperations,
26}
27
28#[cfg_attr(
30 feature = "borsh",
31 derive(borsh::BorshDeserialize, borsh::BorshSerialize)
32)]
33#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
34pub struct WitnessedOperations {
35 pub reads: Vec<WitnessedRead>,
37 pub writes: Vec<WitnessedWrite>,
39}
40
41#[cfg_attr(
43 feature = "borsh",
44 derive(borsh::BorshDeserialize, borsh::BorshSerialize)
45)]
46#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
47pub struct WitnessedPath {
48 pub inner: PathProof,
50 pub path: TriePosition,
52}
53
54#[cfg_attr(
56 feature = "borsh",
57 derive(borsh::BorshDeserialize, borsh::BorshSerialize)
58)]
59#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
60pub struct WitnessedRead {
61 pub key: KeyPath,
63 pub value: Option<ValueHash>,
65 pub path_index: usize,
67}
68
69#[cfg_attr(
71 feature = "borsh",
72 derive(borsh::BorshDeserialize, borsh::BorshSerialize)
73)]
74#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
75pub struct WitnessedWrite {
76 pub key: KeyPath,
78 pub value: Option<ValueHash>,
80 pub path_index: usize,
82}