namada_storage/
conversion_state.rs1use std::collections::BTreeMap;
4
5pub use namada_core::address::Address;
6use namada_core::borsh::{BorshDeserialize, BorshSerialize};
7pub use namada_core::masp::MaspEpoch;
8pub use namada_core::masp_primitives::asset_type::AssetType;
9pub use namada_core::masp_primitives::convert::AllowedConversion;
10pub use namada_core::masp_primitives::merkle_tree::FrozenCommitmentTree;
11pub use namada_core::masp_primitives::sapling::Node as SaplingNode;
12pub use namada_core::token::{Denomination, MaspDigitPos};
13use namada_macros::BorshDeserializer;
14#[cfg(feature = "migrations")]
15use namada_migrations::*;
16
17#[derive(Debug, BorshSerialize, BorshDeserialize, BorshDeserializer)]
19pub struct ConversionLeaf {
20 pub token: Address,
22 pub denom: Denomination,
24 pub digit_pos: MaspDigitPos,
26 pub epoch: MaspEpoch,
28 pub conversion: AllowedConversion,
30 pub leaf_pos: usize,
32}
33
34#[derive(
36 Debug, Default, BorshSerialize, BorshDeserialize, BorshDeserializer,
37)]
38pub struct ConversionState {
39 #[deprecated = "Current native precision has been moved into the native \
41 precision storage key."]
42 pub current_precision: Option<u128>,
43 pub tree: FrozenCommitmentTree<SaplingNode>,
45 pub assets: BTreeMap<AssetType, ConversionLeaf>,
47}
48
49pub trait ReadConversionState {
51 fn conversion_state(&self) -> &ConversionState;
53}
54
55pub trait WithConversionState: ReadConversionState {
57 fn conversion_state_mut(&mut self) -> &mut ConversionState;
59}