dpp/data_contract/associated_token/token_configuration_convention/
mod.rs

1use crate::data_contract::associated_token::token_configuration_convention::v0::TokenConfigurationConventionV0;
2#[cfg(feature = "json-conversion")]
3use crate::serialization::JsonConvertible;
4#[cfg(feature = "value-conversion")]
5use crate::serialization::ValueConvertible;
6use bincode::{Decode, Encode};
7use derive_more::From;
8use serde::{Deserialize, Serialize};
9use std::fmt;
10
11pub mod accessors;
12pub mod methods;
13pub mod v0;
14
15/// Versioned wrapper for token display conventions.
16///
17/// `TokenConfigurationConvention` provides a flexible, forward-compatible structure
18/// for representing human-readable metadata about a token, such as localized names
19/// and decimal formatting standards.
20///
21/// This enum enables evolution of the convention schema over time without breaking
22/// compatibility with older tokens. Each variant defines a specific format version.
23#[cfg_attr(feature = "json-conversion", derive(JsonConvertible))]
24#[derive(Serialize, Deserialize, Encode, Decode, Debug, Clone, PartialEq, Eq, PartialOrd, From)]
25#[cfg_attr(feature = "value-conversion", derive(ValueConvertible))]
26#[serde(tag = "$formatVersion")]
27pub enum TokenConfigurationConvention {
28    /// Version 0 of the token convention schema.
29    ///
30    /// Defines localized names (by ISO 639 language codes) and the number of decimal places
31    /// used for displaying token amounts.
32    #[serde(rename = "0")]
33    V0(TokenConfigurationConventionV0),
34}
35
36impl fmt::Display for TokenConfigurationConvention {
37    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
38        match self {
39            TokenConfigurationConvention::V0(v0) => {
40                write!(f, "{}", v0) //just pass through
41            }
42        }
43    }
44}